Skip to content
Klarhimmel UI

Copy button

npm install
npx shadcn add @klarhimmel/copy-button
DetailsAbout, usage, props and more

An icon button that copies a value and confirms with a check.

When to use

  • Use for

    Next to a command, token or id people paste elsewhere.

  • Not for

    Long text. Offer a download instead.

  • Pairs with

    Command boxes, code blocks.

Preview

npx shadcn add @klarhimmel/button
copy-button.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { CopyButton } from '@/components/klarhimmel/ui/copy-button';

export default function Example() {
  return (
    <Theme theme="brand">
      <CopyButton value="npm install" label="Copy command" />
    </Theme>
  );
}

Import

Import

import { CopyButton } from '@/components/klarhimmel/ui/copy-button';
Files
copy-button.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

Props

PropTypeDefaultDescription
valuestringrequiredRequired. The text copied to the clipboard.
labelstring'Copy'Accessible name of the button.
copiedLabelstring'Copied'
classNamestring-Extra classes, merged after the component's own.

Accessibility

KeyDoes
Enter / SpaceCopies and shows a check