CSS Conditionals
#18436
Replies: 1 comment
-
|
I think you've inverted a couple of things
Curiously I think with arbitrary values we can almost do it already in tailwind eg it might be possible to clean that up slightly with something like a state selector could potentially use built in styles too by omitting var() more examples |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
There is now
if()statements in CSS: https://drafts.csswg.org/css-conditional-values-1I think that this could be added to css, and not require using js for this.
I propose the following syntax:
<elm class="cond[x]-[condition]; true[x]:[value when if[x] is true]; false[x]:[value when if[x] is false]" />so Example 5:
would be in tailwind:
You can also define
else ifs effectively. I propose one of these syntax:false[prev]:cond[new]-[cond]elif[prev]:cond[new]-[cond]whereprevis the id of the previous condition andnewis the id of the new condition.You can only define
falseor theelse if.So this example:
goes to this:
If there is only one condition in an element, you don't need to specify the id.
Beta Was this translation helpful? Give feedback.
All reactions