Components

Dialog

The shadcn/ui Dialog (modal) with a short, calm open and close animation, dimmed backdrop and scrollable content — plus three accessible React dialog blocks built with Motion and Radix: a card that morphs into a dialog, an async confirm dialog and a drag-to-dismiss bottom sheet drawer.

  • Drop-in shadcn API
  • Radix focus trap
  • Motion blocks
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/dialog.json

Replaces components/ui/dialog.tsx with the same exports and props, so the Command palette and existing dialogs keep working. Animations are CSS (tw-animate-css, included with shadcn/ui), so the base needs no Motion.

Usage

edit-profile.tsx
import { Button } from "@/components/ui/button"
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"

export function EditProfile() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button variant="outline">Edit profile</Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Edit profile</DialogTitle>
          <DialogDescription>Changes are visible to your team.</DialogDescription>
        </DialogHeader>
        {/* form */}
      </DialogContent>
    </Dialog>
  )
}

Examples

Default

Fades and scales in slightly with a short ease-out, then exits faster than it entered so closing feels instant. Focus moves into the dialog and returns to the trigger.

Long content

Content taller than the screen scrolls inside the dialog instead of spilling off the viewport, while the page behind stays locked.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Morphing Dialog

A card that expands into a dialog. The surface, media, title and subtitle share a Motion layoutId, so each part flies to its new size and position; extra content fades in after the morph. Built on Radix Dialog, so focus trapping, Escape, outside click and focus return all work. Under reduced motion it simply fades.

$ npx shadcn@latest add https://duskui.com/r/morphing-dialog.json
PropTypeDefaultDescription
open / onOpenChangeboolean / (open: boolean) => void—Controlled state (on MorphingDialog).
defaultOpenbooleanfalseUncontrolled initial state.
MorphingDialogTriggermotion.button props—The card. Put only inline content (spans) inside.
MorphingDialogContentmotion.div props & { overlayClassName }—The open dialog, portalled and centered.
MorphingDialogMedia / Title / Subtitlemotion props—Shared parts. Use them in both the trigger and the content.
MorphingDialogDescriptionmotion.div props—Content-only body that fades in; wired to aria-describedby.
MorphingDialogClosemotion.button props—Round close button; children replace the X icon.

Confirm Dialog

A confirmation dialog for risky actions. Return a promise from onConfirm and the confirm button shows the DuskUI Button loading state; Escape and outside clicks are blocked mid-request, it closes on success, and a failure shakes the dialog and shows the error inline. Optional type-to-confirm for destructive actions. Try both buttons.

$ npx shadcn@latest add https://duskui.com/r/confirm-dialog.json
PropTypeDefaultDescription
triggerReactElement—Element that opens the dialog. Omit when controlling open.
open / onOpenChangeboolean / (open: boolean) => void—Controlled state.
titleReactNode—Dialog title. Required.
descriptionReactNode—Supporting text.
onConfirm() => unknown | Promise<unknown>—Runs on confirm. Throw to keep the dialog open with an error.
variant"default" | "destructive""default"Destructive turns the icon and button red.
confirmTextstring—Text the user must type before confirming.
confirmLabel / cancelLabelReactNode"Confirm" / "Cancel"Button labels.
pendingLabelReactNode—Shown next to the spinner while confirming.
iconReactNode | null—Top icon. Defaults to a warning for destructive; null hides it.
errorMessageReactNode—Replaces the thrown error's message.

Drawer Dialog

A bottom sheet that slides up and can be dragged down by its handle or header to dismiss. A quick flick or a drag past closeThreshold closes it, anything less springs back, and the backdrop fades as you drag. It's still a Radix Dialog underneath, so Escape, the backdrop and the close button work too.

$ npx shadcn@latest add https://duskui.com/r/drawer-dialog.json
PropTypeDefaultDescription
triggerReactElement—Element that opens the drawer.
open / onOpenChangeboolean / (open: boolean) => void—Controlled state.
title / descriptionReactNode—Header text, wired to aria-labelledby / -describedby.
footerReactNode—Actions pinned under the scrollable body.
showCloseButtonbooleantrueRender an X next to the title.
closeThresholdnumber0.3Fraction of the height to drag before it closes.

API Reference

Same parts as shadcn/ui: Dialog, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, DialogClose, DialogOverlay and DialogPortal. Each forwards the Radix Dialog props.

PropTypeDefaultDescription
open / onOpenChangeboolean / (open: boolean) => void—Controlled state (on Dialog).
modalbooleantrueTrap focus and lock page scroll (on Dialog).
showCloseButtonbooleantrueRender the X button (on DialogContent).
onOpenAutoFocus / onEscapeKeyDown / onInteractOutside(event) => void—Radix hooks on DialogContent; call preventDefault() to override.

Accessibility

  • Built on Radix Dialog: focus is trapped inside, Escape closes, focus returns to the trigger and the page behind is hidden from screen readers.
  • Always render a DialogTitle (visually hidden with sr-only if needed) and a description or aria-describedby={undefined}.
  • Confirm Dialog uses role="alertdialog", focuses Cancel first and keeps both buttons focusable while pending.
  • Under prefers-reduced-motion the base dialog only fades, the morph becomes a fade and the drawer fades instead of sliding.