Skip to content

Snippet

A command line snippet with a copy button.

Installation

pnpm dlx shadcn@latest add @frontal-labs/snippet

Usage

import { Snippet } from "@/components/snippet";
<Snippet>npm install @frontal-labs/ui</Snippet>

Pass lines to render several commands in one block, each with its own prompt:

<Snippet
  lines={[
    { text: "git clone https://github.com/acme/repo.git" },
    { text: "cd repo" },
    { prompt: "#", text: "bun install" },
  ]}
/>

API Reference

Snippet

When lines is set it replaces children, and each entry's prompt overrides the block-level prompt. Copying joins the line texts with newlines; otherwise it copies the rendered children. The copy button shows a check for two seconds and calls onCopy after the clipboard write resolves.

The SnippetProps type is exported alongside the component.

Open the source under Manual above for the exact prop types.