Display UI

Alert Dialog

A modal dialog that interrupts the user to confirm an action or display critical information before proceeding .

Loading...

Installation

npx shadcn@latest add https://display-ui.vercel.app/r/AlertDialog

Usage

import { AlertDialog } from "@/components/display-ui/AlertDialog"
<AlertDialog.Main>
  <AlertDialog.Trigger>Open Alert</AlertDialog.Trigger>
  <AlertDialog.Content>
    <AlertDialog.Title>Delete Confirmation</AlertDialog.Title>
    <AlertDialog.Description>
      Are you sure you want to delete this item? This action cannot be undone.
    </AlertDialog.Description>
    <AlertDialog.Actions>
      <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
      <AlertDialog.Confirm onClick={() => alert("Item Deleted!")}>
        Delete
      </AlertDialog.Confirm>
    </AlertDialog.Actions>
  </AlertDialog.Content>
</AlertDialog.Main>

API

Alert-Dialog Props

For Main AlertDialog Content

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]The root container for the alert dialog. Must wrap Trigger and Content components.-
defaultOpenbooleanControls whether the dialog is open by default on initial render.false

For AlertDialog Trigger

AttributeTypeDescriptionDefault
childrenReactNodeThe content displayed inside the trigger button that opens the dialog.-
classNamestringAdditional CSS classes to customize the trigger button styling.-

For AlertDialog Content

AttributeTypeDescriptionDefault
childrenReactNodeThe main dialog content. Typically includes Title, Description, and Actions.-
classNamestringAdditional CSS classes applied to the dialog content container.-

For AlertDialog Title

AttributeTypeDescriptionDefault
childrenReactNodeThe heading text displayed at the top of the dialog.-
classNamestringAdditional CSS classes to customize the title styling.-

For AlertDialog Description

AttributeTypeDescriptionDefault
childrenReactNodeDescriptive text providing more context about the dialog action.-
classNamestringAdditional CSS classes to customize the description text.-

For AlertDialog Actions

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]Container for action buttons such as Cancel and Confirm.-
classNamestringAdditional CSS classes to customize the actions layout.-

For AlertDialog Content

AttributeTypeDescriptionDefault
childrenReactNodeLabel displayed inside the cancel button. Closes the dialog when clicked.-
classNamestringAdditional CSS classes to customize the cancel button styling.-

For AlertDialog Confirm

AttributeTypeDescriptionDefault
childrenReactNodeLabel displayed inside the confirm button.-
onClick(event: React.MouseEvent<HTMLButtonElement>) => voidCallback fired when the confirm button is clicked. The dialog closes automatically after execution.-
classNamestringAdditional CSS classes to customize the confirm button styling.-

Credits

This component is inspired by Rehman Kalawant Design Shared On Github.

On this page