Add `className` prop to all components
See original GitHub issueRelying on class names is brittle, risking typos (or making string constants necessary) and opening up an escape hatch to meddle with the insides of components. It is better to remove className
props entirely and rely on emotion
component-based styling instead.
After running into some tricky-to-debug styling errors using the components, the scope of this PR has changed. Read along 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Passing in class names to react components
Shouldn't adding className prop to a React component pass on that className to the first container element instead of passing it as a...
Read more >Pass class names as props to React components
Pass a string containing the class names as a prop. · Destructure the prop in the child component. · Assign the class names...
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
Passing Classnames as props in React. In all honesty, I probably made it sounds like it was going to be very complicated, right?...
Read more >Passing classnames as a props to the React component
In this tutorial, we are going to learn about how to pass the classnames as a props to the react component.
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
I think that we can try this pattern for our module -> https://github.com/pedronauck/docz/blob/master/examples/typescript/src/components/Alert.tsx
So we retrieve all native react props (including classname), and it’s pretty 😎
I’m totally in favor of allowing a
className
prop everywhere. I think it makes sense for components to receiveclassName
s all the time, but not ad-hoccss
styles.Good catch, Peter!