import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogTrigger,
Button
} from "@porcelana/ui";
export default function Example() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="danger">Delete alarm…</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogTitle>Delete this alarm?</AlertDialogTitle>
<AlertDialogDescription>The 06:00 weekday alarm will be removed from every device.</AlertDialogDescription>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="danger">Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Import
Import
import { AlertDialogContent, AlertDialogAction, AlertDialogCancel } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app root
Props
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
AlertDialogContent
Prop
Type
Default
Description
aria-label
string
–
Defines a string value that labels the current element.
@see aria-labelledby.
asChild
boolean
–
Render the single child element instead, merging props and behaviour onto it.
centered
boolean
–
Keep the centered modal on phones instead of the bottom sheet.
deferPointerDownOutside
boolean
–
When `true`, a `'pointerdown'` event outside of the layered element will
wait for the interaction's click event before dispatching, allowing
third-party code to stop propagation of later events and cancel dismissal.
forceMount
true
–
Used to force mounting when more control is needed. Useful when
controlling animation with React animation libraries.
id
string
–
Element id. Generated automatically when omitted.
onCloseAutoFocus
((event: Event) => void)
–
Event handler called when auto-focusing on close.
Can be prevented.
onEscapeKeyDown
((event: KeyboardEvent) => void)
–
Event handler called when the escape key is down.
Can be prevented.
onFocusOutside
((event: FocusOutsideEvent) => void)
–
Event handler called when the focus moves outside of the `DismissableLayer`.
Can be prevented.
onOpenAutoFocus
((event: Event) => void)
–
Event handler called when auto-focusing on open.
Can be prevented.
AlertDialogAction
Prop
Type
Default
Description
aria-label
string
–
Defines a string value that labels the current element.
@see aria-labelledby.
asChild
boolean
–
Render the single child element instead, merging props and behaviour onto it.