Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Dialog

  • Stable
  • WCAG 2.2 evidence
  • RTL
  • Web · iOS · Android

A short modal question that needs a decision before work continues, such as "Submit October payroll?". Built on React Aria ModalOverlay + Modal + Dialog: a role="dialog" (or role="alertdialog" for destructive confirmations) named by its title and described by its body; focus moves inside on open (to the secondary action when destructive), Tab stays inside while the page is inert, Escape closes it, and focus returns to the trigger (WCAG 2.1.1, 2.1.2, 2.4.3, 3.3.4, 4.1.2). Consumer duties: a title that asks the question and labels that name the outcome; for long forms use Modal.

import { Dialog } from "@nexera-ui/react";
Loading example…
8
examples
22
props
7
live controls
3
platforms
9
WCAG criteria
5
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
title
children
variant
role
platform
isDismissable
defaultOpen
Generated code
import { Dialog } from "@nexera-ui/react";

<Dialog />

Examples 7

The same examples as Storybook, rendered live. Open Code to copy one.

Destructive

Figma Variant=Destructive: an alertdialog with the trash icon and a destructive primary action. Focus starts on Cancel, so pressing Enter by habit does not delete anything.

Loading example…

IOS

Figma Platform=iOS: a centred alert with a row of text buttons (no icon, no close button).

Loading example…

IOS destructive

Figma Platform=iOS, Variant=Destructive: the destructive action is red.

Loading example…

Android

Figma Platform=Android: an icon above a centred title, and ghost actions at the end.

Loading example…

With content

Figma Show content: extra content under the body.

Loading example…

Long content

Long titles, bodies and labels wrap; the footer buttons wrap when they do not fit.

Loading example…

Right to left

Right-to-left: the icon and title start on the right; actions sit on the left.

Loading example…

Props 22

Press "Try it" on a card to load that prop into the playground.

22 props shown

title*Nexera
ReactNode

Title: a level 2 heading that names the dialog. Ask the question ("Delete contract?").

Default –
bodyNexera
ReactNode

Explanation under the title: what happens and whether it can be undone. It is the dialog's description (aria-describedby), read out when the dialog opens.

Default –
childrenNexera
ReactNode

Extra content under the body, such as a checkbox or a short summary.

Default –
iconNexera
ReactNode

Icon. Web: in a 36 px circle before the title. Android: 24 dp above the title. iOS alerts have no icon, so it is not shown there. Decorative: the title names the dialog.

Default –
primaryLabel*Nexera
string

Label of the main action, naming the outcome ("Submit payroll", "Delete").

Default –
onPrimaryActionNexera
() => void

Called when the main action is pressed; the dialog then closes.

Default –
secondaryLabelNexera
string

Label of the action that backs out, usually "Cancel". Shown when provided.

Default –
onSecondaryActionNexera
() => void

Called when the secondary action is pressed; the dialog then closes.

Default –
variantNexera
"default" | "destructive"

Visual weight of the main action. destructive uses the danger colour, makes the dialog an alertdialog, and puts focus on the secondary action when the dialog opens, so Enter does not destroy anything.

Default default
roleNexera
"dialog" | "alertdialog"

ARIA role. Derived from variant; use alertdialog for any urgent confirmation.

Default variant === "destructive" ? "alertdialog" : "dialog"
platformNexera
"web" | "ios" | "android"

Platform look: web dialog, iOS alert or Android dialog. Defaults to the NexeraProvider platform.

Default "web"
closeLabelNexera
string

Accessible name of the web close button. Translate it for your locale.

Default Close
isDismissableNexera
boolean

Whether a click on the scrim closes the dialog. Off by default: a dialog asks for a decision. Escape closes it (like the secondary action) unless isKeyboardDismissDisabled.

Default false
idNexera
string

Id of the surface element.

Default –
classNameNexera
string

Extra classes for the surface, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style for the surface.

Default –
triggerNexera
ReactElement<unknown, string | JSXElementConstructor<any>>

The element that opens the overlay, usually a Nexera Button. It toggles the overlay when pressed and gets focus back when the overlay closes. Leave it out to open the overlay from your own state (isOpen + onOpenChange).

Default –
isOpenNexera
boolean

Whether the overlay is open (controlled). Use with onOpenChange.

Default –
defaultOpenNexera
boolean

Whether the overlay is open on first render (uncontrolled).

Default false
onOpenChangeNexera
(isOpen: boolean) => void

Called when the overlay opens or closes (Escape, the close button, a slot="close" action, a click outside).

Default –
shouldCloseOnInteractOutsideReact Aria
(element: Element) => boolean

When user interacts with the argument element outside of the overlay ref, return true if onClose should be called. This gives you a chance to filter out interaction with elements that should not dismiss the overlay. By default, onClose will always be called on interaction outside the overlay ref.

Default –
isKeyboardDismissDisabledReact Aria
boolean

Whether pressing the escape key to close the modal should be disabled.

Default false

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

6 direct · 3 supporting
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.10ReflowLevel AA · supporting test
  • 1.4.12Text SpacingLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 2.1.2No Keyboard TrapLevel A · tested directly
  • 2.4.3Focus OrderLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · supporting test
  • 3.3.4Error Prevention (Legal, Financial, Data)Level AA · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

  • data-hovered
  • data-pressed
Usage
<Dialog className="data-hovered:opacity-90 shadow-sm" />

Used in blocks

Related components