diff --git a/.changeset/fix-shiki-theme-priority.md b/.changeset/fix-shiki-theme-priority.md new file mode 100644 index 00000000..9a4e6c2a --- /dev/null +++ b/.changeset/fix-shiki-theme-priority.md @@ -0,0 +1,11 @@ +--- +"streamdown": patch +--- + +Fix: `shikiTheme` prop priority chain is now fully reachable. + +Previously, `shikiTheme` had a default value in the props destructuring (`= defaultShikiTheme`), making the `plugins?.code?.getThemes()` fallback unreachable in both orderings. The fix removes the destructuring default and moves it to the end of the nullish coalescing chain, so all three levels are reachable: + +1. Explicit `shikiTheme` prop (highest priority) +2. Code plugin's `getThemes()` (second priority) +3. Built-in `defaultShikiTheme` (final fallback) diff --git a/packages/streamdown/index.tsx b/packages/streamdown/index.tsx index be32d9fd..5e666cff 100644 --- a/packages/streamdown/index.tsx +++ b/packages/streamdown/index.tsx @@ -438,7 +438,7 @@ export const Streamdown = memo( rehypePlugins = defaultRehypePluginsArray, remarkPlugins = defaultRemarkPluginsArray, className, - shikiTheme = defaultShikiTheme, + shikiTheme, mermaid, controls = true, isAnimating = false, @@ -609,7 +609,8 @@ export const Streamdown = memo( // Combined context value - single object reduces React tree overhead const contextValue = useMemo( () => ({ - shikiTheme: plugins?.code?.getThemes() ?? shikiTheme, + shikiTheme: + shikiTheme ?? plugins?.code?.getThemes() ?? defaultShikiTheme, controls, isAnimating, lineNumbers,