SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Dialog

A modal surface built on the native <dialog> element, opened and closed declaratively through Invoker Commands (commandfor/command) instead of a JavaScript-tracked open state.

Or press ⌘ I from anywhere.

Invite people to Acme

They join with the role you pick here. You can change it later from the members list.

Separate more than one address with a comma.

View code
tsx
<Button commandfor="invite" command="show-modal">Invite people</Button>
<Text>
	Or press <Keyboard>⌘</Keyboard> <Keyboard>I</Keyboard> from anywhere.
</Text>

<Dialog id="invite" aria-labelledby="invite-title" mix={[hotkey("mod+i")]}>
	<Dialog.Header>
		<Dialog.Title id="invite-title">Invite people to Acme</Dialog.Title>
		<Dialog.Description>
			They join with the role you pick here. You can change it later from the members list.
		</Dialog.Description>
	</Dialog.Header>

	<TextField name="invites" type="email" placeholder="ana@acme.com, luis@acme.com" required>
		<TextField.Label>Email addresses</TextField.Label>
		<TextField.Description>Separate more than one address with a comma.</TextField.Description>
	</TextField>

	<Label htmlFor="invite-role">Role</Label>
	<Select id="invite-role" name="role">
		<Select.Option value="viewer">Viewer — read everything</Select.Option>
		<Select.Option value="member" selected>
			Member — create and edit
		</Select.Option>
		<Select.Option value="admin">Admin — manage members and billing</Select.Option>
	</Select>

	<Label htmlFor="invite-note">Note</Label>
	<TextArea id="invite-note" name="note" placeholder="Anything they should know before joining." />

	<Dialog.Footer>
		<Button commandfor="invite" command="close" variant="outline" color="neutral">
			Cancel
		</Button>
		<Button commandfor="invite" command="close">Send invites</Button>
	</Dialog.Footer>
	<Dialog.Close commandfor="invite" aria-label="Close" />
</Dialog>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add dialog

Usage

typescript
import { Dialog } from "@sdxc/ui";

Renders the dialog panel as a native <dialog> host, its ::backdrop tinted and, where supported, blurred to dim the page behind it. The panel declares the ui-dialog named container so Dialog.Header and Dialog.Footer can size against the panel's own width; Invoker Commands open and close it declaratively — a trigger elsewhere points commandfor at this element's id with command="show-modal", and any control inside, including Dialog.Close, points commandfor at that same id with command="close".

Composition

The parts the component publishes, each a static property of the host.

  • Dialog
  • Dialog.HeaderRenders Dialog.HeaderProps.children as the panel's header slot: a column stacking Dialog.Title and Dialog.Description, centered while narrow and start-aligned (flipping under dir="rtl") once the panel's own ui-dialog container grows past 40rem.
  • Dialog.TitleRenders Dialog.TitleProps.children as the panel's heading, inside the native heading element matching the nearest ambient heading level — <h1> by default — sized and weighted as the panel's most prominent line of text at every level.
  • Dialog.DescriptionRenders Dialog.DescriptionProps.children as the panel's supporting copy, in a native <p> set to the panel's muted foreground color so it reads as secondary to Dialog.Title.
  • Dialog.FooterRenders Dialog.FooterProps.children as the panel's action row: a column of stacked, full-width controls while the panel is narrow, switching to a single end-aligned row past the panel's own 40rem container mark.
  • Dialog.CloseRenders a dismiss control for the ancestor Dialog named by commandfor: a small, ghost-styled Button with a fixed "X" glyph, pinned to the panel's corner.

Examples

Animated entrance

Welcome to Acme

Your workspace is ready. Invite your team when you are.

View code
tsx
<Button commandfor="welcome" command="show-modal">Show welcome</Button>

<Dialog id="welcome" aria-labelledby="welcome-title" mix={zoom({ duration: durations.normal })}>
	<Dialog.Header>
		<Dialog.Title id="welcome-title">Welcome to Acme</Dialog.Title>
		<Dialog.Description>Your workspace is ready. Invite your team when you are.</Dialog.Description>
	</Dialog.Header>
	<Dialog.Footer>
		<Button commandfor="welcome" command="close">Get started</Button>
	</Dialog.Footer>
</Dialog>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
childrenRemixNode—YesThe panel's compound parts: Dialog.Header, Dialog.Footer, Dialog.Close, or any other content.

Also accepts everything in TagProps<"dialog">.

Dialog.Header

Also accepts everything in TagProps<"div">.

Dialog.Title

Also accepts everything in TagProps<"h1">.

Dialog.Description

Also accepts everything in TagProps<"p">.

Also accepts everything in TagProps<"div">.

Dialog.Close

PropTypeDefaultRequiredDescription
commandforstring—Yesid of the ancestor Dialog this button dismisses.
command"close"—NoInvoker Commands verb dispatched to the target Dialog. Defaults to "close".
"aria-label"string—YesAccessible label for the icon-only control — required, since the button carries no visible text for assistive technology to read.

Also accepts everything in Omit< Button.Props, "children" | "variant" | "color" | "size" | "aria-label" | "commandfor" | "command" >.

@sdxc/ui

Can’t find it? Contact us