New secret

Clipboard copy for lit-material: copyText() with a fallback for non-secure pages, a copy button, and a read-only value with copy (and optional masking), and a newly created secret shown once.

  • 6.4 KB gzipped
  • @lit-material/clipboard 1.8.0
  • Renders on the server

Example

Install

npm install @lit-material/clipboard @lit-material/tokens
import "@lit-material/clipboard/new-secret.js";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-new-secret>

A secret shown once, right after it was created: an access token, an API key, a recovery code. The value with a copy button, and a warning that it can't be shown again. Put a "Done" button in the actions slot that drops the element (and the secret) from the page.

Properties

PropertyAttributeTypeDefaultDescription
valuevaluestring""The secret.
labellabelstring""What it is, e.g. "Access token \"ci\"": the heading and the value's accessible name.

Events

EventDescription
copyBubbles from the copy button; detail is { text, ok }.

Slots

SlotDescription
warningReplaces the default warning text.
actionsButtons under the value, e.g. "Done".

CSS parts

PartDescription
containerThe outlined box.
valueThe lit-material-clipboard-copy holding the secret.

CSS custom properties

PropertyDescription
--lit-material-new-secret-shapeCorner radius (default --md-sys-shape-corner-medium).

Source on GitHub npm