[v4] How to alias a whole color? #15101
Replies: 3 comments 4 replies
-
Hey! Right now there's no way to do it in a single line, haven't had the "eureka" moment that inspired the right API yet. Might be something we add though if we can come up with a syntax that feels right 👍 |
Beta Was this translation helpful? Give feedback.
-
I would rely on this a lot in version 3 with something like this in the config:
Having similar in v4 would be great. In meantime we'll just need to explicitly map custom color names. |
Beta Was this translation helpful? Give feedback.
-
Assuming you want the range of shades for a given named color: /* alias-tailwind-color.scss */
@mixin alias-tailwind-color($alias-name, $base-color-name) {
$color-shades: (50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950);
@theme {
@each $shade in $color-shades {
$variable-name: "--color-" + $alias-name + "-" + $shade;
$base-variable-name: "--color-" + $base-color-name + "-" + $shade;
#{$variable-name}: var(#{$base-variable-name});
}
}
} That mixin generates a Then invoke where needed: @use `alias-tailwind-color.scss` as *;
@include alias-tailwind-color("grayish", "zinc"); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Following the guide to Customizing your theme adding aliases works:
But is there a way to do that in a single line?
Something like:
(But that doesn't work)
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions