tsimport {XDSAlertDialog} from '@xds/core/AlertDialog'
| Guidance | Practices |
|---|---|
| Do | Make the action button label specific — "Delete project" is better than "OK" or "Confirm". |
| Do | Describe what will happen in the description so the user knows the consequences before confirming. |
| Don't | Use AlertDialog for non-destructive actions — use a standard Dialog instead. |
| Prop | Type | Description |
|---|---|---|
isOpenrequired | boolean | Whether the dialog is open. |
onOpenChangerequired | (isOpen: boolean) => unknown | Visibility change callback. |
titlerequired | string | Dialog title. Linked via aria-labelledby. |
descriptionrequired | string | Consequence description. Linked via aria-describedby. |
actionLabelrequired | string | Action button label. |
onActionrequired | () => unknown | Called when action button is clicked. Does NOT auto-close. |
cancelLabel | string (default: 'Cancel') | Cancel button label. |
actionVariant | XDSButtonVariant (default: 'destructive') | Action button variant. |
isActionLoading | boolean | Shows loading spinner on the action button. |
width | number | string (default: 400) | Dialog width. |
isInline | boolean (default: false) | Renders alert dialog content inline without modal behavior. For documentation previews and showcases only. |
| Prop | Type | Description |
|---|---|---|
show | (options: AlertDialogOptions) => void | Show the alert dialog with the given options. Options are the same as XDSAlertDialog props minus isOpen/onOpenChange. |
hide | () => void | Hide the alert dialog. |
isOpen | boolean | Whether the dialog is currently open. |
element | ReactNode | The dialog element — render this in your JSX tree. |
tsx'use client';import {useState} from 'react';import {XDSAlertDialog} from '@xds/core/AlertDialog';export default function AlertDialogAsyncAction() {const [isLoading, setIsLoading] = useState(false);return (<XDSAlertDialogisOpenisInlineonOpenChange={() => {}}title="Revoke access?"description="This user will immediately lose access to all shared resources."actionLabel="Revoke"isActionLoading={isLoading}onAction={async () => {setIsLoading(true);await new Promise(r => setTimeout(r, 2000));setIsLoading(false);}}/>);}
tsx'use client';import {XDSAlertDialog,useXDSImperativeAlertDialog,} from '@xds/core/AlertDialog';// Remove isInline for production — alert dialogs should be modal.export default function AlertDialogDeleteConfirmation() {const alert = useXDSImperativeAlertDialog();const alertProps = {title: 'Delete item?',description:'This action cannot be undone. The item and all its data will be permanently removed.',actionLabel: 'Delete',} as const;return (<><XDSAlertDialogisOpenisInlineonOpenChange={() => {}}{...alertProps}onAction={() =>alert.show({...alertProps, onAction: () => alert.hide()})}/>{alert.element}</>);}