Documentation
Snippet

Snippet

The Snippet component is used to display blocks of code or text with a convenient copy-to-clipboard feature. It supports customization through different accent colors and can optionally display a command-line prompt before each line.

Usage

First of all, you need to import the Snippet component from the kitchn package.

import { Snippet } from "kitchn"

Default

Multi-line

No prompt

Callback

Type

Props

NameTypeDefaultRequiredDescription
textstring | string[]""YesThe text or code to be displayed in the snippet. Can be a single string or an array of strings for multi-line snippets.
promptbooleantrueNoIf true, displays a command-line prompt ($) before each line of text.
typekeyof AccentColors"primary"NoDefines the accent color for the snippet.
onCopy(text: string) => voidnullNoCallback function that gets triggered when the text is copied.