suiss/ui · Component
Dialog
A modal window that appears above the page to focus people on a task or message.
Dialog is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Dialog wraps the dialog primitive of the chosen base. The Dialog root manages the open state, and DialogTrigger opens it. DialogContent renders the window in a portal over a dimmed DialogOverlay, with a close button in the top corner by default. Inside it, DialogHeader holds the DialogTitle and DialogDescription, and DialogFooter holds the actions. DialogClose closes the dialog from any element.
Use a dialog for a short, focused task such as editing a few fields. To confirm a destructive or important action that needs an explicit response, consider an alert dialog. For larger content that slides in from an edge, use a sheet or drawer.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Composition
Use the following composition to build a Dialog:
Examples
Without close button
A dialog with no corner close button that adds a Close action to the footer instead.
Destructive
A dialog that confirms deleting a project, with a destructive action and a Cancel button.
Accessibility
- The window has the
dialogrole.DialogTitleprovides its accessible name andDialogDescriptionits accessible description. - Opening the dialog moves focus inside it. Escape closes it and returns focus to the trigger.
- The icon-only close button has a visually hidden
Closelabel. - Always include a
DialogTitle; hide it visually withsr-onlyif the design has no visible title.
API Reference
Dialog
The root that manages the dialog's open state.
Also accepts the props of the primitive part it wraps.
The dialog is uncontrolled by default; set defaultOpen to start open, or control it with open and onOpenChange. Render the trigger as another component, such as a Button, with the render prop. Use DialogClose with render for a Cancel button.
The dialog is uncontrolled by default; set defaultOpen to start open, or control it with open and onOpenChange. Set asChild on DialogTrigger to render your own Button as the trigger, and on DialogClose for a Cancel button.
The dialog is uncontrolled by default; set defaultOpen to start open, or control it with isOpen and onOpenChange. The first pressable child of Dialog, such as a Button, opens it. Give a Button slot="close" for a Cancel button.
DialogTrigger
The button that opens the dialog.
Also accepts the props of the primitive part it wraps.
DialogPortal
Renders its children into a portal outside the current DOM hierarchy.
Also accepts the props of the primitive part it wraps.
DialogClose
A button that closes the dialog.
Also accepts the props of the primitive part it wraps.
DialogOverlay
The dimmed layer behind the dialog.
Also accepts the props of the primitive part it wraps.
DialogContent
The dialog window, rendered in a portal with an overlay and an optional close button.
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | true |
closeLabel | string | - |
| Prop | Type | Default |
|---|---|---|
isDismissable | boolean | true |
isKeyboardDismissDisabled | boolean | - |
isDismissable closes the dialog on a press outside it, and isKeyboardDismissDisabled stops Escape from closing it.
Also accepts the props of the primitive part it wraps.
Set showCloseButton={false} to remove the corner close button, and set closeLabel to replace its icon with a text label. When the close button is shown, the first child gets extra end padding so it does not run under the button. The window is sm:max-w-md by default; override it with className.
DialogHeader
Groups the title and description.
Also accepts the props of React.ComponentProps<"div">.
DialogFooter
Holds the dialog's actions.
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | false |
Also accepts the props of React.ComponentProps<"div">.
Set showCloseButton to add a secondary Close button after the actions. The footer stacks its actions in reverse order on small screens and aligns them to the end on wider screens.
DialogTitle
The dialog's title, which also names it for assistive technology.
Also accepts the props of the primitive part it wraps.
DialogDescription
Supporting text that describes the dialog for assistive technology.
Also accepts the props of the primitive part it wraps.
Each part sets a data-slot, such as dialog-content or dialog-footer, for styling. data-open and data-closed drive the fade and zoom animation.
Web preview
Dialog opens a centered card over a dimmed scrim. DialogContent renders through a portal (inside a full-window overlay on iOS), scales and fades in, and shows a round close button in the top-right corner by default. Tapping the scrim closes the dialog.
Use it for short forms and information that the user can dismiss freely. When the user must make an explicit choice, use Alert Dialog instead.
Installation
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/dialog.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/dialog.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/dialog.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Default
Web preview
Destructive
A destructive action with a cancel button in the footer.
Web preview
Without close button
No corner button, with a Close button in the footer.
Web preview
With close label
A text close button through closeLabel.

Accessibility
- The popup has the
dialogrole, is labelled by the title and is marked as modal for VoiceOver. - Focus moves to the title when the dialog opens.
- The Android back button and the VoiceOver escape gesture close it.
- The icon close button is labelled "Close".
API Reference
Dialog
The root that manages the open state.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | (open: boolean, details) => void | - |
modal | boolean | true |
disablePointerDismissal | boolean | false |
Use open and onOpenChange for controlled state, or defaultOpen for uncontrolled. modal blocks interaction with the rest of the screen while open, and disablePointerDismissal keeps the dialog open when the overlay is tapped.
DialogOverlay
Dimmed scrim that closes the dialog when tapped.
Also accepts the props of React.ComponentProps<typeof DialogPrimitive.Backdrop>.
DialogContent
Centered card with an optional close button.
| Prop | Type | Default |
|---|---|---|
portalHost | string | - |
showCloseButton | boolean | true |
closeLabel | string | - |
Also accepts the props of React.ComponentProps<typeof DialogPrimitive.Popup>.
Set showCloseButton={false} to hide the corner button, or pass closeLabel to show a text button such as "Done" instead of the icon. The header adds end padding so the title does not run under it. portalHost names the portal host to render into. On iOS the content is wrapped in a full-window overlay so it appears above native navigation, and animations respect the system Reduce Motion setting.
DialogHeader
Column for the title and description.
Also accepts the props of ViewProps.
DialogFooter
Area for actions.
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | false |
Also accepts the props of ViewProps.
Footer buttons stack vertically with the first child at the bottom, and sit in a row aligned to the end on wider screens. Set showCloseButton to append a secondary Close button. Use DialogClose with render to turn any Button into a close button.
DialogTitle
Dialog heading.
Also accepts the props of React.ComponentProps<typeof DialogPrimitive.Title>.
DialogDescription
Supporting text.
Also accepts the props of React.ComponentProps<typeof DialogPrimitive.Description>.
.dialog
| Parameter | Type | Default |
|---|---|---|
isPresented | Binding<Bool> | - |
content | () -> Content | - |
DialogContent
Centered card with an optional close button.
| Parameter | Type | Default |
|---|---|---|
showCloseButton | Bool | true |
closeLabel | LocalizedStringKey? | nil |
content | () -> Content | - |
DialogHeader
Column for the title and description.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
DialogFooter
Area for actions.
| Parameter | Type | Default |
|---|---|---|
showCloseButton | Bool | false |
content | () -> Content | - |
Overloads: init(showCloseButton:content:), init(showCloseButton:).
DialogTitle
Dialog heading.
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
DialogDescription
Supporting text.
| Parameter | Type | Default |
|---|---|---|
_ description | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
DialogClose
A button that closes the dialog.
| Parameter | Type | Default |
|---|---|---|
action | (() -> Void)? | nil |
label | () -> Label | - |
_ title | LocalizedStringKey | - |
Overloads: init(action:label:), init(_:action:).
Dialog
The root that manages the open state.
| Parameter | Type | Default |
|---|---|---|
open | Boolean | - |
onOpenChange | (Boolean) -> Unit | - |
modifier | Modifier | Modifier |
showCloseButton | Boolean | true |
closeLabel | String? | null |
dismissible | Boolean | true |
content | @Composable ColumnScope.() -> Unit | - |
DialogHeader
Column for the title and description.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
DialogFooter
Area for actions.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
showCloseButton | Boolean | false |
content | @Composable () -> Unit | - |
DialogTitle
Dialog heading.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
DialogDescription
Supporting text.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
