Highlight colours code with the syntax battery's tokens, in 37 languages. CodeBlock is that in a frame: a header, a copy button, a footer, built in one line or from its parts.
Highlight
A pre of coloured tokens. It follows light and dark, scrolls sideways unless told to wrap, and styles written on it reach the pre.
Text and a languageAn unknown or empty language shows the text plain, at the same size.
Type someThe tokens are worked out again as the text changes. Aliases are not known here: use the battery's own names (py is plain, python is coloured).
lang
1def area(r):
2 # pi r squared
3 return 3.14159 * r ** 2
4
5print(area(2))
6
CodeBlock
The code block of shadcn and of AI Elements. With code= it is whole in one line; without, it is the frame its parts are written in.
In one lineA header with the title (or else the language's name), a copy button, the content.
title
showLineNumbers
wrap
Counter.jsx
12import { useState } from "react";
13
14export function Counter({ start = 0 }) {
15 const [count, setCount] = useState(start);
16- const label = "Count: " + count;
17+ const label = `Count: ${count}`;
18 return (
19 <button onClick={() => setCount(count + 1)}>
20 {label}
21 </button>
22 );
23}
24
startLine=12: the marks name lines as numbered, so line 16 is the fifth.
Variants and sizesvariant: default, destructive. size: default, sm. With neither title nor language there is no header and the copy button sits over the corner.
sum.ts
export const sum = (xs: number[]) => xs.reduce((a, b) => a + b, 0);
No title: the language names it
ts
export const sum = (xs: number[]) => xs.reduce((a, b) => a + b, 0);
Neither: bare, the button in the corner
export const sum = (xs: number[]) => xs.reduce((a, b) => a + b, 0);
CodeBlockCopyButtonCopies its value, then shows a check for two seconds. label names it; what is written under it follows the icon.
$mote build app.mote --single
With a label and words
Paste somewhere to see it: a page cannot read the clipboard back without asking.
Built from the partsHeader (title, filename, actions), content, footer. There is no context between them: the selector and the content are given the same state.