@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,284 @@
1
+ kind: component
2
+ id: button
3
+ name: Button
4
+ description: Used to trigger an action — like submitting a form, starting a dialog, or running a command.
5
+ metadata:
6
+ tags:
7
+ - action
8
+ - form
9
+ - interactive
10
+ - trigger
11
+ - button
12
+ - submit
13
+ - primary
14
+ - secondary
15
+ - tertiary
16
+ - CTA
17
+ - loading
18
+ - destructive
19
+ status:
20
+ status: beta
21
+ sections:
22
+ - kind: guidelines
23
+ for: all
24
+ framing: when-to-use
25
+ title: When to use
26
+ items:
27
+ - level: should
28
+ statement: "To trigger an action within the app (for example, 'Publish', 'Delete', 'Save')."
29
+ - level: should
30
+ statement: To submit data in a form context. Use type='submit' via the native HTML attribute.
31
+ - level: should-not
32
+ statement: To send the user to a new URL within a line of text or paragraph. Use Link instead. Users of assistive technology expect buttons to perform actions and links to navigate.
33
+ alternatives:
34
+ - to: link
35
+ - level: should-not
36
+ statement: 'As nav items within a sidebar or menu. Use List.ButtonItem instead.'
37
+ alternatives:
38
+ - to: list-button-item
39
+ - level: should-not
40
+ statement: To switch views on a screen. Use Tab instead. The Tab component has ARIA attributes that make keyboard navigation accessible.
41
+ alternatives:
42
+ - to: tabs
43
+ - level: should-not
44
+ statement: To toggle a boolean form value (on/off). Use Switch or Checkbox instead.
45
+ alternatives:
46
+ - to: switch
47
+ - to: checkbox
48
+ - id: buttons-only-display-icon-text
49
+ level: must-not
50
+ statement: For buttons that only display an icon with no text label. Use IconButton instead.
51
+ alternatives:
52
+ - to: icon-button
53
+ - kind: guidelines
54
+ for: agent
55
+ framing: when-to-use
56
+ title: When to use
57
+ items:
58
+ - level: should-not
59
+ statement: Don't use Button for navigation (changing URL). Use Link instead.
60
+ alternatives:
61
+ - to: link
62
+ - level: should-not
63
+ statement: Don't use Button for binary form toggles that take effect immediately. Use Switch instead.
64
+ alternatives:
65
+ - to: switch
66
+ - kind: guidelines
67
+ for: all
68
+ framing: how-to-use
69
+ items:
70
+ - id: button-icon-only-accessible-name
71
+ level: must
72
+ statement: "An icon-only Button (icon with no `text` prop) needs an `aria-label`. Describe the action, not the icon: 'Add item', not 'Plus'."
73
+ checks:
74
+ - href: ../evals/cases.yaml
75
+ role: agent-test
76
+ checkedBy: assisted
77
+ refines:
78
+ - to: shared-foundations#icon-only-control-needs-name
79
+ $extensions:
80
+ io.jev:
81
+ type: boolean
82
+ - level: must
83
+ statement: '**`as` prop and keyboard behavior.** When `as="a"`, the element activates with Enter only — Space does not trigger links. Don''t use `as` for elements whose behavioral contract Button does not fulfill.'
84
+ tags: [accessibility]
85
+ - level: must
86
+ statement: "**Focus ring.** A visible focus ring appears on keyboard focus. Don't suppress it without providing a high-contrast alternative."
87
+ tags: [accessibility]
88
+ - refs:
89
+ - to: content-guidelines#name-the-action
90
+ rel: same-as
91
+ - level: should
92
+ statement: Ensure buttons have a logical tab order in the document flow (left to right, top to bottom).
93
+ - level: should
94
+ statement: Limit the number of level='primary' buttons on the screen. Display one primary action per logical section.
95
+ - level: should
96
+ statement: Set iconEnd to ChevronDownIcon when a Button opens a Popover.
97
+ - level: should
98
+ statement: Bias toward text labels in buttons to aid comprehension.
99
+ - level: should
100
+ statement: Use iconStart in Button for visual emphasis. Only when it doesn't hurt scannability. Keep icon/text button pairing to one button per group.
101
+ - level: must-not
102
+ statement: '**Disabled strategy.** Never place a tooltip on a disabled button. Button uses HTML `disabled`, which removes it from the tab order, so keyboard users cannot reach the tooltip. When users need to find a disabled control, use `aria-disabled="true"` instead to keep it focusable while blocking action (WCAG 2.1.1 A).'
103
+ tags: [accessibility]
104
+ refines:
105
+ - to: accessibility-guidelines#disabled-control-no-tooltip
106
+ - level: must-not
107
+ statement: Don't use Button without a text label. Button relies on the text label to describe its purpose. Use IconButton in cases where the icon is the only visual indicator.
108
+ - level: must-not
109
+ statement: Don't disable buttons as a blocking function for incomplete form fields. People may not know what caused the button to be disabled. Allow submission and show feedback instead.
110
+ - level: must-not
111
+ statement: Don't hide buttons that represent critical actions. Primary actions must be visible at all times.
112
+ - level: must-not
113
+ statement: 'Don''t use `tone="critical"` without an icon, such as `iconStart={ErrorOutlineIcon}`.'
114
+ tags: [accessibility]
115
+ refines:
116
+ - to: shared-foundations#tone-paired-with-second-channel
117
+ - kind: guidelines
118
+ for: agent
119
+ framing: how-to-use
120
+ items:
121
+ - level: must-not
122
+ statement: Do not use `mode` in Button—it's not a valid prop. `level` is the equivalent v5 prop. Refer to the `level` prop for what values it accepts.
123
+ - level: must-not
124
+ statement: Do not use `primary` for the `tone` prop. `primary` is now a value in v5's `level` prop.
125
+ - kind: guidelines
126
+ for: agent
127
+ framing: how-to-use
128
+ items:
129
+ - id: most-buttons-tertiary
130
+ level: should
131
+ statement: Most buttons should be level='tertiary'. The default, primary, is only for a section's single most important action.
132
+ - level: should
133
+ statement: Use text='Label' to set the button label. Children text nodes also work but text prop is the primary API. Do not set both text and children — both render, the text first and the children after it.
134
+ - level: should
135
+ statement: Pass `ref` straight to Button when you need the rendered element — to move focus to it, or to anchor a Popover to its trigger. It reaches the underlying element; there is no wrapper to add and no forwardRef to wait for.
136
+ - level: must-not
137
+ statement: Button does not accept Box layout props. Props like `flexShrink`, `flexGrow`, `width`, `margin`, and `padding` are not valid on Button and cause a TypeScript error. Wrap Button in Box to control layout.
138
+ - id: button-not-hand-written-native
139
+ level: must-not
140
+ statement: Interactive controls use the Button component rather than a hand-written native `<button>`; standard DOM attributes and handlers pass through Button.
141
+ checks:
142
+ - href: ../evals/cases.yaml
143
+ role: agent-test
144
+ checkedBy: assisted
145
+ $extensions:
146
+ io.jev:
147
+ type: boolean
148
+ - level: must-not
149
+ statement: Do not use Button for navigation to a new page or URL — use Link instead.
150
+ - kind: guidelines
151
+ for: all
152
+ title: Accessibility
153
+ description: 'Target conformance: WCAG Level AA.'
154
+ tags: [accessibility]
155
+ items:
156
+ - refs:
157
+ - to: shared-foundations#aria-disabled-keeps-focus
158
+ rel: same-as
159
+ - refs:
160
+ - to: shared-foundations#aria-pressed-toggle
161
+ rel: same-as
162
+ - kind: guidelines
163
+ for: all
164
+ title: Content
165
+ tags: [content]
166
+ items:
167
+ - refs:
168
+ - to: content-guidelines#sentence-case-all-system-set
169
+ rel: same-as
170
+ - kind: definitions
171
+ for: all
172
+ title: Content
173
+ items:
174
+ - term: Be concise
175
+ definition: Button labels should be short and clear. Use simple, direct language.
176
+ - term: Start with verbs
177
+ definition: "Labels should describe the action taken (for example, 'Publish', 'Edit', 'Upload'). For extra clarity, add the subject of the action (for example, 'Upload image')."
178
+ uses:
179
+ - to: icons
180
+ note: Button's iconStart and iconEnd props accept icon components from @sanity/icons.
181
+ alternatives:
182
+ - to: icon-button
183
+ - to: link
184
+ - to: list-button-item
185
+ - to: switch
186
+ refs:
187
+ - href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32075-2332
188
+ rel: design
189
+ role: Figma component (v5)
190
+ sourceFiles:
191
+ - platform: react
192
+ file: packages/ui/src/components/button/Button.tsx
193
+ imports:
194
+ - platform: react
195
+ code: |-
196
+ import { Button } from '@sanity/ui'
197
+
198
+ <Button text="Publish" />
199
+ package: '@sanity/ui'
200
+ traits:
201
+ - traitType: state
202
+ kind: boolean
203
+ id: enabled
204
+ description: Button's standard state (default). Represents that a button is clickable.
205
+ - traitType: state
206
+ kind: boolean
207
+ id: hovered
208
+ description: Visual cue that the cursor is resting over the button.
209
+ - traitType: state
210
+ kind: boolean
211
+ id: pressed
212
+ description: Visual cue that the button is being pressed.
213
+ - traitType: state
214
+ kind: boolean
215
+ id: focused
216
+ description: Visual cue that the button is keyboard-focused.
217
+ - traitType: state
218
+ kind: boolean
219
+ id: disabled
220
+ description: >-
221
+ Blocks the user from using the button. Removed from the tab order via HTML
222
+ disabled. Use only when performing the action could be harmful, or while
223
+ loading={true}. Let people know why it's disabled and how to fix it with
224
+ visible text or a status message next to the button.
225
+ - traitType: state
226
+ kind: boolean
227
+ id: loading
228
+ description: >-
229
+ Shows the action is in progress. The button is also disabled while
230
+ loading. Use only for processes consistently longer than 200ms. For
231
+ processes over three seconds, show a confirmation message when the action completes.
232
+ - traitType: variant
233
+ kind: enum
234
+ id: level
235
+ description: Controls the visual weight of the button. Tertiary covers most actions, then secondary, with primary least used.
236
+ values:
237
+ - id: tertiary
238
+ description: No background, low visual weight. For rare or background actions (forgot password, close/dismiss in a dialog).
239
+ - id: secondary
240
+ description: Outlined/bordered look. For common but not the most critical actions (cancel in dialogs, save as draft).
241
+ - id: primary
242
+ description: Default value. Solid background, full visual weight. The most critical action in a workflow (publish, log in).
243
+ - traitType: variant
244
+ kind: enum
245
+ id: tone
246
+ description: Semantic color of the button.
247
+ values:
248
+ - id: neutral
249
+ description: Neutral gray for general actions within the product.
250
+ - id: critical
251
+ description: Red for destructive or unsafe actions. Pair with iconStart={ErrorOutlineIcon} to show meaning to people with color vision differences.
252
+ - traitType: variant
253
+ kind: enum
254
+ id: type
255
+ description: The native HTML type attribute passes through to the underlying <button> element.
256
+ values:
257
+ - id: button
258
+ description: Standard button (default). For all actions outside of a form context.
259
+ - id: submit
260
+ description: Submits form data.
261
+ - id: reset
262
+ description: Resets form data.
263
+ - traitType: variant
264
+ kind: enum
265
+ id: density
266
+ description: Composite prop setting padding and gap together.
267
+ values:
268
+ - id: regular
269
+ description: Gap 2 and padding 2. Default spacing.
270
+ - id: loose
271
+ description: Gap 3 and padding 3. For spacious contexts.
272
+ - traitType: variant
273
+ kind: boolean
274
+ id: fullwidth
275
+ description: Sets CSS width to 100% to fill the container.
276
+ $extensions:
277
+ com.sanity.ui:
278
+ implementationStatus:
279
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
280
+ implemented: true
281
+ migrationGuide:
282
+ context: 'Migration guide for this component, covering the codemod and the changes it cannot make. Held as an extension because it is temporary: migration tooling and porting agents read it, and it should be dropped when Sanity UI 3 support ends.'
283
+ guidance: |-
284
+ Button's prop API has changed. The `mode` prop is replaced by `level` with new values, icon props are renamed, the `selected` prop is removed, and tone values are reduced. `styled-components` is no longer used, so custom extensions like `styled(Button)` will not work.
@@ -0,0 +1,317 @@
1
+ kind: component
2
+ id: card
3
+ name: Card
4
+ description: Groups related content into a single visual element.
5
+ metadata:
6
+ tags: [layout, container, surface, card, panel, tile, region, status, tone]
7
+ status:
8
+ status: stable
9
+ sections:
10
+ - kind: guidelines
11
+ for: all
12
+ framing: when-to-use
13
+ title: When to use
14
+ items:
15
+ - level: should
16
+ statement: To group related content on a distinct background surface.
17
+ - level: should
18
+ statement: To create visual separation between content regions.
19
+ - level: should
20
+ statement: To wrap content that needs consistent internal padding and rounded corners.
21
+ - id: layout-without-distinct-visual-surface
22
+ level: should-not
23
+ statement: For layout without a distinct visual surface — use Box or Flex.
24
+ alternatives:
25
+ - to: box
26
+ - to: flex
27
+ - level: should-not
28
+ statement: For structural UI regions like sidebars and toolbars — use Box or Flex.
29
+ alternatives:
30
+ - to: box
31
+ - to: flex
32
+ - level: should-not
33
+ statement: For anything the user activates — use Button.
34
+ alternatives:
35
+ - to: button
36
+ - level: must-not
37
+ statement: To contain large parts of an interface that typically represent a section or large surface area. Use Box or Flex instead.
38
+ alternatives:
39
+ - to: box
40
+ - to: flex
41
+ - kind: guidelines
42
+ for: all
43
+ framing: how-to-use
44
+ items:
45
+ - refs:
46
+ - to: shared-foundations#tone-signals-state
47
+ rel: same-as
48
+ - refs:
49
+ - to: shared-foundations#tone-paired-with-second-channel
50
+ rel: same-as
51
+ - id: density-matches-context
52
+ level: should
53
+ statement: Use density to match the surrounding layout density, so the Card's density prop matches the density used by adjacent or sibling components in the same layout region.
54
+ example:
55
+ title: How to satisfy this
56
+ description: Set density='compact' when the card appears inside a high-density list or table. Set density='loose' when the card is a featured or standalone element in a low-density layout. Leave density at the default 'regular' when the surrounding layout uses standard spacing.
57
+ checkedBy: manual
58
+ - id: card-wrapped-for-layout
59
+ level: should
60
+ statement: Wrap Card in Box or Flex to control layout sizing — Card handles appearance, the wrapper handles position — so layout sizing props like width, height, flexGrow, overflow, and position are applied to that Box or Flex wrapper, not directly to Card.
61
+ example:
62
+ title: How to satisfy this
63
+ description: Inspect the component tree and confirm that sizing or positioning props appear on a Box or Flex element that is the direct parent of Card. Confirm that the Card element itself carries only density, tone, margin, and as props.
64
+ checkedBy: manual
65
+ - refs:
66
+ - to: shared-foundations#card-not-for-structural-regions
67
+ rel: same-as
68
+ - id: no-nested-cards
69
+ level: must-not
70
+ statement: Don't nest cards — no Card element should render as a direct or indirect descendant of another Card element. Use Box, Flex, or VStack for internal layout within a card.
71
+ example:
72
+ title: How to satisfy this
73
+ description: Inspect the rendered component tree and confirm there is no Card inside another Card. Use Box, Flex, or VStack for all internal layout structure within a Card.
74
+ checkedBy: manual
75
+ - id: no-onclick-on-card
76
+ level: must-not
77
+ statement: Card carries no `onClick` or other interaction handler; interactive behaviour lives on a Button or PressArea instead.
78
+ example:
79
+ title: How to satisfy this
80
+ description: Inspect the component tree and confirm that Card has no onClick, onKeyDown, onPointerDown, or similar event handler props. Use Button for actions where keyboard accessibility and focus management are required.
81
+ checks:
82
+ - href: ../evals/cases.yaml
83
+ role: agent-test
84
+ checkedBy: assisted
85
+ $extensions:
86
+ io.jev:
87
+ type: boolean
88
+ - id: no-inline-style-for-spacing
89
+ level: must-not
90
+ statement: 'Card elements carry no `style` attribute setting padding or border-radius. Card has no `padding` or `radius` props; spacing comes from `density`.'
91
+ example:
92
+ title: How to satisfy this
93
+ description: Inspect the Card element's props in the component tree and confirm no style prop is present with padding or border-radius values. Use the density prop to control padding and border-radius through the design token scale.
94
+ checks:
95
+ - href: ../evals/cases.yaml
96
+ role: agent-test
97
+ checkedBy: assisted
98
+ $extensions:
99
+ io.jev:
100
+ type: boolean
101
+ - id: no-layout-props
102
+ level: must-not
103
+ statement: Don't pass layout props to Card. It takes density and tone for its look, and rejects padding, radius, border, shadow, gap, flex, width, height, position, and overflow props with a TypeScript error. Put layout sizing on a Box or Flex around the Card.
104
+ - kind: guidelines
105
+ for: agent
106
+ framing: how-to-use
107
+ items:
108
+ - level: must
109
+ statement: Use Card's `density` prop as the method for setting a Card's size. It handles padding and radius together. This is an intentional design decision to keep Card usage consistent
110
+ - level: must-not
111
+ statement: 'Do not put a Box inside Card to change its padding. Density is the only spacing control Card has: when no value is an exact fit, use the closest one.'
112
+
113
+ - kind: guidelines
114
+ for: all
115
+ title: Content guidelines
116
+ tags: [content]
117
+ items:
118
+ - level: should
119
+ statement: Limit card content to a single topic.
120
+ - level: should
121
+ statement: Content should be related. Split different topics into separate cards.
122
+
123
+ - kind: guidelines
124
+ for: all
125
+ title: Accessibility
126
+ tags: [accessibility]
127
+ items:
128
+ - refs:
129
+ - to: semantics#heading-levels-sequential
130
+ rel: same-as
131
+ - refs:
132
+ - to: semantics#landmark-requirements
133
+ rel: same-as
134
+ - level: should
135
+ statement: When the whole Card surface should be pressable, wrap it in PressArea. PressArea renders a native button or anchor and leaves Card to carry the visual state.
136
+ alternatives:
137
+ - to: press-area
138
+ note: The supported way to make a whole Card pressable.
139
+ - level: must-not
140
+ statement: Card has no keyboard activation, focus management, or ARIA role. Do not use `as="button"` — wrap the Card in a PressArea, which renders a native button or anchor and leaves the Card to carry the visual state. Use Button when the action needs a labelled control rather than a whole pressable surface.
141
+ alternatives:
142
+ - to: press-area
143
+ note: The supported way to make a whole Card pressable.
144
+ - kind: section
145
+ for: agent
146
+ freeform:
147
+ - title: Adding internal padding
148
+ body: |-
149
+ Use Card's `density` prop to set padding, gap, and border-radius together. Density is the primary approach — it keeps spacing on the design token scale.
150
+
151
+ ```tsx
152
+ // correct — density sets padding, gap, and border-radius
153
+ <Card density="loose">
154
+ <Heading as="h2">Title</Heading>
155
+ <Text>Body</Text>
156
+ </Card>
157
+ ```
158
+
159
+ Do not add an inner `Box` to change Card's padding, even when no density option is an exact fit. Use the closest one.
160
+
161
+ ```tsx
162
+ // wrong — an inner Box re-spaces the Card
163
+ <Card>
164
+ <Box paddingTop={2}>
165
+ <Text>Body</Text>
166
+ </Box>
167
+ </Card>
168
+
169
+ // wrong — padding is not a Card prop, so this is a TypeScript error
170
+ <Card padding={4}>
171
+ <Heading as="h2">Title</Heading>
172
+ </Card>
173
+ ```
174
+
175
+ The same applies to every other layout prop. See the no-layout-props rule in the guidelines above.
176
+ - title: density values
177
+ body: |-
178
+ Card's `density` prop sets padding, gap, and border-radius together via the design token scale. It is the primary way to control spacing inside a Card.
179
+
180
+ | Value | Padding | Description |
181
+ |-------|---------|-------------|
182
+ | `compact` | {space-3} | Tighter spacing for dense lists or sidebars |
183
+ | `regular` | {space-4} | Default. Standard spacing |
184
+ | `loose` | {space-5} | More breathing room for featured content |
185
+
186
+ Density also propagates a spacing context to nested components.
187
+
188
+ alternatives:
189
+ - to: box
190
+ note: Structural container without a visual surface
191
+ refs:
192
+ - href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=30993-2035
193
+ rel: design
194
+ role: Figma component (v5)
195
+ - to: space
196
+ rel: relates-to
197
+ - to: flex
198
+ rel: relates-to
199
+ note: Layout container without a visual surface
200
+ sourceFiles:
201
+ - platform: react
202
+ file: packages/ui/src/components/card/Card.tsx
203
+ imports:
204
+ - platform: react
205
+ code: import { Card } from '@sanity/ui'
206
+ package: '@sanity/ui'
207
+ traits:
208
+ - traitType: variant
209
+ kind: enum
210
+ id: tone
211
+ description: Semantic color of the card surface.
212
+ values:
213
+ - id: default
214
+ description: No semantic meaning — used for grouping content with lower visual emphasis.
215
+ - id: neutral
216
+ description: No semantic meaning — increased visual emphasis over default.
217
+ - id: positive
218
+ description: Success, published, healthy states.
219
+ - id: suggest
220
+ description: Suggestions, recommendations, informational content.
221
+ - id: caution
222
+ description: Needs attention, in review.
223
+ - id: critical
224
+ description: Error, failed, rejected.
225
+ - traitType: variant
226
+ kind: enum
227
+ id: density
228
+ description: Composite prop setting padding, gap, and border-radius together.
229
+ values:
230
+ - id: compact
231
+ description: Padding {space-3}, radius {radius-2}. For high-density lists and table rows.
232
+ - id: regular
233
+ description: Padding {space-4}, radius {radius-3}. Default for standard content cards.
234
+ - id: loose
235
+ description: Padding {space-5}, radius {radius-4}. For low-density or featured cards.
236
+ $extensions:
237
+ com.sanity.ui:
238
+ implementationStatus:
239
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
240
+ implemented: true
241
+ migrationGuide:
242
+ context: 'Migration guide for this component, covering the codemod and the changes it cannot make. Held as an extension because it is temporary: migration tooling and porting agents read it, and it should be dropped when Sanity UI 3 support ends.'
243
+ codemod: |-
244
+ Card no longer inherits Box's full prop set — it accepts only `density`, `tone`, `margin*`, and `as`. `density` replaces `padding`+`radius`; other layout props (`flexGrow`, `width`, `overflow`, `position`, etc.) are TypeScript errors when passed directly. `tone=`"muted"`/`"transparent"` no longer exist — use `"neutral"`.
245
+
246
+ Run the codemod: `pnpx @sanity/ui-codemod latest:card --paths <paths> --toPackage @sanity/ui`. Run the Box codemod first — this codemod converts non-conforming Cards to Box.
247
+ guidance: |-
248
+ Card in the new system is a focused visual surface. It no longer extends Box.
249
+
250
+ ### Key differences
251
+
252
+ - v5 components use CSS classes with a static stylesheet as opposed to `styled-components`.
253
+ - Card no longer inherits all Box props (padding, margin, overflow, flex, grid). The new Card accepts only `density`, `tone`, `margin*`, and `as`.
254
+ - `density` replaces `padding` \+ `radius`. Instead of setting padding and radius separately, choose `'compact'` ({space-3} padding, {radius-2} radius), `'regular'` ({space-4}, {radius-3}), or `'loose'` ({space-5}, {radius-4}).
255
+ - Layout props are rejected by the type checker. `flexGrow`, `width`, `overflow`, `position`, and every other layout prop fail to compile on Card. Wrap Card in a Box or Flex.
256
+ - `tone` values have changed. There is no `'muted'` or `'transparent'` tone. Use `'default'` for the base tone. Available: `'default'`, `'neutral'`, `'positive'`, `'suggest'`, `'caution'`, `'critical'`.
257
+ - No `scheme` prop. Dark mode inversion is no longer done at the Card level.
258
+ - No `border`, `shadow`, `muted`, `pressed`, `selected` props. Card has been changed to be more focused and purpose-built.
259
+
260
+ ### Removed props (no longer accepted on Card)
261
+
262
+ | v3 prop | v5 prop | Notes |
263
+ | :---- | :---- | :---- |
264
+ | `padding` | –– | Removed. Use `density` (couples padding \+ radius). Pick the closest density; do not nest a Box inside Card to recreate a v3 padding value. |
265
+ | `radius` | –– | Removed. Use `density` (couples padding \+ radius). |
266
+ | `shadow` | –– | Removed. Use `tone` for surface treatment. |
267
+ | `border` | –– | Removed. Always rendered. Cannot be opted out of. |
268
+ | `scheme` | –– | Removed. Use `tone` instead. |
269
+
270
+ ### `density` scale
271
+
272
+ | Density | Padding | Radius |
273
+ | :---- | :---- | :---- |
274
+ | `compact` | {space-3} | {radius-2} |
275
+ | `regular` | {space-4} | {radius-3} |
276
+ | `loose` | {space-5} | {radius-4} |
277
+
278
+ ### Detailed list of differences
279
+
280
+ | v3 prop | v5 prop | Notes |
281
+ | :---- | :---- | :---- |
282
+ | `padding={3}` | `density="compact"` | Card no longer accepts individual `padding` or `radius` props. Use `density` (`'compact'`, `'regular'`, `'loose'`). |
283
+ | `radius={2}` | `density="compact"` | Coupled with padding into `density`. |
284
+ | `shadow={1}` | — | Removed. Card has no `shadow` prop. |
285
+ | `border` | — | Removed as a prop. Card always renders a 1px border via CSS. |
286
+ | `borderTop`, `borderRight`, etc. | — | Removed. Card has no individual border-side props. |
287
+ | `scheme="dark"` | — | Removed. |
288
+ | `muted` | — | Removed. |
289
+ | `pressed` | — | Removed. Card is not interactive. |
290
+ | `selected` | — | Removed. Card is not interactive. |
291
+ | All Box layout props | — | Removed. Card no longer extends Box. Wrap in Box or Flex for layout control. |
292
+ | — | `density` | New. Composite prop for padding \+ border-radius (`'compact'`, `'regular'`, `'loose'`). |
293
+ | — | `display` | New. `'block'`, `'inline-block'`, `'none'`. |
294
+
295
+ ### Breaking changes
296
+
297
+ - Card no longer extends Box. Wrap it in a Box or Flex for layout control.
298
+ - `padding` and `radius` props removed. `<Card padding={3}>` and `<Card radius={2}>` fail to compile. Use `density` (`'compact'`, `'regular'`, `'loose'`).
299
+ - `tone="inherit"` removed. Card no longer inherits tone from a parent context.
300
+ - `scheme` prop removed. `<Card scheme="dark">` fails to compile.
301
+ - `shadow` prop removed. `<Card shadow={1}>` fails to compile.
302
+ - `border` prop removed. `<Card border>` fails to compile. Card always renders a 1px border. Border color is controlled by `tone`.
303
+ - `borderTop`, `borderRight`, `borderBottom`, `borderLeft` removed. Individual border-side props are not available.
304
+ - `muted`, `pressed`, `selected` props removed. Card is no longer interactive. Passing any of them is a TypeScript error.
305
+ - `styled-components` no longer used. Custom styled-components extensions like `styled(Card)` will not work.
306
+
307
+ ### Codemod
308
+
309
+ A codemod is available to make the changes above less painful. Run the command below with the path to the file or directory you want to migrate. Pass a space-delimited list for multiple paths.
310
+
311
+ ```
312
+ pnpx @sanity/ui-codemod latest:card --paths <paths> --toPackage @sanity/ui
313
+ ```
314
+
315
+ Some components may need manual review. When a component cannot be migrated or has unclear changes, the codemod adds a “UI-POC-CODEMOD TODO” comment.
316
+
317
+ For the best results, run the Box codemod first. One caveat: this codemod will transform Cards that don’t match the updated styling (padding, radius, and border) to Box. Double-check any UI that follows the Card usage guidelines and should not be converted.