Secret Field

A read-only secret, such as an API key, hidden until shown, with buttons to copy and regenerate it.

Secret key

Installation

  1. Add the registryOnce per project
  2. Add secret-field

Usage

Secret Field is a Copy Field that hides the value until the eye button is pressed. Copying always copies the whole value.

For password entry, use an Input with type="password". If the browser should never see the secret at all, don't send it to the page.

Examples

Visible characters

visibleSuffix and visiblePrefix set how many characters stay visible at each end while the secret is hidden.

Webhook signing secret
Publishable key
Database password

Regenerate

onRegenerate adds a button for making a new secret. Set regenerating while it's in progress. revealed and onRevealedChange control whether the value is shown.

Secret key

Props

The file also exports maskSecret(value, visiblePrefix, visibleSuffix), which masks a secret as a string, such as for a table of keys.

SecretField