Replies: 1 comment 2 replies
-
|
Hi @David0036! I'm Dosu and I’m helping the storybook team. There isn't a built-in way in Storybook 10.x or @storybook/addon-docs to make "Show Code" display the variable name (like If copy-pasteable code is critical for your docs, you could consider adding a custom code snippet or a note in your docs panel to show the recommended usage with the variable name. If you need more control, you might look into writing a custom docs block or decorator, but this would require manual maintenance. Let me know if you want ideas for workarounds or custom code snippet strategies! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Environment
Problem
I'm using
argTypes.mappingto provide icon options in Storybook controls. When users select an icon and click "Show Code", the output displays the entire FontAwesome icon object instead of the variable name.Current Setup
Current "Show Code" Output
When I select
faPlusfrom the controls dropdown, "Show Code" displays:Desired Output
I would like "Show Code" to display:
Question
Is there a recommended way to achieve this?
The current output makes the documentation less useful since users can't simply copy-paste the code - they have to manually replace the object with the proper import.
This seems like a common use case for icon libraries (FontAwesome, Heroicons, Lucide) and component libraries (Material UI, Chakra UI) where props accept complex objects.
Any guidance would be appreciated!
Thank you!
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions