[V4] Defaults for --value() and --modifier()? #18030
katerlouis
started this conversation in
Ideas
Replies: 0 comments
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.
-
Imagine the following utility:
.atl
=position: absolute; top: 0; left: 0
, so far so good.atl-5
= as above with spacing variables for top and left.atl-5/10
= same as above but left has spacing10
instead of5
This
@utility
-declaration works perfect foratl
andatl-5
, as the secondleft:
assignment is just dropped due to no modifier being present.With a modifier present, however, the output css features 2
left
-assignments. This works functionally as the secondleft
overwrites the firstleft
, but the double assignment is bugging me.What about a way to assign default values to
--value()
and--modifier()
in case they are not present.This would for one allow
atl
(without value nor modifier) to default to a desired value, and also allow only oneleft
assignment in this example.Ideally defaults could be nested like so:
left: --spacing(--modifier(number, --value(number, 0)))
Ideally tailwind would be smart enough to recognize, that if there are defaults present for
--value
, that I don't need to declare a separate@utility atl
just for the default-version. Seems like not much of a burden, until you need a lot of utilities with fallbacks. In this example I also want combinations forbottom
andright
as well, and of course also forfixed
.atl, abl, atr, atl, ftl, fbl, ftr, fbr
alongside their
-*
valued version.What do you think?
Beta Was this translation helpful? Give feedback.
All reactions