Loading...
Skip to main content

Code block

CodeBlock renders syntax-highlighted code with Shiki. String children are highlighted as-is, while React elements are serialized to JSX source first.

Example

export const Hello = () => <strong>Hello, Idea React!</strong>;

Language

language accepts javascript, jsx, typescript, tsx, css, html, json, sh, or text. The highlighted markup is injected inline, so the block needs no client-side JavaScript.

Color scheme

Highlight colors follow the inherited CSS color-scheme: light, dark, or light dark to follow the system preference. Bootstrap theme containers work automatically, including nested containers with a different theme. Changing the scheme updates highlighting without rerendering the component.

<CodeBlock language="ts">{`const answer: number = 42;`}</CodeBlock>
Documentation navigation
On this page
On this page