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

VariantPurpose
ConvenienceCompatible trigger, title, description, body, footer, and close path.
CompoundMeaningful parts may be omitted, reordered, or customized while Base UI retains behavior.

Anatomy

SlotPurpose
triggerControl that opens the dialog.
portalOptional container boundary for portalled modal content.
backdropBackdrop that separates the dialog from the page.
contentModal surface rendered through a portal.
headerTitle, optional description, and close boundary.
headingGrouped title and optional description.
titleRequired accessible dialog name; renders as a neutral 16 px div by default.
descriptionOptional supporting context using the standard 14 px body size.
bodyTask, decision, and action content that scrolls within the viewport boundary.
footerOptional action row aligned to the inline end.
closeSecondary icon Button with a localizable accessible name.

States

StatePurpose
OpenFocus moves into the dialog.
ClosedFocus 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

PropPurpose
triggerReact node or text that opens the dialog.
title / descriptionAccessible dialog name and optional context. titleAs opts into h2-h6 only when the title belongs in the document outline.
bodyClassNameOptional class hook for the body slot.
DialogRoot and compound partsExpose Trigger, Portal, Backdrop, Content, Header, Title, Description, Body, Footer, and Close without changing the convenience Dialog API.
closeLabelAccessible close-control name; defaults to "Close dialog".

Implementation contract

ContractValue
Registry itemdialog installs 7 source files into the configured components directory.
Base UIdialog
Registry dependenciesbutton
Package dependencies@base-ui/react, @nerio-ui/adapters, clsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly 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

Do

Use the convenience API for the common path and compound parts only when the task needs structural control.

Do not

Do not use Dialog for long workflows or consequential confirmation that belongs in AlertDialog.

Tokens

These are the primary customization points. Override semantic or component tokens instead of changing component source.

TokenPurpose
--n-dialog-width-mdPublic customization point for this component contract.
--n-dialog-viewport-insetPublic customization point for this component contract.
--n-dialog-paddingPublic customization point for this component contract.
--n-dialog-header-gapPublic customization point for this component contract.
--n-dialog-header-marginPublic customization point for this component contract.
--n-dialog-body-gapPublic customization point for this component contract.
--n-overlay-z-indexPublic customization point for this component contract.
--n-overlay-floating-z-indexPublic customization point for this component contract.
--n-overlay-backgroundPublic customization point for this component contract.
--n-overlay-borderPublic customization point for this component contract.
--n-overlay-backdropPublic customization point for this component contract.
--n-overlay-backdrop-filterPublic customization point for this component contract.
--n-overlay-foregroundPublic customization point for this component contract.
--n-overlay-foreground-mutedPublic customization point for this component contract.
--n-overlay-control-backgroundPublic customization point for this component contract.
--n-overlay-control-background-hoverPublic customization point for this component contract.
--n-overlay-surface-filterPublic customization point for this component contract.
--n-overlay-shadowPublic customization point for this component contract.
--n-input-background-on-overlayPublic customization point for this component contract.
--n-input-background-on-overlay-hoverPublic customization point for this component contract.
--n-input-foreground-on-overlayPublic customization point for this component contract.
--n-input-placeholder-on-overlayPublic customization point for this component contract.
--n-motion-overlay-enter-durationPublic customization point for this component contract.
--n-motion-overlay-enter-easingPublic customization point for this component contract.
--n-motion-overlay-exit-durationPublic customization point for this component contract.
--n-motion-overlay-exit-easingPublic customization point for this component contract.
--n-focus-ringPublic customization point for this component contract.