Modal
Modal is a dialog for focused interactions that require user attention before continuing.
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.
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.
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
Modal.Body
<div> is passed through to it. See MDN: <div>.Modal.Close
| Name | Description | Default |
|---|---|---|
asChild | boolean | — |
children | ReactElement<unknown, string | JSXElementConstructor<any>> | — |
Radix Dialog.Close is passed through to it. See Radix Dialog.Close.Modal.Content
| Name | Description | Default |
|---|---|---|
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 |
Radix Dialog.Content is passed through to it. See Radix Dialog.Content.Modal.Description
Radix Dialog.Description is passed through to it. See Radix Dialog.Description.Modal.Footer
| Name | Description | Default |
|---|---|---|
variant | Footer layout. `extension` separates the secondary and primary actions; defaults to `default`. 'default''extension' | 'default' |
<div> is passed through to it. See MDN: <div>.Modal.Header
<div> is passed through to it. See MDN: <div>.Modal.Overlay
| Name | Description | Default |
|---|---|---|
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
Radix Dialog.Overlay is passed through to it. See Radix Dialog.Overlay.Modal.Title
Radix Dialog.Title is passed through to it. See Radix Dialog.Title.Modal.Trigger
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.Descriptionbecomes the dialog’s description; without one, passaria-describedby={undefined}toModal.Content.- Focus moves inside on open and returns to the trigger on close.
- With
persistent, keep a visible way out (Cancel or the X).
| Part | Renders | Description |
|---|---|---|
| ModalRenders no element | — | Modal is a dialog for focused interactions that require user attention before continuing. |
| Modal.BodyRenders no element | <div> | The main content area. |
| Modal.CloseRenders no element | Radix Dialog.Close | A close icon button, or a single caller-provided control when using `asChild`. |
| Modal.ContentRenders no element | Radix Dialog.Content | The content surface rendered within `Modal`. |
| Modal.DescriptionRenders no element | Radix Dialog.Description | Props for `Modal.Description`. |
| Modal.FooterRenders no element | <div> | The action area beneath the main content. |
| Modal.HeaderRenders no element | <div> | The header area for a title and supporting content. |
| Modal.OverlayRenders no element | Radix Dialog.Overlay | The scrim behind the content. |
| Modal.TitleRenders no element | Radix Dialog.Title | Props for `Modal.Title`. |
| Modal.TriggerRenders no element | Radix Dialog.Trigger | The Radix Dialog trigger. |
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>