AlertDialog
A Duostrap modal confirmation dialog with safe cancel focus and explicit action intent.
Duostrap AlertDialog pairs classic .modal.fade and .modal-backdrop.fade chrome and motion with alert-dialog focus safety, focusing Cancel first and blocking outside-click dismissal.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-alert-dialog-root>
<wc-duostrap-alert-dialog-trigger>
Show Dialog
</wc-duostrap-alert-dialog-trigger>
<wc-duostrap-alert-dialog-mask></wc-duostrap-alert-dialog-mask>
<wc-duostrap-alert-dialog-content>
<wc-duostrap-alert-dialog-title>
Are you absolutely sure?
</wc-duostrap-alert-dialog-title>
<wc-duostrap-alert-dialog-description>
This action cannot be undone. This will permanently delete
your account and remove your data from our servers.
</wc-duostrap-alert-dialog-description>
<wc-duostrap-alert-dialog-footer>
<wc-duostrap-alert-dialog-cancel>
Cancel
</wc-duostrap-alert-dialog-cancel>
<wc-duostrap-alert-dialog-action>
Continue
</wc-duostrap-alert-dialog-action>
</wc-duostrap-alert-dialog-footer>
</wc-duostrap-alert-dialog-content>
</wc-duostrap-alert-dialog-root>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (@proto.ui/prototypes-duostrap).
import { BootstrapAlertDialogRoot, BootstrapAlertDialogTrigger, BootstrapAlertDialogMask, BootstrapAlertDialogContent, BootstrapAlertDialogTitle, BootstrapAlertDialogDescription, BootstrapAlertDialogFooter, BootstrapAlertDialogCancel, BootstrapAlertDialogAction,} from '../proto-ui/components/react';
export function Example() { return ( <BootstrapAlertDialogRoot> <BootstrapAlertDialogTrigger>Show Dialog</BootstrapAlertDialogTrigger> <BootstrapAlertDialogMask /> <BootstrapAlertDialogContent> <BootstrapAlertDialogTitle>Are you absolutely sure?</BootstrapAlertDialogTitle> <BootstrapAlertDialogDescription> This action cannot be undone. This will permanently delete your account. </BootstrapAlertDialogDescription> <BootstrapAlertDialogFooter> <BootstrapAlertDialogCancel>Cancel</BootstrapAlertDialogCancel> <BootstrapAlertDialogAction>Continue</BootstrapAlertDialogAction> </BootstrapAlertDialogFooter> </BootstrapAlertDialogContent> </BootstrapAlertDialogRoot> );}Compose Root, Trigger, Mask, Content, Title, Description, Footer, Cancel, and Action:
- Modality and motion:
Maskrenders the 0.8-opacity backdrop with a 150ms linear fade;Contentruns the 300ms Bootstrap modal drop-in and fade transition, traps focus, blocks outside-click dismissal, and focusesCancelfirst. - Footer: Passive Bootstrap
.modal-footerband with top divider and right-aligned action buttons. - Actions and variants: Activating
Actionemitsactionbefore requesting close;EscapeandCancelrequest dismissal directly. BothTriggerandActionaccept classic Bootstrap button variants such asvariant="danger".
Examples
Section titled “Examples”Set size="sm" on Content for a compact 360px modal width.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-alert-dialog-root>
<wc-duostrap-alert-dialog-trigger>
Show Compact Dialog
</wc-duostrap-alert-dialog-trigger>
<wc-duostrap-alert-dialog-mask></wc-duostrap-alert-dialog-mask>
<wc-duostrap-alert-dialog-content size="sm">
<wc-duostrap-alert-dialog-title>
Allow accessory to connect?
</wc-duostrap-alert-dialog-title>
<wc-duostrap-alert-dialog-description>
Do you want to allow the USB accessory to connect to this
device?
</wc-duostrap-alert-dialog-description>
<wc-duostrap-alert-dialog-footer>
<wc-duostrap-alert-dialog-cancel>
Don't allow
</wc-duostrap-alert-dialog-cancel>
<wc-duostrap-alert-dialog-action>
Allow
</wc-duostrap-alert-dialog-action>
</wc-duostrap-alert-dialog-footer>
</wc-duostrap-alert-dialog-content>
</wc-duostrap-alert-dialog-root>Destructive
Section titled “Destructive”Use variant="danger" on Trigger and Action for classic Duostrap .btn-danger styling.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-alert-dialog-root>
<wc-duostrap-alert-dialog-trigger variant="danger">
Delete Chat
</wc-duostrap-alert-dialog-trigger>
<wc-duostrap-alert-dialog-mask></wc-duostrap-alert-dialog-mask>
<wc-duostrap-alert-dialog-content size="sm">
<wc-duostrap-alert-dialog-title>
Delete chat?
</wc-duostrap-alert-dialog-title>
<wc-duostrap-alert-dialog-description>
This will permanently delete this chat conversation and remove
any saved memories.
</wc-duostrap-alert-dialog-description>
<wc-duostrap-alert-dialog-footer>
<wc-duostrap-alert-dialog-cancel>
Cancel
</wc-duostrap-alert-dialog-cancel>
<wc-duostrap-alert-dialog-action variant="danger">
Delete
</wc-duostrap-alert-dialog-action>
</wc-duostrap-alert-dialog-footer>
</wc-duostrap-alert-dialog-content>
</wc-duostrap-alert-dialog-root>Controlled
Section titled “Controlled”Pass open and listen to openChange and action to manage dialog state externally.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-alert-dialog-root id="bs-controlled">
<wc-duostrap-alert-dialog-trigger>
Archive Workspace
</wc-duostrap-alert-dialog-trigger>
<wc-duostrap-alert-dialog-mask></wc-duostrap-alert-dialog-mask>
<wc-duostrap-alert-dialog-content>
<wc-duostrap-alert-dialog-title>
Archive this workspace?
</wc-duostrap-alert-dialog-title>
<wc-duostrap-alert-dialog-description>
Members will keep read-only access until an administrator
restores the workspace.
</wc-duostrap-alert-dialog-description>
<wc-duostrap-alert-dialog-footer>
<wc-duostrap-alert-dialog-cancel>
Cancel
</wc-duostrap-alert-dialog-cancel>
<wc-duostrap-alert-dialog-action>
Archive
</wc-duostrap-alert-dialog-action>
</wc-duostrap-alert-dialog-footer>
</wc-duostrap-alert-dialog-content>
</wc-duostrap-alert-dialog-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#bs-controlled');
setElementProps(root, { open: false });
root.addEventListener('openChange', (e) =>
setElementProps(root, { open: e.detail.open })
);
</script>| Prop / Event / Method | Type | Default |
|---|---|---|
open | boolean | undefined (uncontrolled) |
defaultOpen | boolean | false |
disabled | boolean | false |
a11yLabel | string | '' |
openChange (event) | { open: boolean; reason: string null; focusReason: string null } | — |
openAlertDialog / close / toggle (methods) | (reason?: string) => void | — |
Content, Mask, Footer & Commands
Section titled “Content, Mask, Footer & Commands”| Part & Prop / Event | Type | Default |
|---|---|---|
Content.size | 'default' 'sm' | 'default' (560px) |
Content.enterDuration / leaveDuration | number | 300 |
Mask.passthrough | boolean | false |
Mask.enterDuration / leaveDuration | number | 150 |
Footer | Passive container (no props) | — |
Trigger.variant | 'default' 'primary' 'warning' 'danger' 'success' 'info' 'inverse' | 'default' |
Action.variant | 'default' 'primary' 'warning' 'danger' 'success' 'info' 'inverse' | 'primary' |
Trigger / Cancel / Action.disabled | boolean | false |
Action.action (event) | { reason: string } | — |