Krizaka UI
Krizaka UI
Composants

Confirm button

A destructive action in two presses: the first arms it and says what will happen, the second runs it.

WebBêtaActions

Web uniquement — React, depuis @krizaka/ui/confirm-button. Bêta : son API peut encore changer à une version mineure.

Pourquoi il est là. Used by Orochia.

Quand l’utiliser

  • For a destructive action on one item, in place: delete a comment, remove a member, leave a group.
  • When a dialog would be too heavy and an undo is not possible.

Quand ne pas l’utiliser

  • When the consequences need explaining, or several things are affected.À la place : Dialog
  • For an action that is not destructive.À la place : Button
  • When the action can be undone: run it at once and offer “Undo” in a toast.À la place : Toast

Installation

Installer

npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Importer

import { ConfirmButton } from "@krizaka/ui/confirm-button";

Exemples

Icon, idle

An icon named by label.

Armed

After the first press: the danger border and tint, the words legible.

With words

Once armed, armedContent replaces the words.

Props

A two-step button: press to arm, press again within timeoutMs to confirm. State: data-armed.

PropTypeDéfautDescription
confirmLabelrequisstring—What the second press does, in words — shown and announced once armed ("Delete for good?"). Passed translated.
onConfirmrequis() => void—Runs on the second press.
announcestring—A message announced politely by assistive technology when it changes (“Saved”, “Upload failed”) — passed translated.
armedContentReactNode—What it shows once armed (default: its children, then confirmLabel).
indicatorbooleantrueShows the glyph while loading / with a status. false: you draw your own.
labelstring—The accessible name while idle, for an icon-only button (the confirm label names it once armed).
loadingboolean—Disables and signals the wait (aria-busy, data-loading) and shows the Krizaka loader glyph before the label; the button keeps its colour.
magneticboolean—The button leans a few pixels toward a fine pointer (driven by MotionObserver; never under reduced motion or on touch).
onArmedChange((armed: boolean) => void)—Notified when it arms and disarms.
progressnumber | null—Between 0 and 1, while loading: the glyph's trace and a light fill across the button grow to the value (an upload, an export).
shape"rounded" | "pill" | "cut"roundedrounded · pill · cut (45° corners, the Krizaka chamfer).
shimmerboolean—A sheen of light crosses the button on hover — for the one action a page is about.
size"icon" | "sm" | "md" | "lg"mdsm · md · lg, or icon (a square).
status"success" | "error" | null—How the action ended: success draws a check, error a cross (and the button shakes its head once); a ring of the status colour opens around it. Clear it to return to rest.
timeoutMsnumber4000Disarms after this many milliseconds (4000 by default).
variant"danger" | "primary" | "gradient" | "secondary" | "outline" | "ghost"ghostThe look: primary (the accent), gradient (accent → accent-2), secondary (a raised surface), outline, ghost, danger.

Accessibilité

  • Once armed, confirmLabel names the button and is announced politely.
  • An icon-only confirm button needs label while idle.
  • The armed state is data-armed: style it with the danger tint, the words stay a text role.

Clavier

TouchesAction
Enter / SpaceArms, then confirms.
EscDisarms; so does moving the focus away.

Bonnes pratiques

  • confirmLabel says the consequence as a question: “Delete for good?”.
  • Keep timeoutMs short (4 s by default): an armed button left on screen is a trap.
  • Never use window.confirm for this.

Générée depuis le code de @krizaka/ui 3.9.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page