From 576a9c61cbc4b5176257fcb7ad1b8e278f37edc0 Mon Sep 17 00:00:00 2001 From: Dmitrii Troitskii Date: Fri, 3 Apr 2026 19:10:57 +0000 Subject: [PATCH 1/2] fix: prioritize shikiTheme prop over code plugin default theme --- .changeset/fix-shiki-theme-priority.md | 7 +++++++ packages/streamdown/index.tsx | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-shiki-theme-priority.md diff --git a/.changeset/fix-shiki-theme-priority.md b/.changeset/fix-shiki-theme-priority.md new file mode 100644 index 00000000..26845f3c --- /dev/null +++ b/.changeset/fix-shiki-theme-priority.md @@ -0,0 +1,7 @@ +--- +"streamdown": patch +--- + +Fix: `shikiTheme` prop now takes priority over the code plugin's default theme. + +Previously, the nullish coalescing order was incorrect, causing the code plugin's `getThemes()` to override the explicitly passed `shikiTheme` prop. The order has been swapped so the prop takes precedence. diff --git a/packages/streamdown/index.tsx b/packages/streamdown/index.tsx index be32d9fd..ebdafc89 100644 --- a/packages/streamdown/index.tsx +++ b/packages/streamdown/index.tsx @@ -609,7 +609,7 @@ 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(), controls, isAnimating, lineNumbers, From 2182c43f6381dc6f677471ad1570f3cd7773982f Mon Sep 17 00:00:00 2001 From: Dmitrii Troitskii Date: Wed, 8 Apr 2026 21:10:06 +0000 Subject: [PATCH 2/2] fix: make all three shikiTheme priority levels reachable Remove the destructuring default so shikiTheme can be undefined, making plugins?.code?.getThemes() actually reachable as a fallback. Priority chain: explicit prop > code plugin > defaultShikiTheme. --- .changeset/fix-shiki-theme-priority.md | 8 ++++++-- packages/streamdown/index.tsx | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.changeset/fix-shiki-theme-priority.md b/.changeset/fix-shiki-theme-priority.md index 26845f3c..9a4e6c2a 100644 --- a/.changeset/fix-shiki-theme-priority.md +++ b/.changeset/fix-shiki-theme-priority.md @@ -2,6 +2,10 @@ "streamdown": patch --- -Fix: `shikiTheme` prop now takes priority over the code plugin's default theme. +Fix: `shikiTheme` prop priority chain is now fully reachable. -Previously, the nullish coalescing order was incorrect, causing the code plugin's `getThemes()` to override the explicitly passed `shikiTheme` prop. The order has been swapped so the prop takes precedence. +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 ebdafc89..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: shikiTheme ?? plugins?.code?.getThemes(), + shikiTheme: + shikiTheme ?? plugins?.code?.getThemes() ?? defaultShikiTheme, controls, isAnimating, lineNumbers,