Skip to content
Components / Overlays

Dialog

A modal task with a title, an explanation and explicit actions.

@fabrials/ui
Loading state

Installation

  1. Import the control from @fabrials/ui, after setting the app up.

    TypeScript
    import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogBody, DialogFooter, DialogActions, DialogClose } from "@fabrials/ui";
  2. Or install it under shadcn's name, so code that imports @/components/ui/dialog gets this control. See shims.

    npx shadcn@latest add @fabrials/dialog

API reference

Prop / exportTypeDescription
openbooleanControlled open state.
onOpenChange(open) => voidFires on open and dismiss. Escape during an IME composition does not close the dialog.
DialogContent sizedefault | wide | settings | full-narrowdefault is 32rem, wide 46rem, settings 62 by 42rem (72 by 48 from 100rem). Wide, settings and full-narrow are the whole screen below 48rem.
DialogContent closecorner | footercorner is the X; footer draws no X and puts a Close button first in the DialogFooter (showCloseButton on DialogFooter is shadcn's name for it).
DialogContent padding / keepMountednone / booleanpadding=none removes the padding; keepMounted keeps the dialog in the DOM, hidden, while it is closed.
DialogContent closeVariant / DialogFooter closeVariantButton variantThe variant of the Close that close=footer puts in the footer: secondary by default, outline for a product whose secondary actions are outlines. Set once on DialogContent; a DialogFooter closeVariant wins.
DialogContent containerelement | ref | nullWhere the dialog is portalled; the body by default. Hold the element in state when the dialog can be open on the first render (a ref object is still empty then). null waits.
DialogBody scroll / paddingboolean / noneA DialogBody as a direct child of DialogContent gives a fixed header, a body that is the only scroller and a fixed footer. scroll=false lets the content scroll itself (a settings rail and panels). In a window under 30rem tall the dialog scrolls as a whole and only the footer sticks; the footer publishes its height and the dialog pads its scrolling with it, so a focused field is never under the footer.
DialogActionschildrenPortals the actions into the footer from a stateful child (a form under the body), after Close. Nothing renders until the footer has mounted.

Behavior

Focus moves into the dialog and returns to the trigger on Escape. The title names the task. Under 34rem the footer wraps: the secondary buttons share rows and the ink action, last as in the tab order, takes the full bottom row; every button is 44 px. Keep the header to the title and put the description first in the body: a phone in landscape or at a large text size then keeps room for the body. A body with no focusable content should be given tabIndex 0 and a name.

Accessibility

Keyboard and contrast
Keep visible labels, keyboard focus and status announcements when customizing. These components inherit your theme; maintain sufficient contrast in both color modes. The preview is keyboard operable.