AlertDialog

A confirmation dialog with cancel and action buttons.

AlertDialog rendered by Tarve AlertDialog rendered by Tarve
Native render. The live version loads when this comes into view.

Import

import { AlertDialog } from "@tarve/core";

Usage

AlertDialog.tsx
import { AlertDialog, Button } from "@tarve/core";

let open = true;

<>
  <Button variant="destructive" onClick={() => (open = true)}>
    Delete project
  </Button>
  <AlertDialog
    open={open}
    title="Delete project?"
    description="This action cannot be undone."
    actionLabel="Delete"
    actionVariant="destructive"
    onAction={() => console.log("deleted")}
    onOpenChange={(next) => {
      open = next;
    }}
  />
</>

Props

PropTypeDefault
open required boolean—
title required string—
actionDisabled boolean—
actionLabel string"Continue"
actionVariant ButtonProps["variant"]"default"
cancelLabel string"Cancel"
closeOnEscape booleanfalse
description string—
onAction () => void—
onCancel () => void—
onOpenChange (open: boolean) => void—

Common props

Shared by every component. See descriptions →

childrenclassclassNamehighlightidkeymotionFromonHighlightonPasteonPointerLeaveonPointerMoveonSizeonTransitionEndrovingGroupstyle

Types

ButtonProps
interface ButtonProps extends BaseProps {
  variant?: ButtonVariant;
  size?: "sm" | "default" | "lg";
  disabled?: boolean;
  control?: Control;
  onClick?: () => void;
  onHover?: (hovered: boolean) => void;
  /**
   * Liquid Glass capsule: `true`, a variant or options. `destructive` tints it red,
   * `ghost` is clear glass without a shadow, `glass={{ tint }}` makes a prominent coloured one.
   */
  glass?: GlassProp;
}