-
|
Hi team, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Related to #7844 We don't provide that feature out of the box but you can swizzle the If your icon is an emoji (or is "serializable" as JSON) you could add it to the sidebar item metadata using
Run
-const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
+const icon = item?.customProps?.myEmoji ?? (isInternalUrl(item.href) ? '📄️' : '🔗');
For explicitly defined sidebars: {
type: 'doc',
id: 'doc1',
customProps: {myEmoji: '🦀'}
},For autogenerated sidebars, this can be done with front matter: ---
sidebar_custom_props:
myEmoji: 🦀
---If your icon is not serializable (for example a React component), you can create a map of icons and use the same trick to provide the icon name instead of the icon code. Then your |
Beta Was this translation helpful? Give feedback.


Related to #7844
We don't provide that feature out of the box but you can swizzle the
DocCardcomponent and adjust the React code to render the icon you want. It receives a sidebar item as a prop.If your icon is an emoji (or is "serializable" as JSON) you could add it to the sidebar item metadata using
customProps.myCustomIcon = '🥂'insidebars.jsor usingsidebar_custom_propsin front matter for autogenerated sidebars. Then you'll receive that string in theDocCardswizzled component.DocCardto customize itRun
npm run swizzle @docusaurus/theme-classic DocCard -- --ejectDocCardcode you want to display an emoji provided as sidebar item custom props:-const icon = …