Skip to content
synccn

Secret Field

New

API key and token display: masked with the prefix and last characters showing, reveal, copy and regenerate.

Secret key

demo_key_••••••••••••••••••••••••3f9a

Example key. Use it on your server only.

Webhook signing secret

demo_whk_•••••••••••••••••••••••8Tt1

Installation

$ pnpm dlx shadcn@latest add @synccn/secret-field

First time in this project? Connect synccn with one command.

Usage

import { SecretField } from "@/components/ui/secret-field";<SecretField label="Secret key" value={key} onRegenerate={roll} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

SecretField

Read-only field for API keys and tokens: masked by default with the prefix and last characters showing, reveal, copy, and an optional regenerate button.

  • valuerequired
    string

    The secret, such as an API key or webhook signing secret.

  • label
    string

    Label shown above the field.

  • visibleEnd
    number

    Default 4

    Characters left visible at the end while hidden, like "sk_live_••••3f9a".

  • onRegenerate
    () => unknown

    Shows a button to roll a new secret. Called when it's clicked; return a promise to show a spinner.

  • hint
    string

    Small print under the field.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • Hidden secrets are announced as hidden rather than read out as dots. Reveal is a toggle button with aria-pressed.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-label, aria-pressed