Spacing
Overview of the space scale and spacing tokens in Apsara.Consistent spacing creates visual rhythm and hierarchy in your interface. Apsara provides a comprehensive spacing scale through CSS custom properties that maintain proportional relationships across your application. These tokens ensure consistent spacing whether you're building custom layouts, extending components, or creating new UI patterns.
Scale
Spacing values are derived from a 17-step scale, which provides fine-grained control over layout spacing. The scale starts at 2px and progressively increases to 120px, allowing for both tight and spacious layouts.
TokenValueDescription
--rs-space-12pxMinimal spacing, icon gaps
--rs-space-24pxTight spacing, small gaps
--rs-space-38pxCompact padding, inline spacing
--rs-space-412pxStandard small padding
--rs-space-516pxDefault padding, common gaps
--rs-space-620pxMedium padding
--rs-space-724pxComfortable spacing
--rs-space-828pxGenerous padding
--rs-space-932pxLarge spacing
--rs-space-1040pxSection gaps
--rs-space-1148pxLarge section spacing
--rs-space-1256pxExtra large spacing
--rs-space-1364pxMajor divisions
--rs-space-1472pxLayout spacing
--rs-space-1580pxPage sections
--rs-space-1696pxLarge page sections
--rs-space-17120pxMaximum spacing
Semantic Groupings
The spacing scale can be organized into semantic groups for easier selection:
TokenValueDescription
Compact2px - 8pxTight UI elements, icon spacing (tokens 1-3)
Comfortable12px - 24pxStandard component padding (tokens 4-7)
Spacious28px - 48pxSection spacing, larger gaps (tokens 8-11)
Layout56px - 120pxPage sections, major divisions (tokens 12-17)
Usage
1/* Custom card grid layout */2.card-grid {3 display: grid;4 gap: var(--rs-space-5);5 padding: var(--rs-space-7);6}78/* Sidebar navigation */9.sidebar-nav {10 display: flex;11 flex-direction: column;12 gap: var(--rs-space-2);13 padding: var(--rs-space-4) var(--rs-space-5);14}1516/* Page section with header */17.page-section {18 margin-top: var(--rs-space-13);19}2021.page-section-header {22 margin-bottom: var(--rs-space-6);23}2425/* Form field groups */26.form-group {27 display: flex;28 flex-direction: column;29 gap: var(--rs-space-3);30 margin-bottom: var(--rs-space-5);31}3233/* Inline icon with text */34.icon-text {35 display: flex;36 align-items: center;37 gap: var(--rs-space-2);38}
Best Practices
- Use smaller values (1-5) for internal component spacing like padding and gaps between inline elements
- Use medium values (5-9) for spacing between related components and within sections
- Use larger values (10-17) for spacing between sections and major layout divisions
- Be consistent - use the same spacing token for similar contexts throughout your application
- Avoid mixing pixel values with spacing tokens to maintain consistency