Command Palette

Search for a command to run...

Alert Dialog

shadcn/ui

A modal dialog that interrupts the user with important content and expects a response.

Alert Dialog

import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogIcon, AlertDialogTitle, AlertDialogTrigger } from "@/components/optics/alert-dialog";import { Button } from "@/components/optics/button";import { Info } from "lucide-react";<AlertDialog>  <AlertDialogTrigger asChild>    <Button variant="raised">      Show Dialog    </Button>  </AlertDialogTrigger>  <AlertDialogContent>    <AlertDialogHeader>      <AlertDialogIcon>        <div className="p-2 rounded-full squircle-none flex items-center justify-center shadow-md bg-emerald-500/20">          <Info className="text-emerald-600" />        </div>        <AlertDialogTitle>          Are you absolutely sure?        </AlertDialogTitle>      </AlertDialogIcon>      <AlertDialogDescription>        This action cannot be undone. This will permanently delete your account and remove your data from our servers.      </AlertDialogDescription>    </AlertDialogHeader>    <AlertDialogFooter>      <AlertDialogCancel>        Cancel      </AlertDialogCancel>      <AlertDialogAction>        Continue      </AlertDialogAction>    </AlertDialogFooter>  </AlertDialogContent></AlertDialog>

Installation

pnpm dlx shadcn@latest add @optics/alert-dialog

Props

<AlertDialog />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean

<AlertDialogPortal />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogOverlay />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogTrigger />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogContent />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogHeader />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogFooter />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogTitle />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogDescription />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogAction />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogCancel />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean
<AlertDialogIcon />
Name
Type
open
boolean
defaultOpen
boolean
modal
boolean | "trap-focus"
onOpenChange
(...args) => void
onOpenChangeComplete
((open: boolean) => void)
disablePointerDismissal
boolean
triggerId
string
defaultTriggerId
string
payload
object
nativeButton
boolean
render
React.ReactElement
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
forceRender
boolean