-
I'm attempting to create a custom CSS utility that behaves similarly to Tailwind CSS's built-in text-* classes, specifically for applying text colors. 'ion-text': (value) => ({
'--color': withOpacity(value),
}), but in v4 @utility ion-text-* {
--color: --value(--color- *);
} This utility successfully applies the base color. However, If I try to use this utility with an opacity value (e.g., ion-text-primary/50), it fails. i want an exact functional replica of Tailwind's text-* utility, which allows for both color application and dynamic opacity control (e.g., text-blue-500 and text-blue-500/50). Could anyone provide guidance on how to modify this utility, Any insights into how Tailwind achieves this with its text-* utility ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As per the documentation, you'd use @utility ion-text-* {
--foo: calc(--modifier(integer) * 1%);
--color: --alpha(--value(--color- *) / var(--foo, 100%));
} As for how Tailwind core achieves this with its tailwindcss/packages/tailwindcss/src/utilities.ts Line 4999 in ed3cecd |
Beta Was this translation helpful? Give feedback.
As per the documentation, you'd use
--modifier()
:As for how Tailwind core achieves this with its
text-*
utility, start from here:tailwindcss/packages/tailwindcss/src/utilities.ts
Line 4999 in ed3cecd