Components / Dialog
Dialog
A focused conversation above the page. Use Dialog for contextual information and reversible workflows, not urgent blocking alerts.
Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.
Usage playground
Open a focused information panel. Change the accessible title and description, then copy the complete example.
"use client";
import { Button } from "@/components/ui/yads-button";
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/ui/yads-dialog";
export default function WorkspaceInformation() {
Installation
pnpm dlx [email protected] add biehlio/yet-another-design-system/dialog#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40Documentation samples use basic Tailwind utilities for layout. Install each YADS component imported by the sample.
Requires a project configured for shadcn. Installs @/components/ui/yads-dialog, its CSS module, @radix-ui/react-dialog and JetBrains Mono. No Tailwind, theme globals, Input or Label component is required. Adjust import aliases to your project.
Examples also use the released YADS Button: install the Button registry item separately. Dialog itself has no Button dependency. Copy sample includes a complete client module, even while collapsed. Add a client boundary in React Server Component apps.
Controlled confirmation
Review a reversible local action. Cancel, Escape and clicking the overlay dismiss without changing the project. Confirm closes the controlled dialog and announces completion. For urgent, blocking decisions that must not dismiss outside, use AlertDialog instead.
Spring launch is active.
"use client";
import { useRef, useState } from "react";
import { Button } from "@/components/ui/yads-button";
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/ui/yads-dialog";
Customization
Pass className or style to Content, Header, Footer, Title and Description. Content owns its scoped colors; no site stylesheet is needed. The nearest explicit .light or .dark ancestor of Dialog is carried through the body portal and updates when that ancestor changes. Without one, the component uses light mode.
For a wider panel, pass a className recipe that sets width: min(40rem, calc(100% - 2rem)) with enough specificity to override Content’s width. Keep the viewport gutter and max-height. Color overrides may set --yads-dialog-background, --yads-dialog-foreground, --yads-dialog-muted, --yads-dialog-border and --yads-dialog-ring on Content. Check contrast and keyboard focus in both themes. Portalled content is not a DOM descendant of your page wrapper: target its own class, not wrapper-descendant selectors.
Accessibility
- Always include a meaningful
DialogTitleand normally a conciseDialogDescription. Radix links them to the dialog automatically. If description is intentionally omitted, setaria-describedby={undefined}on Content. Do not omit the title. - Modal is the default: Tab and Shift+Tab stay inside, background pointer interactions and scrolling are blocked, and background content is hidden from assistive technology. Escape, the named close button and overlay pointer dismissal close the dialog. Focus returns to its trigger.
- Keep a trigger mounted for reliable focus return. Use
onOpenAutoFocusto focus a safe first action (Cancel in the confirmation), not a destructive action. Do not override autofocus without moving focus yourself. - This is Dialog, not AlertDialog. Confirmation here is reversible and dismissible. For an interruptive decision requiring an explicit response, choose AlertDialog semantics and behavior instead.
API reference
All exports come from @/components/ui/yads-dialog. Root, Trigger, Close, Portal and Overlay retain Radix Dialog props. Styled elements forward refs and native attributes. Content always renders a div with role="dialog" and does not support asChild or forceMount; Title renders h2 and Description renders p. Native IDs, ARIA attributes, data attributes, styles and event handlers are forwarded.
| Export | Props | Type / default | Behavior |
|---|---|---|---|
| Dialog | open / defaultOpen | boolean / false | Controlled or uncontrolled visibility. Use onOpenChange(open) with open. |
| Dialog | modal | boolean / true | Modal traps focus and blocks background interactions. Non-modal opts out; most uses should retain true. |
| DialogTrigger / DialogClose | asChild | boolean / false | Merge behavior into one ref-forwarding child; otherwise renders a native button. |
| DialogContent | ref, className, style | HTMLDivElement / not set | Always renders a div; asChild and forceMount are not supported. Includes its own portal, overlay and named close button. |
| DialogContent | onOpenAutoFocus / onCloseAutoFocus | event callbacks / Radix defaults | Focus first focusable child on open and trigger on close; preventDefault only when providing a sensible alternative. |
| DialogContent | onEscapeKeyDown / onPointerDownOutside / onInteractOutside | event callbacks / dismiss | Radix events; preventDefault can stop dismissal. Do not remove every way to close. |
| DialogTitle / DialogDescription | children, ref, native attributes | ReactNode / not set | Required meaningful title and normally a description. Render h2 and p; IDs associate them with Content. |
| DialogHeader / DialogFooter | children, ref, native attributes | ReactNode / not set | Layout-only divs, no dialog semantics. |
| DialogPortal / DialogOverlay | Radix primitive props | body container / not forced | Used internally by DialogContent. Do not wrap Content in a second portal or add a second overlay. |
Content owns its portal, overlay and close button, and mounts only while open. It does not expose independent portal/overlay props. Unsupported asChild and forceMount values from untyped callers are ignored; they cannot change the div or mount closed content.
Responsive behavior
The panel keeps a one-rem viewport gutter, caps height to the dynamic viewport and scrolls internally. Footer actions stack below 480px; long content wraps. Close has a 44px target. Reduced motion removes opening fades. No swipe-to-dismiss gesture is required. On narrow screens the section rail becomes a keyboard-accessible disclosure; Escape closes it and returns focus.