-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
addComponents Type doesn't accept nested properties in media queries #14054
Comments
I kind of solved this by combining all of my styles under one media query seems to be working. Bad:
Good:
|
Hey! The issue is not the media itself, but the array that is being used. Currently the only spot where we allow arrays from a type perspective is for string based values. For all nesting related things, we accept objects where the key is your selector/media query. I think the better solution compared to your initial code snippet is to move things around a little bit and use nesting a bit more: https://tailwindcss.com/docs/plugins#adding-components E.g.: addComponents({
'.range': {
'@media (min-width: 400px)': {
'&::-webkit-slider-thumb': {
width: 'var(--range-thumb-size)',
height: 'var(--range-thumb-size)',
marginTop: 'calc(((var(--range-thumb-size) / 2) - var(--range-track-height) / 2) * -1)',
background:
"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='white' d='M377.941 169.941V216H134.059v-46.059c0-21.382-25.851-32.09-40.971-16.971L7.029 239.029c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971V296h243.882v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.568 0-33.941l-86.059-86.059c-15.119-15.12-40.971-4.412-40.971 16.97z'/%3E%3C/svg%3E\")\n no-repeat\n center center / 20px 20px\n var(--range-thumb-background)",
},
},
},
}) This way the Now you should also be able to use other keys with different selectors, for example for Hope this helps! |
What version of Tailwind CSS are you using?
v3.4.6
What build tool (or framework if it abstracts the build tool) are you using?
prejss-cli: 0.3.3
postcss-cli: 11.0.0
What version of Node.js are you using?
v20.15.1
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction:
Describe your issue
I am using prejss-cli to convert css into js and then pulling that converted js into the plugin and into addComponents.
unfortunately it's not happy with the first type on the addComponents argument.
Seems like if it's an array then it's expecting a string not an object?
The text was updated successfully, but these errors were encountered: