Built on Radix UI Dialog
Dialog
A modal window with a pastel glass backdrop and an elastic pop-in animation. Focus is trapped while it is open and returned when it closes.
Playground
<ChibiDialog>
<ChibiDialogTrigger asChild>
<ChibiButton>Adopt a cat</ChibiButton>
</ChibiDialogTrigger>
<ChibiDialogContent>
<ChibiDialogHeader>
<ChibiDialogTitle>Adopt Mochi?</ChibiDialogTitle>
<ChibiDialogDescription>She enjoys naps and snacks.</ChibiDialogDescription>
</ChibiDialogHeader>
<ChibiInput label="Your name" />
<ChibiDialogFooter>
<ChibiDialogClose asChild>
<ChibiButton variant="ghost">Maybe later</ChibiButton>
</ChibiDialogClose>
<ChibiButton>Yes, adopt!</ChibiButton>
</ChibiDialogFooter>
</ChibiDialogContent>
</ChibiDialog>Import
import {
ChibiDialog,
ChibiDialogTrigger,
ChibiDialogContent,
ChibiDialogHeader,
ChibiDialogTitle,
ChibiDialogDescription,
ChibiDialogFooter,
ChibiDialogClose,
} from '@chibi-ui/react/dialog';Examples
const [open, setOpen] = useState(false);
<ChibiDialog open={open} onOpenChange={setOpen}>
<ChibiDialogContent size="sm">
<ChibiDialogHeader>
<ChibiDialogTitle>Delete snack?</ChibiDialogTitle>
<ChibiDialogDescription>This cannot be undone.</ChibiDialogDescription>
</ChibiDialogHeader>
<ChibiDialogFooter>
<ChibiDialogClose asChild>
<ChibiButton variant="ghost">Cancel</ChibiButton>
</ChibiDialogClose>
<ChibiButton onClick={() => { remove(); setOpen(false); }}>Delete</ChibiButton>
</ChibiDialogFooter>
</ChibiDialogContent>
</ChibiDialog>Accessibility
- role="dialog" with aria-modal. It is labelled by ChibiDialogTitle and described by ChibiDialogDescription.
- Focus moves into the dialog and is trapped there. On close it returns to the trigger.
- Closes on Esc and on outside click. The page behind it is scroll-locked and hidden from assistive tech.
- The close button has an accessible label, which you can set with closeLabel.
- Under prefers-reduced-transparency the glass blur becomes a solid backdrop. Under prefers-reduced-motion only the fade remains.
API reference
ChibiDialog
| Prop | Type | Default | Description |
|---|---|---|---|
| open / defaultOpen | boolean | โ | Controlled / uncontrolled open state. |
| onOpenChange | (open: boolean) => void | โ | Called when open state changes. |
| modal | boolean | true | Modal behaviour. |
ChibiDialogContent
| Prop | Type | Default | Description |
|---|---|---|---|
| size | 'sm' | 'md' | 'lg' | 'md' | Max width. |
| hideCloseButton | boolean | false | Hide the built-in close button. |
| closeLabel | string | 'Close dialog' | Close button label. |
| container | HTMLElement | null | โ | Portal container. |