Twigs Logo

AlertDialog

A component which can be used to warn or get users attention before destructive actions.

Import

import {AlertDialog,AlertDialogAction,AlertDialogActions,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogTitle,AlertDialogTrigger,Button} from "@sparrowengg/twigs-react";

Usage

const AlertDialogExample = () => {
  return (
    <AlertDialog>
      <AlertDialogTrigger asChild>
        <Button color="error">Delete account</Button>
      </AlertDialogTrigger>
      <AlertDialogContent>
        <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
        <AlertDialogDescription>
          This action cannot be undone. This will permanently delete your
          account and remove your data from our servers.
        </AlertDialogDescription>
        <AlertDialogActions>
          <AlertDialogCancel asChild>
            <Button color="default" size="lg">
              Cancel
            </Button>
          </AlertDialogCancel>
          <AlertDialogAction asChild>
            <Button color="error" size="lg">
              Yes, delete account
            </Button>
          </AlertDialogAction>
        </AlertDialogActions>
      </AlertDialogContent>
    </AlertDialog>
  );
};

Props

AlertDialog

PropTypeDefault
defaultOpen?
boolean
-
open?
boolean
-
onOpenChange?
function
-
css?
object
-

Data Attributes

These props are used for the conditional rendering of the components

PropTypeDefault
[data-state]?
'open' | 'closed'
-