Components › Display

Code block

A block of code with a file name, line numbers, marked lines and a copy button.

Installation

npx plankui@latest add code-block

Usage

import { CodeBlock } from "@/components/ui/code-block";

<CodeBlock code={source} filename="app.tsx" lineNumbers highlightLines={[3]} />

API reference

PropTypeDefaultDescription
codestringrequiredThe code. JavaScript, TypeScript and JSX are coloured.
filenamestring"Code"Shown in the header.
lineNumbersbooleanfalseNumber each line.
highlightLinesnumber[][]1-based lines to mark.
syntaxbooleantrueTurn off for shell output or plain text.

View the source on GitHub