Skip to content

Secret reveal

A secret shown once, such as an API key, that takes focus and has a warning and copy button.

<div data-mount="key"></div>

Installation

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

Usage

<section class="cap-secret" aria-labelledby="k-h">
  <h2 class="cap-secret-title" id="k-h">Your new API key</h2>
  <pre class="cap-secret-value" tabindex="-1" aria-labelledby="k-h" aria-describedby="k-n">sample_live_4f9c...</pre>
  <div class="cap-secret-foot">
    <p class="cap-secret-note" id="k-n">This will not be shown again. Copy it now and store it somewhere safe.</p>
    <!-- the copy button -->
  </div>
</section>

API reference

SecretReveal

PropTypeRequiredDoes
titleReactNodeYes
secretstringYes
noteReactNode
copyReactNodeThe copy control: Capsomer's CopyButton with text={secret} and a name ("Copy API key").
headingLevel"h2" | "h3" | "h4"
focusOnShowboolean

Parts and data attributes

ClassIs
.cap-secretthe root
.cap-secret-foota part
.cap-secret-notea part
.cap-secret-titlea part
.cap-secret-valuea part