Add an option to include the component's displayName in the generated class names
See original GitHub issueHi this is feature request for an option to include the component’s displayName in the generated class names, something like MyComponent_u2jd38
.
Without this, it is very hard identify where styling issues comes from when using Dev Tools to investigate. After a few weeks using styled-components
in my team, this issue has been raised by several people. We transitioned from css-modules
where we had this feature and now we miss it a lot.
FYI: We would probably enable this option for development
builds only.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Styled Components adding component name as class name
I have a component called AlphaBarWrapper with a styled component inside of it called StyledAlphabar . Styled Components is adding ...
Read more >How to Control Class Names in Styled Components
A meaningful class name can be composed of namespace , displayName , and fileName , in addition to the default name. Maximally, we...
Read more >ASP.NET Core Blazor forms and input components
Learn how to use forms with field validation and built-in input components in Blazor.
Read more >Documenting components - Vue Styleguidist
Vue styleguidist generates documentation for your components based on the comments in your source code declarations and Readme files. Note: See examples of ......
Read more >Context - React
createContext('light'); class App extends React.Component { render() { // Use a Provider to pass the current theme to the tree below. // Any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For those using create react app, you can solve this without ejecting by using babel macros.
Simply import
styled-components/macro
instead of the usualstyled-components
. You don’t need to install anything special. The downside is that you will need to import this everywhere.Example:
When used, this component will have a nice readable className like
MyStyledComponent_fa09we8
.For people using create react app, is there any way to solve this without ejecting?