Skip to content

Dialog

Get Ritla UI

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

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add dialog

    Also works with shadcn: npx shadcn@latest add @ritla/dialog

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or 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

dialog.tsx
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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

A list inside the dialog

Menus and lists opened from inside a dialog show above it, on the popover layer.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

API reference

Dialog / AlertDialog

PropTypeDefaultDescription
open / defaultOpen / onOpenChangebooleanNoneControls whether it's open.
disablePointerDismissalbooleanfalseA click outside doesn't close it (forms). Always so in AlertDialog.

DialogContent

PropTypeDefaultDescription
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 / finalFocusRefObject<HTMLElement>NoneWhere focus starts and where it returns.

DialogHeader

PropTypeDefaultDescription
titleReactNodeNoneFigma's Title; it names the dialog.
descriptionReactNodeNoneFigma's Description; it describes the dialog.
iconIconComponentNoneFigma'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.
closeButtonbooleantrueFigma's X close button.
closeLabelstring"Close"The close button's name, in the dialog's language by default.
dividerbooleanfalseFigma's Divider.
patternbooleanfalseFigma's Pattern: the decorative rings behind the icon.

DialogActions

PropTypeDefaultDescription
childrenReactNodeNoneThe buttons in reading order: Cancel, then confirm.
layout"fill" | "stacked" | "end""fill"The actions' Figma Type. On phones every type stacks, confirm on top.
startReactNodeNoneA checkbox or link at the row's start (layout="end").
dividerbooleanfalseFigma's Divider.

DialogSummary / DialogSummaryRow

PropTypeDefaultDescription
DialogSummarydlNoneThe summary card, inside DialogBody. 4 rows at most.
labelReactNodeNoneThe row's label (Row label).
childrenReactNodeNoneThe row's value (Row value). Wrap Latin text inside Arabic in <bdi>.

DialogBody / DialogTrigger / DialogClose

PropTypeDefaultDescription
DialogBodydivNoneThe content between header and actions; it scrolls when needed.
renderReactElementNoneThe 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.

KeyAction
TabShift+TabBetween the dialog's controls only; the page behind is inert.
EscCloses it and returns focus to the button that opened it.
EnterSubmits the form inside.

ARIA

  • Role dialog (or alertdialog for destructive confirmations) with aria-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-18 Semibold, description body-14, lg buttons.
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.

  • R022text-align: left explicitly set on majority-Arabic text
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space
  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)