ApiKeyField

A secret kept out of sight. The prefix and last four characters stay readable; Reveal decodes the rest left to right and a bar counts down to when it masks itself again. Auth.

Open playground
Secret key
•••••••••••••••••••••••••••••ypdn
Created 12 Mar. Last used today.

About

ApiKeyField is a React component in the Auth category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { ApiKeyField } from "@ashutoshswamy/smoui" and set value, label, onRegenerate among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { ApiKeyField } from "@ashutoshswamy/smoui";

<ApiKeyField value="demo_key_9f3kq2m7xv4ctb8wz1h6ypdn" meta="Created 12 Mar" onRegenerate={() => api.rotateKey()} />

Props 5

value

The secret.

string
label

Default Secret key.

string
onRegenerate

Returns the new key, which is revealed once. Leave out to hide the button.

() => Promise<string> | string
meta

A line under the field.

string
autoHideSeconds

Seconds a revealed key stays visible. 0 keeps it.

numberdefault 10