Skip to content

Custom functional utility with color values #18041

Answered by wongjn
jacksleight asked this question in Help
Discussion options

You must be logged in to vote
@utility overlay-* {
    --alpha: calc(1% * --modifier(integer));
    --color: --alpha(--value(--color-*) / var(--alpha, 100%));
    border-image: linear-gradient(to top, var(--color), var(--color)) fill 1;
}

--modifier() is where the value after the slash. If there is no slash, the declaration is removed.
--alpha() is Tailwind syntax sugar for color-mix().

https://play.tailwindcss.com/BAEVBTPuJc

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jacksleight
Comment options

Answer selected by jacksleight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants