diff --git a/src/docs/src/routes/(docs)/docs/config/+page.svelte.md b/src/docs/src/routes/(docs)/docs/config/+page.svelte.md index b5f8d952ed9..30ff55861cf 100644 --- a/src/docs/src/routes/(docs)/docs/config/+page.svelte.md +++ b/src/docs/src/routes/(docs)/docs/config/+page.svelte.md @@ -28,6 +28,7 @@ module.exports = { rtl: false, // rotate style direction from left-to-right to right-to-left. You also need to add dir="rtl" to your html tag and install `tailwindcss-flip` plugin for Tailwind CSS. prefix: "", // prefix for daisyUI classnames (components, modifiers and responsive class names. Not colors) logs: true, // Shows info about daisyUI version and used config in the console when building your CSS + themeSelector: ":root", // Which element to attach the theming variables to. }, //... @@ -92,3 +93,10 @@ module.exports = { + +- ### themeSelector + + `String (default: ":root")` + + + diff --git a/src/theming/functions.js b/src/theming/functions.js index d88717d0c73..6e72e55884d 100644 --- a/src/theming/functions.js +++ b/src/theming/functions.js @@ -176,6 +176,7 @@ module.exports = { }, injectThemes: function (addBase, config, themes, colorFunction) { + const themeSelector = config("daisyui.themeSelector") ?? ":root"; const includedThemesObj = {} // includedThemesObj["@supports (not(color: lch(0 0 0)))"] = {} // add default themes @@ -222,7 +223,7 @@ module.exports = { themeOrder.forEach((themeName, index) => { if (index === 0) { // first theme as root - themesToInject[":root"] = includedThemesObj["[data-theme=" + themeName + "]"] + themesToInject[themeSelector] = includedThemesObj["[data-theme=" + themeName + "]"] } else if (index === 1) { // auto dark if (config("daisyui.darkTheme")) { @@ -231,7 +232,7 @@ module.exports = { themeOrder.includes(config("daisyui.darkTheme")) ) { themesToInject["@media (prefers-color-scheme: dark)"] = { - [":root"]: includedThemesObj[`[data-theme=${config("daisyui.darkTheme")}]`], + [themeSelector]: includedThemesObj[`[data-theme=${config("daisyui.darkTheme")}]`], } } } else if (config("daisyui.darkTheme") === false) { @@ -239,7 +240,7 @@ module.exports = { } else { if (themeOrder[0] !== "dark" && themeOrder.includes("dark")) { themesToInject["@media (prefers-color-scheme: dark)"] = { - [":root"]: includedThemesObj["[data-theme=dark]"], + [themeSelector]: includedThemesObj["[data-theme=dark]"], } } }