UI.MD

Search documentation

Search for components, guides, and tokens

Spacing & scale

A 4px base unit drives a consistent spacing scale. Use 4px for tight gaps (icon-to-text) and 8px and up for structural spacing (form fields, list items, sections).

Base spacing scale

All spacing derives from --spacing: 0.25rem (4px). Bars scale in proportion to value.

p-1
4px
p-2
8px
p-3
12px
p-4
default
16px
p-5
20px
p-6
24px
p-8
32px
p-12
48px
p-16
64px
p-20
80px

Content group coupling

4px within a group, 8px between groups. Elements that read as a single unit (a title and its lead, a label and its value) sit at 4px to signal association. Anything beyond that is structure.

Tight coupling (4px)

The paragraph sits close enough to read as the same thought: one unit, one breath. This is gap-1.

gap-1 · 4px

Loose coupling (8px)

The paragraph feels separated: the right call between groups, the wrong call inside one. This is gap-2.

gap-2 · 8px

Max widths

Width constraints for containers and panels, from small popovers to full page.

--spacing-max-w-smPopovers, tooltips320px
--spacing-max-w-mdDialogs, small panels384px
--spacing-max-w-lgForms, medium panels512px
--spacing-max-w-xlContent columns, prose672px
--spacing-max-w-2xlWide content, two-column896px
--containerPage content maximum1540px

Breakpoints

Mobile-first responsive breakpoints. Tailwind defaults, applied as min-width media queries.

sm:Large phones, small tablets640px
md:Tablets, primary breakpoint768px
lg:Small laptops1024px
xl:Desktops1280px
2xl:Large desktops1536px

Shadow scale

Four elevation levels, from subtle form control depth to modal-level lift.

shadow-xs

Form controls (Input, Select, Checkbox)

shadow-sm

Subtle elevation

shadow-mddefault

Cards, elevated surfaces

shadow-lg

Modals, sheets, dialogs

Border radius

A progressive scale from subtle rounding to fully circular. Each level has a defined usage.

xs

0.125rem

Checkbox, micro elements

sm

0.25rem

Menu items, small controls

md (default)

0.375rem

Form controls, cards

lg

0.5rem

Dialogs, buttons

xl

0.75rem

Drawers, sheets, large panels

2xl

1rem

Feature cards

full

9999px

Badges, pills, switches

Z-index scale

Named layers prevent z-index wars. Each level has a clear purpose.

--z-raisedContent over siblings10
--z-stickySticky elements20
--z-drawerDrawer portal30
--z-mobile-menuMobile menu overlay40
--z-headerFixed header50
--z-dropdownDropdowns, tooltips60
--z-overlayModal backdrops70
--z-modalModal content80
--z-toastToast notifications90
--z-maxEmergency override999