Sub topic 3
Styles, Tokens, and Reusable Components
Assume you know basic typography and can edit a design or layout tool. This chapter uses CSS examples, but the same ideas apply in Figma, Canva, Illustrator, and InDesign.
Styles, tokens, and reusable components
A style is a named, reusable choice such as a text style, color, or spacing value. A token is a named value that represents a design decision. A reusable component is a repeated element with a consistent structure and appearance.
Tokens reduce accidental variation. Components then reuse those tokens.
:root {
--color-text: #1a1a1a;
--color-accent: #0b5fff;
--space-sm: 8px;
--space-md: 16px;
--space-lg: 32px;
}
.card {
display: grid;
gap: var(--space-sm);
padding: 24px;
max-width: 40ch;
color: var(--color-text);
}
.button {
background: var(--color-accent);
color: #ffffff;
padding: var(--space-sm) var(--space-md);
}The repeated spacing values create consistency. The card's gap applies proximity. Its heading can use larger, heavier type for contrast. Reusing the same accent color connects buttons and links across the page.
Combining the four principles in one layout
A strong page applies all four principles together:
- Proximity groups a heading with its paragraph and separates it from the next section.
- Alignment places headings, text, images, and buttons on shared edges.
- Contrast makes the title larger and heavier than supporting text.
- Repetition reuses the same colors, type styles, spacing, and component shapes.
Diagnosing and fixing a weak layout
Review the layout without focusing on decoration. Ask what feels unclear and match the symptom to a principle.
| Symptom | Likely fix |
|---|---|
| Related labels look unrelated | Reduce the gap between them |
| Elements seem scattered | Align them to a shared edge |
| Everything has equal emphasis | Increase size or weight differences |
| Each card looks different | Reuse the same component styles |
Change one principle at a time, then inspect the whole composition again.
Common mistakes and overuse
Too much contrast makes everything compete for attention. Too many alignments can create a rigid or confusing structure. Excessive repetition produces a dull page, while weak repetition makes it feel accidental. Proximity also fails when spacing is nearly, but not clearly, different.
Use the smallest change that communicates the relationship. Check color contrast separately from visual contrast so text remains legible for people with low vision.
Exercise
A page uses three unrelated blue colors, uneven card padding, and headings that do not share a left edge. Which principles should you apply first?
Show answer
Apply repetition by defining one accent color and consistent padding, then apply alignment by placing headings on a shared left edge.