Components come in variations to fit different contexts.
Variants control style; sizes control scale. Both must stay consistent and predictable.
A strong variant system is built around:
- Purpose
- Hierarchy
- Consistency
- Scalability
- Accessibility
In this lesson, you'll learn:
- What variants are
- What sizes are
- Variant types (primary, secondary, destructive, ghost)
- Size scales (sm, md, lg)
- How variants and sizes combine
- Managing component density
- Consistency across a system
- Common variant mistakes
- Accessibility considerations
- How to design reusable component matrices
Two independent dimensions describe a component.
A change in style or emphasis.
primary → filled, brand color
secondary → outlined or soft
ghost → borderless text
destructive → signals danger
A change in scale.
sm → compact
md → standard
lg → prominent
When combined, they form a matrix:
sm md lg
primary [fill sm] [fill md] [fill lg]
secondary [out sm] [out md] [out lg]
ghost [ghost sm] [ghost md] [ghost lg]
One primary action per screen.
High visual weight.
Supporting or alternative actions.
Less emphasis.
Low-emphasis actions, often inline.
Actions that delete or permanently change.
Distinct danger styling, clearly separated from other actions.
Sizes should map to real contexts.
sm → dense rows, tables, secondary UI
md → standard mid-weight surfaces (default)
lg → main actions, hero, prominent UI
Guidelines:
- Use md as the default so sizes stay consistent
- Reserve sm for genuinely dense spaces
- Use lg sparingly for important moments
Size should carry meaning, not just look different.
When two variants sit together, emphasize clearly.
Dialog footer:
[ Secondary ] [ Primary ]
↳ one leading action
Avoid two equally strong buttons in one group.
Rules:
- Primary + secondary is the most common pairing
- Never place two primaries side by side
- Separate destructive actions from negative-default actions
Sizes must preserve usability.
Minimum touch target:
44 × 44px preferred
40 × 40px acceptable compact
If sm dips below touch limits, expand the hit area to the minimum touch target even when the visible box is smaller.
Sizes also control density.
| Density | Use |
|---|---|
| Compact | Data tables, dense dashboards |
| Comfortable | Standard applications (default) |
| Spacious | Marketing, empty states, onboarding |
Rules:
- Let users choose density where data-heavy
- Keep spacing tokens aligned to the grid (8px steps)
- Never mix density levels within one screen
The same variant should mean the same thing everywhere.
primary button == primary emphasis
primary nav tab == primary emphasis
If the visual weight differs per component, users lose intuition.
Guidelines:
- Define variants at the design-system level, once
- Reuse the same color/contrast tokens for each variant
- Audit components so "primary" always reads as primary
Imagine a file manager toolbar.
- Two filled primary buttons for contradictory actions
- Sizes randomly mixed (a 32px ghost next to a 48px primary)
- Destructive "Delete" looks identical to "New Folder"
- No mid-size level, so compact UI feels cramped
Users can't tell which action dominates, and the toolbar feels random.
- One primary "New Folder" action, one secondary "Upload"
- "Delete" distinct and reserved
- Consistent sizes (md for toolbar, sm for row-level actions)
- Clear touch targets everywhere
The toolbar reads instantly, and users act with confidence.
Endless variants destroy consistency.
Competing actions confuse hierarchy.
Breaking the size matrix within one view.
Sizes that differ by 1px read as accidental.
Danger actions camouflaged as normal ones.
Compact variants with unusable targets.
Variants and sizes must serve everyone.
Best practices:
- Keep contrast across all variant styles
- Preserve touch targets even at small sizes
- Keep destructive styling distinct, not just color-coded
- Provide visible focus on every variant & size
- Document variant semantics for screen readers
Good variants improve usability for all users.
Before you move on, make sure you understand:
- What variants are
- What sizes are
- Variant types (primary, secondary, ghost, destructive)
- Size scales (sm, md, lg)
- Combining variants and sizes
- Density levels
- Cross-component consistency
- Common variant mistakes
- Accessibility principles


