userquin / vuetify-nuxt-module

Zero-config Nuxt Module for Vuetify
https://vuetify-nuxt-module.netlify.app/
MIT License
187 stars 20 forks source link

How to modify SASS variables of a vuetify component? #198

Open GitTheCodeAndHitTheRoad opened 4 months ago

GitTheCodeAndHitTheRoad commented 4 months ago

Hello,

I am trying to change some SASS variables for the v-date-picker from vuetify but I can't make it work yet. I checked the documentation from vuetify itself and some issue reports from nuxt about this topic but I'm not sure what the best approach is when using the vuetify-nuxt-module.

What would be the correct steps to modify the SASS variable of a vuetify-compent?

Any help much appreciated!

HendrikJan commented 4 months ago

I am having the same problem.

Some SASS variables can be edited (like $button-border-radius) but variables that have to do with fonts cannot be edited (like $body-font-family).

The variables that can be edited, can be edited in this way:

// nuxt.config.js
vuetify: {
    moduleOptions: {
      styles: { configFile: 'assets/vuetify.scss' }
    }
}

And the scss file:

@use 'vuetify' with (

  // This variable can be changed
  $grid-breakpoints: (xs: 0,
    sm: 768px,
    md: 992px,
    lg: 1200px,
    xl: 1900px),

  // This variable cannot be changed
  $body-font-family: 'Open Sans' sans-serif,
);

If someone knows how to change all available variable, and specifically the font settings, please help!

userquin commented 4 months ago

check nuxt channel in vuetify discord server: https://discord.com/channels/340160225338195969/1198016523873308745

GitTheCodeAndHitTheRoad commented 4 months ago

I am having the same problem.

Some SASS variables can be edited (like $button-border-radius) but variables that have to do with fonts cannot be edited (like $body-font-family).

The variables that can be edited, can be edited in this way:

// nuxt.config.js
vuetify: {
    moduleOptions: {
      styles: { configFile: 'assets/vuetify.scss' }
    }
}

And the scss file:

@use 'vuetify' with (

  // This variable can be changed
  $grid-breakpoints: (xs: 0,
    sm: 768px,
    md: 992px,
    lg: 1200px,
    xl: 1900px),

  // This variable cannot be changed
  $body-font-family: 'Open Sans' sans-serif,
);

If someone knows how to change all available variable, and specifically the font settings, please help!

Thank you for the suggestion. I am still getting an error about the fact that the module is alreadt loaded: Internal server error: [sass] Module loop: this module is already being loaded.

How did you solve this?

HendrikJan commented 4 months ago

I am having the same problem. Some SASS variables can be edited (like $button-border-radius) but variables that have to do with fonts cannot be edited (like $body-font-family). The variables that can be edited, can be edited in this way:

// nuxt.config.js
vuetify: {
    moduleOptions: {
      styles: { configFile: 'assets/vuetify.scss' }
    }
}

And the scss file:

@use 'vuetify' with (

  // This variable can be changed
  $grid-breakpoints: (xs: 0,
    sm: 768px,
    md: 992px,
    lg: 1200px,
    xl: 1900px),

  // This variable cannot be changed
  $body-font-family: 'Open Sans' sans-serif,
);

If someone knows how to change all available variable, and specifically the font settings, please help!

Thank you for the suggestion. I am still getting an error about the fact that the module is alreadt loaded: Internal server error: [sass] Module loop: this module is already being loaded.

How did you solve this?

Oh, I mistyped something.

It works in my code with @use 'vuetify/settings'

HendrikJan commented 4 months ago

Another solution can be found here on Discord: https://discord.com/channels/340160225338195969/1198016523873308745/1209515947342176296

GitTheCodeAndHitTheRoad commented 4 months ago

Oh, I mistyped something.

It works in my code with @use 'vuetify/settings'

Thanks for the quick reply! I also tried that before but in that case all my vuetify css is completely gone. Could it be that it is needed to first import the whole 'default' css file and only overwrite the desired SASS variables?

HendrikJan commented 4 months ago

I don't know. Maybe you need to add css: ['@assets/vuetify.scss'] to nuxt.config. It made a difference in another scenario for me, but I'm a bit clueless as to how it works exactly.

You could als have a look in the Vuetify Discord. Some other suggestions are given there.