Toggle between dark and light theme #9307
-
How can one toggle between dark and light theme at runtime? I did this before in Vuetify using this following code, but i have no idea how to this in Quasar? Any help would be appreciated. It doesn't appear to be documented anywhere that I could find.
My sample code...
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
you must enable the dark mode plugin in quasar.config.js then you can activate it with: |
Beta Was this translation helpful? Give feedback.
-
Don't forget to add the "Dark" plugin to quasar.conf.js plugins: [
'Dark'
] Also, in quasar.conf.js, you can set auto mode if you like: framework: {
config: {
dark: 'auto'
},
... If you provide a button to the user to toggle, you can do it like this: <q-btn flat round @click="$q.dark.toggle()" :icon="$q.dark.isActive ? 'brightness_2' : 'brightness_5'" /> and, finally, if you need to adjust things based on dark or not, you can do it like this: :class="{ 'text-black bg-grey-4': $q.dark.isActive, 'text-white bg-primary': !$q.dark.isActive }" |
Beta Was this translation helpful? Give feedback.
you must enable the dark mode plugin in quasar.config.js then you can activate it with:
"this.$q.dark.set(true)" or "this.$q.dark.toggle()" inside vue files
https://quasar.dev/quasar-plugins/dark#introduction