ApiKeyField

Masked API-key display with reveal + copy buttons. Optional scope chips and relative "last used" timestamp.

Installation

pnpm dlx shadcn@latest add @shadmin/api-key-field

Usage

import { ApiKeyField } from '@/components/admin';
 
<ApiKeyField source="apiKey" />
<ApiKeyField
  source="apiKey"
  scopesSource="scopes"
  lastUsedSource="lastUsedAt"
/>

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Record field with the key
scopesSourceOptionalstring-Sibling field with scope strings
lastUsedSourceOptionalstring-Sibling field with ISO timestamp
maskedFormatOptional"last4" | "full""last4"Masking strategy
classNameOptionalstring-CSS class

Reveal

Reveal/hide toggles per render — the unmasked state lives in component state, not in the record. Closing and reopening the view re-masks.