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.

Overlapping classes

See original GitHub issue

Hello!

Awesome work on this library, feels amazing! 🎉

In React, we have a scenario which we have troubles solving using tailwindcss, but feels like we should be able to solve it using something like this. Imagine a React component that has some tailwindcss classes defined in implementation, but also receives a className prop that should be able to override it.

An example:

function Button({ className = "", children }) {
  return (
    <button className={tw("border text-white bg-blue-600", className)}>{children}</button>
  );
}

If I use this component as: <Button>blue</Button>, button should be blue, but if I try to pass bg-red-600 as className, <Button className="bg-red-600">red</Button>, then it should be red. Because of the way classes are applied (based on order in stylesheet), this isn’t possible without removing bg-blue-600 from className.

I wrote simple demo available here using twind that demonstrates simple scenario that doesn’t work.

Is there a theoretical way to make this work with this approach? I’d be willing to contribute with a bit of guidance. 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lukejacksonncommented, Dec 28, 2020

Nice, I’m not against that at all!

1reaction
just214commented, Dec 28, 2020

It’s declarative, clearly defined in the rendered markup, and it works exactly as it should as far as I can tell. I think this is great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle overlapping classes - Cross Validated
If overlapping classes means that a single data instances are assigned multiple classes, you basically two options:.
Read more >
Policy | Enrolling in Overlapping or Back-to-back Classes
Classes with any common meeting time are considered to be overlapping. · Students are not permitted to register for classes that overlap unless...
Read more >
Class-modelling of overlapping classes. A two-step ...
Therefore, in this study, a two-step authentication of overlapping classes is proposed, which combines the advantages of class-modelling and ...
Read more >
SVM for Overlapping Classes
Overlapping Class Distributions. • We have assumed training data are linearly separable in mapped space ϕ(x). • Resulting SVM gives exact separation in....
Read more >
Overlapping class meeting times leave students stressed
Because of the new changes, some students face 15-minute scheduling overlaps for courses they prefer to take during the same quarter.
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