Skip to content

UI: Dialog

View as Markdown

A modal dialog with a title, content and a row of actions. Import the token file once (@pithyx/ui/tokens.css) and wrap the app in UiProvider; see @pithyx/ui.

Generated from the TSDoc comments of @pithyx/ui 1.0.0-rc.9 at build time; the text below the headings is the comment in the source.

The props of Dialog: React Aria’s modal props plus title, content and actions.

  • Omit<ModalOverlayProps, "className" | "children">
title: ReactNode;

The heading, also the dialog’s accessible name.

optional icon?: ReactNode;

An icon before the title.

optional tone?: "danger" | "default";

danger for a destructive question; default when left out.

optional role?: "dialog" | "alertdialog";

alertdialog for a question that interrupts the user; dialog when left out.

optional size?: "medium" | "default" | "large";

medium for longer forms such as a user with its rights; large for side-by-side content (the pool wizard).

children: ReactNode;

The content.

actions: ReactNode;

The buttons at the bottom, usually a Button each.

function Dialog(props): Element;

A modal dialog with a title, content and a row of actions. Open it with isOpen and onOpenChange, or inside a React Aria DialogTrigger; Escape and a press outside close it unless isDismissable is false.

Parameter Type Description
props DialogProps React Aria’s modal overlay props plus title, content and actions.

Element

The modal overlay with the dialog.

<Dialog
title="Delete 3 files?"
tone="danger"
role="alertdialog"
isOpen={open}
onOpenChange={setOpen}
actions={
<Button variant="danger" onPress={remove}>
Delete
</Button>
}
>
They go to the recycle bin.
</Dialog>