Modal

Modal is a dialog for focused interactions that require user attention before continuing.

tsx
import { Button } from '@/components/ui/wideset/button/Button';
import { Modal } from '@/components/ui/wideset/modal/Modal';

<Modal>
  <Modal.Trigger asChild>
    <Button variant="secondary" preset="border">
      Archive project
    </Button>
  </Modal.Trigger>
  <Modal.Content>
    <Modal.Header>
      <Modal.Title>Archive “Website redesign”?</Modal.Title>
      <Modal.Description>Your team will lose edit access.</Modal.Description>
    </Modal.Header>
    <Modal.Body>
      Archived projects are read-only. You can restore them from Settings at any time.
    </Modal.Body>
    <Modal.Footer>
      <Modal.Close asChild>
        <Button variant="secondary" preset="border">
          Cancel
        </Button>
      </Modal.Close>
      <Modal.Close asChild>
        <Button>Archive</Button>
      </Modal.Close>
    </Modal.Footer>
  </Modal.Content>
</Modal>

Installation

pnpm dlx wideset add modal

Copies the component and any Wideset components it uses into your project.

Examples

Footers

default right-aligns the actions under a divider: the usual confirm or cancel. extension spreads them across a tinted band, for a footer that also carries a secondary action or a note on the left, such as a step count or a link to help.

tsx
import { Button } from '@/components/ui/wideset/button/Button';
import { Modal } from '@/components/ui/wideset/modal/Modal';

const frame =
  'flex w-[600px] max-w-full flex-col overflow-hidden rounded-ws-container-md border border-ws-dynamic-secondary-default bg-ws-static-overlay shadow-ws-high';

export default function ModalFooters() {
  return (
    <Modal>
      <div className="gap-ws-9 flex flex-col items-center">
        <div className={frame}>
          <Modal.Header>
            <Modal.Title>Rename project</Modal.Title>
          </Modal.Header>
          <Modal.Body>The new name is shown to everyone on the team.</Modal.Body>
          <Modal.Footer variant="default">
            <Button variant="secondary" preset="border">
              Cancel
            </Button>
            <Button>Save</Button>
          </Modal.Footer>
        </div>
        <div className={frame}>
          <Modal.Header>
            <Modal.Title>Invite people</Modal.Title>
          </Modal.Header>
          <Modal.Body>Invited people get an email with a link to join the workspace.</Modal.Body>
          <Modal.Footer variant="extension">
            <Button variant="secondary" preset="ghost">
              Copy invite link
            </Button>
            <Button>Send invites</Button>
          </Modal.Footer>
        </div>
      </div>
    </Modal>
  );
}

Persistent

persistent on Modal.Content ignores clicks outside and the Escape key, so the modal closes only through its own buttons. Use it when leaving without an answer would lose work, such as an unsaved form or a step that must be confirmed. Keep a visible way out (Cancel or the close button); a modal the user cannot leave traps keyboard and screen reader users.

tsx
import { Button } from '@/components/ui/wideset/button/Button';
import { Modal } from '@/components/ui/wideset/modal/Modal';

export default function ModalPersistent() {
  return (
    <Modal>
      <Modal.Trigger asChild>
        <Button variant="secondary" preset="border">
          Discard changes
        </Button>
      </Modal.Trigger>
      <Modal.Content persistent>
        <Modal.Header>
          <Modal.Title>Discard unsaved changes?</Modal.Title>
          <Modal.Description>Edits to “Invoice #1042” since 10:24 will be lost.</Modal.Description>
        </Modal.Header>
        <Modal.Body>Your draft is not saved. Discarding cannot be undone.</Modal.Body>
        <Modal.Footer>
          <Modal.Close asChild>
            <Button variant="secondary" preset="border">
              Keep editing
            </Button>
          </Modal.Close>
          <Modal.Close asChild>
            <Button>Discard</Button>
          </Modal.Close>
        </Modal.Footer>
      </Modal.Content>
    </Modal>
  );
}

API reference

Modal

No props of its ownIt takes its content as children and nothing else.

Modal.Body

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Modal.Close

NameDescriptionDefault
asChildboolean—
childrenReactElement<unknown, string | JSXElementConstructor<any>>—
Every other prop of Radix Dialog.Close is passed through to it. See Radix Dialog.Close.

Modal.Content

NameDescriptionDefault
autoFocusOnOpen

Focuses into modal after opening.

boolean
true
closeAriaLabel

Accessible label for that close button. Defaults to `'Close modal'`.

string
'Close modal'
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
persistent

Prevents closing the modal by outside click and Escape key.

boolean
false
showCloseButton

Renders the close button in the top-right corner. Defaults to `true`.

boolean
true
Every other prop of Radix Dialog.Content is passed through to it. See Radix Dialog.Content.

Modal.Description

No props of its ownIt takes its content as children.
Every other prop of Radix Dialog.Description is passed through to it. See Radix Dialog.Description.

Modal.Footer

NameDescriptionDefault
variant

Footer layout. `extension` separates the secondary and primary actions; defaults to `default`.

'default''extension'
'default'
Every other prop of <div> is passed through to it. See MDN: <div>.

Modal.Header

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Modal.Overlay

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
Every other prop of Radix Dialog.Overlay is passed through to it. See Radix Dialog.Overlay.

Modal.Title

No props of its ownIt takes its content as children.
Every other prop of Radix Dialog.Title is passed through to it. See Radix Dialog.Title.

Modal.Trigger

No props of its ownIt takes its content as children.
Every other prop of Radix Dialog.Trigger is passed through to it. See Radix Dialog.Trigger.

Accessibility

  • Always render Modal.Title; it is the dialog’s accessible name.
  • Modal.Description becomes the dialog’s description; without one, pass aria-describedby={undefined} to Modal.Content.
  • Focus moves inside on open and returns to the trigger on close.
  • With persistent, keep a visible way out (Cancel or the X).
PartRendersDescription
Modal—Modal is a dialog for focused interactions that require user attention before continuing.
Modal.Body<div>The main content area.
Modal.CloseRadix Dialog.CloseA close icon button, or a single caller-provided control when using `asChild`.
Modal.ContentRadix Dialog.ContentThe content surface rendered within `Modal`.
Modal.DescriptionRadix Dialog.DescriptionProps for `Modal.Description`.
Modal.Footer<div>The action area beneath the main content.
Modal.Header<div>The header area for a title and supporting content.
Modal.OverlayRadix Dialog.OverlayThe scrim behind the content.
Modal.TitleRadix Dialog.TitleProps for `Modal.Title`.
Modal.TriggerRadix Dialog.TriggerThe Radix Dialog trigger.
tsx
import { Button } from '@/components/ui/wideset/button/Button';
import { Modal } from '@/components/ui/wideset/modal/Modal';

<Modal>
  <Modal.Trigger asChild>
    <Button variant="secondary" preset="border">
      Archive project
    </Button>
  </Modal.Trigger>
  <Modal.Content>
    <Modal.Header>
      <Modal.Title>Archive “Website redesign”?</Modal.Title>
      <Modal.Description>Your team will lose edit access.</Modal.Description>
    </Modal.Header>
    <Modal.Body>
      Archived projects are read-only. You can restore them from Settings at any time.
    </Modal.Body>
    <Modal.Footer>
      <Modal.Close asChild>
        <Button variant="secondary" preset="border">
          Cancel
        </Button>
      </Modal.Close>
      <Modal.Close asChild>
        <Button>Archive</Button>
      </Modal.Close>
    </Modal.Footer>
  </Modal.Content>
</Modal>

Appearance

Footer

Content

Close button
Action

Behavior

Persistent