@@ -7,13 +7,13 @@ order: 3
77
88# Spacing
99
10- ::: warning Work in Progress
11- This section is under development.
12- :::
10+ Consistent spacing creates visual harmony and helps users understand relationships between elements. Use spacing tokens instead of arbitrary pixel values.
1311
14- ** Always use design token spacing ** ( ` p-spacing-100 ` , ` m-spacing-200 ` ) for consistent design. Standard Tailwind spacing ( ` p-2 ` , ` m-4 ` ) is available as a fallback for edge cases only.
12+ ## Base Unit
1513
16- ## Spacing Scale
14+ The spacing scale is built on an ** 8px base unit** . Token values are multiples of this base (e.g., ` spacing.100 ` = 1× = 8px, ` spacing.200 ` = 2× = 16px).
15+
16+ ## Scale
1717
1818Use the ` *-spacing-{value} ` pattern where ` * ` = ` p ` , ` m ` , ` gap ` , ` px ` , ` py ` , ` mx ` , ` my ` , etc.
1919
@@ -34,58 +34,53 @@ Use the `*-spacing-{value}` pattern where `*` = `p`, `m`, `gap`, `px`, `py`, `mx
3434| ` spacing.800 ` | ` *-spacing-800 ` | ` --spacing-800 ` | 4rem (64px) |
3535| ` spacing.1000 ` | ` *-spacing-1000 ` | ` --spacing-1000 ` | 5rem (80px) |
3636
37+ ## When to Use Each Size
38+
39+ ### Small (2-8px)
40+
41+ Use for tight, related elements:
42+
43+ - Gap between icon and text
44+ - Padding inside compact components
45+ - Spacing between form label and input
46+
47+ ### Medium (12-24px)
48+
49+ Use for component-level spacing:
50+
51+ - Padding inside buttons and cards
52+ - Gap between list items
53+ - Spacing between related form fields
54+
55+ ### Large (32-80px)
56+
57+ Use for layout and sections:
58+
59+ - Margins between page sections
60+ - Padding around main content areas
61+ - Spacing between unrelated groups
62+
3763## Negative Spacing
3864
39- | Token | Tailwind | CSS | Value |
40- | ---------------------- | ----------------- | ------------------------ | ---------------- |
41- | ` spacing.negative.25 ` | ` -*-spacing-25 ` | ` --spacing-negative-25 ` | -0.125rem (-2px) |
42- | ` spacing.negative.50 ` | ` -*-spacing-50 ` | ` --spacing-negative-50 ` | -0.25rem (-4px) |
43- | ` spacing.negative.75 ` | ` -*-spacing-75 ` | ` --spacing-negative-75 ` | -0.375rem (-6px) |
44- | ` spacing.negative.100 ` | ` -*-spacing-100 ` | ` --spacing-negative-100 ` | -0.5rem (-8px) |
45- | ` spacing.negative.150 ` | ` -*-spacing-150 ` | ` --spacing-negative-150 ` | -0.75rem (-12px) |
46- | ` spacing.negative.200 ` | ` -*-spacing-200 ` | ` --spacing-negative-200 ` | -1rem (-16px) |
47- | ` spacing.negative.250 ` | ` -*-spacing-250 ` | ` --spacing-negative-250 ` | -1.25rem (-20px) |
48- | ` spacing.negative.300 ` | ` -*-spacing-300 ` | ` --spacing-negative-300 ` | -1.5rem (-24px) |
49- | ` spacing.negative.400 ` | ` -*-spacing-400 ` | ` --spacing-negative-400 ` | -2rem (-32px) |
50-
51- ## Border Radius
52-
53- | Token | Tailwind | CSS | Value |
54- | ------------- | -------------- | --------------- | -------------- |
55- | ` radius.none ` | ` rounded-none ` | ` --radius-none ` | 0 |
56- | ` radius.2xs ` | ` rounded-2xs ` | ` --radius-2xs ` | 0.125rem (2px) |
57- | ` radius.xs ` | ` rounded-xs ` | ` --radius-xs ` | 0.25rem (4px) |
58- | ` radius.sm ` | ` rounded-sm ` | ` --radius-sm ` | 0.375rem (6px) |
59- | ` radius.md ` | ` rounded-md ` | ` --radius-md ` | 0.5rem (8px) |
60- | ` radius.lg ` | ` rounded-lg ` | ` --radius-lg ` | 0.75rem (12px) |
61- | ` radius.xl ` | ` rounded-xl ` | ` --radius-xl ` | 1rem (16px) |
62- | ` radius.2xl ` | ` rounded-2xl ` | ` --radius-2xl ` | 1.5rem (24px) |
63- | ` radius.3xl ` | ` rounded-3xl ` | ` --radius-3xl ` | 2rem (32px) |
64- | ` radius.4xl ` | ` rounded-4xl ` | ` --radius-4xl ` | 3rem (48px) |
65- | ` radius.full ` | ` rounded-full ` | ` --radius-full ` | 999px |
66-
67- ## Border Width
68-
69- | Token | Tailwind | CSS | Value |
70- | ---------------- | ---------- | ------------------- | ----- |
71- | ` border.width.0 ` | ` border-0 ` | ` --border-width-0 ` | 0 |
72- | ` border.width.1 ` | ` border-1 ` | ` --border-width-1 ` | 1px |
73- | ` border.width.2 ` | ` border-2 ` | ` --border-width-2 ` | 2px |
74-
75- ## Shadow
76-
77- | Token | Tailwind | CSS | Description |
78- | ----------------- | ----------------- | ------------------- | --------------------------- |
79- | ` shadow.raised ` | ` shadow-raised ` | ` --shadow-raised ` | Subtle elevation for cards |
80- | ` shadow.overlay ` | ` shadow-overlay ` | ` --shadow-overlay ` | Modals, dropdowns, popovers |
81- | ` shadow.overflow ` | ` shadow-overflow ` | ` --shadow-overflow ` | Scroll indicators |
82-
83- ## Icon Size
84-
85- | Token | Tailwind | CSS | Value |
86- | -------------- | --------- | ---------------- | ----- |
87- | ` icon.size.xs ` | ` icon-xs ` | ` --icon-size-xs ` | 12px |
88- | ` icon.size.sm ` | ` icon-sm ` | ` --icon-size-sm ` | 16px |
89- | ` icon.size.md ` | ` icon-md ` | ` --icon-size-md ` | 20px |
90- | ` icon.size.lg ` | ` icon-lg ` | ` --icon-size-lg ` | 24px |
91- | ` icon.size.xl ` | ` icon-xl ` | ` --icon-size-xl ` | 32px |
65+ Use negative values to pull elements closer or overlap containers. Common for breaking out of parent padding.
66+
67+ | Token | Tailwind | CSS | Value |
68+ | ---------------------- | ---------------- | ------------------------ | ---------------- |
69+ | ` spacing.negative.25 ` | ` -*-spacing-25 ` | ` --spacing-negative-25 ` | -0.125rem (-2px) |
70+ | ` spacing.negative.50 ` | ` -*-spacing-50 ` | ` --spacing-negative-50 ` | -0.25rem (-4px) |
71+ | ` spacing.negative.75 ` | ` -*-spacing-75 ` | ` --spacing-negative-75 ` | -0.375rem (-6px) |
72+ | ` spacing.negative.100 ` | ` -*-spacing-100 ` | ` --spacing-negative-100 ` | -0.5rem (-8px) |
73+ | ` spacing.negative.150 ` | ` -*-spacing-150 ` | ` --spacing-negative-150 ` | -0.75rem (-12px) |
74+ | ` spacing.negative.200 ` | ` -*-spacing-200 ` | ` --spacing-negative-200 ` | -1rem (-16px) |
75+ | ` spacing.negative.250 ` | ` -*-spacing-250 ` | ` --spacing-negative-250 ` | -1.25rem (-20px) |
76+ | ` spacing.negative.300 ` | ` -*-spacing-300 ` | ` --spacing-negative-300 ` | -1.5rem (-24px) |
77+ | ` spacing.negative.400 ` | ` -*-spacing-400 ` | ` --spacing-negative-400 ` | -2rem (-32px) |
78+
79+ ## Guidelines
80+
81+ | Do | Don't |
82+ | ----------------------------------------------- | ------------------------------------------ |
83+ | Use spacing tokens (` p-spacing-100 ` ) | Use arbitrary values (` p-[7px] ` ) |
84+ | Group related items with smaller spacing | Use the same spacing everywhere |
85+ | Increase spacing to separate unrelated sections | Cram elements together to save space |
86+ | Be consistent within similar components | Mix different spacing for the same purpose |
0 commit comments