# Animated Dialog for UI SDK (/docs/components/dialog)

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

<ComponentPreview slug="dialog" source="{&#x22;code&#x22;:&#x22;\&#x22;use client\&#x22;\n\nimport * as React from \&#x22;react\&#x22;\n\nimport {\n  Dialog,\n  DialogBackdrop,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n} from \&#x22;@/components/keyframery/dialog\&#x22;\n\nconst field = [\n  \&#x22;h-9 w-full rounded-[10px] bg-background px-3 text-[13px] text-foreground outline-none\&#x22;,\n  \&#x22;shadow-[0_0_0_1px_rgb(0_0_0/0.09),0_1px_2px_rgb(0_0_0/0.05)] dark:shadow-[0_0_0_1px_rgb(255_255_255/0.1)]\&#x22;,\n  \&#x22;transition-[box-shadow] duration-[calc(150ms*var(--kf-speed,1))] hover:shadow-[0_0_0_1px_rgb(0_0_0/0.16),0_1px_2px_rgb(0_0_0/0.05)]\&#x22;,\n  \&#x22;dark:hover:shadow-[0_0_0_1px_rgb(255_255_255/0.16)]\&#x22;,\n  \&#x22;focus:shadow-[0_0_0_1px_var(--ring),0_0_0_4px_color-mix(in_oklab,var(--ring),transparent_75%)]\&#x22;,\n  \&#x22;motion-reduce:transition-none\&#x22;,\n].join(\&#x22; \&#x22;)\n\nfunction Label({ children, htmlFor }: { children: React.ReactNode; htmlFor: string }) {\n  return (\n    <label htmlFor={htmlFor} className=\&#x22;mb-1.5 block text-[12px] font-medium text-muted-foreground\&#x22;>\n      {children}\n    </label>\n  )\n}\n\nexport default function DialogDemo({\n  variant = \&#x22;primary\&#x22;,\n  modal = \&#x22;modal\&#x22;,\n  presentation = \&#x22;dialog\&#x22;,\n  disabled = false,\n  focusableWhenDisabled = false,\n  dismissible = true,\n  closeOnOutsidePress = true,\n  keepMounted = false,\n  showClose = true,\n  editLabel = \&#x22;Edit trip\&#x22;,\n  description = \&#x22;Everyone on the trip sees these details.\&#x22;,\n  cancel = \&#x22;Cancel\&#x22;,\n  save = \&#x22;Save changes\&#x22;,\n  tripName = \&#x22;Hen weekend\&#x22;,\n  width = 440,\n  radius = 18,\n  gap = 8,\n  face = \&#x22;\&#x22;,\n  ink = \&#x22;\&#x22;,\n  action = \&#x22;\&#x22;,\n}: {\n  variant?: \&#x22;default\&#x22; | \&#x22;primary\&#x22; | \&#x22;destructive\&#x22; | \&#x22;icon\&#x22;\n  modal?: \&#x22;modal\&#x22; | \&#x22;trap-focus\&#x22; | \&#x22;non-modal\&#x22;\n  presentation?: \&#x22;dialog\&#x22; | \&#x22;sheet\&#x22; | \&#x22;auto\&#x22;\n  disabled?: boolean\n  focusableWhenDisabled?: boolean\n  dismissible?: boolean\n  closeOnOutsidePress?: boolean\n  keepMounted?: boolean\n  showClose?: boolean\n  editLabel?: string\n  description?: string\n  cancel?: string\n  save?: string\n  tripName?: string\n  width?: number\n  radius?: number\n  gap?: number\n  face?: string\n  ink?: string\n  action?: string\n}) {\n  const theme = {\n    \&#x22;--dialog-width\&#x22;: `${width}px`,\n    \&#x22;--dialog-radius\&#x22;: `${radius}px`,\n    \&#x22;--dialog-gap\&#x22;: `${gap}px`,\n    ...(face ? { \&#x22;--dialog-face\&#x22;: face } : null),\n    ...(ink ? { \&#x22;--dialog-ink\&#x22;: ink } : null),\n    ...(action ? { \&#x22;--dialog-action\&#x22;: action } : null),\n  } as React.CSSProperties\n  return (\n    <div style={theme} className=\&#x22;flex w-full max-w-[340px] items-center gap-3 rounded-[14px] bg-muted/60 p-3 pl-4\&#x22;>\n      <div className=\&#x22;min-w-0 flex-1\&#x22;>\n        <div className=\&#x22;text-[14px] font-semibold tracking-tight\&#x22;>{tripName}</div>\n        <div className=\&#x22;mt-0.5 text-[12px] text-muted-foreground tabular-nums\&#x22;>Margate, 9 people</div>\n      </div>\n      <Dialog modal={modal === \&#x22;modal\&#x22; ? true : modal === \&#x22;trap-focus\&#x22; ? \&#x22;trap-focus\&#x22; : false} presentation={presentation} dismissible={dismissible} closeOnOutsidePress={closeOnOutsidePress}>\n        <DialogTrigger disabled={disabled} focusableWhenDisabled={focusableWhenDisabled}>{editLabel}</DialogTrigger>\n        <DialogBackdrop />\n        <DialogContent style={theme} keepMounted={keepMounted}>\n          <DialogHeader>\n            <DialogTitle>{editLabel}</DialogTitle>\n            <DialogDescription>{description}</DialogDescription>\n          </DialogHeader>\n          <div className=\&#x22;mt-5 grid gap-4\&#x22;>\n            <div>\n              <Label htmlFor=\&#x22;trip-name\&#x22;>Name</Label>\n              <input id=\&#x22;trip-name\&#x22; className={field} key={tripName} defaultValue={tripName} />\n            </div>\n            <div className=\&#x22;grid grid-cols-2 gap-3\&#x22;>\n              <div>\n                <Label htmlFor=\&#x22;trip-from\&#x22;>Arrive</Label>\n                <input id=\&#x22;trip-from\&#x22; className={cn2(field, \&#x22;tabular-nums\&#x22;)} defaultValue=\&#x22;14 May 2026\&#x22; />\n              </div>\n              <div>\n                <Label htmlFor=\&#x22;trip-to\&#x22;>Leave</Label>\n                <input id=\&#x22;trip-to\&#x22; className={cn2(field, \&#x22;tabular-nums\&#x22;)} defaultValue=\&#x22;17 May 2026\&#x22; />\n              </div>\n            </div>\n            <div>\n              <Label htmlFor=\&#x22;trip-stay\&#x22;>Where you're staying</Label>\n              <input id=\&#x22;trip-stay\&#x22; className={field} defaultValue=\&#x22;The Sands, Margate\&#x22; />\n            </div>\n          </div>\n          <DialogFooter>\n            <DialogClose>{cancel}</DialogClose>\n            <DialogClose variant={variant} data-play=\&#x22;save\&#x22; aria-label={save} value=\&#x22;save\&#x22;>\n              {variant === \&#x22;icon\&#x22; ? <svg aria-hidden viewBox=\&#x22;0 0 16 16\&#x22; fill=\&#x22;none\&#x22; stroke=\&#x22;currentColor\&#x22; strokeWidth=\&#x22;1.5\&#x22;><path d=\&#x22;m3.5 8 3 3 6-6\&#x22; /></svg> : save}\n            </DialogClose>\n          </DialogFooter>\n          {showClose && variant !== \&#x22;icon\&#x22; && <DialogClose variant=\&#x22;icon\&#x22; />}\n        </DialogContent>\n      </Dialog>\n    </div>\n  )\n}\n\nfunction cn2(...parts: string[]) {\n  return parts.join(\&#x22; \&#x22;)\n}&#x22;,&#x22;bindings&#x22;:{&#x22;variant&#x22;:[1087,1096],&#x22;modal&#x22;:[1108,1115],&#x22;presentation&#x22;:[1134,1142],&#x22;disabled&#x22;:[1157,1162],&#x22;focusableWhenDisabled&#x22;:[1190,1195],&#x22;dismissible&#x22;:[1213,1217],&#x22;closeOnOutsidePress&#x22;:[1243,1247],&#x22;keepMounted&#x22;:[1265,1270],&#x22;showClose&#x22;:[1286,1290],&#x22;editLabel&#x22;:[1306,1317],&#x22;description&#x22;:[1335,1377],&#x22;cancel&#x22;:[1390,1398],&#x22;save&#x22;:[1409,1423],&#x22;tripName&#x22;:[1438,1451],&#x22;width&#x22;:[1463,1466],&#x22;radius&#x22;:[1479,1481],&#x22;gap&#x22;:[1491,1492],&#x22;face&#x22;:[1503,1505],&#x22;ink&#x22;:[1515,1517],&#x22;action&#x22;:[1530,1532]},&#x22;root&#x22;:[2362,4729],&#x22;importOffset&#x22;:239}" />

## Installation [#installation]

**CLI**

```bash
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.

**Manual**

**Install the dependencies**

```bash
npm install @ui-sdk/core@0.1.0-beta.9 @ui-sdk/react@0.1.0-beta.9 clsx tailwind-merge
```

**Add the motion tokens**

Copy the [motion tokens](/docs/installation#what-the-cli-adds-to-your-css) into your global CSS, and this file into `lib/keyframery.tsx`. Every component shares them.

**lib/keyframery.tsx**

```tsx
"use client"

/* Speed for Keyframery components, as a prop.

   Every duration in the components is written as calc(Nms * var(--kf-speed, 1)). These helpers set
   that variable for you, so nobody has to know it exists:

     <Tabs speed="fast">                      one component
     <KeyframeryProvider speed="slow">        the whole app

   Parts that render in a portal (popups, menus, dialogs) are not inside the component in the page,
   so they pick the speed up through React context instead of the CSS cascade. */

import * as React from "react"

/** `"fast"` (0.6×), `"normal"` (1×), `"slow"` (1.4×), or any multiplier: `0.8` is 20% quicker. */
export type Speed = "fast" | "normal" | "slow" | number

export type SpeedProps = {
  /** How fast the component moves. `"fast"` (0.6×), `"normal"` (1×), `"slow"` (1.4×), or a multiplier like `0.8`. Popups follow it too. */
  speed?: Speed
}

export type MotionStyleName = "springy" | "calm" | "snappy" | "playful"

const presets = { fast: 0.6, normal: 1, slow: 1.4 } as const

export function speedValue(speed: Speed | undefined): number | undefined {
  if (speed === undefined) return undefined
  return typeof speed === "number" ? speed : presets[speed]
}

const SpeedContext = React.createContext<number | undefined>(undefined)

type SpeedStyle = React.CSSProperties & { "--kf-speed"?: number }

/* Wraps a component's parts. Without `speed` it adds nothing to the page. With it, a
   `display: contents` element carries the variable to the parts in place, and context carries it
   to the parts in a portal. */
export function Speed({ speed, children }: SpeedProps & { children?: React.ReactNode }) {
  const value = speedValue(speed)
  if (value === undefined) return children
  const style: SpeedStyle = { display: "contents", "--kf-speed": value }
  return (
    <SpeedContext value={value}>
      <span data-slot="speed" style={style}>
        {children}
      </span>
    </SpeedContext>
  )
}

/* For parts that render in a portal: adds the speed of the component they belong to. `style` can
   be an object or UI SDK's function of the part's state. */
export function useSpeedStyle<S>(style: S): S {
  return withSpeed(style, React.useContext(SpeedContext))
}

/* Adds a speed to a part's own `style`, for a part that takes `speed` and renders in a portal. */
export function withSpeed<S>(style: S, speed: Speed | undefined): S {
  const value = speedValue(speed)
  if (value === undefined) return style
  if (typeof style === "function")
    return ((state: unknown) => ({ "--kf-speed": value, ...(style as (s: unknown) => React.CSSProperties)(state) })) as S
  return { "--kf-speed": value, ...(style as React.CSSProperties | undefined) } as S
}

/* UI SDK parts take `children` as content or as a function of the part's state. A styled part
   that adds elements of its own (a chevron, a moving key) wraps either form with this, so the
   function form keeps working. */
export function mapChildren<State>(
  children: React.ReactNode | ((state: State) => React.ReactNode),
  wrap: (content: React.ReactNode) => React.ReactNode,
): React.ReactNode | ((state: State) => React.ReactNode) {
  return typeof children === "function" ? (state: State) => wrap(children(state)) : wrap(children)
}

/* Sets speed and motion style for the whole app, popups included. A component's own `speed` prop
   still wins inside that component. Server-rendered pages can put `data-motion` on <html> directly
   to avoid a change after hydration. */
export function KeyframeryProvider({
  speed,
  motion,
  children,
}: SpeedProps & {
  /** The motion style for the whole app: `"springy"` (the default), `"calm"`, `"snappy"` or `"playful"`. */
  motion?: MotionStyleName
  children?: React.ReactNode
}) {
  const value = speedValue(speed)
  React.useLayoutEffect(() => {
    const html = document.documentElement
    if (motion) html.setAttribute("data-motion", motion)
    if (value !== undefined) html.style.setProperty("--kf-speed", String(value))
    return () => {
      if (motion) html.removeAttribute("data-motion")
      if (value !== undefined) html.style.removeProperty("--kf-speed")
    }
  }, [motion, value])
  return children
}
```

**Copy the component**

**components/keyframery/dialog.tsx**

```tsx
"use client"

export * from "@/components/keyframery/primitives/dialog"

/* Theming: set on a part or its ancestor; unset variables preserve the original theme.
   --dialog-face: Dialog sheet (default: --popover).
   --dialog-ink: Dialog body text (default: --popover-foreground).
   --dialog-action: Primary or destructive action (default: --primary / --destructive (dark destructive mixed with --background 24%)).
   --dialog-radius: Sheet corners (default: 18px).
   --dialog-width: Sheet width limit (default: 440px).
   --dialog-padding: Sheet padding (default: 1.25rem).
   --dialog-gap: Footer key spacing (default: 0.5rem).
 */

/* Styled dialog: the animated primitive plus the Keyframery look. */

import {
  Dialog as DialogRoot,
  DialogBackdrop as DialogBackdropPart,
  DialogClose as DialogClosePart,
  DialogContent as DialogContentPart,
  DialogDescription as DialogDescriptionPart,
  DialogShortcut as DialogShortcutPart,
  DialogTitle as DialogTitlePart,
  DialogTrigger as DialogTriggerPart,
} from "@/components/keyframery/primitives/dialog"
import * as React from "react"

import { Speed, type SpeedProps, useSpeedStyle } from "@/lib/keyframery"
import { cn } from "@/lib/utils"

/* UI SDK accepts a class name or a function of state; keep both working. */
function withClass<S>(base: string, className: string | ((state: S) => string | undefined) | undefined) {
  return typeof className === "function" ? (state: S) => cn(base, className(state)) : cn(base, className)
}

type DialogCloseVariant = "default" | "primary" | "destructive" | "icon"

/* A key: the thing you press. Shared by the trigger and the close buttons. */
const keyBase = cn(
  "inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 leading-none font-medium whitespace-nowrap outline-none select-none [&_svg]:pointer-events-none [&_svg]:shrink-0",
  /* The primitive presses the key; colour and shadow ride the same 200ms pop. */
  "transition-[color,background-color,box-shadow,opacity,scale] duration-[calc(200ms*var(--kf-speed,1))] ease-pop",
  "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
  "data-disabled:cursor-not-allowed data-disabled:opacity-50 data-pending:cursor-progress data-pending:opacity-70",
  "motion-reduce:transition-none!",
)

const keySurface = cn(
  "bg-background text-foreground dark:bg-accent",
  "shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_1px_rgb(0_0_0/0.05),0_3px_6px_-2px_rgb(0_0_0/0.1)]",
  "dark:shadow-[0_0_0_1px_rgb(255_255_255/0.07),inset_0_1px_0_rgb(255_255_255/0.08),0_2px_6px_-1px_rgb(0_0_0/0.6)]",
  "not-data-disabled:hover:bg-[color-mix(in_oklab,var(--background),var(--foreground)_3%)]",
  "dark:not-data-disabled:hover:bg-[color-mix(in_oklab,var(--accent),var(--foreground)_7%)]",
  "not-data-disabled:hover:shadow-[0_0_0_1px_rgb(0_0_0/0.1),0_1px_1px_rgb(0_0_0/0.05),0_4px_8px_-2px_rgb(0_0_0/0.12)]",
  "dark:not-data-disabled:hover:shadow-[0_0_0_1px_rgb(255_255_255/0.12),inset_0_1px_0_rgb(255_255_255/0.1),0_2px_6px_-1px_rgb(0_0_0/0.6)]",
  "not-data-disabled:active:shadow-[0_0_0_1px_rgb(0_0_0/0.1),0_1px_1px_rgb(0_0_0/0.04),0_1px_2px_-1px_rgb(0_0_0/0.06)]",
  "dark:not-data-disabled:active:shadow-[0_0_0_1px_rgb(255_255_255/0.09),inset_0_1px_0_rgb(255_255_255/0.04),0_1px_2px_-1px_rgb(0_0_0/0.6)]",
)

const closeVariants: Record<DialogCloseVariant, string> = {
  default: cn(keySurface, "h-8 rounded-[9px] px-3 text-[13px] [&_svg]:size-4"),
  primary: cn(
    "h-8 rounded-[9px] px-3 text-[13px] [&_svg]:size-4",
    "bg-[var(--dialog-action,var(--primary))] text-primary-foreground",
    "shadow-[inset_0_1px_0_rgb(255_255_255/0.14),0_1px_2px_rgb(0_0_0/0.25)]",
    "dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.7),0_1px_2px_rgb(0_0_0/0.5)]",
    "not-data-disabled:hover:bg-[color-mix(in_oklab,var(--dialog-action,var(--primary)),var(--background)_14%)]",
    "not-data-disabled:active:shadow-[inset_0_1px_0_rgb(255_255_255/0.08),0_0_1px_rgb(0_0_0/0.3)]",
  ),
  destructive: cn(
    "h-8 rounded-[9px] px-3 text-[13px] [&_svg]:size-4",
    "bg-[var(--dialog-action,var(--destructive))] text-background dark:bg-[color-mix(in_oklab,var(--dialog-action,var(--destructive)),var(--background)_24%)] dark:text-foreground",
    "shadow-[inset_0_1px_0_rgb(255_255_255/0.18),0_1px_2px_rgb(0_0_0/0.2)]",
    "dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.16),0_1px_2px_rgb(0_0_0/0.5)]",
    "not-data-disabled:hover:bg-[color-mix(in_oklab,var(--dialog-action,var(--destructive)),var(--foreground)_10%)]",
    "dark:not-data-disabled:hover:bg-[color-mix(in_oklab,var(--dialog-action,var(--destructive)),var(--background)_14%)]",
    "not-data-disabled:active:shadow-[inset_0_1px_0_rgb(255_255_255/0.08),0_0_1px_rgb(0_0_0/0.3)]",
  ),
  /* The small corner key that closes the dialog. */
  icon: cn(
    keySurface,
    "absolute top-3.5 right-3.5 size-7 rounded-[8px] text-muted-foreground not-data-disabled:hover:text-foreground [&_svg]:size-3.5",
  ),
}

function XIcon() {
  return (
    <svg
      viewBox="0 0 16 16"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden
    >
      <path d="M4.5 4.5l7 7M11.5 4.5l-7 7" />
    </svg>
  )
}

function Dialog({ speed, ...props }: React.ComponentProps<typeof DialogRoot> & SpeedProps) {
  return (
    <Speed speed={speed}>
      <DialogRoot {...props} />
    </Speed>
  )
}

/* A key by default. Pass `render` to use a button of your own instead. */
function DialogTrigger({
  className,
  ...props
}: React.ComponentProps<typeof DialogTriggerPart>) {
  return (
    <DialogTriggerPart
      className={withClass(
        cn(
          !props.render && [keyBase, keySurface, "h-8 rounded-[9px] px-3 text-[13px] [&_svg]:size-4"],
          props.render && "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
        ),
        className,
      )}
      {...props}
    />
  )
}

/* The page dims behind the dialog. The primitive blurs it in and out. */
function DialogBackdrop({
  className,
  style,
  ...props
}: React.ComponentProps<typeof DialogBackdropPart>) {
  return (
    <DialogBackdropPart
      className={withClass("fixed inset-0 bg-black/25 dark:bg-black/55", className)}
      {...props} style={useSpeedStyle(style)}
    />
  )
}

/* The sheet. The primitive unfolds it from below and cascades its sections in. */
function DialogContent({
  className,
  style,
  ...props
}: React.ComponentProps<typeof DialogContentPart>) {
  return (
    <DialogContentPart
      className={withClass(
        cn(
          "fixed inset-0 m-auto h-fit max-h-[calc(100dvh-32px)] w-[min(var(--dialog-width,440px),calc(100vw-32px))] max-w-none overflow-y-auto overscroll-contain",
          "border-0 p-[var(--dialog-padding,1.25rem)] outline-none backdrop:bg-transparent",
          "rounded-[var(--dialog-radius,18px)] bg-[var(--dialog-face,var(--popover))] text-[color:var(--dialog-ink,var(--popover-foreground))]",
          "shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_2px_6px_-2px_rgb(0_0_0/0.08),0_24px_56px_-12px_rgb(0_0_0/0.28)]",
          "dark:shadow-[0_0_0_1px_rgb(255_255_255/0.08),0_24px_56px_-12px_rgb(0_0_0/0.8)]",
        ),
        className,
      )}
      {...props} style={useSpeedStyle(style)}
    />
  )
}

/* Title and description stacked, with room for the corner close key. */
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="dialog-header"
      className={cn("flex flex-col gap-1 pr-9", className)}
      {...props}
    />
  )
}

/* The answers, right-aligned at the foot of the sheet. */
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="dialog-footer"
      className={cn("mt-5 flex items-center justify-end gap-[var(--dialog-gap,0.5rem)]", className)}
      {...props}
    />
  )
}

function DialogTitle({
  className,
  ...props
}: React.ComponentProps<typeof DialogTitlePart>) {
  return (
    <DialogTitlePart
      className={withClass("text-[15px] leading-5 font-semibold tracking-tight", className)}
      {...props}
    />
  )
}

function DialogDescription({
  className,
  ...props
}: React.ComponentProps<typeof DialogDescriptionPart>) {
  return (
    <DialogDescriptionPart
      className={withClass("text-[13px] leading-5 text-muted-foreground", className)}
      {...props}
    />
  )
}

/* A key. `variant="icon"` is the small corner key with an X, and needs no children. */
function DialogClose({
  className,
  variant = "default",
  children,
  ...props
}: React.ComponentProps<typeof DialogClosePart> & { variant?: DialogCloseVariant }) {
  return (
    <DialogClosePart
      data-variant={variant}
      aria-label={variant === "icon" && !children ? "Close" : undefined}
      className={withClass(cn(!props.render && [keyBase, closeVariants[variant]]), className)}
      {...props}
    >
      {variant === "icon" && !children ? <XIcon /> : children}
    </DialogClosePart>
  )
}

function DialogShortcut({
  className,
  ...props
}: React.ComponentProps<typeof DialogShortcutPart>) {
  return (
    <DialogShortcutPart
      className={withClass("ms-1 text-[12px] leading-none tracking-[0.04em] text-muted-foreground tabular-nums", className)}
      {...props}
    />
  )
}

export {
  Dialog,
  DialogBackdrop,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogShortcut,
  DialogTitle,
  DialogTrigger,
}

/* UI SDK's helpers for this component, passed through. */
export { createDialogController } from "@/components/keyframery/primitives/dialog"
```

**components/keyframery/primitives/dialog.tsx**

```tsx
"use client"

/* Animated drop-in for `@ui-sdk/react/dialog`: same parts, same props. Swap the import and keep
   your code. This file adds motion only. Colours, radii, shadows and spacing stay yours. */

import {
  DialogBackdrop as DialogBackdropPart,
  DialogClose as DialogClosePart,
  DialogContent as DialogContentPart,
  DialogTrigger as DialogTriggerPart,
} from "@ui-sdk/react/dialog"
import * as React from "react"

import { cn } from "@/lib/utils"

/* UI SDK accepts a class name or a function of state; keep both working. */
function withClass<S>(base: string, className: string | ((state: S) => string | undefined) | undefined) {
  return typeof className === "function" ? (state: S) => cn(base, className(state)) : cn(base, className)
}

export * from "@ui-sdk/react/dialog"

/* Press: the key gives under the finger and springs back on release. */
const press =
  "transition-[scale] duration-[calc(200ms*var(--kf-speed,1))] ease-pop not-data-disabled:not-data-pending:active:scale-[0.96] motion-reduce:transition-none!"

/* Cascade: each direct child of the content (a header, a body, a footer) rises in out of a blur a
   little after the one before it. It is a keyframe animation rather than a transition because the
   children have no earlier style to transition from when the content first appears. Close buttons
   and arrows are left out so their own presses stay quick, and nothing on the children transitions,
   so a hover is never delayed. */
const cascadeKeyframes = "@keyframes kf-cascade{from{opacity:0;translate:0 8px;filter:blur(4px)}}@media (prefers-reduced-motion:reduce){@keyframes kf-cascade{from{opacity:0}}}"
const cascade = cn(
  "[&>*:not([data-slot$=-close],[data-slot$=-arrow])]:animate-[kf-cascade_calc(420ms*var(--kf-speed,1))_var(--ease-spring)_backwards]",
  "[&>*:not([data-slot$=-close],[data-slot$=-arrow])]:[animation-delay:calc(calc(40ms*var(--kf-speed,1))+(min(sibling-index(),10)-1)*calc(40ms*var(--kf-speed,1)))]",
  "motion-reduce:[&>*]:animate-none",
)

function DialogTrigger({ className, ...props }: React.ComponentProps<typeof DialogTriggerPart>) {
  return <DialogTriggerPart className={withClass(press, className)} {...props} />
}

function DialogClose({ className, ...props }: React.ComponentProps<typeof DialogClosePart>) {
  return <DialogClosePart className={withClass(press, className)} {...props} />
}

/* The page behind softens into a blur as it dims, and clears faster than it came. */
function DialogBackdrop({ className, ...props }: React.ComponentProps<typeof DialogBackdropPart>) {
  return (
    <DialogBackdropPart
      className={withClass(
        cn(
          "backdrop-blur-[4px] transition-[opacity,backdrop-filter] duration-[calc(380ms*var(--kf-speed,1))] ease-house",
          "data-starting-style:opacity-0 data-starting-style:backdrop-blur-none",
          "data-ending-style:opacity-0 data-ending-style:backdrop-blur-none data-ending-style:duration-[calc(180ms*var(--kf-speed,1))]",
          "motion-reduce:transition-none!",
        ),
        className,
      )}
      {...props}
    />
  )
}

/* Unfold from below: the sheet rises 24px out of a blur, grows from 0.9 and settles on a spring,
   then its sections cascade in. It leaves quickly, sinking a little. */
function DialogContent<Payload = unknown>({
  className,
  ...props
}: React.ComponentProps<typeof DialogContentPart<Payload>>) {
  return (
    <>
      <style href="kf-cascade" precedence="default">
        {cascadeKeyframes}
      </style>
      <DialogContentPart<Payload>
        className={withClass(
          cn(
            "group/dialog transition-[opacity,scale,translate,filter] duration-[calc(420ms*var(--kf-speed,1))] ease-spring",
            "data-starting-style:translate-y-6 data-starting-style:scale-[0.9] data-starting-style:opacity-0 data-starting-style:blur-[8px]",
            "data-ending-style:translate-y-2 data-ending-style:scale-[0.96] data-ending-style:opacity-0 data-ending-style:blur-[4px] data-ending-style:duration-[calc(180ms*var(--kf-speed,1))] data-ending-style:ease-house",
            "data-nested-open:scale-[0.95] data-nested-open:opacity-70",
            cascade,
            "motion-reduce:transition-none!",
          ),
          className,
        )}
        {...props}
      />
    </>
  )
}

export { DialogBackdrop, DialogClose, DialogContent, DialogTrigger }
```

**Check the import paths**

The files import from `@/components/keyframery/…` and `@/lib/…`. Change those if your project's aliases differ.

## Usage [#usage]

```tsx
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 [#anatomy]

How the parts fit together:

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

## Examples [#examples]

### With a form [#with-a-form]

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

<ExamplePreview name="dialog/form">
  ```tsx
  import {
    Dialog,
    DialogBackdrop,
    DialogClose,
    DialogContent,
    DialogDescription,
    DialogFooter,
    DialogHeader,
    DialogTitle,
    DialogTrigger,
  } from "@/components/keyframery/dialog"
  import { Input } from "@/components/keyframery/input"

  export default function DialogForm() {
    return (
      <Dialog>
        <DialogTrigger>Edit profile</DialogTrigger>
        <DialogBackdrop />
        <DialogContent>
          <DialogHeader>
            <DialogTitle>Edit profile</DialogTitle>
            <DialogDescription>This is how others see you on the team.</DialogDescription>
          </DialogHeader>
          <div className="mt-4 flex flex-col gap-3">
            <label className="flex flex-col gap-1.5 text-[13px] font-medium">
              Name
              <Input defaultValue="Maya Chen" />
            </label>
            <label className="flex flex-col gap-1.5 text-[13px] font-medium">
              Role
              <Input defaultValue="Product designer" />
            </label>
          </div>
          <DialogFooter>
            <DialogClose>Cancel</DialogClose>
            <DialogClose variant="primary">Save</DialogClose>
          </DialogFooter>
          <DialogClose variant="icon" />
        </DialogContent>
      </Dialog>
    )
  }
  ```
</ExamplePreview>

### Controlled [#controlled]

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

<ExamplePreview name="dialog/controlled">
  ```tsx
  import * as React from "react"

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

  export default function DialogControlled() {
    const [open, setOpen] = React.useState(false)
    const publish = () => new Promise((resolve) => setTimeout(resolve, 900)).then(() => setOpen(true))
    return (
      <>
        <Button variant="primary" onClick={publish}>
          Publish
        </Button>
        <Dialog open={open} onOpenChange={setOpen}>
          <DialogBackdrop />
          <DialogContent>
            <DialogHeader>
              <DialogTitle>It's live</DialogTitle>
              <DialogDescription>Your post is published and shared with 1,204 followers.</DialogDescription>
            </DialogHeader>
            <DialogFooter>
              <DialogClose variant="primary">Done</DialogClose>
            </DialogFooter>
          </DialogContent>
        </Dialog>
      </>
    )
  }
  ```
</ExamplePreview>

### Sheet on phones [#sheet-on-phones]

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

<ExamplePreview name="dialog/sheet">
  ```tsx
  import { Dialog, DialogBackdrop, DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/keyframery/dialog"

  export default function DialogSheet() {
    return (
      <Dialog presentation="auto">
        <DialogTrigger>Share</DialogTrigger>
        <DialogBackdrop />
        <DialogContent>
          <DialogHeader>
            <DialogTitle>Share this list</DialogTitle>
            <DialogDescription>On a phone this slides up from the bottom of the screen.</DialogDescription>
          </DialogHeader>
          <DialogClose variant="icon" />
        </DialogContent>
      </Dialog>
    )
  }
  ```
</ExamplePreview>

## Motion [#motion]

| Move        | What you see                                                          |
| ----------- | --------------------------------------------------------------------- |
| **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.                                   |

Timing and springiness follow the [motion style](/docs/motion-styles) you set. To change how fast this dialog moves, pass `speed`:

```tsx
<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 [#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.

| Variable           | What it changes               | Default                                                                  |
| ------------------ | ----------------------------- | ------------------------------------------------------------------------ |
| `--dialog-face`    | Dialog sheet                  | --popover                                                                |
| `--dialog-ink`     | Dialog body text              | --popover-foreground                                                     |
| `--dialog-action`  | Primary or destructive action | --primary / --destructive (dark destructive mixed with --background 24%) |
| `--dialog-radius`  | Sheet corners                 | 18px                                                                     |
| `--dialog-width`   | Sheet width limit             | 440px                                                                    |
| `--dialog-padding` | Sheet padding                 | 1.25rem                                                                  |
| `--dialog-gap`     | Footer key spacing            | 0.5rem                                                                   |

## API reference [#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](https://ui-sdk.dev/docs/components/dialog).

### Dialog [#dialog]

<PropsTable rows="[{&#x22;name&#x22;:&#x22;speed&#x22;,&#x22;type&#x22;:&#x22;\&#x22;fast\&#x22; | \&#x22;normal\&#x22; | \&#x22;slow\&#x22; | number&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;How fast the component moves. `\&#x22;fast\&#x22;` (0.6×), `\&#x22;normal\&#x22;` (1×), `\&#x22;slow\&#x22;` (1.4×), or a multiplier like `0.8`. Popups follow it too.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;container&#x22;,&#x22;type&#x22;:&#x22;Element | DocumentFragment&#x22;,&#x22;full&#x22;:&#x22;Element | DocumentFragment&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;open&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Whether the dialog is open. Pass it to control the dialog.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;defaultOpen&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:&#x22;false&#x22;,&#x22;description&#x22;:&#x22;Whether the dialog starts open, when uncontrolled. Focus moves into it once it's on the page.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;onOpenChangeComplete&#x22;,&#x22;type&#x22;:&#x22;(open: boolean) => void&#x22;,&#x22;full&#x22;:&#x22;(open: boolean) => void&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Runs once the dialog has finished opening or closing, after any animation.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;dismissible&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:&#x22;true&#x22;,&#x22;description&#x22;:&#x22;Allow Escape and back gesture dismissal.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;onDismissAttempt&#x22;,&#x22;type&#x22;:&#x22;(details: DialogDismissAttemptDetails) => void&#x22;,&#x22;full&#x22;:&#x22;(details: DialogDismissAttemptDetails) => void&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Runs when a dismissal was refused, because `dismissible` is false, an outside press doesn't close it, or a Close part's action is running. Ask \&#x22;Discard changes?\&#x22; here.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;persistentElements&#x22;,&#x22;type&#x22;:&#x22;(string | Element)[] | (() => Element[])&#x22;,&#x22;full&#x22;:&#x22;(string | Element)[] | (() => Element[])&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Elements that stay usable while the dialog makes the page inert, like a chat launcher or a password manager's button. Elements, CSS selectors, or a function that returns elements, read when the dialog opens. Presses on them never close it.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;pendingAnnouncement&#x22;,&#x22;type&#x22;:&#x22;string&#x22;,&#x22;full&#x22;:&#x22;string&#x22;,&#x22;default&#x22;:&#x22;\&#x22;Loading\&#x22;&#x22;,&#x22;description&#x22;:&#x22;What screen readers hear once a Close part's action has been running for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;onOpenChange&#x22;,&#x22;type&#x22;:&#x22;function&#x22;,&#x22;full&#x22;:&#x22;(open: boolean, details: DialogOpenChangeDetails) => void&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Runs when the dialog wants to open or close. `details.reason` says why, `details.cancel()` stops it, and `details.returnValue` carries what closed it.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;onPayloadChange&#x22;,&#x22;type&#x22;:&#x22;function&#x22;,&#x22;full&#x22;:&#x22;(payload: unknown, details: ChangeDetails<DialogPayloadChangeReason>) => void&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Runs when the payload the content shows changes: a trigger with another payload opens the dialog, or takes a non-modal dialog over while it's open, which fires no `onOpenChange`, and so does a controller's `open({ payload })` on the open dialog. `details.cancel()` keeps the previous payload.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;modal&#x22;,&#x22;type&#x22;:&#x22;boolean | \&#x22;trap-focus\&#x22;&#x22;,&#x22;full&#x22;:&#x22;boolean | \&#x22;trap-focus\&#x22;&#x22;,&#x22;default&#x22;:&#x22;true&#x22;,&#x22;description&#x22;:&#x22;true blocks the page; trap-focus traps focus only; false allows the page beside the dialog.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;closeOnOutsidePress&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:&#x22;true, or false when `modal` is false&#x22;,&#x22;description&#x22;:&#x22;Dismiss after an outside press is released.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;presentation&#x22;,&#x22;type&#x22;:&#x22;PresentationSetting<\&#x22;dialog\&#x22;>&#x22;,&#x22;full&#x22;:&#x22;PresentationSetting<\&#x22;dialog\&#x22;>&#x22;,&#x22;default&#x22;:&#x22;\&#x22;dialog\&#x22;&#x22;,&#x22;description&#x22;:&#x22;Dialog, bottom sheet or automatic touch adaptation.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;controller&#x22;,&#x22;type&#x22;:&#x22;PopupController<…>&#x22;,&#x22;full&#x22;:&#x22;PopupController<any, DialogOpenChangeReason, {}, any, DialogPayloadChangeReason>&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Opens, closes and inspects the dialog from anywhere, and connects triggers outside it. Create one with `createDialogController()`.&#x22;,&#x22;required&#x22;:false}]" />

### DialogTrigger [#dialogtrigger]

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

<PropsTable rows="[{&#x22;name&#x22;:&#x22;shortcut&#x22;,&#x22;type&#x22;:&#x22;string&#x22;,&#x22;full&#x22;:&#x22;string&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;A keyboard shortcut that presses the trigger, like `\&#x22;mod+k\&#x22;`. `mod` is Command on Apple platforms and Control elsewhere. Sets `aria-keyshortcuts`, and a Shortcut part inside shows it. A modal dialog pauses the page's shortcuts while it's open.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;focusableWhenDisabled&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:&#x22;false&#x22;,&#x22;description&#x22;:&#x22;Keep the disabled trigger keyboard focusable.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;payload&#x22;,&#x22;type&#x22;:&#x22;{}&#x22;,&#x22;full&#x22;:&#x22;{}&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Data for the content to render when this trigger opens the dialog, like the row it belongs to.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;controller&#x22;,&#x22;type&#x22;:&#x22;PopupController<…>&#x22;,&#x22;full&#x22;:&#x22;PopupController<any, DialogOpenChangeReason, {}, any, DialogPayloadChangeReason>&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Connects a trigger outside the dialog, like one per table row, to the dialog with this controller.&#x22;,&#x22;required&#x22;:false}]" />

### DialogContent [#dialogcontent]

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

<PropsTable rows="[{&#x22;name&#x22;:&#x22;container&#x22;,&#x22;type&#x22;:&#x22;Element | DocumentFragment&#x22;,&#x22;full&#x22;:&#x22;Element | DocumentFragment&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;initialFocus&#x22;,&#x22;type&#x22;:&#x22;DialogInitialFocus&#x22;,&#x22;full&#x22;:&#x22;DialogInitialFocus&#x22;,&#x22;default&#x22;:&#x22;\&#x22;auto\&#x22;&#x22;,&#x22;description&#x22;:&#x22;Where focus goes when the dialog opens. Opening with touch focuses the dialog itself, so no on-screen keyboard appears.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;finalFocus&#x22;,&#x22;type&#x22;:&#x22;PopupFocusTarget&#x22;,&#x22;full&#x22;:&#x22;PopupFocusTarget&#x22;,&#x22;default&#x22;:&#x22;\&#x22;trigger\&#x22;&#x22;,&#x22;description&#x22;:&#x22;Where focus goes when the dialog closes while focus is inside it.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;keepMounted&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:&#x22;false&#x22;,&#x22;description&#x22;:&#x22;Keep closed dialog content hidden in the DOM.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;inline&#x22;,&#x22;type&#x22;:&#x22;boolean&#x22;,&#x22;full&#x22;:&#x22;boolean&#x22;,&#x22;default&#x22;:&#x22;false&#x22;,&#x22;description&#x22;:&#x22;Renders the dialog and its backdrop where they are in the page instead of above it, so it can stay inside a frame, like an app preview. Pair it with `modal=\&#x22;trap-focus\&#x22;` to keep the rest of the page usable. A `container` on the dialog still moves its backdrop, so leave it off.&#x22;,&#x22;required&#x22;:false}]" />

### DialogClose [#dialogclose]

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

<PropsTable rows="[{&#x22;name&#x22;:&#x22;variant&#x22;,&#x22;type&#x22;:&#x22;\&#x22;default\&#x22; | \&#x22;destructive\&#x22; | \&#x22;primary\&#x22; | \&#x22;icon\&#x22;&#x22;,&#x22;full&#x22;:&#x22;DialogCloseVariant&#x22;,&#x22;default&#x22;:&#x22;\&#x22;default\&#x22;&#x22;,&#x22;description&#x22;:&#x22;Default, primary, destructive or corner icon key.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;value&#x22;,&#x22;type&#x22;:&#x22;string&#x22;,&#x22;full&#x22;:&#x22;string&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Reported as `returnValue` in `onOpenChange` and by the controller's `open()`. `createConfirm()` resolves `true` for `\&#x22;confirm\&#x22;`.&#x22;,&#x22;required&#x22;:false},{&#x22;name&#x22;:&#x22;action&#x22;,&#x22;type&#x22;:&#x22;function&#x22;,&#x22;full&#x22;:&#x22;(event: Event, details: ActionDetails) => unknown&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;Runs when the part is pressed, before the dialog closes. A returned Promise keeps the dialog open while it runs: the part gets `data-pending`, `aria-busy` and `aria-disabled`, screen readers hear the dialog's `pendingAnnouncement` after a second, and nothing but the controller closes the dialog. It closes with reason `\&#x22;action\&#x22;` once the Promise resolves. A rejection keeps it open and puts the reason in the part's `error` state until the next press, or until the dialog opens again. `details.source` says how the part was pressed, for changes made after an `await`.&#x22;,&#x22;required&#x22;:false}]" />

### DialogShortcut [#dialogshortcut]

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

<PropsTable rows="[{&#x22;name&#x22;:&#x22;shortcut&#x22;,&#x22;type&#x22;:&#x22;string&#x22;,&#x22;full&#x22;:&#x22;string&#x22;,&#x22;default&#x22;:null,&#x22;description&#x22;:&#x22;The keys to show. Inside a trigger, its `shortcut`.&#x22;,&#x22;required&#x22;:false}]" />

### Other parts [#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 [#keyboard]

| Key               | What it does                                             |
| ----------------- | -------------------------------------------------------- |
| <kbd>Tab</kbd>    | Moves between the dialog's controls. Focus stays inside. |
| <kbd>Escape</kbd> | Closes the dialog.                                       |

## Accessibility [#accessibility]

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in [Accessibility](/docs/accessibility).

## Swap the import [#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.

```tsx
// 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.
