How to enable dark mode with custom colors in light theme in vuetify?

shashi verma

I am using vuetify 2.0 and I am facing an issue, in my vuetify.js file I have the following code

export default new Vuetify({
    theme:{
        themes: {
            light: {
                primary: '#3f51b5',
                secondary: '#b0bec5',
                accent: '#8c9eff',
                error: '#b71c1c',
              }
        },
        dark: true
    }

})

vuetify theme https://vuetifyjs.com/en/customization/theme

Here, I have set the custom color for the light theme by default but when I set the dark to true the colors I have set for light gets changed. Why this is happening, why can't I have my own color on dark mode? How can we override this or this is a default feature?

Updated below

export default new Vuetify({
    theme:{
        themes: {
            light: store.getters.selectedTheme.theme,
            dark: store.getters.selectedTheme.theme
        },
        // dark: true
    },

})

and true/false for dark is I am setting through checkbox and the method I am calling on onChange on checkbox is below

emitDarkMode(e) {
        this.$vuetify.theme.dark = e;
      // this.$store.dispatch("darkModeHandler");
    },

The main thing is, I have 5 differnt color sets for theme like for primary, secondary etc and setting these theme colot with radio button. Like If I click on red(error), theme color will be set to red and so on. and doing all this with vuex. But when I switch to dark mode my theme color gets change to the default color of vuetify and I am unable to dynamically change the theme color through radio button on dark mode.

Thanks

Asim Khan

and you can define other dark theme like below

export default new Vuetify({
    theme:{
        themes: {
            light: {
                primary: '#3f51b5',
                secondary: '#b0bec5',
                accent: '#8c9eff',
                error: '#b71c1c',
              },
            dark: {
              //here you will define primary secondary stuff for dark theme
            }
        },
        dark: true
    }

})

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to change colors from light mode to dark mode in Taipy charts?

How to Change Light and Dark Theme Colors for Material-UI AppBar?

How to handle custom colors for Dark Mode in Swift

How to enable dark mode for markdown-it-vue plugin with vuetify

Get update for light/dark mode theme change

How to change the theme colors in Vuetify in standalone/CDN mode?

Is there any fast switch between light mode and dark mode (light/dark theme) in 16.04?

How to detect device theme (light/dark) in android?

Jetpack Compose: How to change theme from light to dark mode programmatically onClick

Cannot create custom vuetify theme colors

How to enable Dark Mode on the Simulator?

How to enable Dark Mode for Xcode

Restrict SwiftUI ColorPicker to only colors that work in light/dark mode

Gradient colors not changing if change mode on dark/light when hide app

Finding dark/light colors

Flutter Theme (dark & light)

How to use SearchView from dark theme in Light Appcompat theme

How to add light theme and dark theme to Vaadin tooltip?

How to detect phone system is dark theme or light theme?

How to Change theme of google map according to app theme (Dark & Light)?

How to save cookies for Dark/Light Mode Toggle?

Dark & Light Mode: How to switch manifest and favicon?

How to override css for Dark/Light Mode Toggle?

Recommended Dark/Light or custom Theme implementation in Flutter Cupertino

Vuetify conditional dark theme

Kdenlive dark theme on Ubuntu 20.04 (How to Enable?)

How do I easily support light and dark mode with a custom color used in my app?

Light and dark mode in swift

Implementing Light and Dark mode?