← All Exercises
Theme a Card with Custom Properties and Color Scheme
intermediatecss
Background
Semantic tokens plus color-scheme give native controls and scrollbars matching colors without duplicated component rules.
Problem
Create a card whose background, text, and border colors come from custom properties that switch automatically under prefers-color-scheme dark, including native form controls.
Input
A card with a heading, paragraph, and button.
Output
Token definitions for light and dark plus component rules that consume them.
Sample tests
Sample 1
Input: System prefers light
Expected: :root defines --surface, --text, and --border and the card uses var(--surface)
Sample 2
Input: System prefers dark
Expected: the media query overrides the same tokens and color-scheme light dark lets native controls follow
Your solution
Learning objective
Structure semantic color tokens and switch them with prefers-color-scheme while keeping components token-driven.