-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compound variants not work with responsive values #52
Comments
I'm running into this issue too – the classes are properly applied, but the Tailwind compiler doesn't seem to pick them up so the styles aren't generated. |
@mohammadgarmroodi Here is my fork: |
Closing due to lack of reproducability and response. |
Can we reopen this? We merged from cva to Here's an repro using the latest tailwind-variants version: |
Yeah, it looks like the logic from the regular variants is missing/not implemented for compoundVariants. cc @mskelton |
Is it intended to work or it is a limitation like it is with Panda CSS?
To be fair, I think implementing this logic will impact performance as it needs to loop against the variants and the responsive screens? |
Wondering as well if it's intended. Guys what's your workarounds? |
To be more specific, compounded values are working, but are not responsive, it apply only to initial value. |
Same issue here |
Bumping this thread because I'm running into this issue too. Is there a fix underway? Or a workaround? |
This comment was marked as off-topic.
This comment was marked as off-topic.
Same issue encountered here as well. const mediaVariants = tv(
{
base: 'w-full flex-1 grow basis-1/2',
compoundVariants: [
{
class: 'order-2 pt-0',
layout: 'vertical',
mediaPosition: 'bottom',
},
],
defaultVariants: {
fill: false,
mediaPosition: 'center',
},
variants: {
fill: {
true: 'relative aspect-[4/3]',
},
layout: {
horizontal: '',
vertical: '',
},
mediaPosition: {
bottom: 'pt-7',
center: 'py-7',
},
},
},
{
responsiveVariants: true,
}
) When initialized with... mediaVariants({
layout: { initial: 'vertical', sm: 'horizontal' },
mediaPosition: 'bottom',
}) Will always force the
My current workaround feels bad but works okay for my use case:
Not ideal though. Very dependant on having the breakpoints of this component never change. |
my company and I have create a package that achieve this pretty well if you want to have a look and way faster |
@mskelton Raising this issue as well. Here is a test case for responsive compound variants that can be added which currently fails. Note the comment in the expected results array: describe("Tailwind Variants (TV) - Screen Variants", () => {
test("should work with responsive compound variants", () => {
const button = tv(
{
base: "text-xs font-bold",
variants: {
variant: {
solid: "border-none bg-blue-500",
outline: "bg-transparent border border-blue-500"
},
size: {
sm: "text-sm",
md: "text-md",
lg: "text-lg"
}
},
compoundVariants: [
{
variant: "solid",
size: "sm",
className: "bg-red-500"
}
]
},
{
responsiveVariants: true
}
);
const result = button({
variant: {
initial: "outline",
md: "solid"
},
size: 'sm'
});
const expectedResult = [
"bg-transparent",
"border",
"border-blue-500",
"font-bold",
"md:bg-red-500", // expected md:bg-red-500 -- received md:bg-blue-500
"md:border-none",
"text-sm"
];
expect(result).toHaveClass(expectedResult);
});
}); |
The same issue, |
The same issue here. This is a pretty important feature. |
Describe the bug
compound variants does not support responsive values
To Reproduce
https://stackblitz.com/edit/vite-react-tailwind-dtjgiu?file=src%2FApp.jsx
The text was updated successfully, but these errors were encountered: