From f98bfd0fa55c058f86800fc0daeb0e68cdcecf77 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 31 Mar 2026 17:54:48 +0800 Subject: [PATCH 1/2] feat(streamdown): add hierarchical list bullet styles with depth tracking(#377) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `listStyle` prop to configure bullet style cycling for nested unordered lists. Defaults to hierarchical mode which cycles through disc → circle → square styles based on nesting depth. Features: - Two style presets: flat (uniform disc, backward compatible) and hierarchical (disc/circle/square cycling) - `data-depth` attributes on all list elements for custom CSS targeting - Proper unordered depth tracking that skips ordered list nesting - Context-based depth propagation for accurate per-level styling --- .changeset/add-list-style-prop.md | 10 ++ .../streamdown/__tests__/components.test.tsx | 3 +- .../streamdown/__tests__/link-safety.test.tsx | 2 + .../streamdown/__tests__/list-style.test.tsx | 169 ++++++++++++++++++ .../__tests__/node-attribute-removed.test.tsx | 4 +- packages/streamdown/index.tsx | 15 ++ packages/streamdown/lib/components.tsx | 56 +++++- 7 files changed, 252 insertions(+), 7 deletions(-) create mode 100644 .changeset/add-list-style-prop.md create mode 100644 packages/streamdown/__tests__/list-style.test.tsx diff --git a/.changeset/add-list-style-prop.md b/.changeset/add-list-style-prop.md new file mode 100644 index 00000000..333c9250 --- /dev/null +++ b/.changeset/add-list-style-prop.md @@ -0,0 +1,10 @@ +--- +"streamdown": minor +--- + +Add `listStyle` prop for hierarchical bullet styling in nested lists. + +- New `listStyle` prop accepts `"flat"` or `"hierarchical"` (default: `"hierarchical"`) +- Hierarchical mode cycles bullet styles through disc → circle → square based on nesting depth +- Flat mode preserves the previous uniform `list-disc` behavior +- All list elements (`