Snippet

Code in a sentence, or a command with a copy button.

Source

Examples

One command, several commands, or a line without a prompt.

One command
Several commands
No prompt

Inline code

Snippet.Inline puts code, URLs, and values inside a sentence. Long values wrap.

Install posthog-js, then set api_host in your SDK configuration.

Connect your agent to https://mcp.posthog.com/mcp to query product data from your editor.

Colors

Use gray (the default) in most cases, and one other color per section at most. The colors have no status meaning. Gray lets the surface show through, and the other colors are opaque.

gray
white
yellow
blue

Every inline color

Every color, as inline code.

whitegraybrandbluecobaltcoralcorn-bluegreenlemonlimepurpletangerinetealvioletyellow

Copy on click

By default, a click selects the whole snippet. With copyOnClick, a click also copies it. Use it for values that people copy often, such as tokens and install commands.

Your project token is phc_k8Fz2nQw7xR4tY1u.

Usage

These are defaults, not laws. Break one when you have a good reason, or when it makes the design more cohesive or more interesting.

  • Use Snippet for a command to copy, and Snippet.Inline for code in a sentence. For multi-line code, use CodeBlock.

API

Snippet is a site component. The block takes div element props and supplies the copy button. Snippet.Inline takes code element props.

Snippet

PropTypeDefaultDescription
textstring | readonly string[]–The code or command lines. Required.
promptbooleantrueShow a dollar prompt before each line.
color'gray' | 'white' | 'blue' | 'cobalt' | 'coral' | 'corn-blue' | 'green' | 'lemon' | 'lime' | 'purple' | 'tangerine' | 'teal' | 'violet' | 'yellow''gray'Sets the fill, border, and text color.
copyOnClickbooleanfalseCopies the snippet when the user clicks it. Without it, a click selects the whole snippet.
onCopy() => void–Runs after the copy button writes to the clipboard.

Snippet.Inline

PropTypeDefaultDescription
color'gray' | 'white' | 'blue' | 'cobalt' | 'coral' | 'corn-blue' | 'green' | 'lemon' | 'lime' | 'purple' | 'tangerine' | 'teal' | 'violet' | 'yellow''gray'Sets the fill, border, and text color.
copyOnClickbooleanfalseCopies the snippet when the user clicks it. Without it, a click selects the whole snippet.
onCopy() => void–Runs after a click copies the text. Needs copyOnClick.
childrenReactNode–The code text.