- Add
@nuxtjs/vuetifydependency to your project
yarn add --dev @nuxtjs/vuetify # or npm install --save-dev @nuxtjs/vuetify- Add
@nuxtjs/vuetifyto thebuildModulessection ofnuxt.config.js
< 2.9.0, use modules instead.
{
buildModules: [
// Simple usage
'@nuxtjs/vuetify',
// With options
['@nuxtjs/vuetify', { /* module options */ }]
]
}{
buildModules: [
'@nuxtjs/vuetify'
],
vuetify: {
/* module options */
}
}- Type:
Array- Items:
String
- Items:
- Default:
[]
Provide a way to customize Vuetify SASS variables.
Only works with tree-shaking.
Usage example :
// assets/variables.scss
// Change default font family (MUST be before `styles.sass` import)
$body-font-family: 'Montserrat', sans-serif;
// Other variables you want to modify
$font-size-root: 14px;
$btn-border-radius: 0px;
// If you need to extend Vuetify SASS lists
@import '~vuetify/src/styles/styles.sass';
$material-light: map-merge($material-light, ( cards: blue ));// nuxt.config.js
export default {
vuetify: {
customVariables: ['~/assets/variables.scss']
}
}The list of customizable variables can be found by looking at the files here.
- Type:
ObjectorBoolean - Default:
{
font: true,
icons: 'mdi'
}Automatically handle Roboto font & Material Design Icons.
These assets are handled automatically by default to provide a zero-configuration which let you play directly with Vuetify.
defaultAssets.font automatically adds the Roboto font stylesheet from official google fonts to load the font with font-display: swap.
You can disable it if you plan to use different font or manually handle font loading. See customVariables section to override default font-family: 'Roboto'.
defaultAssets.icons automatically adds the icons stylesheet from a CDN to load all the icons (not optimized for production).
Here are the accepted values for this option :
| Value | Icons |
|---|---|
'mdi' (default) |
Material Designs Icons (CDN) |
'md' |
Material Icons (CDN) |
'fa' |
Font Awesome 5 (CDN) |
'fa4' |
Font Awesome 4 (CDN) |
false |
Disable auto add of the icons stylesheet |
This option (if not set to
false) will automatically overrideicons.iconfontVuetify option so that Vuetify components use these icons.
Please refer to Vuetify Icons documentation for more information about icons, notably for using only bunch of SVG icons instead of including all icons in your app.
You can also set the whole defaultAssets option to false to prevent any automatic add of these two assets.
- Type:
String
Location of the Vuetify options that will be passed to Vuetify.
This file will be compiled by webpack, which means you'll benefit fast hot reload when changing these options, but also be able to use TypeScript without being forced to use TypeScript runtime.
// nuxt.config.js
export default {
vuetify: {
optionsPath: './vuetify.options.js'
}
}Note that you can also use Directory Aliases like
'~/path/to/option.js'
All vuetify options are supported, it includes :
// vuetify.options.js
export default {
breakpoint: {},
icons: {},
lang: {},
rtl: true,
theme: {}
}Notice that passing the Vuetify options directly to Module options is still supported, but it will trigger Nuxt entire rebuild if options are changed.
If you need to access Nuxt context within the options file, you need to export a function instead :
// vuetify.options.js
export default function ({ app }) {
return {
lang: {
t: (key, ...params) => app.i18n.t(key, params)
}
}
}- Type:
Boolean - Default:
process.env.NODE_ENV === 'production'
Uses vuetify-loader to enable automatic tree-shaking. Enabled only for production by default.
If you're using TypeScript, you'll need to add @nuxtjs/vuetify in your compilerOptions of your tsconfig.json :
{
"compilerOptions": {
"types": [
"@types/node",
"@nuxt/vue-app",
"@nuxtjs/vuetify"
]
}
}You'll then be able to have autocompletion in Context (ctx.$vuetify) and Vue instances (this.$vuetify).
If you're building an application that will need to work offline (more likely a PWA), you will need to bundle your fonts and icons in your app instead of using online resources.
It means you must set defaultAssets option to false.
For fonts, you may leverage CSS @font-face rule with local path of your fonts.
For icons, you can either use the same way than above, or leverage tree-shaken SVG libraries like Material Design Icons SVG or Font Awesome 5 SVG.
You'll find a step by step guide to upgrade from 1.5.x to 2.x here
- Clone this repository
- Install dependencies using
yarn installornpm install - Start development server using
yarn devornpm run dev
Copyright (c) Nuxt Community
