videorc/ui

Dialog

A modal on the dialog tier of the float glass in four widths, with a body that scrolls between a header and a footer that stay put, and no backdrop blur.

Installation

$ pnpm dlx shadcn@latest add @videorc/dialog

Usage

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog";
<Dialog>
  <DialogTrigger render={<Button variant="secondary" />}>
    Rename scene…
  </DialogTrigger>
  <DialogContent size="sm">
    <DialogHeader>
      <DialogTitle>Rename scene</DialogTitle>
      <DialogDescription>The new name shows in the Studio.</DialogDescription>
    </DialogHeader>
    <DialogFooter>
      <DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
      <Button onClick={save}>Save</Button>
    </DialogFooter>
  </DialogContent>
</Dialog>

Size a dialog with size, never a max-w-* or max-h-* of its own.

Anatomy

<Dialog>
  <DialogTrigger />
  <DialogContent>
    <DialogHeader>
      <DialogTitle />
      <DialogDescription />
    </DialogHeader>
    <DialogBody />
    <DialogFooter>
      <DialogClose />
    </DialogFooter>
  </DialogContent>
</Dialog>

Examples

Sizes

sm (384 px) for a rename or one question, md (448 px, the default) for confirmations and short forms, lg (576 px) for forms, pickers and setup, xl (768 px) for review and media.

Scrolling body

A dialog is never taller than the window less 16 px a side. Put long content in a DialogBody: it takes the height the header and footer leave and scrolls, so they stay in view. A dialog without one scrolls whole.

Theming

Token or attributeMeaning
glass-float-dialogThe dialog tier: a step brighter than the popup tier, with its own drop
rounded-panel, p-5, gap-512 px corners and the dialog's spacing
max-h-[calc(100vh-2rem)]The height rule
data-sizesm, md, lg or xl
bg-black/30The overlay, with no backdrop blur: blur wedged the compositor on a vibrancy window
data-open, data-closedFades and scales from 0.98 in 100 ms

dialogContentVariants({ size }) returns the dialog's classes, DIALOG_SURFACE_CLASS the surface alone (for a card on the dialog tier that isn't a dialog), and DIALOG_SIZE_CLASS the widths.

Keyboard

KeyAction
Tab, Shift+TabMoves through the dialog's controls; focus stays inside
EscapeCloses the dialog

Accessibility

DialogTitle names the dialog and DialogDescription describes it. Focus moves to the first control on open (choose another with initialFocus) and back to the trigger on close. The close button reads "Close".

API reference

Every Base UI Dialog prop, plus:

DialogContent

Prop

Type

DialogFooter

Prop

Type