- Components
Copy button
An icon button that copies a value and confirms with a check.
npx shadcn add @klarhimmel/copy-buttonWhen 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/buttoncopy-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>
);
}Install
Import
import { CopyButton } from '@/components/klarhimmel/ui/copy-button';- Lands in
- components/klarhimmel/ui/copy-button.tsx, plus cn() and the theme item if they are missing. Import theme.css after Tailwind.
- 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.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | Required. The text copied to the clipboard. |
label | string | 'Copy' | Accessible name of the button. |
className | string | - | Extra classes, merged after the component's own. |