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

docs: include Vuetify SASS variables overriding #288

Merged
merged 24 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0b50892
Add documentation for Vuetify SAAS variable overriding
anonmos Nov 20, 2024
f1f938f
Fix a typo in sass-variables.md
anonmos Nov 20, 2024
b43f780
Fix SASS typos
anonmos Nov 20, 2024
abad0c9
Swap comments for 'other options'
anonmos Nov 20, 2024
6a50149
Move saas-variables.md to sass-modern-compiler.md
anonmos Nov 20, 2024
37ff8ff
Delete docs/guide/saas-variables.md
anonmos Nov 20, 2024
5c649b6
Add reference to SASS Modern Compiler in Server Side Rendering
anonmos Nov 20, 2024
9c3b472
Make SSR link to modern SASS vars relative
anonmos Nov 20, 2024
aa757e5
Update SASS Modern Compiler doc title
anonmos Nov 20, 2024
0cd48a3
Make server side rendering reference to overriding sass variables mor…
anonmos Nov 20, 2024
eb1e650
Change main.scss note to a tip for clarity
anonmos Nov 20, 2024
f7d458d
Use backwards-compatible path syntax
anonmos Nov 22, 2024
747ca5f
Use globals.scss for Vuetify override and clarify tip
anonmos Nov 22, 2024
97d24cf
Update styles paths to be more standards compliant
anonmos Nov 22, 2024
fbf6f53
Add example link to component-level sass overrides
anonmos Nov 22, 2024
d62fcb4
Reword step 5 for clarity
anonmos Nov 22, 2024
080868b
Update file header to SASS customization
anonmos Nov 22, 2024
c6b426f
Update left-panel option name for clarity
anonmos Nov 22, 2024
9516006
Update forgotten '@/' in nuxt config file
anonmos Nov 22, 2024
fde8173
Rename sass-modern-compiler to sass-customization and update link path
anonmos Nov 22, 2024
da8dbee
Update broken link reference
anonmos Nov 22, 2024
807c9d0
Add link to global sass variable index
anonmos Nov 22, 2024
0dd2cc5
Make settings.scss code styled
anonmos Nov 22, 2024
066ff53
Change settings.scss to components.scss
anonmos Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion docs/guide/sass-modern-compiler.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SASS Modern Compiler
# SASS Modern Compiler and SASS Variables

From version `0.17.0`, this module will configure Nuxt to use the new SASS modern compiler (`modern-compiler`). You don't need to change anything in your configuration to use it:
- update `vite` version to `v5.4.0` or higher (if you're using Nuxt `3.12.4` or higher, you don't need to update `vite`)
Expand All @@ -7,3 +7,62 @@ From version `0.17.0`, this module will configure Nuxt to use the new SASS moder
If the `sass-embedded` dependency is not installed, the module will configure the `modern` compiler for you. In case you get errors, enable the `disableModernSassCompiler` option in the module configuration to fall back to the `legacy` compiler.

Check [Build Performance](https://vuetifyjs.com/en/features/sass-variables/#build-performance) in Vuetify docs for more details.

## Overriding SASS Variables

Vuetify allows for [overriding global and component-level SASS variables](https://vuetifyjs.com/en/features/sass-variables/). Setting these up requires configuration that is slightly different from the Vuetify
documentation while using this Nuxt module.

1) In your styles directory (for this example, we'll use `${workspace}/assets/styles`), create two files - `assets/styles/main.scss` and `assets/styles/settings.scss`
TechAkayy marked this conversation as resolved.
Show resolved Hide resolved

2) In the `main.scss` file, we'll want to add
```scss
@use 'vuetify' with (
// Global Vuetify SASS variable overrides. For example:
// $utilities: false,
// $reset: false,
// $color-pack: false,
// $body-font-family: sans-serif
)
```

3) In the `settings.scss` file, we'll want to add
```scss
// $button-text-transform-override: capitalize;

@forward 'vuetify/settings' with (
// Component Vuetify SASS variable overrides.
// For example -- overriding button font capitalization (as seen at the bottom of the v-btn guide here https://vuetifyjs.com/en/api/v-btn/):
TechAkayy marked this conversation as resolved.
Show resolved Hide resolved
// $button-text-transform: $button-text-transform-override,
);
```

4) In your `nuxt.config.ts`, add a `css` entry to the `defineNuxtConfig` configuration object that points to `main.scss` like so:
```javascript
export default defineNuxtConfig({
css: ['assets/styles/main.scss']
TechAkayy marked this conversation as resolved.
Show resolved Hide resolved
// other options
})
```

_Note: This will import `main.scss` into ALL of your components by default. If you would like different behavior, you can create a different file with these overrides and import that instead._
userquin marked this conversation as resolved.
Show resolved Hide resolved

5) Again in your `nuxt.config.ts`, we'll want to add another entry to the `defineNuxtConfig` configuration object that overrides the default Vuetify Styles imports and instead imports your settings:
TechAkayy marked this conversation as resolved.
Show resolved Hide resolved
```javascript
export default defineNuxtConfig({
css: ['assets/styles/main.scss'],
vuetify: {
moduleOptions: {
/* module specific options */
/* https://www.youtube.com/watch?v=aamWg1TuC3o */
disableVuetifyStyles: true,
styles: {
configFile: 'assets/styles/settings.scss'
TechAkayy marked this conversation as resolved.
Show resolved Hide resolved
},
},
}
// other options
})
```

You should now be able to override your [global Vuetify SASS variables](https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/styles/settings/_variables.scss) as well as your [component-level Vuetify SASS variables](https://vuetifyjs.com/en/features/sass-variables/#variable-api)
2 changes: 2 additions & 0 deletions docs/guide/server-side-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export default defineNuxtConfig({
})
```

For a more detailed example, see the [SASS Modern Compiler doc](https://github.com/vuetifyjs/nuxt-module/blob/main/docs/guide/sass-modern-compiler.md#overriding-sass-variables).
userquin marked this conversation as resolved.
Show resolved Hide resolved

## Vuetify Themes

If you're using multiple Vuetify Themes with SSR enabled, Vuetify [useTheme](https://vuetifyjs.com/en/api/use-theme/) will not work since there is no way to know which theme to use in the server (the server will use the default theme).
Expand Down