Alert dialog
A question that needs an answer before something that can’t easily be undone. A press outside makes it swell instead of closing it.
Examples
Default
It rises into the centre like the Dialog. A press outside makes it swell instead of closing it, and focus starts on Cancel.
Badge
With variant='badge' the question sits centred under an icon in AlertDialogMedia, and the answers stack.
An action that takes time
Return a promise from onClick: the dialog stays open with a spinner until it settles, and stays open when it rejects. This one fails once.
Type to confirm
For the highest stakes, ask for the name in AlertDialogBody, start focus there with initialFocus, and allow the action once it matches.
Controlled
Opened with open, it needs no trigger, as when a menu item asks first. Focus goes back to what had it before.
Installation
npx shadcn@latest add https://kinoui.com/r/alert-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.tsxlib/refuse.tscomponents/kino/alert-dialog.tsx- Packages
@base-ui/reactclass-variance-authority- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
AlertDialog
AlertDialogContent
AlertDialogMedia
AlertDialogAction
Data attributes
Accessibility
- It is an
alertdialog: focus moves into it and stays there, and a screen reader reads the title and the description when it opens. - Focus starts on Cancel, the safe answer, so Enter right after it opens does nothing that can’t be undone. When it closes, focus goes back to the trigger; set
finalFocuswhen the action removes it. - A press outside doesn’t close it. Escape does, except while an action runs, and so does Cancel.
- While an action runs, the action button keeps focus and is announced as busy, and Cancel waits. An error in
AlertDialogErroris announced, and focus stays on the action, ready to try again. - When the system asks for less motion, it fades in and out where it stands, and at a press outside Cancel lights up instead of the dialog swelling.