Code block

Code with a copy button, colored by any highlighter.

Installation

Examples

Default

html is the code's markup from a highlighter, here Sugar High's. The code block colors Sugar High's markup; other highlighters color their own. A line that doesn't fit scrolls.

highlight.tsx

Plain text

Without html, the code shows uncolored, as suits a shell command.

plain.tsx

Wrapping

wrap wraps a line that doesn't fit instead of scrolling it.

wrap.tsx

Long code

A max height, such as max-h-48, scrolls the code down inside the block, fading it at the edge while more lies past it. The copy button stays put.

scroll.tsx

Anatomy

Each part's data-slot, which a theme styles, is beside it.