Keyframery

Dialog

Rises from below out of a blur, then its title, fields and buttons arrive one after another.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/dialog

This adds components/keyframery/dialog.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import {
  Dialog,
  DialogBackdrop,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/keyframery/dialog"

export default function Usage() {
  return (
    <Dialog>
      <DialogTrigger>Open</DialogTrigger>
      <DialogBackdrop />
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Title</DialogTitle>
          <DialogDescription>Description</DialogDescription>
        </DialogHeader>
        <DialogClose variant="icon" />
      </DialogContent>
    </Dialog>
  )
}

Anatomy

How the parts fit together:

Dialog
├── DialogTrigger
├── DialogBackdrop
└── DialogContent
    ├── DialogHeader
    │   ├── DialogTitle
    │   └── DialogDescription
    └── DialogClose

Examples

With a form

A header, your content and a footer of actions. variant="icon" is the small close key in the corner.

Controlled

Pass open and onOpenChange to open it from code, like after a save.

Sheet on phones

presentation="auto" shows a dialog on wide screens and a sheet that slides up, and can be swiped away, on phones.

Motion

MoveWhat you see
UnfoldThe sheet rises from below out of a blur while the backdrop blurs in.
CascadeTitle, fields and buttons arrive one after another.
PressThe close key and buttons press in.

Timing and springiness follow the motion style you set. To change how fast this dialog moves, pass speed:

<Dialog speed="fast">
  …
</Dialog>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--dialog-faceDialog sheet--popover
--dialog-inkDialog body text--popover-foreground
--dialog-actionPrimary or destructive action--primary / --destructive (dark destructive mixed with --background 24%)
--dialog-radiusSheet corners18px
--dialog-widthSheet width limit440px
--dialog-paddingSheet padding1.25rem
--dialog-gapFooter key spacing0.5rem

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK dialog reference.

Dialog

Prop

Type

DialogTrigger

Renders a <button>, and takes its props too.

Prop

Type

DialogContent

Renders a <div>, and takes its props too.

Prop

Type

DialogClose

Renders a <button>, and takes its props too.

Prop

Type

DialogShortcut

Renders a <span>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • DialogBackdrop: a <div>
  • DialogHeader: a <div>
  • DialogTitle: a <h2>
  • DialogDescription: a <p>
  • DialogFooter: a <div>

Keyboard

KeyWhat it does
TabMoves between the dialog's controls. Focus stays inside.
EscapeCloses the dialog.

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's dialog with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/dialog"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/dialog"

Questions

How does the animated Dialog for UI SDK move?

Unfold: The sheet rises from below out of a blur while the backdrop blurs in. Cascade: Title, fields and buttons arrive one after another. Press: The close key and buttons press in.

Do I need Motion or Framer Motion for the animated Dialog?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/dialog instead. It has the same parts and props as @ui-sdk/react/dialog and adds motion only.

What happens to the Dialog when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page