Spacing
The Axmed Design System uses a 4px base grid for consistent spatial rhythm across all components and layouts. Spacing tokens are named by their multiplier:--space-1 = 1×4px, --space-2 = 2×4px, and so on.
Spacing Scale
All spacing values are built on a 4px base unit, ensuring consistent alignment and rhythm throughout the interface.| Token | Value | Multiplier | Common Usage |
|---|---|---|---|
--space-0 | 0px | — | No spacing, reset |
--space-0-5 | 2px | 0.5× | Dividers, fine adjustments |
--space-1 | 4px | 1× | Icon gaps, inline spacing |
--space-1-5 | 6px | 1.5× | Between tight and compact |
--space-2 | 8px | 2× | Button padding, tag gaps |
--space-3 | 12px | 3× | Nav item padding, card internal |
--space-4 | 16px | 4× | Section padding, modal body |
--space-5 | 20px | 5× | Card padding, drawer header |
--space-6 | 24px | 6× | Modal container, drawer body |
--space-8 | 32px | 8× | Large gap between groups |
--space-10 | 40px | 10× | Page section margins |
--space-12 | 48px | 12× | Empty state vertical padding (md) |
--space-16 | 64px | 16× | Large content separation |
--space-20 | 80px | 20× | Empty state vertical padding (lg), hero sections |
Spacing Categories
Micro (0-4px)
Use for very tight spacing like icon gaps, dividers, and fine adjustments:--space-0(0px): Reset spacing--space-0-5(2px): Hairline dividers--space-1(4px): Icon-to-text gaps--space-1-5(6px): Small element spacing
Compact (8-12px)
Use for component-internal spacing like button padding and navigation items:--space-2(8px): Button padding, tag gaps--space-3(12px): Nav item padding, card internal spacing
Default (16-24px)
Use for comfortable spacing in modals, cards, and sections:--space-4(16px): Section padding, modal body--space-5(20px): Card padding, drawer header--space-6(24px): Modal container, drawer body
Large (32-48px)
Use for clear separation between groups and sections:--space-8(32px): Large gaps between UI groups--space-10(40px): Page section margins--space-12(48px): Spacious vertical padding
Extra Large (64-80px)
Use for page-level separation and hero sections:--space-16(64px): Large content separation--space-20(80px): Hero sections, empty state padding
Usage Examples
Component Padding
Layout Spacing
Icon and Text Spacing
Grid Layouts
Page Layout
Design Principles
4px Base Grid
All spacing values are multiples of 4px, which provides:- Consistency: Predictable spacing across all components
- Flexibility: Fine-grained control with half-steps (2px) when needed
- Alignment: Elements naturally align to a common grid
Progressive Scale
The spacing scale grows progressively, with smaller increments at tight spacings and larger jumps at generous spacings:- Tight range (0-12px): 2-4px increments
- Medium range (16-24px): 4-8px increments
- Large range (32-80px): 8-16px increments
Semantic Naming
Token names indicate their scale multiplier (e.g.,--space-4 = 4×4px = 16px), making it easy to understand relative sizes and choose appropriate spacing.
Responsive Spacing
While spacing tokens are fixed values, you can adjust them responsively using media queries:Best Practices
Use spacing tokens instead of arbitrary values
Use spacing tokens instead of arbitrary values
Always use spacing tokens rather than hardcoded pixel values. This ensures consistency and makes it easier to maintain a cohesive spacing system.
Choose spacing that matches the hierarchy
Choose spacing that matches the hierarchy
Use tighter spacing (space-1 to space-3) for related elements within a component, and larger spacing (space-6 to space-10) for separating distinct sections.
Maintain consistent vertical rhythm
Maintain consistent vertical rhythm
Use the same spacing token for similar types of separation throughout your interface. For example, always use
--space-4 for spacing between form fields.Half-steps are for edge cases
Half-steps are for edge cases
Use
--space-0-5 and --space-1-5 sparingly, only when standard increments don’t achieve the desired visual effect (e.g., hairline dividers).All spacing tokens are defined in
_spacing.scss and automatically included when you import the design system’s CSS.