Theme

Easily change the colors of your application programmatically. Rebuild the default stylesheet and customize various aspects of the framework for your particular needs.

Theme generator

Discover and generate new color themes for your Vuetify applications using our Theme Generator tool.

Light and Dark

Vuetify supports both light and dark variants of the Material Design spec. This designation starts at the root application component, v-app and is supported by majority of components. By default, your application will use the light theme, but this can be easily overwritten by adding the dark prop.

<v-app dark>
...
</v-app>

When you designate a component as light or dark, all of its children will inherit and apply the same unless otherwise specified. Due to CSS specificity, there are certain combinations that might prompt you to manually assign the theme for nested children. This is most likely to occur when using the dark theme.

Customizing

By default, Vuetify has a standard theme applied for all components.

{
  primary: '#1976D2',
  secondary: '#424242',
  accent: '#82B1FF',
  error: '#FF5252',
  info: '#2196F3',
  success: '#4CAF50',
  warning: '#FFC107'
}

This can be easily changed. Simply pass a theme property to the Vue.use function. You can choose to modify all or only some of the theme properties, with the remaining inheriting from the default.

Vue.use(Vuetify, {
  theme: {
    primary: '#3f51b5',
    secondary: '#b0bec5',
    accent: '#8c9eff',
    error: '#b71c1c'
  }
})

You can also use the pre-defined material colors.

import colors from 'vuetify/es5/util/colors'

Vue.use(Vuetify, {
  theme: {
    primary: colors.purple.base,
    secondary: colors.grey.darken1,
    accent: colors.shades.black,
    error: colors.red.accent3
  }
})

Under the hood, Vuetify will generate css classes based upon these values that will be accessible in the DOM. These classes will follow the same markup as other helper classes, primary or secondary--text for example.

These values will also be made available on the instance $vuetify object under the theme property. This allows you to dynamically modify your theme. Behind the scenes, Vuetify will regenerate and update your theme classes, seamlessly updating your application.

this.$vuetify.theme.primary = '#4caf50'

Options

Vuetify generates theme styles at run-time for SPA’s and server side for SSR applications. The generated styles will be placed in a <style> tag with the id of vuetify-theme-stylesheet.

By default, primary, secondary and accent will have darken and lighten classes created. This allows you to follow the same syntax as working with regular colors, i.e. class="primary darken-1". This can be changed during the plugin bootstrap:

Vue.use(Vuetify, {
  theme: {
    primary: 'red',
    secondary: 'purple'
  },
  options: {
    themeVariations: ['primary', 'secondary']
  }
})

Minification

For SSR applications, you can pass a callback function to $vuetify.options.minifyTheme to reduce the initial page size. When using this option, it is recommended to also use themeCache.

Vue.use(Vuetify, {
  options: {
    minifyTheme: function () {
      return process.env.NODE_ENV === 'production'
        ? val.replace(/[\s|\r\n|\r|\n]/g, '')
        : null
    }
  }
})

Caching

A custom caching object and be provided (works in tandem with minifyTheme) to increase SSR efficiency. The object must contain a get and a set method. Below is an example using LRU cache.

const themeCache = LRU({
  max: 10,
  maxAge: 1000 * 60 * 60 // 1 hour
})

Vue.use(Vuetify, {
  options: {
    themeCache
  }
})

Modifying Stylus variables

Vuetify is built on top of stylus. Similar to scss, you can change variables and re-compile the style files. A list of available variables is located here. In order to build the stylus file, you will need to configure your application to support stylus. If you are using one of the pre-made templates available on the Quick Start guide, you can skip the next section.

Setup stylus-loader with Webpack

In the command line, run:

$ npm i stylus stylus-loader style-loader css-loader --save-dev
// or
$ yarn add -D stylus stylus-loader style-loader css-loader

This will install the dependencies needed to import and parse stylus files. Once installed, open your webpack config and add a rule for stylus. For SSR based applications, ensure that the import is in your main client-entry.

module: {
  rules: [
    {
      test: /\.styl$/,
      loader: ['style-loader', 'css-loader', 'stylus-loader']
    }
  ]
}

Create a folder called stylus in your src directory (or appropriate assets directory) with a file named main.styl. This will serve as the entry point to import and rebuild the default Vuetify styles. Once created, open the .styl file and add this entry.

// main.styl
@import '~vuetify/src/stylus/main'

Keep in mind that the relative location of node_modules may differ in your project so adjust accordingly. It is recommended that the import be located in your main application index.js or client-entry.js file. DO NOT import your main.styl inside of a component. This will cause performance issues and drastically slow down HMR (hot module reloading).

// app.js
import './stylus/main.styl'

After you have decided on your import location, if you are requiring the Vuetify stylesheet by a <link> tag in your index file, remove it. Restart your build processes and re-open your project. You should see all of the styles working correctly.

Changing values

Now that stylus is configured, you can set default values for the stylus variables that you wish to change. These must be declared before the import and will automatically override the Vuetify defaults.

$body-font-family = 'Open Sans'
$alert-font-size = 18px
 
@import '~vuetify/src/stylus/main'
// For a-la-carte
@import '~vuetify/src/stylus/app'