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";
import "capsomer/tokens.css";
import "capsomer/danger-zone.css";
import { DangerZone } from "capsomer/react/danger-zone";
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
| Prop | Type | Required | Does |
|---|
title | ReactNode | | The label over the controls. |
|---|
note | ReactNode | | One line on what the controls do and keep, beside them. |
|---|
children | ReactNode | Yes | The risky controls: buttons that each preview and confirm (a confirm dialog), never act at once. |
|---|
Parts and data attributes
| Class | Is |
|---|
.cap-danger | the root |
|---|
.cap-danger-actions | a part |
|---|
.cap-danger-note | a part |
|---|
.cap-danger-title | a part |
|---|
Accessibility
| Key | Does |
|---|
| Tab | Moves 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.