Skip to contentKino
Skip to Content

Dialog

A dialog that rises into the centre, and is a sheet on the bottom edge of a small screen.

npx shadcn add https://kinoui.com/r/dialog.json
Share on

Examples

Default

It rises into the centre and leaves faster than it came. On a screen under 640px wide it is a sheet on the bottom edge.

Long content

Put what can grow in DialogBody. It scrolls, and the header and the footer stay in place.

Without the close button

When the footer’s buttons are the answer, leave the close button out with showCloseButton={false}. Escape still closes it.

Content that changes height

When content appears or goes, the box moves to its new height and the footer stays on its bottom edge.

A dialog on a dialog

Put the second Dialog inside the first one’s content. The first steps back, and Escape closes only the one on top.

Controlled

A dialog opened with the open prop needs no trigger. When it closes, focus goes back to what had it before.

Installation

npx shadcn@latest add https://kinoui.com/r/dialog.json
Files
lib/reduce-motion.tslib/resize.tslib/scroll.tslib/panel.tsxlib/refs.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/dialog.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Dialog

PropTypeDefaultDescription
defaultOpenbooleanfalseWhether it is open at first, when you leave the state to the dialog.
openbooleanNoneWhether it is open, when you hold the state.
onOpenChange(open, details) => voidNoneCalled when it opens or closes.

DialogContent

PropTypeDefaultDescription
showCloseButtonbooleantrueShows the close button in the top corner. Without it, the title takes the room it left.
classNamestringNoneThe width: max-w-md unless you set another.
initialFocusRefObjectfunctionbooleanNoneWhat takes focus when it opens, in place of the first control or the scrolling body.
finalFocusRefObjectfunctionbooleanNoneWhat takes focus when it closes, in place of the trigger. Set it when the action removes the trigger.
containerHTMLElementShadowRootRefObjectdocument.bodyWhere it renders. Give that element contain: layout and overflow: clip, and the dialog treats it as the screen.

DialogBody

PropTypeDefaultDescription
classNamestringNoneGoes to its content, for padding and gaps.
...propsComponentProps<'div'>NoneEvery other prop, and ref, goes to the element that scrolls.

CSS variables

VariableSet it onDefaultDescription
--dialog-riseDialogContent, or <body>1remHow far it rises into place. It leaves by half of that.
--dialog-recede-scaleDialogContent, or <body>0.95How far it steps back while a dialog opens on top of it.

Accessibility

  • Focus moves into the dialog when it opens, Tab stays inside it, and Escape or a press outside closes it. Focus then goes back to the trigger.
  • Every dialog needs a DialogTitle, which names it for a screen reader. Give it sr-only to hide it.
  • While the body scrolls it takes focus first, so the arrow keys scroll it, and a screen reader hears it as a region named by the title.
  • On a screen under 448px tall, such as a phone on its side, the whole dialog scrolls, so the body is never a slit.
  • When the system asks for less motion, the dialog fades in and out where it stands, and a change of height is instant.