Secret field

Free

A key or token you can show and copy: the eye swaps when shown, and the copy icon draws its tick and turns green for a moment.

npx shadcn@latest add https://pixilui.com/r/secret-field.json

Preview

Show the key, copy it, and the tick says it worked.
Size

When to use

Use it when

  • API keys, webhook secrets and tokens in settings.

Use something else when

  • A password a person types: use Input with type="password".

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/secret-field.json

Adds secret-field.tsx with field.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { SecretField } from "@/components/pixilui/secret-field";

<SecretField
  value={value}
  revealIcon={revealIcon}
  copyIcon={copyIcon}
  onCopy={onCopy}
/>

Fills its container's width; the label row and the message wrap.

API reference

PropTypeDefault
valueRequiredstring""The key or token.
revealIconRequiredReactNode–The show button's icon (the animated reveal icon: its eye swaps on reveal).
copyIconRequiredReactNode–The copy button's icon (the animated copy-check icon: it draws its tick).
labelReactNode–The label above the field.
descriptionReactNode–Help under the field ("Only admins can rotate it").
iconReactNode–The icon before the key (the animated key icon).
showLabelstring"Show key"The show button's name while the key is hidden.

Also takes every native <input> attribute except size, prefix, value, defaultValue, type, onCopy, and a ref.

Keyboard

TabMoves to the show button, then the copy button.
Enter SpaceShows or hides the key, or copies it.

Accessibility

  • The show button says Show key or Hide key with aria-pressed; copy says Copy key, then Copied.

Motion

  • The eye swaps when the key shows; the copy icon draws its tick for 1.6s. Both are the locked animated icons.
InputA field that checks what you typed and says what's wrong in words.
Copy buttonThe copy icon swaps to a check that draws itself; the width holds.
AI fieldA still gradient rim marks the field that asks the agent.

PixilUI Pro opens soon. The first 20 licenses are $99.