Dialog, Popover, DropdownMenu
Fiddlebg-overlay with one hairline and shadow-overlay.Usage
The import, then a use to start from. Both copy as they are.
Import
import { Button } from "@/components/ui/button";import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger} from "@/components/ui/dialog";Example
<Dialog> <DialogTrigger asChild> <Button variant="destructiveOutline">Delete site</Button> </DialogTrigger> <DialogContent> <DialogHeader> <DialogTitle>Delete docs.acme.dev?</DialogTitle> <DialogDescription>Visitors will see a 404 until you publish again.</DialogDescription> </DialogHeader> <DialogFooter> <DialogClose asChild> <Button variant="outline">Cancel</Button> </DialogClose> <Button variant="destructive" onClick={deleteSite}> Delete site </Button> </DialogFooter> </DialogContent></Dialog>When to use
Use it for
Dialogfor a decision that blocks the page: confirming a destructive step, or a short form.DialogBodyholds anything between the header and the footer.Popoverfor a small interactive panel anchored to its trigger: a filter, a picker.DropdownMenufor actions on a thing, with destructive items last.- All three sit on
bg-overlaywith one hairline andshadow-overlay; don't restyle them.
Avoid
- A dialog for information that fits on the page, or for a long flow: give the flow a page.
- A popover with only text in it: that's a
Tooltip.
Accessibility
Checks
- Dialogs trap focus, close on Escape and return focus to the trigger. Keep
DialogTitle, even when it's visually hidden. - Menus move with the arrow keys and type-ahead, and every item has a text label.
API
Read from each component's stories, the same source as COMPONENTS.md, and kept in step by check:design-system.
Dialog
Its stories don't declare
argTypes, so no props are listed. The variants show its states.Also exportsDialogBodyDialogCloseDialogContentDialogDescriptionDialogFooterDialogHeaderDialogOverlayDialogPortalDialogTitleDialogTrigger
VariantsDefaultPersistentOpenByDefault
Popover
Its stories don't declare
argTypes, so no props are listed. The variants show its states.Also exportsPopoverAnchorPopoverClosePopoverContentPopoverTrigger
VariantsDefaultOpenByDefault
DropdownMenu
Its stories don't declare
argTypes, so no props are listed. The variants show its states.Also exportsDropdownMenuCheckboxItemDropdownMenuContentDropdownMenuGroupDropdownMenuItemDropdownMenuLabelDropdownMenuPortalDropdownMenuRadioGroupDropdownMenuRadioItemDropdownMenuSeparatorDropdownMenuShortcutDropdownMenuSubDropdownMenuSubContentDropdownMenuSubTriggerDropdownMenuTrigger
VariantsDefaultWithCheckboxItemsWithCheckboxIndicatorsWithRadioItemsWithSubmenuWithRadioItemsWithoutIndicator