CSS custom properties can be updated at runtime using JavaScript or CSS selectors, allowing themes to switch without recompiling Sass. Sass variables are static and compiled at build time.
Sass maps are defined using parentheses with key: value pairs separated by commas. Equal signs or brackets are invalid syntax.
dark class is added to the body?$light-theme: (background: #ffffff, text: #000000); $dark-theme: (background: #121212, text: #e0e0e0); :root { --background: map-get($light-theme, background); --text: map-get($light-theme, text); } body.dark { --background: map-get($dark-theme, background); --text: map-get($dark-theme, text); } body { background-color: var(--background); color: var(--text); }
dark class changes CSS variables to dark theme values.When body has the dark class, the CSS variable --text is set to the dark theme's text color #e0e0e0. This color is used for the text.
button elements differently when the dark theme is active by adding a dark class to body. Which selector correctly targets buttons only in dark mode?The selector body.dark button targets all buttons inside a body element that has the dark class. Other options either target buttons with the dark class or incorrect hierarchy.
Accessibility guidelines recommend maintaining sufficient contrast ratios in all themes to ensure text is readable for everyone, including users with visual impairments.