Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

AlertDialog

A modal dialog with role="alertdialog". Screen readers announce it immediately, and it does not close when clicking outside. Use it only when you must interrupt the user for an urgent answer, such as confirming a destructive action or a session timeout. For forms and regular information, use Dialog.

View in Storybook (opens in a new tab)

Installation

import { AlertDialog } from "@ginga-ui/core";

Basic usage

An alert dialog that asks for confirmation of a destructive action. It does not close when clicking outside and requires an explicit choice.

alert-dialog.tsx
alert-dialog.module.css
import { AlertDialog, AlertDialogTitle, Button, DialogTrigger, Modal } from "@ginga-ui/core";
import styles from "./alert-dialog.module.css";
import { CircleAlert, Trash2 } from "lucide-react";

export function BasicExample() {
  return (
    <DialogTrigger>
      <Button variant="filled" startIcon={<Trash2 />}>
        Delete file
      </Button>
      <Modal>
        <AlertDialog variant="danger">
          <AlertDialogTitle icon={<CircleAlert />}>
            Delete file
          </AlertDialogTitle>
          <p>
            This action cannot be undone. Are you sure you want to delete it?
          </p>
          <div className={styles.actions}>
            <Button slot="close" variant="outline">
              Cancel
            </Button>
            <Button slot="close" variant="filled" startIcon={<Trash2 />}>
              Delete
            </Button>
          </div>
        </AlertDialog>
      </Modal>
    </DialogTrigger>
  );
}

Warning variant

Use the variant prop to change the title color and accent.

alert-dialog.tsx
alert-dialog.module.css
import { AlertDialog, AlertDialogTitle, Button, DialogTrigger, Modal } from "@ginga-ui/core";
import styles from "./alert-dialog.module.css";
import { LogOut, TriangleAlert } from "lucide-react";

export function WarningExample() {
  return (
    <DialogTrigger>
      <Button variant="outline" startIcon={<LogOut />}>
        Log out
      </Button>
      <Modal>
        <AlertDialog variant="warning">
          <AlertDialogTitle icon={<TriangleAlert />}>
            Confirm log out
          </AlertDialogTitle>
          <p>Any unsaved changes will be lost. Do you want to log out?</p>
          <div className={styles.actions}>
            <Button slot="close" variant="outline">
              Cancel
            </Button>
            <Button slot="close" variant="filled" startIcon={<LogOut />}>
              Log out
            </Button>
          </div>
        </AlertDialog>
      </Modal>
    </DialogTrigger>
  );
}

No variant

Without a variant, the dialog uses the default colors. This example notifies the user that the session has expired and they must log in again.

alert-dialog.tsx
alert-dialog.module.css
import { AlertDialog, AlertDialogTitle, Button, DialogTrigger, Modal } from "@ginga-ui/core";
import styles from "./alert-dialog.module.css";
import { LogIn, TimerOff } from "lucide-react";

export function PlainExample() {
  return (
    <DialogTrigger>
      <Button variant="light" startIcon={<TimerOff />}>
        Simulate session timeout
      </Button>
      <Modal>
        <AlertDialog>
          <AlertDialogTitle>Session expired</AlertDialogTitle>
          <p>
            You have been logged out for your security. Log in again to
            continue.
          </p>
          <div className={styles.actions}>
            <Button slot="close" variant="filled" startIcon={<LogIn />}>
              Log in
            </Button>
          </div>
        </AlertDialog>
      </Modal>
    </DialogTrigger>
  );
}

Props

AlertDialog

role is fixed to "alertdialog". Place it inside DialogTrigger and Modal.

NameTypeDefaultDescription
variant"info" | "success" | "warning" | "danger"-Color variant. When omitted, the dialog uses the default colors.

Also accepts the props of React Aria's Dialog (opens in a new tab).

AlertDialogTitle

NameTypeDefaultDescription
iconReactNode-Icon shown before the title.

Also accepts the props of React Aria's Heading (opens in a new tab).