@sanity/ui 5.0.0-alpha.22 → 5.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +10 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/docs/components/avatar-counter.dsds.yaml +78 -0
  6. package/docs/components/avatar-stack.dsds.yaml +96 -0
  7. package/docs/components/avatar.dsds.yaml +115 -0
  8. package/docs/components/badge.dsds.yaml +126 -0
  9. package/docs/components/box.dsds.yaml +223 -0
  10. package/docs/components/button.dsds.yaml +284 -0
  11. package/docs/components/card.dsds.yaml +317 -0
  12. package/docs/components/checkbox.dsds.yaml +204 -0
  13. package/docs/components/code.dsds.yaml +167 -0
  14. package/docs/components/container.dsds.yaml +189 -0
  15. package/docs/components/dialog.dsds.yaml +343 -0
  16. package/docs/components/divider.dsds.yaml +93 -0
  17. package/docs/components/eyebrow.dsds.yaml +217 -0
  18. package/docs/components/flex.dsds.yaml +237 -0
  19. package/docs/components/grid.dsds.yaml +217 -0
  20. package/docs/components/h-stack.dsds.yaml +127 -0
  21. package/docs/components/heading.dsds.yaml +233 -0
  22. package/docs/components/hotkeys.dsds.yaml +60 -0
  23. package/docs/components/icon-button.dsds.yaml +220 -0
  24. package/docs/components/icon.dsds.yaml +275 -0
  25. package/docs/components/indicator-stack.dsds.yaml +98 -0
  26. package/docs/components/indicator.dsds.yaml +108 -0
  27. package/docs/components/inline.dsds.yaml +127 -0
  28. package/docs/components/kbd.dsds.yaml +59 -0
  29. package/docs/components/link.dsds.yaml +108 -0
  30. package/docs/components/list-button-item.dsds.yaml +103 -0
  31. package/docs/components/list-item-image.dsds.yaml +82 -0
  32. package/docs/components/list-item-text.dsds.yaml +80 -0
  33. package/docs/components/list-item.dsds.yaml +148 -0
  34. package/docs/components/list.dsds.yaml +162 -0
  35. package/docs/components/popover.dsds.yaml +208 -0
  36. package/docs/components/press-area.dsds.yaml +279 -0
  37. package/docs/components/radio.dsds.yaml +198 -0
  38. package/docs/components/select.dsds.yaml +214 -0
  39. package/docs/components/skip-to-content.dsds.yaml +110 -0
  40. package/docs/components/spinner.dsds.yaml +119 -0
  41. package/docs/components/switch.dsds.yaml +202 -0
  42. package/docs/components/tab.dsds.yaml +54 -0
  43. package/docs/components/tabs-list.dsds.yaml +56 -0
  44. package/docs/components/tabs-panel.dsds.yaml +54 -0
  45. package/docs/components/tabs.dsds.yaml +104 -0
  46. package/docs/components/text-area.dsds.yaml +170 -0
  47. package/docs/components/text-input.dsds.yaml +189 -0
  48. package/docs/components/text.dsds.yaml +268 -0
  49. package/docs/components/tooltip-group.dsds.yaml +90 -0
  50. package/docs/components/tooltip.dsds.yaml +216 -0
  51. package/docs/components/v-stack.dsds.yaml +155 -0
  52. package/docs/components/visually-hidden.dsds.yaml +112 -0
  53. package/docs/evals/cases.yaml +1319 -0
  54. package/docs/examples/checkbox-2.tsx +57 -0
  55. package/docs/examples/confirmation-dialogs-1.tsx +27 -0
  56. package/docs/examples/confirmation-dialogs-2.tsx +55 -0
  57. package/docs/examples/confirmation-dialogs-3.tsx +28 -0
  58. package/docs/examples/confirmation-dialogs-4.tsx +38 -0
  59. package/docs/examples/popover-1.tsx +48 -0
  60. package/docs/examples/popover-2.tsx +53 -0
  61. package/docs/foundations/accessibility-guidelines.dsds.yaml +301 -0
  62. package/docs/foundations/color-guidelines.dsds.yaml +308 -0
  63. package/docs/foundations/content-guidelines.dsds.yaml +285 -0
  64. package/docs/foundations/semantics.dsds.yaml +125 -0
  65. package/docs/foundations/spacing-guidelines.dsds.yaml +226 -0
  66. package/docs/foundations/typography-guidelines.dsds.yaml +322 -0
  67. package/docs/icons.dsds.yaml +2513 -0
  68. package/docs/index.dsds.yaml +515 -0
  69. package/docs/overview/api-essentials.dsds.yaml +221 -0
  70. package/docs/overview/component-reference.dsds.yaml +215 -0
  71. package/docs/overview/designer-contribution-model.dsds.yaml +77 -0
  72. package/docs/overview/developer-contribution-model.dsds.yaml +362 -0
  73. package/docs/overview/installation.dsds.yaml +238 -0
  74. package/docs/overview/quick-start.dsds.yaml +317 -0
  75. package/docs/overview/resources.dsds.yaml +34 -0
  76. package/docs/patterns/confirmation-dialogs.dsds.yaml +140 -0
  77. package/docs/patterns/error-messaging.dsds.yaml +58 -0
  78. package/docs/patterns/forms.dsds.yaml +356 -0
  79. package/docs/patterns/layouts.dsds.yaml +403 -0
  80. package/docs/patterns/loading-states.dsds.yaml +41 -0
  81. package/docs/patterns/messaging.dsds.yaml +72 -0
  82. package/docs/patterns/navigation.dsds.yaml +153 -0
  83. package/docs/patterns/responsive.dsds.yaml +590 -0
  84. package/docs/tokens/color.dsds.yaml +1158 -0
  85. package/docs/tokens/container-widths.dsds.yaml +131 -0
  86. package/docs/tokens/content.dsds.yaml +258 -0
  87. package/docs/tokens/content.tokens.json +180 -0
  88. package/docs/tokens/dtcg/README.md +39 -0
  89. package/docs/tokens/dtcg/css/color.css +107 -0
  90. package/docs/tokens/dtcg/css/container.css +12 -0
  91. package/docs/tokens/dtcg/css/fontFamily.css +10 -0
  92. package/docs/tokens/dtcg/css/fontWeight.css +10 -0
  93. package/docs/tokens/dtcg/css/index.css +13 -0
  94. package/docs/tokens/dtcg/css/radius.css +14 -0
  95. package/docs/tokens/dtcg/css/semantic.css +42 -0
  96. package/docs/tokens/dtcg/css/shadow.css +22 -0
  97. package/docs/tokens/dtcg/css/space.css +16 -0
  98. package/docs/tokens/dtcg/css/typography.css +69 -0
  99. package/docs/tokens/dtcg/json/color.tokens.json +911 -0
  100. package/docs/tokens/dtcg/json/container.tokens.json +44 -0
  101. package/docs/tokens/dtcg/json/fontFamily.tokens.json +10 -0
  102. package/docs/tokens/dtcg/json/fontWeight.tokens.json +18 -0
  103. package/docs/tokens/dtcg/json/radius.tokens.json +58 -0
  104. package/docs/tokens/dtcg/json/semantic.tokens.json +372 -0
  105. package/docs/tokens/dtcg/json/shadow.tokens.json +599 -0
  106. package/docs/tokens/dtcg/json/space.tokens.json +72 -0
  107. package/docs/tokens/dtcg/json/typography.tokens.json +354 -0
  108. package/docs/tokens/font-family.dsds.yaml +79 -0
  109. package/docs/tokens/font-weight.dsds.yaml +103 -0
  110. package/docs/tokens/radius.dsds.yaml +153 -0
  111. package/docs/tokens/semantic.dsds.yaml +397 -0
  112. package/docs/tokens/shadow.dsds.yaml +125 -0
  113. package/docs/tokens/space.dsds.yaml +185 -0
  114. package/docs/tokens/typography.dsds.yaml +316 -0
  115. package/llms.txt +108 -0
  116. package/package.json +5 -2
  117. package/skills/sanity-ui-5/SKILL.md +158 -0
  118. package/skills/sanity-ui-5/references/component-choice.md +37 -0
  119. package/skills/sanity-ui-5/references/components.md +145 -0
  120. package/skills/sanity-ui-5/references/forms-and-accessibility.md +189 -0
  121. package/skills/sanity-ui-5/references/migrating-from-v3.md +250 -0
  122. package/skills/sanity-ui-5/references/props-and-imports.md +169 -0
  123. package/skills/sanity-ui-5/references/setup.md +177 -0
  124. package/skills/sanity-ui-5/references/silent-failures.md +33 -0
  125. package/skills/sanity-ui-5/references/taste.md +53 -0
  126. package/skills/sanity-ui-5/references/tone-and-color.md +55 -0
  127. package/src/version.ts +2 -2
@@ -0,0 +1,125 @@
1
+ kind: sanity.foundation
2
+ id: semantics
3
+ name: Semantics
4
+ description: The HTML a component renders, and what it owes assistive technology. Covers heading structure, landmark elements, and lists rendered through `as`.
5
+ metadata:
6
+ tags:
7
+ - concept
8
+ - foundations
9
+ - semantics
10
+ - accessibility
11
+ - heading
12
+ - heading level
13
+ - outline
14
+ - landmark
15
+ - as
16
+ - section
17
+ - nav
18
+ - main
19
+ - aside
20
+ - form
21
+ - article
22
+ - list
23
+ - WCAG
24
+ status:
25
+ status: stable
26
+ sections:
27
+ - kind: guidelines
28
+ for: all
29
+ title: Headings
30
+ framing: how-to-use
31
+ tags: [accessibility]
32
+ items:
33
+ - id: heading-as-explicit
34
+ level: must
35
+ statement: Set `as` on every Heading, to a level from `h1` to `h6`. Without `as`, Heading renders an `h2`, which is often the wrong level.
36
+ example:
37
+ title: How to satisfy this
38
+ description: Search the code for `<Heading` and confirm every instance sets `as`.
39
+ evidence:
40
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
41
+ role: WCAG 1.3.1 Info and Relationships (A)
42
+ checkedBy: manual
43
+ - id: heading-level-from-outline
44
+ level: must
45
+ statement: Choose a heading's level from its place in the page outline. Set how big it looks with `size`. The two are independent and often differ. `<Heading as="h2" size={4}>` is an `h2` that looks like size 4.
46
+ example:
47
+ title: How to satisfy this
48
+ description: Where `size` and `as` differ, confirm `as` still matches the outline. No heading should change level to look bigger or smaller.
49
+ evidence:
50
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
51
+ role: WCAG 1.3.1 Info and Relationships (A)
52
+ checkedBy: manual
53
+ - id: one-h1-per-page
54
+ level: must
55
+ statement: Give each page one `h1`, for the page title.
56
+ example:
57
+ title: How to satisfy this
58
+ description: Run `document.querySelectorAll('h1').length` in the browser console on the rendered page. The result is 1.
59
+ checkedBy: manual
60
+ - id: heading-levels-sequential
61
+ level: must
62
+ statement: Don't skip heading levels. Each heading is at most one level deeper than the heading before it. An `h2` follows an `h1`, and an `h3` follows an `h2`. Screen reader users navigate by level, and a gap breaks their map of the page.
63
+ example:
64
+ title: How to satisfy this
65
+ description: List the page's headings in DOM order, or open the browser's accessibility tree. No heading is more than one level deeper than the one before it.
66
+ evidence:
67
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
68
+ role: WCAG 1.3.1 Info and Relationships (A)
69
+ checkedBy: manual
70
+ - kind: guidelines
71
+ for: all
72
+ title: Elements rendered through `as`
73
+ framing: how-to-use
74
+ tags: [accessibility]
75
+ items:
76
+ - id: landmark-requirements
77
+ level: must
78
+ statement: |-
79
+ When `as` renders a landmark element, give it what that element needs.
80
+ - `section`: an accessible name, through `aria-labelledby` on its heading or through `aria-label`. A section with no name is not a landmark. A heading inside it does not name it.
81
+ - `nav`: an `aria-label` when the page has more than one `nav`.
82
+ - `aside`: an `aria-label` when the page has more than one `aside`, or when its purpose is not clear.
83
+ - `form`: an accessible name, through `aria-label` or `aria-labelledby`.
84
+ - `main`: one per page, around the primary content.
85
+ - `article`: self-contained content. It needs no name.
86
+ evidence:
87
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
88
+ role: WCAG 1.3.1 Info and Relationships (A)
89
+ - href: https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/
90
+ role: WAI-ARIA landmark regions
91
+ - id: app-shell-landmark-regions
92
+ level: must
93
+ statement: |-
94
+ Map each Sanity app shell region to its HTML landmark. Without landmarks, screen readers experience the layout as a flat list with no structure.
95
+
96
+ | Region | Element | `aria-label` |
97
+ | --- | --- | --- |
98
+ | Navigation sidebar | `<nav>` | Required — e.g. "Main navigation" |
99
+ | Content area | `<main>` | None (one per page) |
100
+ | Inspection sidebar | `<aside>` | Required — e.g. "Document inspector" |
101
+ | Content toolbar | `<header>` within `<main>` | None |
102
+ evidence:
103
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
104
+ role: WCAG 1.3.1 Info and Relationships (A)
105
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/bypass-blocks.html
106
+ role: WCAG 2.4.1 Bypass Blocks
107
+ - id: list-semantics
108
+ level: must
109
+ statement: When `as` renders a `ul` or an `ol`, its children must be `li` elements. Add `role="list"` when `list-style` is `none`. WebKit drops the list semantics without it.
110
+ evidence:
111
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html
112
+ role: WCAG 1.3.1 Info and Relationships (A)
113
+ - kind: section
114
+ for: all
115
+ freeform:
116
+ - title: Overview
117
+ body: |-
118
+ Assistive technology reads the HTML, not the screen. A heading's level, a landmark's name and a list's items are how a screen reader user finds their way around a page.
119
+
120
+ This document is the one place those rules live. Heading and the layout components that take `as` (Box, Card, Container, Flex and Grid) point here.
121
+ - title: Related
122
+ body: |-
123
+ - **Heading** — the component these heading rules apply to.
124
+ - **Typography guidelines** — the type scale behind `size`.
125
+ - **Accessibility guidelines** — the wider WCAG 2.2 AA requirements.
@@ -0,0 +1,226 @@
1
+ kind: sanity.foundation
2
+ id: spacing-guidelines
3
+ name: Spacing guidelines
4
+ description: How to apply the spacing scale in Sanity UI layout components, and how space shows what belongs together.
5
+ metadata:
6
+ tags:
7
+ - concept
8
+ - spacing
9
+ - layout
10
+ - scale
11
+ - padding
12
+ - gap
13
+ - grouping
14
+ - responsive
15
+ - accessibility
16
+ - margin
17
+ - proximity
18
+ - Fibonacci
19
+ status:
20
+ status: stable
21
+ sections:
22
+ - kind: guidelines
23
+ for: all
24
+ framing: how-to-use
25
+ items:
26
+ - id: spacing-is-an-integer-scale-token
27
+ level: must
28
+ statement: 'Pass a spacing step as an integer in braces: `padding={2}`, `gap={3}`. A string like `padding="2"` is a TypeScript error.'
29
+ checks:
30
+ - href: ../evals/cases.yaml
31
+ role: agent-test
32
+ checkedBy: assisted
33
+ $extensions:
34
+ io.jev:
35
+ type: boolean
36
+ - level: must
37
+ statement: Pass `padding` only to Box, Container, Flex, and Grid.
38
+ - level: must
39
+ statement: Set Card's padding and gap with `density`. Passing `padding` or `gap` to Card is a TypeScript error.
40
+ - level: must
41
+ statement: Pass only `gap` and `as` to VStack and HStack. They take no `padding`, `margin`, `columnGap`, or `rowGap`.
42
+ - id: back-groups-with-markup
43
+ level: must
44
+ statement: Back every visual group with markup, such as a `<label>`, a `<fieldset>` with a `<legend>`, list markup, or a labeled region.
45
+ - level: must
46
+ statement: Take every gap from the `0`–`9` scale.
47
+ - level: must
48
+ statement: Document every off-scale value as a named exception.
49
+ - refs:
50
+ - to: shared-foundations#inner-spacing-smaller-than-outer
51
+ rel: same-as
52
+ - refs:
53
+ - to: accessibility-guidelines#touch-target-minimum
54
+ rel: same-as
55
+ - id: group-size-limit-working-memory
56
+ level: should
57
+ statement: Split a list or form of more than about six items into labeled subgroups. Use a heading or a `<fieldset>` with a `<legend>`.
58
+ - level: should
59
+ statement: Separate subgroups by one full scale step more than the gap inside them.
60
+ - level: should
61
+ statement: Use the same row gap and column gap in a grid of similar items.
62
+ - level: should
63
+ statement: Group with space first. Add borders, dividers, or backgrounds only when space alone cannot show the grouping.
64
+ - level: should
65
+ statement: Use a surface or Card only when the content is separate, not to get a container.
66
+ - level: should
67
+ statement: Use `gap` on Flex, Grid, VStack, and HStack, not `margin` on each child.
68
+ - level: should
69
+ statement: Use `padding` instead of `margin`. Stacked vertical margins collapse to the larger value, but padding never collapses.
70
+ - level: should
71
+ statement: Start with steps `3`–`4`. Move tighter or looser only when content density calls for it.
72
+ - level: should
73
+ statement: Keep Card at `density="regular"` unless the context calls for `compact` or `loose`.
74
+ - level: should
75
+ statement: Reduce large spacing values at small breakpoints with responsive arrays.
76
+ - level: should
77
+ statement: Re-check target spacing at the smallest breakpoint after you reduce padding.
78
+ - id: trim-text-against-edges
79
+ level: should
80
+ statement: Add `trim` to text that sits against a border, an icon, or another fixed-height sibling.
81
+ - level: may
82
+ statement: Go off the scale for an optical adjustment, such as icon-to-text alignment.
83
+ - level: should-not
84
+ statement: Do not fill empty space because it is there. Every gap needs a reason.
85
+ - level: should-not
86
+ statement: Do not trim running text. Multi-line body copy needs its leading to stay readable.
87
+ - level: should-not
88
+ statement: Do not shrink a `gap` or `padding` value to make up for untrimmed leading. Trim the text instead.
89
+ - level: must-not
90
+ statement: Do not use steps `6`–`9` inside a component. Keep them for page-level and marketing layouts.
91
+ - level: must-not
92
+ statement: Do not hardcode the pixel values from the scale. Pass the step. The value then follows the token file.
93
+ - kind: section
94
+ for: all
95
+ freeform:
96
+ - title: Overview
97
+ body: |-
98
+ The space between things shows what belongs together, often before people read a word. Sanity UI's scale gives a small set of values that keep spacing consistent. It applies to the layout primitives: Box, Container, Card, Flex, Grid, VStack, and HStack.
99
+
100
+ This foundation covers `@sanity/ui`. Each primitive accepts a different set of spacing props. The Props section lists them.
101
+ - title: Principles
102
+ body: |-
103
+ **Meaningful.** Space is the main tool for grouping. Distance shows how elements relate. Related items sit close together. Unrelated items sit far apart. Borders and backgrounds only add emphasis to a grouping.
104
+
105
+ **Relational.** A gap depends on what surrounds it. In a container with large padding, items need more space between them. In a container with small padding, they need less.
106
+ - title: Fundamentals
107
+ body: |-
108
+ These facts about how people read space underlie every rule in this entry.
109
+
110
+ **Proximity is the strongest sign of relation.** It outweighs color, borders, and labels. Empty space adds less noise than borders or backgrounds.
111
+
112
+ **Only sighted users see spacing.** Screen readers do not announce gaps. Markup, `role`, and `aria` attributes must carry the grouping.
113
+
114
+ **Empty space does work.** It separates content, directs attention, and can signal state, such as an empty state.
115
+
116
+ **Arbitrary spacing suggests arbitrary meaning.** When two similar things have different spacing, people assume the difference means something. Consistent spacing gives people a simpler mental model.
117
+
118
+ **People compare gaps to each other.** One gap means nothing on its own. A {space-3} gap reads as tight next to {space-5}, and loose next to {space-1}.
119
+ - title: The scale
120
+ body: |-
121
+ The scale has ten steps, `0` through `9`. From step `2` up, each value is the sum of the two before it. Steps sit close together at small sizes and spread apart at large ones. The steps and their common uses are in the Space scale entry's table (`space`).
122
+
123
+ Steps `6`–`9` are for full-page and marketing layouts, where a section break must read across the viewport. If you need one inside a component, you probably skipped a grouping decision.
124
+ - title: Why numbers, not names
125
+ body: |-
126
+ Sanity UI uses integers (`padding={3}`), not named keys (`padding="md"`).
127
+
128
+ - Ten integers are faster to scan than ten size names.
129
+ - You can do math. `padding={basePadding - 1}` steps down one stop from a base value.
130
+ - The same number means the same size on every spacing prop.
131
+ - title: Props
132
+ body: |-
133
+ Each primitive takes only the spacing props that fit its role. A wrong prop is a TypeScript error, not a silent no-op.
134
+
135
+ | Component | `padding*` | `margin*` | `gap` / `columnGap` / `rowGap` |
136
+ | --- | --- | --- | --- |
137
+ | `Box` | ✓ | ✓ | — |
138
+ | `Container` | ✓ | ✓ | — |
139
+ | `Card` | via `density` only | ✓ | via `density` only |
140
+ | `Flex` | ✓ | ✓ | ✓ |
141
+ | `Grid` | ✓ | ✓ | ✓ |
142
+ | `VStack` | — | — | `gap` only |
143
+ | `HStack` | — | — | `gap` only |
144
+
145
+ | Prop | Controls | Accepted values |
146
+ | --- | --- | --- |
147
+ | `padding` | Inner spacing on all sides | Integer `0`–`9` |
148
+ | `paddingX` | Inner spacing on left and right | Integer `0`–`9` |
149
+ | `paddingY` | Inner spacing on top and bottom | Integer `0`–`9` |
150
+ | `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft` | Inner spacing on one side | Integer `0`–`9` |
151
+ | `margin` | Outer spacing on all sides | Integer `-9`–`9`, or `'auto'` |
152
+ | `marginX`, `marginY` | Outer spacing on one axis | Integer `-9`–`9`, or `'auto'` |
153
+ | `marginTop`, `marginRight`, `marginBottom`, `marginLeft` | Outer spacing on one side | Integer `-9`–`9`, or `'auto'` |
154
+ | `gap` | Space between children | Integer `0`–`9`, or `'inherit'` |
155
+ | `columnGap`, `rowGap` | Space between children on one axis (Flex, Grid only) | Integer `0`–`9`, or `'inherit'` |
156
+
157
+ Only `margin` goes negative or takes `'auto'`. A negative value pulls a child past its own edge, for example to bleed an image to a card's edge. `'auto'` centers or pushes an element within its row. Container centers itself with `marginX="auto"` by default. Padding and gap only add space.
158
+
159
+ Card's `density` sets padding, gap, and radius together:
160
+
161
+ | `density` | `padding` | `gap` | `radius` |
162
+ | --- | --- | --- | --- |
163
+ | `'compact'` | `3`, {space-3} | `2`, {space-2} | `2`, {radius-2} |
164
+ | `'regular'` (default) | `4`, {space-4} | `3`, {space-3} | `3`, {radius-3} |
165
+ | `'loose'` | `5`, {space-5} | `4`, {space-4} | `4`, {radius-4} |
166
+
167
+ Card's `margin` is a normal prop, outside `density`. Use it to space a Card from its siblings.
168
+
169
+ VStack and HStack have no per-axis gap and no padding or margin. Wrap them in a Box, or use Flex. Flex and Grid add `columnGap` and `rowGap` for separate row and column control. Box and Container hold one child region and have no gap prop.
170
+ - title: Choosing a value
171
+ body: |-
172
+ Choose by content density. Each band has a felt purpose, not only a pixel range.
173
+
174
+ - **Tight (`1`–`2`).** Items that form one unit, such as a label and its input, or an icon and its caption. The gap reads as a pause, not a break.
175
+ - **Standard (`3`–`4`).** Items in the same group with clear separation, such as form fields, cards in a list, or paragraphs. Most UI lives here.
176
+ - **Generous (`5`+).** Sections that need distance. The gap reads as a section change and does a divider's work.
177
+
178
+ | Context | Prop | Value |
179
+ | --- | --- | --- |
180
+ | Form label and input pair | `gap` | `1`–`2` |
181
+ | Form fields in a group | `gap` | `3` |
182
+ | Cards in a list | `gap` | `3`–`4` |
183
+ | Card padding (default) | `density` | `'regular'` (padding `4`) |
184
+ | Card padding (dense lists, table rows, sidebars) | `density` | `'compact'` (padding `3`) |
185
+ | Card padding (featured, standalone) | `density` | `'loose'` (padding `5`) |
186
+ | Section break | `gap` | `5` |
187
+
188
+ Measured space and perceived space can differ. Icon-to-text alignment is the common case: the eye reads balance, not pixels.
189
+ - title: Responsive values
190
+ body: |-
191
+ Every spacing prop accepts an array, read mobile-first: `[base, …larger breakpoints]`. The first value applies at every width. Each later value takes over at its breakpoint and holds until a later value replaces it. A shorter array carries its last value to the largest breakpoint. Write `undefined` in a slot to skip a breakpoint and keep the previous value. That holds for spacing props, which take steps. A prop that takes a CSS string or a number, such as `width`, `gridTemplateColumns` or `truncate`, resets at an `undefined` slot instead, so fill every slot up to the last one you set. The Responsive pattern's breakpoint table (`responsive`) lists the breakpoint for each slot.
192
+
193
+ Smaller padding at small breakpoints keeps content reachable. Heavy reduction can push adjacent targets into overlap.
194
+ - title: Grouping
195
+ body: |-
196
+ Space can group items before you add any border or background.
197
+
198
+ The gap inside a group must read as smaller than the gap around it. The gap between separate groups must read as a clear break.
199
+
200
+ Group size has a limit. Working memory holds about three to six items at once. Past that, labeled subgroups help people scan.
201
+
202
+ Equal row and column gaps in a grid show that every item is a peer. A tighter row or column gap reads as a separate group.
203
+
204
+ Each surface adds a border, a background, and often a shadow. That is why surfaces come after space.
205
+ - title: Vertical rhythm
206
+ body: |-
207
+ The spacing scale assumes a box that ends at its visible edge. Text boxes do not. A `Heading` or `Text` box is taller than its glyphs, because line-height adds leading above and below. Put `gap={3}` next to untrimmed text, and the visible gap reads larger than {space-3}.
208
+
209
+ This matters most where text sits against something with no leading. Examples are Card padding, an icon, an avatar, a divider, or a bordered edge. The `trim` prop removes the extra leading. The scale value is then the real distance. The Typography guidelines (`typography-guidelines`) explain `trim` in their Vertical rhythm section.
210
+
211
+ It matters least between lines of running text. A paragraph's line-height already accounts for its leading. Add a `gap` between paragraphs on top of that as normal.
212
+ - title: Related foundations
213
+ body: |-
214
+ - **Typography** (`typography-guidelines`) covers line height, the `trim` prop, and text spacing (WCAG 1.4.12).
215
+
216
+ Alignment is a separate grouping tool. This entry does not cover it. A shared edge, a column, and numbered steps are examples.
217
+ - kind: section
218
+ for: agent
219
+ freeform:
220
+ - title: Intent
221
+ body: Apply the spacing scale by integer step, chosen by content density. Keep the gap inside a group smaller than the gap around it. Back every visual group with markup.
222
+ refs:
223
+ - to: space
224
+ rel: relates-to
225
+ - to: typography-guidelines
226
+ rel: relates-to