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.

Please considering a more human readable format for generated css classes.

See original GitHub issue

The problem

Emotion produces class names like this: class="css-jdkslf-Item"

image

While the Item trailing the end is useful because it helps identify the name of the Component it was attached to, it also is harder to read at the end.

Proposed solution

It would be better if the class name was something like class="Item-css-kfjdslf" because that makes it easier to scan.

Alternative solutions

Even better would be if you could get rid of the “css-fdsafdjk” entirely. I am guessing it’s there for namespacing css purposes but I think there’s got to be a more visually elegant solution. Something along BEM or these lines maybe? https://zellwk.com/blog/css-architecture-2/

Additional context I’m just using emotion in a framework that uses it as a dependency. So I admittedly don’t know the ends and outs of it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nsaunderscommented, Aug 23, 2020

If you want meaningful class names, you might be interested in a project of mine: https://inline.style/

0reactions
jcklpecommented, Nov 1, 2019

Aren’t source maps there to help you figure out where styles come from? I never need to read the generated class names.

That’s fair. The framework I’m using that uses Emotion has not had support for source maps though there is a pull request currently to fix that so maybe this will be a pretty obvious moot point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BEM 101 - CSS-Tricks
The Block, Element, Modifier methodology (commonly referred to as BEM) is a popular naming convention for classes in HTML and CSS.
Read more >
CSS Guidelines (2.2.5) – High-level advice and guidelines for ...
High-level advice and guidelines for writing sane, manageable, scalable CSS.
Read more >
How to Use BEM Methodology - Toptal
Blocks in BEM are always a starting point of chaining your CSS classes on to. ... Let's consider the following HTML, structured in...
Read more >
6 Tips for Tailwind CSS Development (with resources!)
These are not rules, but I've found they have made my development easier and more readable. 1. Use 'clsx' to Join Classes. Let's...
Read more >
Practical Guide to React and CSS Modules
If I created a new class called item without the select__ suffix, ... it will have a more human readable identifier but still...
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