Skip to content
ChibiUI

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

Generated code
<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

TSX
import {
  ChibiDialog,
  ChibiDialogTrigger,
  ChibiDialogContent,
  ChibiDialogHeader,
  ChibiDialogTitle,
  ChibiDialogDescription,
  ChibiDialogFooter,
  ChibiDialogClose,
} from '@chibi-ui/react/dialog';

Examples

Controlled dialog
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

PropTypeDefaultDescription
open / defaultOpenbooleanโ€”Controlled / uncontrolled open state.
onOpenChange(open: boolean) => voidโ€”Called when open state changes.
modalbooleantrueModal behaviour.

ChibiDialogContent

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Max width.
hideCloseButtonbooleanfalseHide the built-in close button.
closeLabelstring'Close dialog'Close button label.
containerHTMLElement | nullโ€”Portal container.