Tokens
Renders syntax highlighted tokens for the CodeBlock component.
API Reference
Type
AnnotationRendererType
AnnotationRenderersProperties
| Property | Type | Modifiers |
|---|---|---|
| children? | string | Promise<string> | — |
Code string to highlight and render as tokens. | ||
| path? | PathLike | null | — |
Name or path of the tokens to render. This will read the local file system contents from the | ||
| baseDirectory? | PathLike | — |
The base directory to use when analyzing the source code. This will read the local file system contents from the | ||
| language? | Languages | — |
Language to use for syntax highlighting. | ||
| allowErrors? | boolean | string | — |
Whether to allow errors to be displayed. | ||
| showErrors? | boolean | — |
Whether to show errors. | ||
| shouldAnalyze? | boolean | — |
Whether or not to analyze the source code for type errors and provide quick information on hover. | ||
| shouldFormat? | boolean | — |
Whether or not to format the source code using | ||
| css? | { token?: CSSObject; popover?: CSSObject; error?: CSSObject; } | — |
CSS style object to apply to the tokens and popover elements. | ||
| className? | { token?: string; popover?: string; error?: string; } | — |
Class names to apply to the tokens and popover elements. | ||
| style? | { token?: React.CSSProperties; popover?: React.CSSProperties; error?: React.CSSProperties; } | — |
Styles to apply to the tokens and popover elements. | ||
| theme? | ThemeValue | Record<string, ThemeValue> | — |
Optional theme configuration to drive highlighting explicitly. | ||
| renderLine? | (line: { children: React.ReactNode; index: number; isLast: boolean; }) => React.ReactNode | — |
Custom render function for each line of tokens. | ||
| annotations? | AnnotationRenderers | — |
Map of annotation tag names to render functions. When provided, comments matching the annotation signature will be removed from the rendered output and replaced with the corresponding annotation components. | ||
Renders syntax highlighted tokens for the CodeBlock component.
Properties
TokensPropsReturns
Promise<React.JSX.Element>Modifiers
async