Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.
Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
Features
Focus is automatically trapped.
Can be controlled or uncontrolled.
Manages screen reader announcements with
TitleandDescriptioncomponents.Esc closes the component automatically.
Anatomy
Import all parts and piece them together.
API Reference
Root
Contains all the parts of an alert dialog.
Trigger
A button that opens the dialog.
Portal
When used, portals your overlay and content parts into the body.
Overlay
A layer that covers the inert portion of the view when the dialog is open.
Content
Contains content to be rendered when the dialog is open.
Cancel
A button that closes the dialog. This button should be distinguished visually from AlertDialog.Action buttons.
Action
A button that closes the dialog. These buttons should be distinguished visually from the AlertDialog.Cancel button.
Title
An accessible name to be announced when the dialog is opened. Alternatively, you can provide aria-label or aria-labelledby to AlertDialog.Content and exclude this component.
Description
An accessible description to be announced when the dialog is opened. Alternatively, you can provide aria-describedby to AlertDialog.Content and exclude this component.
Examples
Close after asynchronous form submission
Use the controlled props to programmatically close the Alert Dialog after an async operation has completed.
Custom portal container
Customise the element that your alert dialog portals into.
Accessibility
Adheres to the Alert and Message Dialogs WAI-ARIA design pattern.