@streamdown/code plugin provides syntax highlighting for fenced code blocks using Shiki. Languages are lazy-loaded on demand and token results are cached, so rendering stays fast even when many different languages appear in a stream.
Installation
Configure Tailwind CSS
The package ships Tailwind utility classes in its dist bundle. Add a source directive so Tailwind can scan them.Adjust the
- Tailwind v4
- Tailwind v3
globals.css
../ prefix so the path resolves from your CSS file to node_modules. In a monorepo you may need ../../node_modules/....Theme configuration
The plugin accepts athemes tuple: [lightTheme, darkTheme]. Streamdown reads the active color scheme from the user’s system preference and applies the matching theme.
shikiTheme prop:
When a
code plugin is present, plugins.code.getThemes() takes precedence over the shikiTheme prop.Bundled themes
Any value from Shiki’sBundledTheme type is accepted by name (e.g. 'github-light', 'dracula', 'nord'). The full list is available in the Shiki theme gallery.
Custom themes
You can pass aThemeRegistrationAny object directly instead of a theme name:
Supported languages
The plugin supports every language bundled with Shiki (200+). UsegetSupportedLanguages() to get the full list at runtime:
API reference
createCodePlugin(options?)
Returns a CodeHighlighterPlugin instance.
CodeHighlighterPlugin
highlight() returns null when the Shiki highlighter is still loading asynchronously. Pass a callback to receive the result once it is ready — Streamdown handles this automatically via its internal subscriber pattern.
Exported types
Controls
Code block controls (copy and download buttons) are enabled by default. You can configure them via thecontrols prop:
controls={{ code: false }} to hide all code block controls, or controls={false} to hide controls globally.
Pre-configured instance
For convenience,@streamdown/code exports a pre-configured instance with the default ['github-light', 'github-dark'] theme pair:
