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, or tsx. The highlighted markup is injected inline, so the block needs no client-side JavaScript.

<CodeBlock language="ts">{`const answer: number = 42;`}</CodeBlock>