Skip to content
Sign upPro
SettingsKey reveal onceMenu

Key reveal once (Pro)

ProIncluded in $99

A new secret, shown once, with copy, a .env line and a check before it is closed uncopied.

ProA new secret shown once, with copy, a .env line, and a check when closing before copying.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/key-reveal-once

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

tsx
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

ProWithout a variable name, in a narrow frame where a long secret scrolls inside its field.

Props

PropTypeNotes
secretstringThe new secret
namestringThe key's name, under the title
envNamestringOffers a .env line
onDone() => voidClosing; forget the secret here
labelsPartial<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.