Can I apply multiple themes?
Author: YusukeSanoCreated Dec 30, 2021Updated Jan 9, 2026
Labelsenhancementv1
Hello, Thanks for the nice library.
I want to use this library to apply multiple themes of different nature. In the example below, I am trying to apply a cross between two different color themes and two different font themes.
The current method applies all CSS variables to each theme:
:root {
/* default theme (light small) */
--background: white;
--foreground: black;
--fontsize: 16px;
}
:[data-theme='light large'] {
--background: white;
--foreground: black;
--fontsize: 32px;
}
[data-theme='dark small'] {
--background: black;
--foreground: white;
--fontsize: 16px;
}
[data-theme='dark large'] {
--background: black;
--foreground: white;
--fontsize: 32px;
}However, with this method, the amount of description increases in proportion to the number of themes as the number of CSS properties increases. My goal is to compose CSS using only the properties of each theme.
Like so:
:root {
/* default theme (light small) */
--background: white;
--foreground: black;
--fontsize: 16px;
}
[data-theme*='light'] {
--background: white;
--foreground: black;
}
[data-theme*='dark'] {
--background: black;
--foreground: white;
}
[data-theme*='small'] {
--fontsize: 16px;
}
[data-theme*='large'] {
--fontsize: 32px;
}Are there any good methods for that? Pardon my broken English.
Source: pacocoursey/next-themes