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
@apply Directives Not Working With Custom Variant #3574
Comments
I've looked into the test cases of unocss ( |
@zhangzheheng12345 Thanks for digging in. Actually, I tried to do it without the quotation marks, but because I have "format on save" turned on (in VS Code), You helped me realize I just have to wrap the entire thing (e.g., If a user doesn't have "format on save" enabled, then yes, not including quotation mark is definitely easier. But if they do, then maybe the change below would imply to wrap the entire CSS value in quote, not the individual classes? Thanks again for your help. |
Well, since the formatter will add that space by default, I think supporting quotes in |
UnoCSS version
0.58.5
Describe the bug
I followed the docs to wrap custom variant with quotes (e.g.,
"hover:bg-white"
, but the output CSS was not converted. Instead, here are the before and after code:@apply flex flex-row p-4 text-white "hover:color-red-400";
display:flex;flex-direction:row;padding:1rem;--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity));
(custom variant is gone?)
@apply "hover:bg-white" "hover:bg-opacity-5";
@apply "hover:bg-white" "hover:bg-opacity-5";
(custom variant is not converted?)
The only way I would get it working is to use a
--at-apply:
for each custom variant class. I'm not sure if this is the intended behavior or a bug.@apply "hover:bg-white" "hover:bg-opacity-5";
--at-apply: 'hover:bg-white';
--at-apply: 'hover:bg-opacity-5';
Reproduction
https://unocss.dev/play/?html=DwEwlgbgBAxgNgQwM5ILwCIAWYQgKYB2UADgLQBMUARnAPYwDW6UOGxATrQGZhx6kBbQgFd0APgBQASGDC4sRCgxwwSAC6kCtAnhKkADOOkyVkqeeAIomdni4YAxMzUJ2AczxqMAfRoICTGbmMkjE-mIAErRCYR7AAPSh4cYy8QhBCaYSxsBZwZbWtvbo8RzcvHjiAGpgeADuUAAKnDx8Cek58Vk5eRZWIAgupEgQeHBqeAxgGhxjtAggpAMuGNxczDZ2GGnCaphdtG60u%2BIAModQx2rtGV1gZglykgngEGJAA&config=PTAEFMGcBsEsDsAuBaAJrSBDARtcz5wAPFOQ0eAe2QCcpEbYBjRcVZWAWwAdKbFIAKC69%2BoAN6DQoVOABmCcAGFK8BQHMANFNDc6kcIgCCiBrGwBXRLDkBPbdL1RDASSarID3fsMBVKtoAvqByNJScoADkFlRMkJCRwjx8iKAMmPCQcnyc4DQAIrB0LLAAblAhYRGRAAIxlHGQwOmZ2TS5NGhF4CXlCQDcgoLEoqmycpgW0GPyiipqsOoAFJLSLVk5eZAAXKAA2uttHYXF1n1LAJQAul40U1C7ezrSe5FMFpCI4bT3kZoSoHc0D4u0idFQkVAgRuOhh0kgAAsUu8BLtVtIou9Pt9EcirJFQawSMhoOo0sQUHwMupwKAkeUaNsiShWJhoH8dIEvE4DKj9s9vM5EP5KJcvI4fMZTIxLNY7GKBTzXO5MisBfCmGzwLsAIwAOgATOKMUxUPBQQjTNwdiAoJw9YjgByMVCLl4YYELoIgA&css=JAVwNgBGCWEN4ChjAAIEMAOGwE8ICIALAewDcBTAJwC4AjAcwFoB3Q6AF3PwJIpocbEMaAMYccjAKz4A3AiTAAZBDTwFqTNjwAzMOQAeEXQcaVizCBkYAWCJ33sWbTjzJVqI4mGKVT5ACY2AAxBsgoAvkjhQA&options=N4XyA
System Info
Validations
The text was updated successfully, but these errors were encountered: