DOCS
v0.4

Components / Alert Dialog

Alert Dialog

Destructive confirmation dialog with alertdialog ARIA role. Uses danger styling, focuses cancel button by default for safety, and supports custom actions via slot.

overlaysv0.7.0

Playground

Examples

Delete confirmation
Delete Project
<cg-button variant="danger" onclick="this.nextElementSibling.open=true">Delete Project</cg-button><cg-alert-dialog title="Delete project?" description="This will permanently delete the project and all its data. This action cannot be undone." destructive confirm-label="Delete" closable></cg-alert-dialog>
Standard confirm
Submit
<cg-button onclick="this.nextElementSibling.open=true">Submit</cg-button><cg-alert-dialog title="Submit form?" description="Your changes will be sent for review. You can still edit them later." confirm-label="Submit" closable></cg-alert-dialog>

Import

import { CgAlertDialog } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-alert-dialog';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
openbooleanfalseOpen state
titlestring""Dialog title
descriptionstring""Supporting description text
confirm-labelstring"Confirm"Confirm button label
cancel-labelstring"Cancel"Cancel button label
destructivebooleanfalseUse danger styling for confirm button
loadingbooleanfalseShow loading state on confirm
closablebooleanfalseAllow Escape/backdrop close

Events

EventDetailDescription
cg-alert-confirm{}Confirm button clicked
cg-alert-cancel{}Cancel button clicked
cg-alert-open{}Dialog opened
cg-alert-close{}Dialog closed