question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve debugging tw prop styling

See original GitHub issue

When 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.

image

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:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ben-rogersoncommented, May 28, 2020

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:

twin: {
    debugProp: true,
},

Sound good?

0reactions
fvanwijkcommented, Jun 2, 2020

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 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found