API Key Row
ProNewA secret in a list: masked with its prefix and last four characters, with reveal, copy, and rotate and revoke that each ask for a second press.
Installation
pnpm dlx shadcn@latest add @viewport/api-key-row
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| name* | stringWhat the key is for, e.g. "Production server". | — |
| value* | stringThe full key. It is shown masked until revealed. | — |
| created | stringWhen it was made and last used, already formatted. | — |
| lastUsed | string | — |
| onRotate | () => voidReplaces the key. The button asks for a second press first. | — |
| onRevoke | () => voidDeletes the key. The button asks for a second press first. | — |
| className | string | — |
Accessibility
- Hidden keys are read as “Key ending in”, not as a row of bullets.
- Reveal is a toggle with aria-pressed; copy confirms and is announced.
- Rotate and revoke state what the second press will do, and disarm when focus leaves.
- Respects prefers-reduced-motion.