Dialog
A trigger-anchored spatial modal dialog with 3D perspective tilt, spring physics, motion blur, and an accessible focus trap.
Customize
Installation
npx shadcn@latest add @kinetic/dialogUsage
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.
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Controls whether the dialog is open. |
onOpenChange | (open: boolean) => void | - | Called when the user clicks the backdrop, close button, or presses Escape. |
triggerEl | HTMLElement | null | - | Anchor element used to compute spatial origin offset and auto 3D tilt direction. |
title | string | - | Heading displayed at the top of the dialog and exposed as aria-label. |
badge | string | - | Optional eyebrow label rendered above the title. |
description | string | - | Optional supporting copy below the title. |
footer | React.ReactNode | - | Optional footer slot rendered inside a subtle bordered bar. |
fromButton | boolean | true | Animates the panel outward from the trigger button position. |
depth3D | boolean | true | Enables perspective rotateX/rotateY tilt during entrance and exit. |
motionBlur | boolean | true | Applies 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. |
stiffness | number | 125 | Spring stiffness constant for the entrance simulation. |
damping | number | 29 | Spring damping constant controlling overshoot and settle speed. |
tiltAngle | number | 12 | Maximum 3D tilt angle in degrees. |
initialScale | number | 0.78 | Starting scale ratio before springing to 1. |
motionBlurPx | number | 4 | Peak motion blur radius in pixels during travel. |
backdropBlurPx | number | 4 | Static CSS backdrop blur radius in pixels. |
Dialog
Compound modal root supporting controlled and uncontrolled open state plus shared spatial motion defaults.
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen / onOpenChange | boolean / boolean / (open: boolean) => void | defaultOpen=false | Controlled or uncontrolled modal visibility state. |
fromButton / depth3D / motionBlur / fromDirection | boolean / 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 / initialScale | number | 125 / 29 / 760 / 12 / 0.78 | Spring 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.
| Prop | Type | Default | Description |
|---|---|---|---|
container (DialogPortal) | Element | null | document.body | Optional DOM target for portaled dialog nodes. |
backdropBlurPx (DialogOverlay) | number | 4 | Backdrop blur radius in pixels. |
showCloseButton (DialogContent) | boolean | true | Renders 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.
| Prop | Type | Default | Description |
|---|---|---|---|
asChild (Trigger / Close) | boolean | false | Merges click, ref, and ARIA attributes onto the child element. |
showCloseButton (DialogFooter) | boolean | false | Automatically renders a Close button wrapped in DialogClose. |