Snippet
A copyable shell command. Authors never type the leading $. The component draws the prompt.
Default
npm init next-app
1
<Snippet text="npm init next-app" width="300px" />
Inverted
dark inverts the chrome for a terminal-on-black block.
npm init next-app
1
<Snippet dark text="npm init next-app" width="300px" />
Multi-line
Pass a string array. Keep it short. Longer scripts belong in Code Block.
cd project
now
1
<Snippet :text="['cd project', 'now']" width="100%" />
No prompt
Turn the $ off for URLs, JSON, or output that must copy exactly as shown.
npm init next-app
1
<Snippet :prompt="false" text="npm init next-app" width="300px" />
Callback
copy fires after the clipboard write. Use it for toasts or a parent checkmark.
Variants
Placeholder
Empty text plus placeholder. The placeholder is informational and is not copied.
Copy text
copy-text overrides the clipboard payload when the visible line is a short label.
Controlled copied
Drive the checkmark from a parent when another surface copies a different payload.
Best practices
- Snippet is a runnable command the user is meant to copy. Inline tokens use
Inline Code. Multi-line source usesCode Block. - Pass the command as
text. Do not prefix$yourself or the row renders$ $ vercel deploy. - Set
promptto false for non-shell strings so the visible text matches the clipboard. - One command per snippet. An array is a short sequence. Longer scripts move to
Code Blockso people can read before they copy. - Placeholder is sentence case, no trailing period, no “Please”. It is not copied. The copy button disables when text is empty and
copy-textis unset. - Use
copy-textonly when the visible line is not the payload. For a plain string, it is redundant.