structyl

Code Block API

View component

The full prop reference for the Code Block component. A presentational code block with an optional filename header, line numbers, and a built-in copy button.

Import

tsx
import { CodeBlock } from '@structyl/styled';

Props

CodeBlock

A presentational code block with an optional filename/language header, a line-number gutter, line highlighting, and a built-in copy button. Does not perform syntax highlighting. Extends the native pre element.

PropTypeDefault
code#string

The raw source code to display. Required.

language#string | undefined

Language label shown in the header.

filename#string | undefined

Filename shown in the header.

showLineNumbers#boolean

Render a line-number gutter.

false
copyable#boolean

Show the copy-to-clipboard button.

true
highlightLines#number[]

1-based line numbers to highlight.

[]

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library