"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface ColorToken { name: string; value: string; /** CSS variable name, e.g. --accent */ cssVar?: string; usage?: string; } export interface ColorTokenTableProps extends React.HTMLAttributes { tokens: ColorToken[]; } /** Theme token table: swatch + CSS variable + copy action. */ export function ColorTokenTable({ tokens, className, ...props }: ColorTokenTableProps) { const [copied, setCopied] = React.useState(null); const copy = (token: ColorToken) => { try { void navigator.clipboard?.writeText(token.cssVar ?? token.value); } catch { /* ignore */ } setCopied(token.name); setTimeout(() => setCopied(null), 1400); }; return (
{tokens.map((token, idx) => ( ))}
Token Value Copy
{token.value}
); }