Skip to main content

Alert Dialog

The AlertDialog component is a modal dialog used to display critical information or confirm an action.
It wraps Radix UI's AlertDialog and provides consistent styling with Button support.

import { AlertDialog } from "tawuniya/components";

👉 View in Storybook

Props​

PropTypeDefaultDescription
titlestringrequiredTitle displayed in the dialog header.
descriptionstring-Optional description text.
triggerReact.ReactNoderequiredThe element that triggers the dialog (e.g. a Button).
cancelButtonTextstring"Cancel"Text label for the cancel button.
actionButtonTextstring"Continue"Text label for the action button.
actionButtonPropsPartial<ButtonProps>-Props passed to the action button.
cancelButtonPropsPartial<ButtonProps>-Props passed to the cancel button.
actionButtonIconReact.ReactNode-Optional icon displayed before the action button text.
cancelButtonIconReact.ReactNode-Optional icon displayed before the cancel button text.
buttonsAlignment"start" | "center" | "end""end"Alignment of the action buttons inside the footer.
buttonsFullWidthbooleanfalseIf true, both buttons stretch to fill the footer width.
centeredbooleanfalseIf true, centers the title and description text.
classNamestring-Additional classes applied to the dialog content.
titleClassNamestring-Additional classes applied to the dialog title.
descriptionClassNamestring-Additional classes applied to the dialog description.
openboolean-Controls the open state (useful for controlled dialogs).
isLoadingbooleanfalseIf true, shows a loading spinner in the action button.
onOpenChange(open: boolean) => void-Callback fired when the dialog open state changes.
onActionClick() => void-Callback fired when the action button is clicked.

Usage​

Basic Example​

<AlertDialog
title="Delete Item"
description="Are you sure you want to delete this item? This action cannot be undone."
trigger={<Button variant="destructive">Delete</Button>}
/>

With Action & Cancel Text​

<AlertDialog
title="Sign Out"
description="Do you really want to sign out of your account?"
trigger={<Button>Sign Out</Button>}
cancelButtonText="No, stay"
actionButtonText="Yes, sign out"
/>

With Icons & Loading State​

<AlertDialog
title="Submit Form"
description="Do you want to submit the form data now?"
trigger={<Button>Submit</Button>}
actionButtonText="Submit"
actionButtonIcon={<SendIcon size={16} />}
cancelButtonIcon={<XIcon size={16} />}
isLoading={isSubmitting}
onActionClick={handleSubmit}
/>

Buttons Alignment​

<AlertDialog
title="Payment Confirmation"
description="Please confirm your payment details."
trigger={<Button>Pay</Button>}
buttonsAlignment="center"
buttonsFullWidth
/>

Notes​

  • isLoading disables the action button and shows a spinner (Loader2).
  • You can fully customize the buttons via actionButtonProps and cancelButtonProps.