Form modal

A short form in a modal: its fields, a consent to tick, the actions in the footer and keyboard hints under them.

Open full screen

A panel opens over any screen and keeps its own look in every direction: it has no direction of its own.

npx wideset add block-modal-form

Import the default export from @/blocks/wideset/modal-form. The files below are relative to your project's source directory.

Installed with this block
  • block-styles
  • button
  • checkbox
  • form-field
  • icon-button
  • modal
  • select
  • text-input
  • utils
blocks/wideset/modal-form/index.tsx
'use client';

import '@/styles/wideset-blocks.css';

import { Button } from '@/components/ui/wideset/button/Button';
import { useState } from 'react';

import { PaymentFormModal } from './payment-form-modal';

/** Form modal: a short form over the page, here over an empty page that reopens it. */
export default function ModalFormBlock() {
  const [open, setOpen] = useState(true);

  return (
    <div className="ws-block-utility bg-ws-static-foreground flex h-dvh items-center justify-center">
      <Button variant="secondary" preset="border" onClick={() => setOpen(true)}>
        Add payment method
      </Button>
      <PaymentFormModal open={open} onOpenChange={setOpen} />
    </div>
  );
}