Skip to main content

Dialog

A trigger-anchored spatial modal dialog with 3D perspective tilt, spring physics, motion blur, and an accessible focus trap.

@heroicons/react

Customize

Spring stiffness125
Spring damping29
Tilt angle (deg)12
Initial scale0.78
Perspective (px)760
Origin factor0.72
Motion blur (px)4
Backdrop blur (px)4

Installation

npx shadcn@latest add @kinetic/dialog

Usage

The dialog supports two composition styles from @/components/kinetic/ui/dialog: the controlled SpatialDialog wrapper (pass open, onOpenChange, and fromButton so the panel grows from the trigger) and the compound primitives (Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, DialogClose).

import { useState } from "react";
import { SpatialDialog } from "@/components/kinetic/ui/dialog";

export function InviteDialog() {
  const [open, setOpen] = useState(false);
  const [trigger, setTrigger] = useState<HTMLElement | null>(null);

  return (
    <>
      <button ref={setTrigger} onClick={() => setOpen(true)}>
        Invite
      </button>
      <SpatialDialog
        open={open}
        onOpenChange={setOpen}
        triggerEl={trigger}
        title="Invite teammates"
        description="Send an invitation by email."
        footer={<button onClick={() => setOpen(false)}>Done</button>}
      >
        Dialog content
      </SpatialDialog>
    </>
  );
}

Content

Use title and description for the header, badge for a short label above the title, children for the body, and footer for actions.

<SpatialDialog open={open} onOpenChange={setOpen} triggerEl={trigger} badge="New" title="Release notes">
  Body
</SpatialDialog>

Entry direction

Set fromDirection to auto, top, bottom, left, or right. With auto the tilt direction follows where the trigger sits on screen. Set fromButton={false} to stop the panel travelling from the trigger position.

<SpatialDialog fromDirection="left" open={open} onOpenChange={setOpen} triggerEl={trigger} title="From the left" />

Depth and blur

depth3D toggles the perspective tilt and motionBlur toggles the blur while the panel moves. Tune them with perspective, tiltAngle, initialScale, originFactor, motionBlurPx, and backdropBlurPx.

<SpatialDialog depth3D={false} motionBlur={false} open={open} onOpenChange={setOpen} triggerEl={trigger} title="Flat" />

Spring and timing

stiffness and damping control the entrance spring. enterFadeMs, exitDurationMs, and backdropExitMs control fades and exit timing.

<SpatialDialog stiffness={160} damping={24} open={open} onOpenChange={setOpen} triggerEl={trigger} title="Snappy" />

Compound API

Use Dialog with DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, and DialogClose for declarative uncontrolled (defaultOpen) or controlled (open / onOpenChange) dialogs. DialogPortal and DialogOverlay render automatically when DialogContent is placed directly inside Dialog, or compose them explicitly for custom container and backdropBlurPx control. DialogTitle and DialogDescription link aria-labelledby and aria-describedby automatically.

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/kinetic/ui/dialog";
import { Button } from "@/components/kinetic/ui/button";

interface AccountDialogProps {
  defaultOpen?: boolean;
}

export function AccountDialog({ defaultOpen = false }: AccountDialogProps) {
  return (
    <Dialog defaultOpen={defaultOpen}>
      <DialogTrigger asChild>
        <Button variant="outline">Open compound dialog</Button>
      </DialogTrigger>
      <DialogContent showCloseButton>
        <DialogHeader>
          <DialogTitle>Project preferences</DialogTitle>
          <DialogDescription>Update defaults for future deployments.</DialogDescription>
        </DialogHeader>
        <DialogFooter showCloseButton>
          <DialogClose asChild>
            <Button>Save</Button>
          </DialogClose>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}

Motion preferences

With reduced motion enabled, the panel skips the spatial offset, tilt, and scale and uses a short fade. Animation time is scaled by the current Kinetic tempo. Focus is trapped while open and Escape closes the dialog; focus returns to the trigger after it closes.

API Reference

SpatialDialog

Self-contained spatial modal dialog driven by sub-stepped spring physics, 3D tilt, and optional motion blur.

PropTypeDefaultDescription
openboolean-Controls whether the dialog is open.
onOpenChange(open: boolean) => void-Called when the user clicks the backdrop, close button, or presses Escape.
triggerElHTMLElement | null-Anchor element used to compute spatial origin offset and auto 3D tilt direction.
titlestring-Heading displayed at the top of the dialog and exposed as aria-label.
badgestring-Optional eyebrow label rendered above the title.
descriptionstring-Optional supporting copy below the title.
footerReact.ReactNode-Optional footer slot rendered inside a subtle bordered bar.
fromButtonbooleantrueAnimates the panel outward from the trigger button position.
depth3DbooleantrueEnables perspective rotateX/rotateY tilt during entrance and exit.
motionBlurbooleantrueApplies subtle velocity blur while moving and clears filter once settled.
fromDirection"auto" | "top" | "bottom" | "left" | "right""auto"Controls 3D tilt orientation; auto derives angle from triggerEl position.
stiffnessnumber125Spring stiffness constant for the entrance simulation.
dampingnumber29Spring damping constant controlling overshoot and settle speed.
tiltAnglenumber12Maximum 3D tilt angle in degrees.
initialScalenumber0.78Starting scale ratio before springing to 1.
motionBlurPxnumber4Peak motion blur radius in pixels during travel.
backdropBlurPxnumber4Static CSS backdrop blur radius in pixels.

Dialog

Compound modal root supporting controlled and uncontrolled open state plus shared spatial motion defaults.

PropTypeDefaultDescription
open / defaultOpen / onOpenChangeboolean / boolean / (open: boolean) => voiddefaultOpen=falseControlled or uncontrolled modal visibility state.
fromButton / depth3D / motionBlur / fromDirectionboolean / boolean / boolean / "auto" | "top" | "bottom" | "left" | "right"true / true / true / "auto"Spatial launch origin, 3D tilt, travel blur, and direction shared with DialogContent.
stiffness / damping / perspective / tiltAngle / initialScalenumber125 / 29 / 760 / 12 / 0.78Spring physics and 3D perspective parameters inherited by DialogContent.

DialogPortal / DialogOverlay / DialogContent

Portal host, blur backdrop overlay, and 3D spring dialog surface with automatic ARIA labeling and focus trap.

PropTypeDefaultDescription
container (DialogPortal)Element | nulldocument.bodyOptional DOM target for portaled dialog nodes.
backdropBlurPx (DialogOverlay)number4Backdrop blur radius in pixels.
showCloseButton (DialogContent)booleantrueRenders the top-right close button inside DialogContent.

DialogTrigger / DialogClose / DialogHeader / DialogFooter / DialogTitle / DialogDescription

Trigger and close buttons with asChild slot support plus accessible header, footer, title, and description slots.

PropTypeDefaultDescription
asChild (Trigger / Close)booleanfalseMerges click, ref, and ARIA attributes onto the child element.
showCloseButton (DialogFooter)booleanfalseAutomatically renders a Close button wrapped in DialogClose.

Notes

Always include DialogTitle inside DialogContent for screen readers (use className='sr-only' if visually hidden). Include DialogDescription or pass aria-describedby={undefined} to DialogContent.