Key reveal once (Pro)
ProIncluded in $99A new secret, shown once, with copy, a .env line and a check before it is closed uncopied.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { KeyRevealOnce } from "@/components/ui/chatcn/pro/key-reveal-once"
{secret ? (
<KeyRevealOnce
secret={secret}
name="Production server"
envName="CHATCN_API_KEY"
onDone={() => setSecret(null)}
/>
) : null}Says plainly that this is the only time the secret is shown. The secret is set in mono with copy beside it, it can be hidden while someone looks over a shoulder, and with envName a ready NAME=secret line can be copied too. Closing before anything was copied asks once, in place, because a lost key means making a new one. Render it only while the secret should be visible and drop the secret in onDone. api-keys uses it for new and rotated keys.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
secret | string | The new secret |
name | string | The key's name, under the title |
envName | string | Offers a .env line |
onDone | () => void | Closing; forget the secret here |
labels | Partial<KeyRevealOnceLabels> | Every string, for translation |
Accessibility
- Copy buttons announce when they have copied.
- Hide is a toggle button that reports its state.
- Closing uncopied raises an alert with Go back focused.
Motion
The copy icon crossfades to a check. Nothing else moves.