Components with secondary classnames
See original GitHub issueHi, I’m wondering if there is a solution to using styled-components with existing libraries. Lots of libraries adopt customization to css via multiple className
props. For example, react-select uses className
and optionClassName
in a component. Would it be useful to support something like:
const MySelect = styled(ReactSelect)`
border: red;
[optionClassName]
color: blue;
`
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:21 (9 by maintainers)
Top Results From Across the Web
How to add multiple classes to a ReactJS Component?
You can create an element with multiple class names like this: <li className="class1 class2 ...
Read more >Adding Multiple Class Names in React Components
We can use the classnames package to make adding multiple classes easier. It works for both static and dynamic classes. To use it,...
Read more >Passing className to components in React
In React, we are familiar with the concepts of a className on components. It's the way React adds the class attribute to an...
Read more >Passing className to components in React - Daily Dev Tips
In React, we are familiar with the concepts of a className on components. It's the way React adds the class attribute to an...
Read more >Advanced Usage - styled-components
styled-components generates an actual stylesheet with classes, and attaches those classes to the DOM nodes of styled components via the className prop. It ......
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
Just pass in
className
to the generated styled component and it’ll be appended on the prop 😉We’ve decided against introducing a method that let’s you manually get a CSS class name from a CSS string to avoid people overusing it and thusly defeating the whole point of the library. (it’s strictness)
I’m going to close this issue because this is now possible with v2 and the
.attrs
selector: