feat: allow customizing icons via icons prop#414
Merged
haydenbleasel merged 7 commits intovercel:mainfrom Mar 3, 2026
Merged
Conversation
added 3 commits
February 19, 2026 22:39
Add support for specifying a custom starting line number via the code fence meta string, e.g.: ```js startLine=10 const x = 1; ``` Implementation: - Add `remarkCodeMeta` remark plugin that forwards the fenced-code meta string to hast as the `metastring` property so it is available to the custom React code component. - Update the rehype-sanitize default schema to allow the `metastring` attribute on `code` elements. - Parse `startLine=N` from the meta string in `CodeComponent` and pass the value down as a `startLine` prop. - In `CodeBlockBody`, apply `counter-reset: line N-1` as an inline style when `startLine > 1`, which overrides the Tailwind counter-reset class and makes CSS counters begin from the specified number. - Pass `startLine` through the `CodeBlock` and `HighlightedCodeBlockBody` call chains. - Add 12 tests covering the remark plugin, CodeBlockBody prop, and CodeBlock integration. Closes: resolves vercel#287
Add an IconContext-based system that lets users override any of the built-in icons (CheckIcon, CopyIcon, DownloadIcon, etc.) by passing a Partial<IconMap> via the new `icons` prop on <Streamdown>. - Created lib/icon-context.tsx with IconMap type, IconProvider, and useIcons hook - Updated all sub-components to consume icons via useIcons() instead of direct imports - Added icons prop to StreamdownProps with IconProvider wrapper - Exported IconMap type from package entry Closes vercel#412
Contributor
|
Someone is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
- Add missing changeset for icons feature (minor) - Fix IconComponent type to include size prop matching actual usage - Fix IconProvider memoization: use shallow comparison instead of referential equality so inline icon objects don't cause re-renders - Move START_LINE_PATTERN constant below all imports - Add bounds checking for startLine (must be >= 1) - Convert dynamic imports to top-level imports in startLine tests - Add icon-context tests (5 tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
thank you @sleitor 🙏 |
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.
Summary
Two features in one PR:
iconsprop on<Streamdown>startLine=Nmeta stringCustom icons
New
iconsprop accepts aPartial<IconMap>— unspecified icons fall back to defaults.Changes
lib/icon-context.tsxwithIconMaptype,IconProvider, anduseIcons()hookuseIcons()instead of direct importsIconMaptype exported from package entrycomponentsprop pattern using React contextCustom starting line numbers
Code blocks can specify a starting line number in the meta string:
Changes
remarkCodeMetaremark plugin that forwards fenced-code meta strings to hastmetastringattribute allowed through rehype-sanitizestartLine=Nparsed inCodeComponentand passed down as a propCodeBlockBodyappliescounter-reset: line N-1as an inline styleCloses #412, closes #287