diff --git a/components/lib/config/PrimeVue.js b/components/lib/config/PrimeVue.js index ffdf46e7d..09e82430b 100644 --- a/components/lib/config/PrimeVue.js +++ b/components/lib/config/PrimeVue.js @@ -141,13 +141,7 @@ export const defaultOptions = { preset: Aura, options: { prefix: 'p', - colorScheme: { - dark: { - class: 'p-dark', - rule: `.p-dark { [CSS] }` - //default: false - } - }, + colorScheme: 'auto', layer: false /*colorScheme: { // mode: 'light' | 'dark' | 'auto' | object // default: auto diff --git a/components/lib/themes/utils/themeUtils.js b/components/lib/themes/utils/themeUtils.js index f82978dba..6d338700c 100644 --- a/components/lib/themes/utils/themeUtils.js +++ b/components/lib/themes/utils/themeUtils.js @@ -84,21 +84,17 @@ export default { return options; }, applyColorScheme(options = {}, currentColorScheme, defaults) { - if (options.colorScheme) { - const colorSchemeOption = this.getColorSchemeOption(options.colorScheme, defaults); - const isClient = SharedUtils.dom.isClient(); - const isAuto = !colorSchemeOption.light?.default && !colorSchemeOption.dark?.default; - const isDark = isAuto && isClient ? window.matchMedia('(prefers-color-scheme: dark)').matches : colorSchemeOption.dark?.default; - const defaultDocument = isClient ? window.document : undefined; + const colorSchemeOption = this.getColorSchemeOption(options.colorScheme, defaults); + const isClient = SharedUtils.dom.isClient(); + const isAuto = !colorSchemeOption.light?.default && !colorSchemeOption.dark?.default; + const isDark = isAuto && isClient ? window.matchMedia('(prefers-color-scheme: dark)').matches : colorSchemeOption.dark?.default; + const defaultDocument = isClient ? window.document : undefined; - if (isDark && defaultDocument) { - SharedUtils.dom.addClass(defaultDocument.documentElement, colorSchemeOption.dark?.class); - } - - return isDark ? 'dark' : 'light'; + if (isDark && defaultDocument) { + SharedUtils.dom.addClass(defaultDocument.documentElement, colorSchemeOption.dark?.class); } - return currentColorScheme; + return isDark ? 'dark' : 'light'; }, toggleColorScheme(options = {}, currentColorScheme, defaults) { const newColorScheme = currentColorScheme === 'dark' ? 'light' : 'dark';