Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Destructive with Warning Badge Alert Dialog for Solid

A clear-data dialog with a database icon, a Permanent Action badge, and a destructive button labeled Clear All Data.

UI library: Ark UI

A database icon sits in the title Clear All Data. The badge under it reads Permanent Action. The text lists preferences, cache, and local storage. The button does not clear anything.

Use the badge when the title might sound routine. Do not badge every confirm. Show the scope on a Button before this opens. In Solid, Ark UI does not erase the stored data.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Alert Dialog anatomy: content, title, description, cancel, action

Usage

<AlertDialog>
    <AlertDialogTrigger asChild={props => <Button {...props()} variant="destructive">Clear Data</Button>} />
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle class="flex items-center gap-2">
          <DatabaseIcon aria-hidden="true" class="size-5" />
          Clear All Data
        </AlertDialogTitle>
        <Badge pill variant="destructive">
          Permanent Action
        </Badge>
        <AlertDialogDescription>
          This will permanently delete all stored data including user
          preferences, cache, and local storage. This cannot be undone.
        </AlertDialogDescription>
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel>Cancel</AlertDialogCancel>
        <AlertDialogClose asChild={props => <AlertDialogAction {...props()} variant="destructive">
            Clear All Data
          </AlertDialogAction>} />
      </AlertDialogFooter>
    </AlertDialogContent>
  </AlertDialog>

FAQ

Why put the badge between the title and the description?

The title says what, the badge says how serious, and the description explains. Placed there, it's read before the details and in that order by screen readers.

What should the badge say?

Two or three direct words: Permanent Action, Cannot Be Undone. Generic words like Caution don't say what's special about the action.

How is the badge styled?

It's a Badge with variant="destructive" and pill, so it follows the theme's destructive color with no extra classes.

When does a badge add something a red button doesn't?

When the action is more than destructive: permanent, immediate, or affecting a lot of data. A routine file deletion doesn't need one.

Can I add several badges?

Keep it to one. Several badges compete with each other; put further warnings in the description.

Does Clear All Data close the dialog?

Yes; clear the data in its click handler.

API Reference

Alert Dialog

Sets asChild, props and variant="destructive". The rest is on the Alert Dialog page.

Button

Sets props and variant="destructive". The rest is on the Button page.

Badge

Sets pill and variant="destructive". The rest is on the Badge page.