Install
Pull Dialog from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Dialog } from "@brika/clay";import { Dialog } from "@brika/clay/components/dialog";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { Button } from '@brika/clay/components/button';
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@brika/clay/components/dialog';
/** Clean modal with a title, description, and two footer actions. */
export default function DialogDefaultDemo() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Open dialog</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Session expiring soon</DialogTitle>
<DialogDescription>
Your session will expire in 5 minutes due to inactivity. Save any
unsaved work before continuing.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose asChild>
<Button variant="outline">Dismiss</Button>
</DialogClose>
<Button>Extend session</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}Dialog, every way
Accessibility
- Focus is trapped inside the dialog while open, Tab cycles only through its interactive elements.
- Escape and clicking the backdrop close the dialog and return focus to the trigger.
-
DialogTitleis required and becomes the accessible name, usesr-onlyto visually hide it if needed. - Scrollable content should be the scrollable region, not the entire dialog.
Theme tokens
Every CSS variable Dialog reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Dialog
without touching component code.
Dialog tokens
19 tokens--dialog-containercolorvar(--popover)components.dialog.containerDialog background.
--dialog-labelcolorvar(--popover-foreground)components.dialog.labelDialog text color.
--dialog-overlay-bgcoloroklch(0 0 0 / 0.5)components.dialog.overlayBgModal scrim color behind the dialog. Lower alpha + non-zero `overlay-backdrop-blur` produces an iOS-style glass scrim that frosts the page instead of dimming it.
--dialog-description-colorcolorvar(--muted-foreground)components.dialog.descriptionColorForeground color of `<DialogDescription>` text rendered beneath the dialog title.
--dialog-close-active-containercolorvar(--accent)components.dialog.closeActiveContainerBackground of the built-in close-X button when its data-state is open.
--dialog-close-active-labelcolorvar(--muted-foreground)components.dialog.closeActiveLabelGlyph color of the built-in close-X button when its data-state is open.
--dialog-close-focus-ring-colorcolorvar(--ring)components.dialog.closeFocusRingColorFocus ring color of the built-in close-X button when keyboard-focused. Defaults to the theme ring color.
--dialog-close-focus-ring-offset-colorcolorvar(--background)components.dialog.closeFocusRingOffsetColorColor drawn between the close-X button and its focus ring (the ring offset). Should match the page background so the offset reads as a gap.
--dialog-radiusradiusvar(--radius-surface)components.dialog.radiusDialog corner radius.
--dialog-padding-xsizecalc(var(--spacing) * 6)components.dialog.paddingXInline padding inside the dialog.
--dialog-padding-ysizecalc(var(--spacing) * 6)components.dialog.paddingYBlock padding inside the dialog.
--dialog-gapsizecalc(var(--spacing) * 4)components.dialog.gapGap between adjacent children inside the dialog.
--dialog-border-widthborder-width1pxcomponents.dialog.borderWidthBorder width on the dialog. Set non-zero for outline-style variants.
--dialog-border-styleborder-stylesolidcomponents.dialog.borderStyleBorder style on the dialog (`solid`, `dashed`, `double`, `none`).
--dialog-overlay-backdrop-blurblur0pxcomponents.dialog.overlayBackdropBlurBackdrop blur applied to the modal scrim. Set non-zero so the page content behind the dialog is frosted by the overlay itself.
--dialog-shadowshadowvar(--shadow-modal)components.dialog.shadowDialog elevation.
--dialog-backdrop-blurblur0pxcomponents.dialog.backdropBlurBackdrop blur applied behind a translucent dialog.
--dialog-durationdurationvar(--motion-standard-duration)components.dialog.durationTransition duration for dialog state changes.
--dialog-easingeasingvar(--motion-standard-easing)components.dialog.easingTransition easing for dialog state changes.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.dialog, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"dialog": {
"paddingX": "calc(var(--spacing) * 6)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-dialog-…) — see the
chips on each token row.
API reference
Props specific to Dialog. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<Dialog />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogClose />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogContent />
1 prop- showCloseButtondefault
truebooleanRender the built-in close X.
<DialogDescription />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogFooter />
1 prop- showCloseButtondefault
falsebooleanRender a "Close" button in the footer.
<DialogHeader />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogOverlay />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogPortal />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogTitle />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DialogTrigger />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.