Skip to content
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

Class prefix breaks TailwindCSS utility classes #84

Open
MoodyBones opened this issue Apr 30, 2021 · 2 comments
Open

Class prefix breaks TailwindCSS utility classes #84

MoodyBones opened this issue Apr 30, 2021 · 2 comments

Comments

@MoodyBones
Copy link

Hi Alex and Nuxt/Tailwind folks

Cheers for the awesome module! I'm super stoked to use it, but I can't get it working with TailwindCSS.

Usually, I put my SVG in a Vue component. I give the SVG class="w-full h-auto" and fill="currentColor", then I control the size and color with the parent element.

I hoped to do the same with this module, but I can't get the responsive/flexible sizing configured. Inspecting the dev tools, I can see that the class names are being prefixed with BaseLogo_svg__w-full BaseLogo_svg__h-auto ..I guess this is the problem. Is there a way to turn these prefixes off?

If not, could you give any tips on how to style them responsively using TailwindCSS?

Chrome dev tools
Screen Shot 2021-04-30 at 13 39 19

BaseLogo.svg
Screen Shot 2021-04-30 at 13 42 00

TheFooter.vue
Screen Shot 2021-04-30 at 13 38 27

nuxt.config.js

   [
      'nuxt-svg-loader',
      {
        svgoConfig: {
          plugins: [
            { prefixIds: false }, // I thought this might disable it, but I can't see a change true or false
          ],
        },
      },
    ],

Many thanks,
Mel

@Kapcash
Copy link

Kapcash commented Oct 3, 2021

Having the same problem right now. Not sure why the library prefixes the css classes inside the loaded svg?

@Kapcash
Copy link

Kapcash commented Oct 3, 2021

Ok I found out how to disable this!

nuxt-svg-loader uses svg-to-vue loader under the hood.
svg-to-vue uses svgo library by default to optimize the svgs before loading them.
svgo has a rule called prefixIds that adds the svg id as a prefix to classes (still not sure why thought).

This rule has been enabled by default on the svg-to-vue loader. (See this issue#2)

It's actually already mentionned on this module's Readme :)
Adding this configuration fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants