Command Copy
Shows a shell command with a button that copies it.
@paneui/theme@paneui/icons@paneui/button@paneui/action-swap-blur@paneui/locale-providerclass-variance-authoritymotion
Installation
pnpm dlx shadcn@latest add @paneui/command-copyUsage
Examples
Copy feedback
The copy glyph cross-fades to a check for 1.6s and a polite live region says “Copied”. Under reduced motion the swap is an opacity fade only. If the clipboard is blocked nothing changes and onCopy is not called.
Labels
The button reads “Copy command” and “Copied” from the nearest LocaleProvider (copyCommand, copied); label overrides the first. The prompt glyph is hidden from assistive tech and never copied.
Long commands
The command stays on one line and scrolls sideways without a scrollbar, so the button never moves.
CommandCopy
Also accepts every prop of div.
- command*
- string
- The command, exactly as it is copied.
- prompt= "$"
- ReactNode
- Glyph before the command;
nullhides it. - label
- string
- Accessible name of the copy button.
- onCopy
- (command: string) => void
- Called after the command reaches the clipboard.
- variant= "default"
- "default" | "floating"
defaultis a raised card;floatingis a translucent, blurred bar with a deeper shadow.- size= "default"
- "default" | "lg"
defaultis 40px with a ghost button;lgis a 56px round bar with a solid round 40px button and larger type from thesmbreakpoint.
| Prop | Type | Default | Description |
|---|---|---|---|
| command* | string | — | The command, exactly as it is copied. |
| prompt | ReactNode | "$" | Glyph before the command; null hides it. |
| label | string | — | Accessible name of the copy button. |
| onCopy | (command: string) => void | — | Called after the command reaches the clipboard. |
| variant | "default" | "floating" | "default" | default is a raised card; floating is a translucent, blurred bar with a deeper shadow. |
| size | "default" | "lg" | "default" | default is 40px with a ghost button; lg is a 56px round bar with a solid round 40px button and larger type from the sm breakpoint. |
- data-variant
- The variant.
- data-size
- The size.
| Data attribute | Description |
|---|---|
| data-variant | The variant. |
| data-size | The size. |