-
Notifications
You must be signed in to change notification settings - Fork 66
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
Icon size cannot be change with TailwindCSS v4 class #346
Comments
That works as intended. That icon is rendered as background image, which is impossible to do without setting width/height, so default width/height are set to 1em. To change that, you can do one of the following:
|
This used to work in TailwindCSS v3. I think there is something to do with the @layer directive in Tailwind V4. ![]() Tailwind V4 uses native CSS layers and styles that are not inside the @layer directive will override the styles defined in the @layer directive based on the MDN specification. ![]() I'm not sure if this issue should be fixed on the Tailwind CSS or Nuxt Icon side |
Because tailwind now use layers we don't need to fight it, we can embrace it defineNuxtConfig({
icon: {
cssLayer: 'icon', // <- this. Try to give unique name to prevent breaking tailwind layer order
},
}) Then Thanks to @riicodespretty for showing problem with naming collision of layers |
Yeah I believe that @untlsn's comment above should solve that issue (Thanks!) And yes I would also suggest to use font-size, like |
Well written ticket and the proposed solution to send icon to the correct css layer appears to be working. I want to use |
In case someone looks it up, I do not recommend @untlsn's solution as it breaks tailwind layer orders, for example making the preflights override utility classes as explained here: tailwindlabs/tailwindcss#15864 (comment). Do not use tailwind layer names, instead here's a safer solution: export default defineNuxtConfig({
// ...
icon: {
cssLayer: 'icon'
},
}) |
When using the Icon component from @nuxt/icon, the icon size cannot be changed using TailwindCSS v4 classes.
Example :
These icons should be 40x40px, but instead, they are using the default size of the icon.
Expected behavior :
The icon should be 40x40px.
Package version :
Minimal Reproduction:
https://github.com/misbahansori/nuxt-icons-issue
The text was updated successfully, but these errors were encountered: