Spacing

Consistent spacing creates visual hierarchy and improves readability in Virtual Labs interfaces.

Stable

Spacing Principles

8px Base Unit

All spacing values are multiples of 8px for consistent alignment and visual rhythm.

Semantic Naming

Use semantic names (xs, sm, md, lg) for common spacing patterns in lab interfaces.

Context Aware

Spacing adapts to content density needs in different lab interface contexts.

Spacing Scale

Base Scale
Numerical spacing tokens based on 4px increments
space-0
0px
space-1
4px
space-2
8px
space-3
12px
space-4
16px
space-5
20px
space-6
24px
space-8
32px
space-10
40px
space-12
48px
space-16
64px
space-20
80px
space-24
96px
space-32
128px
space-40
160px
space-48
192px
space-56
224px
space-64
256px

Semantic Spacing

Semantic Tokens
Named spacing tokens for common use cases
space-xs
4px
space-sm
8px
space-md
16px
space-lg
24px
space-xl
32px
space-2xl
48px
space-3xl
64px

Usage Guidelines

Lab Interface Spacing

Control Panels

Use consistent spacing between controls for easy scanning

gap-4 (16px) between control groups
gap-2 (8px) between related controls

Data Display

Adequate spacing for readability of scientific data

space-y-6 (24px) between data sections
space-y-2 (8px) between data rows
Responsive Spacing

Mobile Devices

Reduce spacing on smaller screens while maintaining usability

px-4 (16px) container padding
gap-3 (12px) between elements

Desktop

Generous spacing for complex lab interfaces

px-8 (32px) container padding
gap-6 (24px) between sections

Implementation

Tailwind CSS Classes
Use these Tailwind classes for consistent spacing
/* Padding */
p-4    /* 16px all sides */
px-6   /* 24px horizontal */
py-3   /* 12px vertical */

/* Margin */
m-4    /* 16px all sides */
mx-auto /* center horizontally */
my-8   /* 32px vertical */

/* Gap (Flexbox/Grid) */
gap-4  /* 16px gap */
gap-x-6 /* 24px horizontal gap */
gap-y-2 /* 8px vertical gap */

/* Space Between */
space-y-4 /* 16px vertical space between children */
space-x-2 /* 8px horizontal space between children */
CSS Custom Properties
Custom properties for advanced spacing control
:root {
  /* Base spacing scale */
  --vl-space-1: 4px;
  --vl-space-2: 8px;
  --vl-space-3: 12px;
  --vl-space-4: 16px;
  --vl-space-6: 24px;
  --vl-space-8: 32px;
  
  /* Semantic spacing */
  --vl-space-xs: var(--vl-space-1);
  --vl-space-sm: var(--vl-space-2);
  --vl-space-md: var(--vl-space-4);
  --vl-space-lg: var(--vl-space-6);
  --vl-space-xl: var(--vl-space-8);
  
  /* Component-specific spacing */
  --vl-control-gap: var(--vl-space-4);
  --vl-section-gap: var(--vl-space-6);
  --vl-container-padding: var(--vl-space-6);
}