feat(streamdown): add hierarchical list bullet styles with depth trac…#489
Open
simon5057 wants to merge 2 commits intovercel:mainfrom
Open
feat(streamdown): add hierarchical list bullet styles with depth trac…#489simon5057 wants to merge 2 commits intovercel:mainfrom
simon5057 wants to merge 2 commits intovercel:mainfrom
Conversation
…king(vercel#377) 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
- Add listStyle to Styling Props TypeTable in configuration.mdx
Contributor
|
@simon5057 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(streamdown): add hierarchical list bullet styles with depth tracking (#377)
Add
listStyleprop 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:
data-depthattributes on all list elements for custom CSS targetingDescription
Adds depth-aware bullet styling to nested unordered lists in the
streamdownpackage. Previously all list items rendered with the same bullet style regardless of nesting level. Now the default"hierarchical"mode cycles through disc → circle → square as lists nest deeper, making it visually easy to distinguish list depth. Users who prefer uniform styling can opt into"flat"mode. All list elements receive adata-depthattribute for full custom CSS control.Type of Change
Related Issues
Fixes #
Closes #
Related to #
Changes Made
ListStylePresettype ("flat" | "hierarchical") andlistStyleprop toStreamdownPropsinindex.tsxlistStyletoStreamdownContextTypewith default value"hierarchical"ListContextinlib/components.tsxto trackdepth,ulDepth, andisUnorderedthrough the component treeLI_BULLET_STYLESpreset map applying bullet classes (list-disc,list-[circle],list-[square]) on<li>elements based onulDepthdata-depthattributes to all<ul>,<ol>, and<li>elements for custom CSS targetingremendalias tovitest.config.tsfor proper module resolution in testsTesting
Test Coverage
Created
packages/streamdown/__tests__/list-style.test.tsxwith 9 dedicated test cases:data-depth on <ul>data-depth="0", nested hasdata-depth="1"data-depth on <ol>data-depth on <li>flat mode<li>uselist-discregardless of depthhierarchical modeno bullets in <ol><li>inside<ol>receive no bullet classno bullet class on <ul><li>, not parent<ul>sibling lists resetmixed ol/ululDepthonly counts<ul>levels, skipping<ol>nestingAll 142 tests passing across 5 test files.
Checklist
pnpm changeset)Changeset
Additional Notes
Custom styling via
data-depth:Users can target specific nesting depths directly in CSS without needing a new preset:
ulDepthvsdepth:ulDepthcounts only<ul>nesting levels and is used to determine the bullet style cycle. Totaldepth(which includes<ol>) is used fordata-depthattributes. This means an<li>inside<ol> > <ul>correctly receives the depth-1 bullet style (disc), not depth-2, since the outer<ol>doesn't affect unordered bullet cycling.