AlertDialog
A dialog that forces a decision before moving on. It blocks, and unlike the Modal, clicking the backdrop does NOT dismiss it. For destructive or irreversible confirmations—deleting, canceling, discarding changes.
Overlays · TaishoDS Core, in plain HTML.
Examples
One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.
Confirm account deletion
Confirm by typing the project name
A more descriptive name
Class reference
Every value of each modifier, with its HTML ready to copy.
Variant
The kind of action: default, or danger for a destructive one (the confirm button turns danger).
Confirm text
Confirm stays disabled until the exact text is typed (for dangerous deletions).
When to use
- The action is destructive or irreversible and deserves an explicit confirmation.
- Closing it by accident would have consequences, so it needs a deliberate answer.
- The choice comes down to two or three clear paths (confirm / cancel).
When not to use
- It’s information or a task that can be closed at no cost →
modal. - The notice doesn’t block anything and can live on the page →
bannerornote. - It’s a notification about something that already happened →
toast.
Do
- Name the action on the button: “Delete project,” not “OK.”
- Mark the dangerous action visually (
variant-dangeron the confirm button) and leave cancel as the safe way out. - If the deletion can’t be undone (a whole project, an account), use
data-ts-confirm-textto ask the user to type the name to confirm. Confirm stays disabled until it matches.
Don’t
- Don’t use it for neutral notices. If nothing is lost, don’t block the user.
- Don’t offer five options—if there are more than a couple of paths, it isn’t a confirmation.
TaishoDS Core
Needs Core’s JS, which hooks in through data-ts-* attributes.
It’s a modal <dialog>. The browser handles opening, closing, focus trapping, and Esc, and the destructive variant is styling only. The only thing that needs JavaScript is typed confirmation—typing an exact text to enable Confirm.
Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.
data-ts-confirmdata-ts-confirm-inputdata-ts-confirm-textdata-ts-field-spinnerdata-ts-input
What it does: Only if you ask for typed confirmation. The <dialog> takes data-ts-confirm-text="...", the field takes data-ts-confirm-input, and the button takes data-ts-confirm (rendered disabled). Core enables the button when the typed text matches exactly, disables it again while loading, and clears the field when the dialog closes. Without typed confirmation there’s nothing to initialize. Initial focus lands on the field, the dialog’s first control.
Limitation
From the CDN, without a build, this component has no file of its own—it comes with taisho.base.css and the files below. Also load:
taisho.button.csstaisho.icon.csstaisho.input.csstaisho.kbd.csstaisho.modal.csstaisho.spinner.css
For how Core works in general, see Behavior.
Accessibility
Implements the Alert Dialog pattern from the WAI-ARIA APG.
alertdialogrole. The screen reader announces the title and description on open.- The accessible name comes from the title (
aria-labelledby). Anaria-labeloraria-labelledbyon the<dialog>replaces it. With no name at all (atitleattribute also counts as a name), Core warns in the console when the page is served fromlocalhost. - Initial focus lands on the dialog’s first control. In the example that’s Cancel, which comes before the destructive action, so an accidental Enter doesn’t trigger it. If the order changes, put
autofocuson Cancel. - With
data-ts-confirm-text, in the example initial focus lands on the field, which is the first control (Confirm is still disabled, so there’s no risky Enter). The field has a visible<label>, and Confirm keeps the nativedisableduntil the typed text matches exactly. On close, the field is cleared. - Esc is the same as canceling. Clicking the backdrop doesn’t close it—the decision must be explicit.
- Inherits from
<dialog>+showModal(): top layer, trapped focus, aninertbackground, and focus returned to the trigger on close. In WebKit, when the dialog was opened with the mouse, focus does not return to the trigger on close, because Safari does not focus a button on click. - While the dialog is open, the page behind it doesn’t scroll and keeps the scrollbar’s space (
scrollbar-gutter: stable), so the content doesn’t shift.
Keyboard
On top of what the browser already does (Tab moves focus, Enter activates a button).
| Key | What it does |
|---|---|
| Esc | Cancels—it never confirms. The destructive action requires intent. |
| Enter | Activates the focused button. |
Verification
What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.
- axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
- keyboard Key map documented above, checked against the component.
- screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.