ConfirmDialog is an easy to use and customizable Confirmation API using a dialog.
A ConfirmDialog component needs to be present on the page that is interacted with the confirmDialog function that takes a configuration object for customization.
The position property of the confirm options is used to display a Dialog at all edges and corners of the screen.
Declarative is an alternative to the programmatic approach where ConfirmDialog is controlled with a binding to visible and onHide event callback.
Templating allows customizing the message content.
ConfirmDialog width can be adjusted per screen size with the breakpoints option where a key defines the max-width for the breakpoint and value for the corresponding width. When no breakpoint matches width defined in style property is used.
Headless mode is enabled by defining a content prop that lets you implement entire confirmation UI instead of the default elements.
ConfirmDialog component uses alertdialog role along with aria-labelledby referring to the header element however any attribute is passed to the root element so you may use aria-labelledby to override this default behavior. In addition aria-modal is added since focus is kept within the popup.
It is recommended to use a trigger component that can be accessed with keyboard such as a button, if not adding tabIndex would be necessary.
When confirm function is used and a trigger is passed as a parameter, ConfirmDialog adds aria-expanded state attribute and aria-controls to the trigger so that the relation between the trigger and the popup is defined.
If the dialog is controlled with the visible property aria-expanded and aria-controls need to be handled explicitly.
Key | Function |
---|---|
tab | Moves focus to the next the focusable element within the popup. |
shift + tab | Moves focus to the previous the focusable element within the popup. |
escape | Closes the popup and moves focus to the trigger. |
Key | Function |
---|---|
enter | Triggers the action, closes the popup and moves focus to the trigger. |
space | Triggers the action, closes the popup and moves focus to the trigger. |