Componenteditors1.17 KB gzipZero dependencies

Api Key Card

API key card with masked value, reveal toggle, copy and regenerate actions.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add api-key-card

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { ApiKeyCard } from "@/components/ui/api-key-card"; <ApiKeyCard />

Source code

api-key-card.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxapi-key-card.tsx72 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface ApiKeyCardProps extends React.HTMLAttributes<HTMLDivElement> {  label?: string;  /** Key displayed with masking */  apiKey?: string;  onRegenerate?: () => void;} /** API key card: masked value, show/copy/regenerate. */export function ApiKeyCard({ label = "API Key", apiKey = "bb_live_a1b2c3d4e5f6g7h8i9j0", onRegenerate, className, ...props }: ApiKeyCardProps) {  const [revealed, setRevealed] = React.useState(false);  const [copied, setCopied] = React.useState(false);   const masked = apiKey.slice(0, 8) + "•".repeat(Math.max(4, apiKey.length - 12)) + apiKey.slice(-4);

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { ApiKeyCard } from "@/components/ui/api-key-card"; <ApiKeyCard />
PropTypeDescription
labelstringAccessible label text rendered or attached to the control. (Default: "API Key")
apiKeystringKey displayed with masking
onRegenerate() => voidCallback invoked on regenerate.