Improve debugging tw prop styling
See original GitHub issueWhen tw
prop is used, on the output we get for example class="App___StyledDiv-sc-1r3ydil-0 ksfoHe"
. In a bigger tree, it’s impossible to identify elements like that. I am aware that’s a tradeoff of not naming components.
export default function App() {
return (
<div tw="max-w-md mx-auto flex p-6 bg-gray-100 mt-10 rounded-lg shadow-xl" />
)
}
Unfortunately, React Devtools is not helping here either.
It would be really useful if we could see TW styles along with the resulting CSS styles.
What comes into my mind is in DEV mode to basically include data-tw="..."
prop with an original value that wouldn’t be transformed.
<div class="App___StyledDiv-sc-1r3ydil-0 ksfoHe" data-tw="max-w-md mx-auto flex p-6 bg-gray-100 mt-10 rounded-lg shadow-xl" />
I assume that React Devtools can’t be improved here, that would require something from SC/Emotion.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
A Guide To CSS Debugging - Smashing Magazine
Debugging in CSS means figuring out what might be the problem when you have unexpected layout results. We'll look at a few categories...
Read more >Debugging CSS - Learn web development | MDN
So there we have it: an introduction to debugging CSS, which should give you some useful skills to count on when you start...
Read more >Declarative Layout Debugging in React Native | NUMI Blog
1. Writing boilerplate styling to debug layouts. 2. Selecting colors for each view. 3. Removing boilerplate styling afterwards. . You'll notice that we...
Read more >Intro to Twin: Combining the best of Tailwind and CSS-in-JS
My favorite styling option is using the tw prop as an alternative to the default className prop that ships with React for passing...
Read more >How To Debug React Components Using React Developer ...
In this step, you used the profiler to identify re-renders and componenent re-rendering. You also used flamegraphs and ranked graphs to identify ...
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 Free
Top 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
I’m aiming to add this feature - exactly as suggested - to the next version.
Here’s what you’ll add to the config to enable it:
Sound good?
As I was replying on the email subscription directly I didn’t check this before replying, so thanks for the heads up. It is a nice feature for developers 👍