Density modes: should your design system support compact and comfortable layouts?
Some products serve very different users with the same components. A consumer app wants generous spacing and large touch targets, while an internal admin tool or analytics product wants as much information on screen as possible. Density modes try to serve both.
What a density mode changes
- Component heights (buttons, inputs, table rows)
- Internal padding and gaps
- Sometimes font size and icon size
Ways to implement it
- Global density setting: a theme-level switch, often exposed as compact, default and comfortable.
- Per-component size props: small, medium, large variants chosen by the designer per screen.
- Contextual density: a container that tells everything inside to render compact, such as a data table region.
Trade-offs
- Every density level multiplies the states to design, test and document.
- Compact modes can push touch targets below comfortable sizes, so they usually suit pointer-driven, desktop contexts.
- Mixing densities on one screen can look inconsistent if not done carefully.
Accessibility note: users who rely on zoom, larger text or touch input may need the more spacious option, so letting users choose (rather than hard-coding compact) can be a real benefit.
Does your product actually need more than one density, or is a single well-chosen default enough? Where have you seen compact modes work well?
Comments · 4
Build it with spacing tokens from the start. If padding and row heights reference tokens, density is just another theme setting, not a rewrite.
Does compact mode affect accessibility? I'd worry about touch targets getting too small for people using fingers rather than a mouse.
Good concern. Keep compact mode for pointer-driven contexts and keep a comfortable minimum for touch devices, around 44px targets. Density should be a user setting, not forced.
Power users in B2B tools almost always ask for density. It's a cheap feature that reads as "built for professionals", so it's worth shipping.