Dialog

Modal with trapped focus, a restored return point, four positions and a choice of backdrops.

Source
1 file
Dependencies
framer-motion
Playground
no

Examples

Every variant of the shipped component, live. Switch the layout to read them as a table or one at a time, and open Code for the file behind them.

01Form
02Confirm
03Sizes
04Position
05Animation
06Backdrop
07Scrollable

Installation

One package for the whole library — run this once and every component on this site is importable. Adding the tokens to your stylesheet is the other half; the installation guide covers it.

npm install kipui
import { Dialog } from "kipui";
Peer dependencies

react 19

react-dom 19

tailwindcss 4

Bundled dependencies

framer-motion

Usage

dialog-example.tsx
import { Dialog } from "kipui";

<Dialog
  open={open}
  onClose={() => setOpen(false)}
  title="Delete project"
  description="This removes the project and everything in it."
  footer={<Button variant="destructive" onClick={remove}>Delete</Button>}
/>
  • Focus is trapped while open and returned to whatever opened it on close — you don't wire that up yourself.
  • `initialFocus` points at the element that should receive focus first; default is the panel.
  • Turning off both `closeOnEsc` and `closeOnBackdropClick` leaves the close button as the only exit — make sure it's visible.

API reference

Transcribed from the component's own types. Props with no default are required.

PropDefaultDescription
openbooleanrequiredControlled open state.
onClose() => voidrequiredFires on Esc, backdrop click and the close button.
size"sm" | "md" | "lg" | "xl" | "full""md"Panel width.
position"center" | "top" | "bottom" | "left" | "right""center"Where the panel sits in the viewport.
backdrop"blur" | "dim" | "none""dim"Treatment behind the panel.
animation"fade" | "zoom" | "slide""zoom"Enter and exit motion.
closeOnEscbooleantrueEsc dismisses.
closeOnBackdropClickbooleantrueClicking outside dismisses.
showCloseButtonbooleantrueCorner close button.
preventScrollbooleantrueLocks body scroll while open.
initialFocusRefObject<HTMLElement>requiredElement focused on open.
titleReactNoderequiredHeading in the panel, wired to `aria-labelledby`.
descriptionReactNoderequiredLine under the title, wired to `aria-describedby`.
footerReactNoderequiredActions row along the bottom of the panel.
variant"default" | "destructive" | "warning" | "success""default"Colour of the title and its icon.
durationnumber200Enter and exit duration in ms. Drives both the transition and the unmount.
zIndexnumber3000Stacking order of the overlay and panel.
overlayClassNamestringrequiredClasses for the backdrop.
contentClassNamestringrequiredClasses for the padded wrapper inside the panel.