Add theme prefs saving
This commit is contained in:
parent
fb0dba4e03
commit
c25141d53d
1 changed files with 13 additions and 1 deletions
|
@ -16,9 +16,21 @@ import { createVuetify } from 'vuetify'
|
|||
import '@mdi/font/css/materialdesignicons.css'
|
||||
import 'vuetify/styles'
|
||||
|
||||
// Detect system theme preferences
|
||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
|
||||
// Get saved theme or fallback to system
|
||||
const savedTheme = localStorage.getItem('theme')
|
||||
const initialTheme = savedTheme || (prefersDark ? 'dark' : 'light')
|
||||
|
||||
// Save if no theme was already saved
|
||||
if (!savedTheme) {
|
||||
localStorage.setItem('theme', initialTheme)
|
||||
}
|
||||
|
||||
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
|
||||
export default createVuetify({
|
||||
theme: {
|
||||
defaultTheme: 'system',
|
||||
defaultTheme: initialTheme,
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue