Dialog
Dialogs focus a short decision or task above the current product surface.
Overview and decision boundary
Use Dialog to focus a short task or reversible decision above the current surface; use AlertDialog when a consequential action requires an explicit response.
Do not use Dialog for long workflows or consequential confirmation that belongs in AlertDialog.
import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPortal, DialogRoot, DialogTitle, DialogTrigger } from '@nerio-ui/ui/client';<Dialog trigger="Open dialog" title="Share collection">...</Dialog><DialogRoot> <DialogTrigger render={<Button>Open custom dialog</Button>} /> <DialogPortal> <DialogContent> <DialogHeader> <DialogTitle>Move collection</DialogTitle> <DialogDescription>Choose a destination workspace.</DialogDescription> </DialogHeader> ... <DialogFooter> <DialogClose render={<Button variant="secondary">Cancel</Button>} /> <Button>Move collection</Button> </DialogFooter> </DialogContent> </DialogPortal></DialogRoot>Installation and imports
Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.
pnpm exec nerio add dialogimport { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPortal, DialogRoot, DialogTitle, DialogTrigger } from '@nerio-ui/ui/client';Usage
import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPortal, DialogRoot, DialogTitle, DialogTrigger } from '@nerio-ui/ui/client';<Dialog trigger="Open dialog" title="Share collection">...</Dialog><DialogRoot> <DialogTrigger render={<Button>Open custom dialog</Button>} /> <DialogPortal> <DialogContent> <DialogHeader> <DialogTitle>Move collection</DialogTitle> <DialogDescription>Choose a destination workspace.</DialogDescription> </DialogHeader> ... <DialogFooter> <DialogClose render={<Button variant="secondary">Cancel</Button>} /> <Button>Move collection</Button> </DialogFooter> </DialogContent> </DialogPortal></DialogRoot>Variants
| Variant | Purpose |
|---|---|
Convenience | Compatible trigger, title, description, body, footer, and close path. |
Compound | Meaningful parts may be omitted, reordered, or customized while Base UI retains behavior. |
Anatomy
| Slot | Purpose |
|---|---|
trigger | Control that opens the dialog. |
portal | Optional container boundary for portalled modal content. |
backdrop | Backdrop that separates the dialog from the page. |
content | Modal surface rendered through a portal. |
header | Title, optional description, and close boundary. |
heading | Grouped title and optional description. |
title | Required accessible dialog name; renders as a neutral 16 px div by default. |
description | Optional supporting context using the standard 14 px body size. |
body | Task, decision, and action content that scrolls within the viewport boundary. |
footer | Optional action row aligned to the inline end. |
close | Secondary icon Button with a localizable accessible name. |
States
| State | Purpose |
|---|---|
Open | Focus moves into the dialog. |
Closed | Focus returns to the trigger. |
Motion
- overlay entry and exit
- reduced-motion fade-only state change
Accessibility
- Uses the Base UI Dialog primitive.
- The existing Dialog convenience API remains compatible; DialogRoot, DialogTrigger, DialogPortal, DialogBackdrop, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogBody, DialogFooter, and DialogClose expose meaningful compound anatomy.
- The title renders as a neutral 16px div by default; titleAs opts into h2-h6 only when the title belongs in the document outline. The optional description uses the standard 14px body size.
- Focus is trapped while the dialog is open and returns to the trigger on close.
- Defaults closeLabel to "Close dialog" for the secondary icon Button; provide a localized accessible name when needed.
- Compound DialogContent supports deliberate initialFocus and finalFocus targets while every modal composition retains a keyboard-reachable DialogClose.
- Supports controlled open, uncontrolled defaultOpen, onOpenChange, and forwarded trigger, portal, backdrop, content, title, description, body, footer, and close refs.
Review the shared responsibility and evidence boundaries in the Accessibility foundation alongside this component-specific contract. Use the Spacing & layout foundation for shared density, wrapping, overflow, reflow, and component-versus-product ownership guidance. The Color foundation, Typography foundation, and Localization foundation define the shared visual-role, text-resilience, direction, and locale boundaries used by component examples.
API
| Prop | Purpose |
|---|---|
trigger | React node or text that opens the dialog. |
title / description | Accessible dialog name and optional context. titleAs opts into h2-h6 only when the title belongs in the document outline. |
bodyClassName | Optional class hook for the body slot. |
DialogRoot and compound parts | Expose Trigger, Portal, Backdrop, Content, Header, Title, Description, Body, Footer, and Close without changing the convenience Dialog API. |
closeLabel | Accessible close-control name; defaults to "Close dialog". |
Implementation contract
| Contract | Value |
|---|---|
Registry item | dialog installs 7 source files into the configured components directory. |
Base UI | dialog |
Registry dependencies | button |
Package dependencies | @base-ui/react, @nerio-ui/adapters, clsx, react, tailwind-merge, tailwindcss |
Styling contract
| Contract | Value |
|---|---|
Authoring | Complete, statically detectable Tailwind CSS v4 recipes own component visuals. |
Values | Semantic and component --n-* variables remain the canonical customization layer. |
Overrides | Customizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically. |
Residual CSS | Only shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer. |
Design notes
- Use Dialog to focus a short task or reversible decision above the current surface; use AlertDialog when a consequential action requires an explicit response.
Do / do not
Use the convenience API for the common path and compound parts only when the task needs structural control.
Do not use Dialog for long workflows or consequential confirmation that belongs in AlertDialog.
Related components
Tokens
These are the primary customization points. Override semantic or component tokens instead of changing component source.
| Token | Purpose |
|---|---|
--n-dialog-width-md | Public customization point for this component contract. |
--n-dialog-viewport-inset | Public customization point for this component contract. |
--n-dialog-padding | Public customization point for this component contract. |
--n-dialog-header-gap | Public customization point for this component contract. |
--n-dialog-header-margin | Public customization point for this component contract. |
--n-dialog-body-gap | Public customization point for this component contract. |
--n-overlay-z-index | Public customization point for this component contract. |
--n-overlay-floating-z-index | Public customization point for this component contract. |
--n-overlay-background | Public customization point for this component contract. |
--n-overlay-border | Public customization point for this component contract. |
--n-overlay-backdrop | Public customization point for this component contract. |
--n-overlay-backdrop-filter | Public customization point for this component contract. |
--n-overlay-foreground | Public customization point for this component contract. |
--n-overlay-foreground-muted | Public customization point for this component contract. |
--n-overlay-control-background | Public customization point for this component contract. |
--n-overlay-control-background-hover | Public customization point for this component contract. |
--n-overlay-surface-filter | Public customization point for this component contract. |
--n-overlay-shadow | Public customization point for this component contract. |
--n-input-background-on-overlay | Public customization point for this component contract. |
--n-input-background-on-overlay-hover | Public customization point for this component contract. |
--n-input-foreground-on-overlay | Public customization point for this component contract. |
--n-input-placeholder-on-overlay | Public customization point for this component contract. |
--n-motion-overlay-enter-duration | Public customization point for this component contract. |
--n-motion-overlay-enter-easing | Public customization point for this component contract. |
--n-motion-overlay-exit-duration | Public customization point for this component contract. |
--n-motion-overlay-exit-easing | Public customization point for this component contract. |
--n-focus-ring | Public customization point for this component contract. |