Skip to content

How to set different icon for Autogenerated doc list #10476

Answered by slorber
Hisoka-X asked this question in Q&A
Discussion options

You must be logged in to vote

Related to #7844

We don't provide that feature out of the box but you can swizzle the DocCard component 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 = '🥂' in sidebars.js or using sidebar_custom_props in front matter for autogenerated sidebars. Then you'll receive that string in the DocCard swizzled component.

  1. Eject DocCard to customize it

Run npm run swizzle @docusaurus/theme-classic DocCard -- --eject

  1. Change the DocCard code you want to display an emoji provided as sidebar item custom props:
-const icon = …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Hisoka-X
Comment options

@Tudorhc5
Comment options

Answer selected by Hisoka-X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants