# Snippet A compact code display component with a built-in copy-to-clipboard button. Ideal for displaying short commands, installation instructions, or single-line code snippets. ```tsx demo import { Snippet } from "@tenstorrent/vesper/snippet"; export default function SnippetDemo() { return yarn add @tenstorrent/vesper; } ``` ## Options | Prop | Type | Description | Default | | ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------- | | `children` | `string` | The code snippet text to display. Also used as the value copied to the clipboard when the copy button is clicked. | — | | `variant` | `"default" \| "contrast"` | The visual style variant of the snippet. | `"default"` | Any additional props are forwarded to the underlying `
` element. ## Examples ### Basic usage Render a `Snippet` by wrapping string children with it: ```tsx demo import { Snippet } from "@tenstorrent/vesper/snippet"; export default function BasicSnippet() { return yarn add @tenstorrent/vesper; } ``` ### Variants A `Snippet` can be rendered in one of two variants: `"default"` or `"contrast"`. Use the `"contrast"` variant to render a `Snippet` with increased contrast: ```tsx demo import { Snippet } from "@tenstorrent/vesper/snippet"; export default function SnippetVariants() { return (
curl https://api.example.com/data curl https://api.example.com/data
); } ``` ### Multiline snippets `Snippet` preserves newlines in the content it renders, so you can also pass string with line breaks to render multiline snippets. You can use escaped newline characters with `\n`: ```tsx demo import { Snippet } from "@tenstorrent/vesper/snippet"; export default function MultilineSnippet() { return {"nvm use 24\nnode -v >> .nvmrc"}; } ``` You can also use template literals: ```tsx demo import { Snippet } from "@tenstorrent/vesper/snippet"; const INSTALL_COMMAND = `nvm use 24 node -v >> .nvmrc`; export default function TemplateLiteralSnippet() { return {INSTALL_COMMAND}; } ```