Code
Syntax-highlighted code with optional line numbers.
Import
import { Code } from "@tarve/core";Usage
import { Code } from "@tarve/core";
const code = [
"export function sum(a: number, b: number) {",
" return a + b;",
"}",
].join("\n");
<Code code={code} language="ts" path="src/sum.ts" showLineNumbers />Props
| Prop | Type | Default |
|---|---|---|
code required | string | — |
language Syntect syntax name, token, or file extension. | string | — |
path Optional path used for extension-based language detection. | string | — |
showLineNumbers Paint line numbers as non-selectable chrome. | boolean | — |
Inherited from RichProps 1 props
| Prop | Type | Default |
|---|---|---|
syntaxTheme Overrides syntax colours without changing parsing or layout. | Partial<SyntaxTheme> | — |
Common props
Shared by every component. See descriptions →
highlightidkeymotionFromonHighlightonPasteonTransitionEndrovingGroupstyle