CodeBlockRuntime non-ejectable
This component currently does not support copying source code via the eject command. Custom Theme
CodeBlockRuntime renders runnable code blocks at runtime.
Usage
Pass lang, title, and code to render the block; shikiOptions customizes highlighting and also supports transformers.
Use CodeBlockRuntime only when necessary. It increases runtime bundle size, especially when multiple languages are included, and cannot benefit from compile-time highlighting.
Using shiki options
Notation syntax for line and word highlighting, diff, focus, and error/warning annotations works by default. Use shikiOptions.transformers to add custom transformers or override a built-in transformer by its name.
Here is an example using line highlighting without configuration:
Importing file content
You can use the ?raw query to import file content as a string and pass it to the code prop. See Rsbuild - Static Assets for details.
This approach is suitable for scenarios where you need to dynamically display external file content, such as showing example code files.
If you only need to reference external files as code blocks, use the static file code block syntax. It is processed at compile time, with better performance and a smaller bundle size.