Skip to content

Danger zone

The risky controls of a form or detail, set apart from the safe ones under a Danger label.

<div class="cap-danger" id="dz-one" role="group" aria-labelledby="dz-one-t">
  <p class="cap-danger-title" id="dz-one-t">Danger</p>
  <div class="cap-danger-actions">
    <button type="button" class="cap-btn" data-variant="danger">Remove site</button>
    <span class="cap-danger-note">The watcher stops probing it. Its history stays.</span>
  </div>
</div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/danger-zone.css";

Usage

<div class="cap-danger" role="group" aria-labelledby="danger-1">
  <p class="cap-danger-title" id="danger-1">Danger</p>
  <div class="cap-danger-actions">
    <button type="button" class="cap-btn" data-variant="danger">Remove site</button>
    <span class="cap-danger-note">The watcher stops probing it. Its history stays.</span>
  </div>
</div>

Examples

Two controls, one under the pointer

<div class="cap-danger" role="group" aria-labelledby="dz-two-t">
  <p class="cap-danger-title" id="dz-two-t">Danger</p>
  <div class="cap-danger-actions">
    <button type="button" class="cap-btn" data-variant="danger">Delete project</button>
    <button type="button" class="cap-btn" data-variant="danger">Mark failed</button>
  </div>
</div>

API reference

DangerZone

PropTypeRequiredDoes
titleReactNodeThe label over the controls.
noteReactNodeOne line on what the controls do and keep, beside them.
childrenReactNodeYesThe risky controls: buttons that each preview and confirm (a confirm dialog), never act at once.

Parts and data attributes

ClassIs
.cap-dangerthe root
.cap-danger-actionsa part
.cap-danger-notea part
.cap-danger-titlea part

Accessibility

KeyDoes
TabMoves to each control in the zone, in order
  • role="group" named by its visible label (aria-labelledby).
  • The label and the note reach 4.5:1 on --crit-soft (checked in the spec).
  • In forced colors the border stays, so the zone is still framed.