Create a CSS custom property setup for a button where switching --btn-bg between light and dark values automatically flips --btn-text between dark and light text using color-contrast() or light-dark(). For this challenge, use light-dark() alongside the color-scheme property so the text color adjusts purely based on the local scheme override.
.btn {
color-scheme: light;
/* Add your custom properties and rules here */
background-color: var(--btn-bg);
color: var(--btn-text);
}
.btn--dark {
color-scheme: dark;
}
Rules:
- Use CSS
light-dark()to define--btn-text. - Do not redefine
--btn-textmanually inside.btn--dark. - No JavaScript or preprocessors.
Post your solution as a reply. Answer goes up in about a day.