Components/CodeBlock

CodeBlock

Syntax-highlighted code display with copy button, line numbers, and filename header.

Installation

Examples

TypeScript example

With filename header, line numbers, and copy button.

Button.tsx
1import React from "react";
2 
3export function Button(props) {
4  return (
5    <button className="btn">{props.children}</button>
6  );
7}

API Reference

PropTypeDefaultDescription
code*stringrequiredSource code to display.
languagestringLanguage hint for syntax highlighting.
showLineNumbersbooleanfalseShows line number gutter.
filenamestringFilename shown in the header bar.
captionstringOptional caption below the block.