Skip to content

ThemeButton

Light Mode First

With this approach, you declare your light colors first and then use [data-theme="dark"] to set your dark colors.

Show code
:root {
--light-bg: transparent;
--light-text: #3d50f5;
}
[data-theme="dark"] {
--light-bg: #678fff;
--light-text: #222;
}
.light-paragraph {
padding: 8px;
border-radius: 8px;
background-color: var(--light-bg);
color: var(--light-text);
}

Dark Mode First

With this approach, you declare your dark colors first and then use [data-theme="light"] to set your light colors.

Show code
:root {
--dark-bg: #b36200;
--dark-text: #111;
}
[data-theme="light"] {
--dark-bg: transparent;
--dark-text: #ff8c00;
}
.dark-paragraph {
background-color: var(--dark-bg);
padding: 8px;
border-radius: 8px;
color: var(--dark-text);
}