Dialog
Stops the flow to confirm an action, warn about a risk or collect a short input. It sits on a dimmed overlay and keeps focus until it closes.
Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add dialogAlso works with shadcn:
npx shadcn@latest add @ritla/dialogDependencies it brings
@base-ui/react@phosphor-icons/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { Dialog, DialogActions, DialogClose, DialogContent, DialogHeader, DialogTrigger } from "@/components/ui/dialog";<Dialog> <DialogTrigger render={<Button />}>Send money</DialogTrigger> <DialogContent> <DialogHeader icon={CheckCircleIcon} iconColor="success" title="Transfer sent" description="It usually arrives within a few minutes." /> <DialogActions> <DialogClose render={<Button variant="outline" />}>View receipt</DialogClose> <DialogClose render={<Button />}>Done</DialogClose> </DialogActions> </DialogContent></Dialog>Examples
Warning, horizontal
layout="horizontal" puts the icon beside the text at 544px (size="lg"), and layout="end" gathers the buttons at the inline end. For wide screens and short text.
Destructive confirmation
AlertDialog for what deletes or removes: role alertdialog, a click outside doesn't close it, and focus starts on Cancel. The title asks a specific question, the red button repeats the verb, and the card number stays left to right.
A short task in a form
Focus starts in the field and Enter sends. disablePointerDismissal stops a click outside from closing it, so nothing typed is lost.
Long content
The dialog never runs past the screen: DialogBody scrolls while the header and actions stay put. Here with dividers above and below the body, and a checkbox at the start of the action row.
A list inside the dialog
Menus and lists opened from inside a dialog show above it, on the popover layer.
A summary of what it affects
DialogSummary lists the facts the action touches as label and value rows, 4 at most. The value sits at the inline end (the left in Arabic), amounts go through formatNumber so they follow the numerals setting, and the currency comes after the number in Arabic. The header keeps Figma's defaults: a brand icon and no pattern.
API reference
Dialog / AlertDialog
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen / onOpenChange | boolean | None | Controls whether it's open. |
disablePointerDismissal | boolean | false | A click outside doesn't close it (forms). Always so in AlertDialog. |
DialogContent
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | "xl" | "sm" | Width: 400 for confirmations, 480, 544 for Horizontal, 640 for forms. |
breakpoint | "auto" | "desktop" | "mobile" | "auto" | Figma's Breakpoint: centred on desktop, at the bottom on phones. |
initialFocus / finalFocus | RefObject<HTMLElement> | None | Where focus starts and where it returns. |
DialogHeader
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | None | Figma's Title; it names the dialog. |
description | ReactNode | None | Figma's Description; it describes the dialog. |
icon | IconComponent | None | Figma's Featured icon. |
iconColor | "brand" | "gray" | "success" | "warning" | "error" | "brand" | The Icon holder's Color. Pass success to confirm a success and error for what deletes. |
layout | "stacked" | "centered" | "horizontal" | "stacked" | The header's Figma Type. |
closeButton | boolean | true | Figma's X close button. |
closeLabel | string | "Close" | The close button's name, in the dialog's language by default. |
divider | boolean | false | Figma's Divider. |
pattern | boolean | false | Figma's Pattern: the decorative rings behind the icon. |
DialogActions
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | None | The buttons in reading order: Cancel, then confirm. |
layout | "fill" | "stacked" | "end" | "fill" | The actions' Figma Type. On phones every type stacks, confirm on top. |
start | ReactNode | None | A checkbox or link at the row's start (layout="end"). |
divider | boolean | false | Figma's Divider. |
DialogSummary / DialogSummaryRow
| Prop | Type | Default | Description |
|---|---|---|---|
DialogSummary | dl | None | The summary card, inside DialogBody. 4 rows at most. |
label | ReactNode | None | The row's label (Row label). |
children | ReactNode | None | The row's value (Row value). Wrap Latin text inside Arabic in <bdi>. |
DialogBody / DialogTrigger / DialogClose
| Prop | Type | Default | Description |
|---|---|---|---|
DialogBody | div | None | The content between header and actions; it scrolls when needed. |
render | ReactElement | None | The visible button for DialogTrigger and DialogClose. |
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| TabShift+Tab | Between the dialog's controls only; the page behind is inert. |
| Esc | Closes it and returns focus to the button that opened it. |
| Enter | Submits the form inside. |
ARIA
- Role
dialog(oralertdialogfor destructive confirmations) witharia-modal; the title names it and the description describes it. - Focus starts in the first field, or on Cancel in a destructive confirmation, and returns to the button that opened it.
- The close button has a name (Close). Danger isn't shown by the red button alone: the title and the verb say it.
- It opens in 300ms, and only fades under reduced motion.
- The summary is a description list (
<dl>), so screen readers pair each label with its value.
Arabic and RTL notes
Mirrors
- The icon and text align right, and the close button moves to the top left.
- The buttons mirror: Cancel on the right, the confirm button on the left, at the inline end.
- Summary rows mirror: the label on the right, the value on the left.
- The dialog carries the direction and language of where it's written, even though it's portaled.
Does not mirror
- The success, warning and trash icons, and the symmetric rings.
- Numerals
- Amounts follow the numerals setting; card numbers stay left to right inside
<bdi dir="ltr">. - Arabic typography
- Title
body-18Semibold, descriptionbody-14,lgbuttons. - Mixed-direction text
- Write the title as a specific question: “Remove this card?”, not “Are you sure?”.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- text-align: left explicitly set on majority-Arabic text
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)