Project: a design system
Define tokens, build components and ship every state as one coherent kit.
- Centralise tokens
- Build reusable components
- Cover states and motion consistently
A design system is a small set of decisions reused everywhere. Start with tokens, style a few components, then document the states that matter.
- 01Tokens
Define colour, spacing, radius and type scale as custom properties on :root.
- 02Base
Set the page background, text colour and font from the tokens.
- 03Components
Build a button, card and badge that read only from tokens.
- 04States
Add hover, focus-visible, disabled and error states for interactive elements.
- 05Motion
Use one timing curve and one duration for feedback, with a reduced-motion override.
:root {
--brand: #e4472b;
--brand-strong: #c93a21;
--ink: #1c1917;
--paper: #f7f4ee;
--surface: #ffffff;
--line: #e7e2d9;
--space-2: 12px;
--space-3: 24px;
--radius: 12px;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
}
body {
background: var(--paper);
color: var(--ink);
font-family: system-ui, sans-serif;
}
.button {
border: 0;
border-radius: 999px;
padding: 12px 18px;
background: var(--brand);
color: white;
font-weight: 600;
cursor: pointer;
transition: transform 180ms var(--ease), background 180ms ease;
}
.button:hover {
background: var(--brand-strong);
transform: translateY(-1px);
}
.button:focus-visible {
outline: 3px solid rgb(228 71 43 / 0.35);
outline-offset: 2px;
}
.button:disabled {
background: var(--line);
color: #8b8580;
cursor: not-allowed;
}
.card {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--radius);
padding: var(--space-3);
}
@media (prefers-reduced-motion: reduce) {
.button {
transition: none;
}
}Add a secondary button
Create a secondary variant that uses the surface, ink and line tokens with the same focus and disabled behaviour.
.button.secondary {
/* your rules here */
}Why centralise values in custom properties?
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Lock in what you just learned.
Mark this lesson complete to save your place and move one step closer to the certificate.