@sanity/ui 5.0.0-alpha.21 → 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 (128) 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 +6 -3
  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/css/classes/system/shadow.css +45 -0
  128. package/src/version.ts +2 -2
@@ -0,0 +1,78 @@
1
+ kind: component
2
+ id: avatar-counter
3
+ name: AvatarCounter
4
+ description: A counter to display the number of people or agents in a group.
5
+ metadata:
6
+ tags: [avatar, counter, count, overflow, more, users, avatarcounter]
7
+ status:
8
+ status: beta
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 show how many more people there are, next to avatars laid out without AvatarStack.
17
+ - level: should-not
18
+ statement: Inside AvatarStack. Use its `maxLength` prop, which adds the count for you.
19
+ alternatives:
20
+ - to: avatar-stack
21
+ - level: should-not
22
+ statement: For counts that are not people or agents. Use Badge instead.
23
+ alternatives:
24
+ - to: badge
25
+ - kind: guidelines
26
+ for: all
27
+ framing: how-to-use
28
+ items:
29
+ - level: must
30
+ statement: Pass only the number of hidden people as `count`. AvatarCounter shows the number as is, with no "+".
31
+ - level: should
32
+ statement: Match the `size` of the avatars next to it.
33
+ - level: should
34
+ statement: Make the full list of people available, for example in a Popover.
35
+ - kind: guidelines
36
+ for: agent
37
+ framing: how-to-use
38
+ items:
39
+ - level: must-not
40
+ statement: Don't add AvatarCounter as a child of AvatarStack. Set `maxLength` on the stack instead.
41
+ - kind: guidelines
42
+ for: all
43
+ title: Accessibility
44
+ tags: [accessibility]
45
+ items:
46
+ - level: should
47
+ statement: '**Say what the number counts.** Without an `aria-label`, screen readers announce AvatarCounter as "+ 3 more". Set one that names the people, such as "3 more reviewers".'
48
+ alternatives:
49
+ - to: avatar-stack
50
+ - to: badge
51
+ refs:
52
+ - to: avatar
53
+ rel: relates-to
54
+ note: The single person or agent the count stands in for
55
+ sourceFiles:
56
+ - platform: react
57
+ file: packages/ui/src/components/avatar-counter/AvatarCounter.tsx
58
+ imports:
59
+ - platform: react
60
+ code: import { AvatarCounter } from '@sanity/ui'
61
+ package: '@sanity/ui'
62
+ traits:
63
+ - traitType: variant
64
+ kind: enum
65
+ id: size
66
+ description: Height and number size. Matches Avatar's sizes. Not responsive.
67
+ values:
68
+ - id: '0'
69
+ description: Smallest.
70
+ - id: '1'
71
+ description: Small (default).
72
+ - id: '2'
73
+ description: Medium.
74
+ $extensions:
75
+ com.sanity.ui:
76
+ implementationStatus:
77
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
78
+ implemented: true
@@ -0,0 +1,96 @@
1
+ kind: component
2
+ id: avatar-stack
3
+ name: AvatarStack
4
+ description: A visual representation of multiple people and/or agents. When there are more children than maxLength, it shows the rest as a count.
5
+ metadata:
6
+ tags: [avatar, group, users, collaborators, stack, avatarstack, team, cohort]
7
+ status:
8
+ status: beta
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 represent user groups or cohorts.
17
+ - level: should
18
+ statement: To disclose the group of people an action will impact.
19
+ - level: should-not
20
+ statement: To represent a group that doesn't consist of Sanity accounts.
21
+ - level: should-not
22
+ statement: To represent a single person or agent. Use Avatar instead.
23
+ alternatives:
24
+ - to: avatar
25
+ - kind: guidelines
26
+ for: all
27
+ framing: how-to-use
28
+ items:
29
+ - level: must
30
+ statement: Put the people who matter most last in `children`. With `maxLength`, AvatarStack shows the last children and counts the rest.
31
+ - level: should
32
+ statement: 'Sort children logically: by most recently shared or last edited. If no sort logic exists, show the active user first.'
33
+ - level: should
34
+ statement: When not all Avatars are visible, make the full list available as a Popover through user interaction.
35
+ - level: must-not
36
+ statement: Don't set `size` on each Avatar inside AvatarStack. Use the stack's `size` prop. It overrides the size of every child.
37
+ - level: must-not
38
+ statement: Don't add an AvatarCounter yourself. Use the `maxLength` prop.
39
+ alternatives:
40
+ - to: avatar-counter
41
+ - level: must-not
42
+ statement: Don't put anything but Avatar inside AvatarStack.
43
+ - level: must-not
44
+ statement: Don't use as an inline element within a block of text.
45
+ - kind: guidelines
46
+ for: agent
47
+ framing: how-to-use
48
+ items:
49
+ - level: must
50
+ statement: Use `maxLength` to truncate overflow, not a manually added AvatarCounter.
51
+ - level: must-not
52
+ statement: Do not use for non-Sanity entities or groups of apps.
53
+ - kind: guidelines
54
+ for: all
55
+ title: Accessibility
56
+ tags: [accessibility]
57
+ items:
58
+ - level: should
59
+ statement: '**AvatarStack is a list.** It renders a `ul`, with each Avatar in an `li`. Screen readers announce how many people it holds.'
60
+ - level: should
61
+ statement: '**Each Avatar still needs its own `aria-label`.** Stacking Avatars does not change the rules in the Avatar doc. Name each one the way you would a standalone Avatar.'
62
+ - level: should
63
+ statement: '**AvatarStack names the overflow count.** It labels the count, for example "+ 3 more users". With no children it shows 0, labelled "No users".'
64
+ alternatives:
65
+ - to: avatar
66
+ refs:
67
+ - href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=19505-3527
68
+ rel: design
69
+ role: Figma component
70
+ - to: avatar-counter
71
+ rel: relates-to
72
+ note: The count AvatarStack shows when it truncates its children
73
+ sourceFiles:
74
+ - platform: react
75
+ file: packages/ui/src/components/avatar-stack/AvatarStack.tsx
76
+ imports:
77
+ - platform: react
78
+ code: import { AvatarStack } from '@sanity/ui'
79
+ package: '@sanity/ui'
80
+ traits:
81
+ - traitType: variant
82
+ kind: enum
83
+ id: size
84
+ description: Size applied to every Avatar child and the overflow count.
85
+ values:
86
+ - id: '0'
87
+ description: Smallest. For metadata or high-density layouts.
88
+ - id: '1'
89
+ description: Small (default).
90
+ - id: '2'
91
+ description: Medium. When a group is the focus of an element.
92
+ $extensions:
93
+ com.sanity.ui:
94
+ implementationStatus:
95
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
96
+ implemented: true
@@ -0,0 +1,115 @@
1
+ kind: component
2
+ id: avatar
3
+ name: Avatar
4
+ description: A visual representation of a person or agent.
5
+ metadata:
6
+ tags: [avatar, user, profile, image, identity, person, agent, name, photo]
7
+ status:
8
+ status: beta
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: As a way to access a profile (either human or agent).
17
+ - level: should
18
+ statement: To disclose a user or agent associated with content or permissions.
19
+ - level: should-not
20
+ statement: To represent a person or bot that doesn't represent a Sanity user.
21
+ - level: must-not
22
+ statement: To represent an app or studio instance.
23
+ - level: must-not
24
+ statement: To represent a group of people and/or bots. Use AvatarStack instead.
25
+ alternatives:
26
+ - to: avatar-stack
27
+ - kind: guidelines
28
+ for: all
29
+ framing: how-to-use
30
+ items:
31
+ - level: must
32
+ statement: 'Pass the full name of the person or agent as `name`. It is required. Avatar has no `initials` prop: it shows the first letter of `name` as its fallback, so passing `initials` is a TypeScript error.'
33
+ - level: must
34
+ statement: Pass `src` when you have an image. If the image is missing or fails to load, Avatar shows the first letter of `name` instead.
35
+ - level: should
36
+ statement: When space permits, display the full name of the person or agent next to Avatar.
37
+ - level: should
38
+ statement: When space is not available, still give the full name as text, for example with VisuallyHidden next to the Avatar. If the name must appear in a Tooltip, wrap Avatar in PressArea for Tooltip to target.
39
+ - level: should
40
+ statement: Rotate `color` values when more than one Avatar is visible at a time.
41
+ - level: must-not
42
+ statement: Don't use as an inline element within a block of text.
43
+ - kind: guidelines
44
+ for: agent
45
+ framing: how-to-use
46
+ items:
47
+ - level: must-not
48
+ statement: 'Using Avatar as an inline element within a paragraph. Instead: Use Avatar in layout containers (Flex, HStack) separate from running text.'
49
+ - level: must-not
50
+ statement: Don't set Avatar's size with `style`, `className` or `height`. Use the `size` prop.
51
+ - level: must-not
52
+ statement: Don't pass a single letter as `name`. The fallback shows the first letter of `name`, and a letter alone does not name the person for assistive technology.
53
+ - kind: guidelines
54
+ for: all
55
+ title: Accessibility
56
+ tags: [accessibility]
57
+ items:
58
+ - level: should
59
+ statement: "**The accessible name is `aria-label`, or `name` when there is no `aria-label`.** Avatar uses it as the image's `alt` text, and as the label of the letter fallback. Pass the full name in `name`, and set `aria-label` only when the name needs different wording for assistive technology."
60
+ - level: should
61
+ statement: '**Hidden when the name is already announced elsewhere.** The surrounding row, option or button may already state the name. Set `aria-hidden` on the Avatar, which Avatar passes through to its element. Screen readers then skip the repeated name.'
62
+ alternatives:
63
+ - to: avatar-stack
64
+ refs:
65
+ - href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=25-320
66
+ rel: design
67
+ role: Figma component
68
+ - to: avatar-counter
69
+ rel: relates-to
70
+ note: The overflow count AvatarStack shows next to its avatars
71
+ sourceFiles:
72
+ - platform: react
73
+ file: packages/ui/src/components/avatar/Avatar.tsx
74
+ imports:
75
+ - platform: react
76
+ code: import { Avatar } from '@sanity/ui'
77
+ package: '@sanity/ui'
78
+ traits:
79
+ - traitType: variant
80
+ kind: enum
81
+ id: size
82
+ description: Height and letter size of the avatar. Responsive.
83
+ values:
84
+ - id: '0'
85
+ description: Smallest. For metadata or high-density layouts.
86
+ - id: '1'
87
+ description: Small (default), 25px tall. For UI labels, buttons, menu items and toast messages.
88
+ - id: '2'
89
+ description: Medium. When a user is the focus of an element.
90
+ - traitType: variant
91
+ kind: enum
92
+ id: color
93
+ description: Background color behind the letter.
94
+ values:
95
+ - id: gray
96
+ description: Gray (default).
97
+ - id: purple
98
+ description: Purple.
99
+ - id: magenta
100
+ description: Magenta.
101
+ - id: red
102
+ description: Red.
103
+ - id: orange
104
+ description: Orange.
105
+ - id: yellow
106
+ description: Yellow.
107
+ - id: green
108
+ description: Green.
109
+ - id: cyan
110
+ description: Cyan.
111
+ $extensions:
112
+ com.sanity.ui:
113
+ implementationStatus:
114
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
115
+ implemented: true
@@ -0,0 +1,126 @@
1
+ kind: component
2
+ id: badge
3
+ name: Badge
4
+ description: A label used to communicate status, category, count, or other metadata inline.
5
+ metadata:
6
+ tags: [badge, status, label, tag, count, indicator, chip, published, draft]
7
+ status:
8
+ status: beta
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: Communicating status (Published, Draft, Deprecated, In Review).
17
+ - level: should
18
+ statement: Labeling categories, tags, or types inline within a list or table.
19
+ - level: should
20
+ statement: Showing counts or numeric indicators.
21
+ - level: should-not
22
+ statement: For actions — use Button instead.
23
+ alternatives:
24
+ - to: button
25
+ - level: should-not
26
+ statement: For long text. Badges are for scanning, not reading.
27
+ - kind: guidelines
28
+ for: agent
29
+ framing: when-to-use
30
+ title: When to use
31
+ items:
32
+ - level: should-not
33
+ statement: Don't use Badge for inline status prose. Use Text with a tone instead.
34
+ alternatives:
35
+ - to: text
36
+ - kind: guidelines
37
+ for: all
38
+ framing: how-to-use
39
+ items:
40
+ - level: must
41
+ statement: 'A toned Badge''s `text` leads with the state, such as "Error" or "Warning: expires soon", or the Badge carries an `iconStart` that reinforces it. Text that describes the item instead, such as "Failed" or "Timed out", needs the icon.'
42
+ refines:
43
+ - to: shared-foundations#tone-paired-with-second-channel
44
+ - level: should
45
+ statement: Use `text` as the primary way to add a Badge label. `children` should only be used in rares cases where internal text needs specific styling.
46
+ - refs:
47
+ - to: content-guidelines#label-length-by-element
48
+ rel: same-as
49
+ - level: should
50
+ statement: Use tone='neutral' for plain metadata and a semantic tone (positive, suggest, caution, critical) for status.
51
+ refines:
52
+ - to: shared-foundations#tone-signals-state
53
+ - level: should
54
+ statement: Use the iconStart prop for a leading icon. Don't nest an Icon as a child — iconStart sizes and aligns it against the badge's own padding automatically.
55
+ - level: should-not
56
+ statement: Don't place more than 3 badges in a single row. Group related statuses or use a table for dense data.
57
+ - level: must-not
58
+ statement: Don't use Badge for actions. Use Button instead.
59
+ alternatives:
60
+ - to: button
61
+ - id: badge-no-emojis
62
+ level: must-not
63
+ statement: Never put an emoji in a Badge's `text` or `children`. If the badge needs a symbol, use `iconStart` instead..
64
+ checks:
65
+ - href: ../evals/cases.yaml
66
+ role: agent-test
67
+ checkedBy: assisted
68
+ refines:
69
+ - to: shared-foundations#no-emojis
70
+ $extensions:
71
+ io.jev:
72
+ type: boolean
73
+ - kind: guidelines
74
+ for: agent
75
+ framing: how-to-use
76
+ items:
77
+ - level: should-not
78
+ statement: Don't use `children` to add text to Badge unless it is critical to add custom styling. Use the `text` prop instead.
79
+ - level: must-not
80
+ statement: Never place an icon within Badge within `children`. `iconStart` is used for adding icons.
81
+ - level: must-not
82
+ statement: 'Using Badge as a clickable element without keyboard handling. Instead: Use Button for any interactive control.'
83
+ - kind: guidelines
84
+ for: all
85
+ title: Accessibility
86
+ tags: [accessibility]
87
+ items:
88
+ - level: should
89
+ statement: '**Badge is not an icon-plus-count control.** When Badge shows a bare count next to another icon (a comment icon with a "3" badge), the icon still needs its own alternative — Badge''s visible number does not substitute for it. See the Accessibility foundation''s icon-and-value rule.'
90
+ - level: should
91
+ statement: '**Not a substitute for `aria-selected` or `aria-current`.** Badge conveys status inline; it does not set any ARIA state on a parent row. If the badge marks the current or selected item in a list, add `aria-current` or `aria-selected` on the row itself.'
92
+ alternatives:
93
+ - to: button
94
+ - to: text
95
+ refs:
96
+ - href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32275-2381
97
+ rel: design
98
+ role: Figma component (v5)
99
+ sourceFiles:
100
+ - platform: react
101
+ file: packages/ui/src/components/badge/Badge.tsx
102
+ imports:
103
+ - platform: react
104
+ code: import { Badge } from '@sanity/ui'
105
+ package: '@sanity/ui'
106
+ traits:
107
+ - traitType: variant
108
+ kind: enum
109
+ id: tone
110
+ description: Semantic color of the badge.
111
+ values:
112
+ - id: neutral
113
+ description: Gray. Default. No semantic meaning.
114
+ - id: positive
115
+ description: Green. Success, published, healthy.
116
+ - id: suggest
117
+ description: Purple. Educational moments, promotions, soft nudges.
118
+ - id: caution
119
+ description: Yellow/amber. Needs attention, in review.
120
+ - id: critical
121
+ description: Red. Error, failed, rejected, deprecated.
122
+ $extensions:
123
+ com.sanity.ui:
124
+ implementationStatus:
125
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
126
+ implemented: true
@@ -0,0 +1,223 @@
1
+ kind: component
2
+ id: box
3
+ name: Box
4
+ description: The lowest-level building block for containing UI elements. Provides spacing, borders, shadows, and semantic tone without adding flex or grid layout behavior.
5
+ metadata:
6
+ tags: [layout, container, spacing, structure, box, div, wrapper, padding, margin]
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: As a container for child elements.
17
+ - level: should
18
+ statement: To apply padding or margin to a group of elements.
19
+ - level: should
20
+ statement: To create basic visual styling (background, border, shadow) when composing a custom component.
21
+ - level: should-not
22
+ statement: As an interactive element. Box is not intended to act as a button.
23
+ alternatives:
24
+ - to: button
25
+ - level: should-not
26
+ statement: As a way to stack or align child elements. Use Flex, VStack, or HStack instead.
27
+ alternatives:
28
+ - to: flex
29
+ - to: v-stack
30
+ - to: h-stack
31
+ - level: should-not
32
+ statement: 'When you want display: flex. Use Flex instead.'
33
+ alternatives:
34
+ - to: flex
35
+ - level: should-not
36
+ statement: As a way to display children in a grid layout. Use Grid instead.
37
+ alternatives:
38
+ - to: grid
39
+ - level: should-not
40
+ statement: To center content at a max width. Use Container instead.
41
+ alternatives:
42
+ - to: container
43
+ - kind: guidelines
44
+ for: agent
45
+ framing: when-to-use
46
+ title: When to use
47
+ items:
48
+ - level: should-not
49
+ statement: Don't use Box for content surfaces with a distinct visual surface (background + border). Use Card instead.
50
+ alternatives:
51
+ - to: card
52
+ - kind: guidelines
53
+ for: all
54
+ framing: how-to-use
55
+ items:
56
+ - refs:
57
+ - to: api-essentials#sizing-is-a-css-string
58
+ rel: same-as
59
+ - id: box-styling-props-over-inline-styles
60
+ level: should
61
+ statement: Use Box's styling props (tone, padding, width, and similar) to adjust visual appearance rather than inline styles — every visual style Box supports through a prop is set through that prop, not the style attribute.
62
+ example:
63
+ title: How to satisfy this
64
+ description: Review the rendered JSX and confirm no style={{ }} attribute contains a value covered by a Box prop. Check that tone, padding, paddingX, paddingY, width, and related props are used directly on the Box element.
65
+ checkedBy: manual
66
+ - id: box-padding-preferred-over-margin
67
+ level: should
68
+ statement: Use padding over margin when possible — padding keeps spacing inside the component's own box, so internal spacing on a Box should use the padding prop rather than margin.
69
+ example:
70
+ title: How to satisfy this
71
+ description: Review Box usages where spacing is added to the element itself and confirm padding is used. Confirm margin is only present when external spacing between sibling elements is genuinely needed.
72
+ checkedBy: manual
73
+ - refs:
74
+ - to: shared-foundations#layout-primitive-no-text-styles
75
+ rel: same-as
76
+ tags: [content]
77
+ - id: box-no-as-button
78
+ level: must-not
79
+ statement: 'Never use as=''button''. Box does not reset browser defaults for button elements, and it does not fulfill the keyboard and ARIA contract a button requires. No Box element in the codebase should have as=''button'' or as="button" set. Use the Button component instead.'
80
+ example:
81
+ title: How to satisfy this
82
+ description: Search the file or component for as='button' or as="button" on any Box element. Replace any found instances with the Button component.
83
+ alternatives:
84
+ - to: button
85
+ checkedBy: manual
86
+ - id: box-no-inline-flex-styles
87
+ level: must-not
88
+ statement: "Don't use inline styles to apply flex layout to Box — no Box element should use style={{ display: 'flex' }} or a similar inline style. Wrap the content in a Flex component instead."
89
+ example:
90
+ title: How to satisfy this
91
+ description: "Review all Box usages and confirm none have style={{ display: 'flex' }} or style={{ display: 'inline-flex' }}. Replace any found instances by wrapping the content in a Flex component instead."
92
+ alternatives:
93
+ - to: flex
94
+ checkedBy: manual
95
+ - id: box-no-style-prop-for-supported-attrs
96
+ level: must-not
97
+ statement: Don't use the style prop for attributes that have a matching Box prop (width, height, borderRadius, background, and similar) — no Box element should set these through style.
98
+ example:
99
+ title: How to satisfy this
100
+ description: Inspect the style attribute on each Box element and verify none of its keys correspond to a prop Box exposes (width, height, borderRadius, background, padding, margin, etc.). Move any such values from style={{ }} to the equivalent Box prop.
101
+ checkedBy: manual
102
+ - id: box-no-display-grid-or-flex
103
+ level: must-not
104
+ statement: Do not pass display='grid' or display='flex' as a Box prop, and don't set display='inline-grid' or display='inline-flex' either — Box.display only accepts "none" | "block" | "inline-block". Use <Grid> for grid layouts and <Flex> for flex layouts.
105
+ example:
106
+ title: How to satisfy this
107
+ description: Search for display='grid' or display='flex' on Box elements. Replace <Box display='grid'> with <Grid> and <Box display='flex'> with <Flex>.
108
+ checkedBy: manual
109
+ - kind: guidelines
110
+ for: agent
111
+ framing: how-to-use
112
+ items:
113
+ - level: must-not
114
+ statement: "Box has no `backgroundColor` prop. Do not pass `style={{backgroundColor: '...'}}`. For semantic surface colors use `tone` on Box or on a wrapping Card."
115
+ - level: must-not
116
+ statement: "Box has no `borderColor` prop. The `borderTop`, `borderRight`, `borderBottom`, `borderLeft`, and `border` boolean props apply the design-system border token in the current tone color — they do not accept a custom color value. Do not add `style={{borderColor: '...'}}`. For colored borders, use `tone` on a parent Card instead."
117
+ - level: must-not
118
+ statement: Box has no `textAlign` prop. To align text, use the `align` prop on `Text` or `Heading` directly.
119
+ - level: must-not
120
+ statement: "Box has no `borderRadius` prop. Use the `radius` prop instead (integer 0–6 or `'full'`). Do not pass `style={{borderRadius: ...}}`."
121
+ - level: must-not
122
+ statement: 'Adding onClick to a Box to make it interactive. Instead: Use Button for interactive actions.'
123
+ - kind: guidelines
124
+ for: all
125
+ title: Accessibility
126
+ tags: [accessibility]
127
+ items:
128
+ - refs:
129
+ - to: semantics#landmark-requirements
130
+ rel: same-as
131
+ - level: should
132
+ statement: Box spacing comes from the spacing tokens, which scale with browser zoom. Content inside Box must reflow at 320px viewport width without horizontal scrolling (WCAG 1.4.10 AA).
133
+ - refs:
134
+ - to: shared-foundations#layout-primitive-as-not-behavioral
135
+ rel: same-as
136
+ - level: must-not
137
+ statement: Do not use `as` to render `<ul>` or `<ol>`. Use VStack instead.
138
+ alternatives:
139
+ - to: v-stack
140
+ - level: must-not
141
+ statement: Do not use CSS `order` or grid placement on Box children to reorder them from source order. Screen readers and keyboard navigation follow DOM order, not visual order (WCAG 1.3.2 A).
142
+
143
+ alternatives:
144
+ - to: flex
145
+ note: Row or column layout with alignment and gap
146
+ - to: card
147
+ note: Adds a visual surface with background, border, and tone
148
+ - to: container
149
+ refs:
150
+ - to: space
151
+ rel: relates-to
152
+ - to: grid
153
+ rel: relates-to
154
+ note: Two-axis layout for card grids and dashboards
155
+ sourceFiles:
156
+ - platform: react
157
+ file: packages/ui/src/components/box/Box.tsx
158
+ imports:
159
+ - platform: react
160
+ code: import { Box } from '@sanity/ui'
161
+ package: '@sanity/ui'
162
+ $extensions:
163
+ com.sanity.ui:
164
+ implementationStatus:
165
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
166
+ implemented: true
167
+ migrationGuide:
168
+ 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.'
169
+ codemod: |-
170
+ Box replaces `@sanity/ui`'s Box. Breaking changes: `display` no longer accepts `'flex'`/`'grid'` (use Flex/Grid instead), the `flex` shorthand splits into `flexGrow`/`flexShrink`/`flexBasis`, `sizing` is removed, grid child props are renamed with a `grid` prefix (`column` → `gridColumn`, etc.), and `margin` no longer defaults to `0`.
171
+
172
+ Run the codemod: `pnpx @sanity/ui-codemod latest:box --paths <paths> --toPackage @sanity/ui`. If an instance can't be migrated automatically, the codemod inserts a "UI-POC-CODEMOD TODO" comment.
173
+ guidance: |-
174
+ Box in the new system replaces the `@sanity/ui` Box. The core purpose is the same — a general-purpose layout container. The API changes are:
175
+
176
+ ### Key differences
177
+
178
+ - v5 components use CSS classes with a static stylesheet as opposed to `styled-components`.
179
+ - Box no longer uses `flex` shorthand. Use `flexGrow`, `flexShrink`, and `flexBasis` as separate props.
180
+ - Grid child props renamed: `column` → `gridColumn`, `row` → `gridRow`, etc.
181
+ - Box’s `display` prop no longer accepts `'flex'` or `'grid'`. Use the Flex and Grid components.
182
+ - The new API has direct props for styling attributes such as width, height, position, and border, etc.
183
+ - v3 Box used `React.forwardRef`. The new version is a plain function component.
184
+
185
+ ### Detailed list of differences
186
+
187
+ | v3 prop | v5 prop | Notes |
188
+ | :---- | :---- | :---- |
189
+ | `display` | `display` | v3 accepted `'flex'` and `'grid'`. New Box restricts to `'block'`, `'inline-block'`, `'none'`. Use Flex or Grid for those display modes. |
190
+ | `flex={1}` | `flexGrow={1}` | v3 used a single `flex` shorthand. Split into `flexGrow`, `flexShrink`, `flexBasis`. |
191
+ | `overflow="hidden"` | `overflow="hidden"` | v3 accepted `'visible'`, `'hidden'`, `'auto'`. New adds `'scroll'` and `'clip'`. |
192
+ | `height="fill"` | `height="100%"` | v3 used named values (`'fill'`, `'stretch'`). New accepts any CSS string. |
193
+ | `sizing="border"` | — | Removed. Use CSS `box-sizing` via `style` if needed. |
194
+ | `column={2}` | `gridColumn="span 2"` | v3 used numeric shorthand. New uses CSS `grid-column` string syntax. |
195
+ | `row`, `rowStart`, `rowEnd` | `gridRow`, `gridRowStart`, `gridRowEnd` | Renamed with `grid` prefix. |
196
+ | `columnStart`, `columnEnd` | `gridColumnStart`, `gridColumnEnd` | Renamed with `grid` prefix. |
197
+ | — | `tone` | New. Sets a semantic background tint. Unset, Box has no background. Accepts `default`, `neutral`, `positive`, `suggest`, `caution`, and `critical`. |
198
+ | — | `width`, `minWidth`, `maxWidth` | New. Accept any CSS string value. v3 Box had no width props. |
199
+ | — | `height`, `minHeight`, `maxHeight` | New. Accept any CSS string value. |
200
+ | — | `position` | New. Accepts `'absolute'`, `'fixed'`, `'relative'`, `'static'`, `'sticky'`. |
201
+ | — | `zIndex` | New. Accepts any number. |
202
+ | — | `border`, `borderTop`, etc. | New. Boolean props for themed borders. |
203
+ | — | `radius` | New. Border-radius from the design scale (0–6, `'full'`). |
204
+
205
+ ### Breaking changes
206
+
207
+ - **`display` no longer accepts `'flex'` or `'grid'`.** Any `<Box display="flex">` or `<Box display="grid">` silently renders as `display: block`. Replace with `<Flex>` or `<Grid>`.
208
+ - **`flex` prop removed.** `<Box flex={1}>` does nothing. Replace with `<Box flexGrow={1}>`. For the full shorthand, split into `flexGrow`, `flexShrink`, and `flexBasis`.
209
+ - **`height` named values removed.** `height="fill"` and `height="stretch"` are no longer valid. Use `height="100%"` or `height="100vh"` instead.
210
+ - **`sizing` prop removed.** `<Box sizing="border">` does nothing. Use `style={{ boxSizing: 'border-box' }}` if needed.
211
+ - **Grid child props renamed.** `column`, `columnStart`, `columnEnd`, `row`, `rowStart`, `rowEnd` no longer work. Use `gridColumn`, `gridColumnStart`, `gridColumnEnd`, `gridRow`, `gridRowStart`, `gridRowEnd`.
212
+ - **`margin` no longer defaults to `0`.** v3 Box defaulted `margin` to `0`. The new Box has no margin default. If your layout relied on the implicit zero margin, add `margin={0}` directly.
213
+ - **`styled-components` no longer used.** The component uses CSS classes. Custom styled-components extensions like `styled(Box)` will not work. Use `className` and CSS instead.
214
+
215
+ ### Codemod
216
+
217
+ A codemod is available to make the changes above less painful. To get started, run the following command with the path (or space delimited list of paths) to the file or directory you want to migrate.
218
+
219
+ ```
220
+ pnpx @sanity/ui-codemod latest:box --paths <paths> --toPackage @sanity/ui
221
+ ```
222
+
223
+ If a component instance cannot be migrated, includes unclear changes, or needs manual review, the codemod inserts a comment prefixed with “UI-POC-CODEMOD TODO”.