@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.
- package/README.md +10 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/components/avatar-counter.dsds.yaml +78 -0
- package/docs/components/avatar-stack.dsds.yaml +96 -0
- package/docs/components/avatar.dsds.yaml +115 -0
- package/docs/components/badge.dsds.yaml +126 -0
- package/docs/components/box.dsds.yaml +223 -0
- package/docs/components/button.dsds.yaml +284 -0
- package/docs/components/card.dsds.yaml +317 -0
- package/docs/components/checkbox.dsds.yaml +204 -0
- package/docs/components/code.dsds.yaml +167 -0
- package/docs/components/container.dsds.yaml +189 -0
- package/docs/components/dialog.dsds.yaml +343 -0
- package/docs/components/divider.dsds.yaml +93 -0
- package/docs/components/eyebrow.dsds.yaml +217 -0
- package/docs/components/flex.dsds.yaml +237 -0
- package/docs/components/grid.dsds.yaml +217 -0
- package/docs/components/h-stack.dsds.yaml +127 -0
- package/docs/components/heading.dsds.yaml +233 -0
- package/docs/components/hotkeys.dsds.yaml +60 -0
- package/docs/components/icon-button.dsds.yaml +220 -0
- package/docs/components/icon.dsds.yaml +275 -0
- package/docs/components/indicator-stack.dsds.yaml +98 -0
- package/docs/components/indicator.dsds.yaml +108 -0
- package/docs/components/inline.dsds.yaml +127 -0
- package/docs/components/kbd.dsds.yaml +59 -0
- package/docs/components/link.dsds.yaml +108 -0
- package/docs/components/list-button-item.dsds.yaml +103 -0
- package/docs/components/list-item-image.dsds.yaml +82 -0
- package/docs/components/list-item-text.dsds.yaml +80 -0
- package/docs/components/list-item.dsds.yaml +148 -0
- package/docs/components/list.dsds.yaml +162 -0
- package/docs/components/popover.dsds.yaml +208 -0
- package/docs/components/press-area.dsds.yaml +279 -0
- package/docs/components/radio.dsds.yaml +198 -0
- package/docs/components/select.dsds.yaml +214 -0
- package/docs/components/skip-to-content.dsds.yaml +110 -0
- package/docs/components/spinner.dsds.yaml +119 -0
- package/docs/components/switch.dsds.yaml +202 -0
- package/docs/components/tab.dsds.yaml +54 -0
- package/docs/components/tabs-list.dsds.yaml +56 -0
- package/docs/components/tabs-panel.dsds.yaml +54 -0
- package/docs/components/tabs.dsds.yaml +104 -0
- package/docs/components/text-area.dsds.yaml +170 -0
- package/docs/components/text-input.dsds.yaml +189 -0
- package/docs/components/text.dsds.yaml +268 -0
- package/docs/components/tooltip-group.dsds.yaml +90 -0
- package/docs/components/tooltip.dsds.yaml +216 -0
- package/docs/components/v-stack.dsds.yaml +155 -0
- package/docs/components/visually-hidden.dsds.yaml +112 -0
- package/docs/evals/cases.yaml +1319 -0
- package/docs/examples/checkbox-2.tsx +57 -0
- package/docs/examples/confirmation-dialogs-1.tsx +27 -0
- package/docs/examples/confirmation-dialogs-2.tsx +55 -0
- package/docs/examples/confirmation-dialogs-3.tsx +28 -0
- package/docs/examples/confirmation-dialogs-4.tsx +38 -0
- package/docs/examples/popover-1.tsx +48 -0
- package/docs/examples/popover-2.tsx +53 -0
- package/docs/foundations/accessibility-guidelines.dsds.yaml +301 -0
- package/docs/foundations/color-guidelines.dsds.yaml +308 -0
- package/docs/foundations/content-guidelines.dsds.yaml +285 -0
- package/docs/foundations/semantics.dsds.yaml +125 -0
- package/docs/foundations/spacing-guidelines.dsds.yaml +226 -0
- package/docs/foundations/typography-guidelines.dsds.yaml +322 -0
- package/docs/icons.dsds.yaml +2513 -0
- package/docs/index.dsds.yaml +515 -0
- package/docs/overview/api-essentials.dsds.yaml +221 -0
- package/docs/overview/component-reference.dsds.yaml +215 -0
- package/docs/overview/designer-contribution-model.dsds.yaml +77 -0
- package/docs/overview/developer-contribution-model.dsds.yaml +362 -0
- package/docs/overview/installation.dsds.yaml +238 -0
- package/docs/overview/quick-start.dsds.yaml +317 -0
- package/docs/overview/resources.dsds.yaml +34 -0
- package/docs/patterns/confirmation-dialogs.dsds.yaml +140 -0
- package/docs/patterns/error-messaging.dsds.yaml +58 -0
- package/docs/patterns/forms.dsds.yaml +356 -0
- package/docs/patterns/layouts.dsds.yaml +403 -0
- package/docs/patterns/loading-states.dsds.yaml +41 -0
- package/docs/patterns/messaging.dsds.yaml +72 -0
- package/docs/patterns/navigation.dsds.yaml +153 -0
- package/docs/patterns/responsive.dsds.yaml +590 -0
- package/docs/tokens/color.dsds.yaml +1158 -0
- package/docs/tokens/container-widths.dsds.yaml +131 -0
- package/docs/tokens/content.dsds.yaml +258 -0
- package/docs/tokens/content.tokens.json +180 -0
- package/docs/tokens/dtcg/README.md +39 -0
- package/docs/tokens/dtcg/css/color.css +107 -0
- package/docs/tokens/dtcg/css/container.css +12 -0
- package/docs/tokens/dtcg/css/fontFamily.css +10 -0
- package/docs/tokens/dtcg/css/fontWeight.css +10 -0
- package/docs/tokens/dtcg/css/index.css +13 -0
- package/docs/tokens/dtcg/css/radius.css +14 -0
- package/docs/tokens/dtcg/css/semantic.css +42 -0
- package/docs/tokens/dtcg/css/shadow.css +22 -0
- package/docs/tokens/dtcg/css/space.css +16 -0
- package/docs/tokens/dtcg/css/typography.css +69 -0
- package/docs/tokens/dtcg/json/color.tokens.json +911 -0
- package/docs/tokens/dtcg/json/container.tokens.json +44 -0
- package/docs/tokens/dtcg/json/fontFamily.tokens.json +10 -0
- package/docs/tokens/dtcg/json/fontWeight.tokens.json +18 -0
- package/docs/tokens/dtcg/json/radius.tokens.json +58 -0
- package/docs/tokens/dtcg/json/semantic.tokens.json +372 -0
- package/docs/tokens/dtcg/json/shadow.tokens.json +599 -0
- package/docs/tokens/dtcg/json/space.tokens.json +72 -0
- package/docs/tokens/dtcg/json/typography.tokens.json +354 -0
- package/docs/tokens/font-family.dsds.yaml +79 -0
- package/docs/tokens/font-weight.dsds.yaml +103 -0
- package/docs/tokens/radius.dsds.yaml +153 -0
- package/docs/tokens/semantic.dsds.yaml +397 -0
- package/docs/tokens/shadow.dsds.yaml +125 -0
- package/docs/tokens/space.dsds.yaml +185 -0
- package/docs/tokens/typography.dsds.yaml +316 -0
- package/llms.txt +108 -0
- package/package.json +5 -2
- package/skills/sanity-ui-5/SKILL.md +158 -0
- package/skills/sanity-ui-5/references/component-choice.md +37 -0
- package/skills/sanity-ui-5/references/components.md +145 -0
- package/skills/sanity-ui-5/references/forms-and-accessibility.md +189 -0
- package/skills/sanity-ui-5/references/migrating-from-v3.md +250 -0
- package/skills/sanity-ui-5/references/props-and-imports.md +169 -0
- package/skills/sanity-ui-5/references/setup.md +177 -0
- package/skills/sanity-ui-5/references/silent-failures.md +33 -0
- package/skills/sanity-ui-5/references/taste.md +53 -0
- package/skills/sanity-ui-5/references/tone-and-color.md +55 -0
- package/src/version.ts +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: tab
|
|
3
|
+
name: Tabs.Tab
|
|
4
|
+
description: A button that selects one Tabs.Panel. Use it inside Tabs.List.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [tabs, tablist, tabpanel, navigation, views, tab, sections]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: how-to-use
|
|
13
|
+
items:
|
|
14
|
+
- level: must
|
|
15
|
+
statement: When `tone` is not set to neutral, use the `icon` prop to visually reinforce the state of a tab.
|
|
16
|
+
- level: should
|
|
17
|
+
statement: Keep tab labels short, 1 to 3 words.
|
|
18
|
+
- level: should-not
|
|
19
|
+
statement: Don't use icon unless it's necessary to communicate the content related to that tab. Tabs.Tab renders icon before label.
|
|
20
|
+
- level: must-not
|
|
21
|
+
statement: Don't use tone for decorative purposes. tone must only communicate an important state related to the content it reveals.
|
|
22
|
+
- kind: guidelines
|
|
23
|
+
for: agent
|
|
24
|
+
framing: how-to-use
|
|
25
|
+
items:
|
|
26
|
+
- level: must-not
|
|
27
|
+
statement: Don't set id or aria-controls on Tabs.Tab. It builds both from value.
|
|
28
|
+
|
|
29
|
+
refs:
|
|
30
|
+
- to: tabs
|
|
31
|
+
rel: relates-to
|
|
32
|
+
note: The family this tab belongs to.
|
|
33
|
+
- to: tabs-list
|
|
34
|
+
rel: relates-to
|
|
35
|
+
note: Holds the Tabs.Tab buttons in a row.
|
|
36
|
+
- to: tabs-panel
|
|
37
|
+
rel: relates-to
|
|
38
|
+
note: The content this tab selects.
|
|
39
|
+
- href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=23902-5282
|
|
40
|
+
rel: design
|
|
41
|
+
role: Figma component
|
|
42
|
+
|
|
43
|
+
sourceFiles:
|
|
44
|
+
- platform: react
|
|
45
|
+
file: packages/ui/src/components/tabs/Tabs.tsx
|
|
46
|
+
imports:
|
|
47
|
+
- platform: react
|
|
48
|
+
code: import { Tabs } from '@sanity/ui'
|
|
49
|
+
package: '@sanity/ui'
|
|
50
|
+
$extensions:
|
|
51
|
+
com.sanity.ui:
|
|
52
|
+
implementationStatus:
|
|
53
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
54
|
+
implemented: true
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: tabs-list
|
|
3
|
+
name: Tabs.List
|
|
4
|
+
description: The row that holds the Tabs.Tab buttons. It renders with role="tablist", lays its tabs out in a row, and moves focus between them with the arrow keys.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [tabs, tablist, tabpanel, navigation, views, tab, sections]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: how-to-use
|
|
13
|
+
items:
|
|
14
|
+
- id: pre-select-default-tab-user
|
|
15
|
+
level: must
|
|
16
|
+
statement: Set Tabs value to one of the Tab values. This shows a panel on first render.
|
|
17
|
+
- level: must
|
|
18
|
+
statement: Show at least 2 tabs. A single tab provides no benefit.
|
|
19
|
+
- level: must-not
|
|
20
|
+
statement: Don't use more than 10 tabs. If more are needed, consider breaking the page up into smaller separate pages.
|
|
21
|
+
- level: must-not
|
|
22
|
+
statement: Don't pass onKeyDown to Tabs.List. The component ignores it and uses its own arrow-key handler.
|
|
23
|
+
- kind: guidelines
|
|
24
|
+
for: all
|
|
25
|
+
title: Accessibility
|
|
26
|
+
tags: [accessibility]
|
|
27
|
+
items:
|
|
28
|
+
- level: must
|
|
29
|
+
statement: Give Tabs.List an aria-label or aria-labelledby. The type requires one of them.
|
|
30
|
+
|
|
31
|
+
refs:
|
|
32
|
+
- to: tabs
|
|
33
|
+
rel: relates-to
|
|
34
|
+
note: The family this list belongs to.
|
|
35
|
+
- to: tab
|
|
36
|
+
rel: relates-to
|
|
37
|
+
note: The buttons this list holds.
|
|
38
|
+
- to: tabs-panel
|
|
39
|
+
rel: relates-to
|
|
40
|
+
note: The content each tab selects.
|
|
41
|
+
- href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=23902-5282
|
|
42
|
+
rel: design
|
|
43
|
+
role: Figma component
|
|
44
|
+
|
|
45
|
+
sourceFiles:
|
|
46
|
+
- platform: react
|
|
47
|
+
file: packages/ui/src/components/tabs/Tabs.tsx
|
|
48
|
+
imports:
|
|
49
|
+
- platform: react
|
|
50
|
+
code: import { Tabs } from '@sanity/ui'
|
|
51
|
+
package: '@sanity/ui'
|
|
52
|
+
$extensions:
|
|
53
|
+
com.sanity.ui:
|
|
54
|
+
implementationStatus:
|
|
55
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
56
|
+
implemented: true
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: tabs-panel
|
|
3
|
+
name: Tabs.Panel
|
|
4
|
+
description: The content for one tab. It shows when its value matches the selected Tabs value, and stays hidden otherwise.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [tabs, tablist, tabpanel, navigation, views, tab, sections]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: how-to-use
|
|
13
|
+
items:
|
|
14
|
+
- id: tabpanel-tabindex
|
|
15
|
+
level: must
|
|
16
|
+
statement: Tab.Panel has a default tabindex of 0 to enable focusing when there is no focusable content. Tab panels with focusable content should unset the panel’s tabindex so that the panel’s first focusable component receives focus instead.
|
|
17
|
+
- id: tabpanel-value-matches-tab
|
|
18
|
+
level: must
|
|
19
|
+
statement: Give Tabs.Panel the same value as its Tabs.Tab.
|
|
20
|
+
- id: don-conditionally-render-tabpanels-hidden
|
|
21
|
+
level: must-not
|
|
22
|
+
statement: "Don't render Tabs.Panel conditionally. Unselected panels stay mounted with display none. Their content keeps its state."
|
|
23
|
+
- level: should
|
|
24
|
+
statement: Use layout props such as padding on Tabs.Panel for spacing inside the panel.
|
|
25
|
+
- kind: guidelines
|
|
26
|
+
for: agent
|
|
27
|
+
framing: how-to-use
|
|
28
|
+
items:
|
|
29
|
+
- level: must-not
|
|
30
|
+
statement: Don't set id or aria-labelledby on Tabs.Panel. It sets both from value.
|
|
31
|
+
|
|
32
|
+
refs:
|
|
33
|
+
- to: tabs
|
|
34
|
+
rel: relates-to
|
|
35
|
+
note: The family this panel belongs to.
|
|
36
|
+
- to: tabs-list
|
|
37
|
+
rel: relates-to
|
|
38
|
+
note: The row that holds the tabs.
|
|
39
|
+
- to: tab
|
|
40
|
+
rel: relates-to
|
|
41
|
+
note: The button that selects this panel.
|
|
42
|
+
|
|
43
|
+
sourceFiles:
|
|
44
|
+
- platform: react
|
|
45
|
+
file: packages/ui/src/components/tabs/Tabs.tsx
|
|
46
|
+
imports:
|
|
47
|
+
- platform: react
|
|
48
|
+
code: import { Tabs } from '@sanity/ui'
|
|
49
|
+
package: '@sanity/ui'
|
|
50
|
+
$extensions:
|
|
51
|
+
com.sanity.ui:
|
|
52
|
+
implementationStatus:
|
|
53
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
54
|
+
implemented: true
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: tabs
|
|
3
|
+
name: Tabs
|
|
4
|
+
description: 'A family of components that switch between separate but related content sections. Tabs has three parts, each with its own entry: Tabs.List, Tabs.Tab and Tabs.Panel.'
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [tabs, tablist, tabpanel, navigation, views, tab, sections]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
uses:
|
|
10
|
+
- to: tabs-list
|
|
11
|
+
- to: tab
|
|
12
|
+
- to: tabs-panel
|
|
13
|
+
sections:
|
|
14
|
+
- kind: guidelines
|
|
15
|
+
for: all
|
|
16
|
+
framing: when-to-use
|
|
17
|
+
title: When to use
|
|
18
|
+
items:
|
|
19
|
+
- level: should
|
|
20
|
+
statement: "When switching between different yet related views in the same context (for example, 'Content', 'Preview', 'History' in an inspector panel)."
|
|
21
|
+
- level: should
|
|
22
|
+
statement: Organizing sections within a settings or configuration screen.
|
|
23
|
+
- level: should
|
|
24
|
+
statement: Breaking a dense detail view into digestible categories without navigating away.
|
|
25
|
+
- level: should-not
|
|
26
|
+
statement: Navigating between separate pages or top-level routes. Use sidebar navigation or links instead.
|
|
27
|
+
alternatives:
|
|
28
|
+
- to: navigation
|
|
29
|
+
- to: link
|
|
30
|
+
- level: should-not
|
|
31
|
+
statement: Content that should all be visible at once. Use VStack to lay out sections vertically.
|
|
32
|
+
alternatives:
|
|
33
|
+
- to: v-stack
|
|
34
|
+
- level: should-not
|
|
35
|
+
statement: Changing how one view presents the content it already shows. Examples include a density toggle, a sort order, a chart time range. Use Select instead.
|
|
36
|
+
alternatives:
|
|
37
|
+
- to: select
|
|
38
|
+
- kind: guidelines
|
|
39
|
+
for: agent
|
|
40
|
+
framing: when-to-use
|
|
41
|
+
title: When to use
|
|
42
|
+
items:
|
|
43
|
+
- level: should-not
|
|
44
|
+
statement: "Don't use Tabs when the selection changes how a single view renders. Use Select or Radio instead."
|
|
45
|
+
alternatives:
|
|
46
|
+
- to: select
|
|
47
|
+
- to: radio
|
|
48
|
+
- kind: guidelines
|
|
49
|
+
for: all
|
|
50
|
+
framing: how-to-use
|
|
51
|
+
items:
|
|
52
|
+
- level: must
|
|
53
|
+
statement: Render Tabs with a value and an onValueChange handler. Tabs is controlled. The parent holds the selected value.
|
|
54
|
+
- level: must
|
|
55
|
+
statement: Give each Tabs.Tab and each Tabs.Panel the value of the tab it pairs with.
|
|
56
|
+
- level: must
|
|
57
|
+
statement: Keep each value unique within one Tabs. Tabs uses value to link each tab to its panel. A repeated value links the wrong pair.
|
|
58
|
+
- level: must-not
|
|
59
|
+
statement: 'Don''t use two values that differ only in spaces, such as "Draft notes" and "Draft-notes". Tabs turns spaces into hyphens in the ids it builds. Both values produce the same id.'
|
|
60
|
+
- level: must-not
|
|
61
|
+
statement: "Don't render Tabs.Tab or Tabs.Panel outside Tabs. They read the selected value from Tabs and throw an error without it."
|
|
62
|
+
- level: must-not
|
|
63
|
+
statement: Don't nest tabs within tabs.
|
|
64
|
+
- kind: guidelines
|
|
65
|
+
for: agent
|
|
66
|
+
framing: how-to-use
|
|
67
|
+
title: Child parts
|
|
68
|
+
items:
|
|
69
|
+
- level: must
|
|
70
|
+
statement: Tabs has three subcomponents, Tabs.List, Tabs.Tab and Tabs.Panel. Each has its own entry, `tabs-list`, `tab` and `tabs-panel`. Read each one's entry in `docs/components/` before you write it. Its props are not listed here.
|
|
71
|
+
- level: must
|
|
72
|
+
statement: Don't write a subcomponent's props from memory or from this entry. This entry does not list them.
|
|
73
|
+
- kind: guidelines
|
|
74
|
+
for: all
|
|
75
|
+
title: Accessibility
|
|
76
|
+
tags: [accessibility]
|
|
77
|
+
items:
|
|
78
|
+
- level: should
|
|
79
|
+
statement: Use Tabs.List, Tabs.Tab and Tabs.Panel together. They set the roles, ids and focus behavior that link each tab to its panel.
|
|
80
|
+
alternatives:
|
|
81
|
+
- to: link
|
|
82
|
+
refs:
|
|
83
|
+
- to: tabs-list
|
|
84
|
+
rel: relates-to
|
|
85
|
+
note: The row that holds the Tabs.Tab buttons.
|
|
86
|
+
- to: tab
|
|
87
|
+
rel: relates-to
|
|
88
|
+
note: The button that selects a Tabs.Panel.
|
|
89
|
+
- to: tabs-panel
|
|
90
|
+
rel: relates-to
|
|
91
|
+
note: The content for one tab.
|
|
92
|
+
|
|
93
|
+
sourceFiles:
|
|
94
|
+
- platform: react
|
|
95
|
+
file: packages/ui/src/components/tabs/Tabs.tsx
|
|
96
|
+
imports:
|
|
97
|
+
- platform: react
|
|
98
|
+
code: import { Tabs } from '@sanity/ui'
|
|
99
|
+
package: '@sanity/ui'
|
|
100
|
+
$extensions:
|
|
101
|
+
com.sanity.ui:
|
|
102
|
+
implementationStatus:
|
|
103
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
104
|
+
implemented: true
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: text-area
|
|
3
|
+
name: TextArea
|
|
4
|
+
description: A multi-line text field for longer freeform text, like descriptions and comments.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [textarea, form, input, multiline, text, text input, description, comment]
|
|
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: For multi-line freeform text input — descriptions, comments, summaries.
|
|
17
|
+
- level: should-not
|
|
18
|
+
statement: For single-line freeform text input. Use TextInput instead.
|
|
19
|
+
alternatives:
|
|
20
|
+
- to: text-input
|
|
21
|
+
- level: should-not
|
|
22
|
+
statement: For rich text editing. Use a dedicated editor component.
|
|
23
|
+
- kind: guidelines
|
|
24
|
+
for: all
|
|
25
|
+
framing: how-to-use
|
|
26
|
+
items:
|
|
27
|
+
- refs:
|
|
28
|
+
- to: forms#pair-with-visible-label
|
|
29
|
+
rel: same-as
|
|
30
|
+
- level: must
|
|
31
|
+
statement: Mark an invalid field with `hasError`. It renders no message. Add the error text yourself and link it with `aria-describedby`.
|
|
32
|
+
- refs:
|
|
33
|
+
- to: error-messaging#name-what-failed
|
|
34
|
+
rel: same-as
|
|
35
|
+
- refs:
|
|
36
|
+
- to: forms#error-described-in-text
|
|
37
|
+
rel: same-as
|
|
38
|
+
- refs:
|
|
39
|
+
- to: forms#mark-optional-fields
|
|
40
|
+
rel: same-as
|
|
41
|
+
- refs:
|
|
42
|
+
- to: forms#stack-fields-vertically
|
|
43
|
+
rel: same-as
|
|
44
|
+
- level: should
|
|
45
|
+
statement: Set `rows` to fit amount of expected text. The default is 5.
|
|
46
|
+
- level: should
|
|
47
|
+
statement: Use `autoResize` when vertical space is limited and/or the length of text entered can greatly vary. Pair it with `maxHeight`, such as `maxHeight="10rem"`. A long entry then scrolls instead of pushing the page down.
|
|
48
|
+
- level: should
|
|
49
|
+
statement: Use `density="loose"` in forms with wide spacing. `regular` is the default. Give every field in one form the same density.
|
|
50
|
+
- level: should
|
|
51
|
+
statement: Use placeholders that are fully visible within the bounds of the input.
|
|
52
|
+
- refs:
|
|
53
|
+
- to: shared-foundations#error-state-never-disabled
|
|
54
|
+
rel: same-as
|
|
55
|
+
- refs:
|
|
56
|
+
- to: forms#placeholder-not-a-label
|
|
57
|
+
rel: same-as
|
|
58
|
+
- level: must-not
|
|
59
|
+
statement: Don't use `readOnly` for long text people need to read or copy. A read-only TextArea ignores the pointer and mouse users can't scroll or select its text. Show the text with Text instead.
|
|
60
|
+
alternatives:
|
|
61
|
+
- to: text
|
|
62
|
+
- kind: guidelines
|
|
63
|
+
for: agent
|
|
64
|
+
framing: how-to-use
|
|
65
|
+
items:
|
|
66
|
+
- level: must-not
|
|
67
|
+
statement: Don't set `rows` to give an `autoResize` field a starting height. The field sizes to its content and starts one line tall. Browsers without CSS `field-sizing` ignore `autoResize` and use `rows`.
|
|
68
|
+
- level: must-not
|
|
69
|
+
statement: Don't set `aria-invalid` on TextArea by hand. TextArea writes `aria-invalid` from `hasError` after your props and overwrites a hand-set value. Use `hasError`.
|
|
70
|
+
- level: must-not
|
|
71
|
+
statement: >-
|
|
72
|
+
Don't pass layout or spacing props to TextArea. It takes the native textarea attributes plus `autoResize`, `density`, `hasError` and `maxHeight`. `margin`, `padding`, `flexGrow` and the like are TypeScript errors. TextArea always fills its container's width. Size it and space it from a wrapping Box or Flex.
|
|
73
|
+
- kind: guidelines
|
|
74
|
+
for: all
|
|
75
|
+
title: Accessibility
|
|
76
|
+
tags: [accessibility]
|
|
77
|
+
items:
|
|
78
|
+
- refs:
|
|
79
|
+
- to: forms#label-available-to-screen-readers
|
|
80
|
+
rel: same-as
|
|
81
|
+
- to: forms#programmatic-name-required
|
|
82
|
+
rel: same-as
|
|
83
|
+
- to: forms#border-contrast
|
|
84
|
+
rel: same-as
|
|
85
|
+
- to: forms#placeholder-contrast
|
|
86
|
+
rel: same-as
|
|
87
|
+
- to: forms#error-prop-needs-visible-message
|
|
88
|
+
rel: same-as
|
|
89
|
+
- to: forms#field-group-name
|
|
90
|
+
rel: same-as
|
|
91
|
+
alternatives:
|
|
92
|
+
- to: text-input
|
|
93
|
+
refs:
|
|
94
|
+
- href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=38-85
|
|
95
|
+
rel: design
|
|
96
|
+
role: Figma component
|
|
97
|
+
sourceFiles:
|
|
98
|
+
- platform: react
|
|
99
|
+
file: packages/ui/src/components/text-area/TextArea.tsx
|
|
100
|
+
imports:
|
|
101
|
+
- platform: react
|
|
102
|
+
code: import { TextArea } from '@sanity/ui'
|
|
103
|
+
package: '@sanity/ui'
|
|
104
|
+
traits:
|
|
105
|
+
- traitType: state
|
|
106
|
+
kind: boolean
|
|
107
|
+
id: enabled
|
|
108
|
+
description: Resting state. Backdrop background with a high separator border. The border carries the states below; the background only moves for `disabled` and `readOnly`.
|
|
109
|
+
- traitType: state
|
|
110
|
+
kind: boolean
|
|
111
|
+
id: hovered
|
|
112
|
+
description: The border shifts one lightness step — darker in light mode, lighter in dark mode. In the error state it shifts from the error border.
|
|
113
|
+
- traitType: state
|
|
114
|
+
kind: boolean
|
|
115
|
+
id: focused
|
|
116
|
+
description: Focus outline on `:focus-visible`, offset from the border.
|
|
117
|
+
- traitType: state
|
|
118
|
+
kind: boolean
|
|
119
|
+
id: disabled
|
|
120
|
+
description: 'Inert background and a low separator border, with the text in the inert foreground color. `pointer-events: none` makes the field unclickable.'
|
|
121
|
+
- traitType: state
|
|
122
|
+
kind: boolean
|
|
123
|
+
id: read-only
|
|
124
|
+
description: 'Set with `readOnly`. Same inert background and low border as `disabled`, but the text keeps its normal color. `pointer-events: none` stops the mouse from scrolling or selecting the text. The field can still take keyboard focus.'
|
|
125
|
+
- traitType: state
|
|
126
|
+
kind: boolean
|
|
127
|
+
id: error
|
|
128
|
+
description: Set with the `hasError` prop, which adds `aria-invalid="true"` to the textarea. The error styling keys off that attribute. The border turns the error separator color and the text the error foreground color. It carries no message — supply that yourself.
|
|
129
|
+
- traitType: variant
|
|
130
|
+
kind: enum
|
|
131
|
+
id: density
|
|
132
|
+
description: Sets the field's padding. The type size stays at body size 1.
|
|
133
|
+
values:
|
|
134
|
+
- id: regular
|
|
135
|
+
description: Default. Horizontal padding {space-2}, vertical padding {space-1}.
|
|
136
|
+
- id: loose
|
|
137
|
+
description: Horizontal padding {space-3}, vertical padding {space-2}. For forms with wide spacing.
|
|
138
|
+
- traitType: variant
|
|
139
|
+
kind: boolean
|
|
140
|
+
id: autoResize
|
|
141
|
+
description: Grows and shrinks the field with its content, through CSS `field-sizing`. Ignores `rows`. Cap it with `maxHeight`, a CSS length that can vary by breakpoint.
|
|
142
|
+
$extensions:
|
|
143
|
+
com.sanity.ui:
|
|
144
|
+
implementationStatus:
|
|
145
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
146
|
+
implemented: true
|
|
147
|
+
migrationGuide:
|
|
148
|
+
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.'
|
|
149
|
+
guidance: |-
|
|
150
|
+
TextArea is now a plain native textarea, without the sizing props. One `density` prop sets the spacing, and a boolean named `hasError` marks validation. `autoResize` and `maxHeight` are new.
|
|
151
|
+
|
|
152
|
+
### Detailed list of differences
|
|
153
|
+
|
|
154
|
+
| v3 pattern | v5 pattern | Notes |
|
|
155
|
+
| :---- | :---- | :---- |
|
|
156
|
+
| `<TextArea fontSize={2} weight="medium" />` | `<TextArea />` | The type size is fixed at body size 1, in regular weight |
|
|
157
|
+
| `<TextArea padding={3} />` | `<TextArea density="loose" />` | `density` is `regular` or `loose`. Neither value reproduces a v3 `padding={3}` exactly |
|
|
158
|
+
| `<TextArea radius={2} border={false} />` | `<TextArea />` | The radius is fixed at step 2, and the border is always drawn |
|
|
159
|
+
| `<TextArea customValidity="Required" />` | `<TextArea hasError />` plus your own message | `hasError` sets `aria-invalid` and recolors the border and text. It renders no text |
|
|
160
|
+
| `<TextArea rows={…} />` | `<TextArea rows={…} />` | Unchanged. The default is now 5 |
|
|
161
|
+
| No v3 equivalent | `<TextArea autoResize maxHeight="10rem" />` | Grows with the content, up to `maxHeight` |
|
|
162
|
+
| All other native `<textarea>` attributes | Forwarded unchanged | Pass them as before |
|
|
163
|
+
|
|
164
|
+
### Breaking changes
|
|
165
|
+
|
|
166
|
+
- **The v3 styling props are TypeScript errors.** `fontSize`, `weight`, `padding`, `radius`, `border` and `customValidity` are not TextArea props.
|
|
167
|
+
- **`hasError` replaces `customValidity`.** The old prop set the native validation message. The new one is styling plus `aria-invalid`. You own the message and where it appears.
|
|
168
|
+
- **`aria-invalid` follows `hasError`.** A hand-set `aria-invalid` is overwritten. Set `hasError` instead.
|
|
169
|
+
- **No resize handle.** People can't drag the corner to resize the field. Set `rows`, or use `autoResize`.
|
|
170
|
+
- **The width is no longer yours to set on the component.** TextArea fills its container. Size it from the parent.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: text-input
|
|
3
|
+
name: TextInput
|
|
4
|
+
description: Used to accept a single line of text like names, titles, zip codes.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [textinput, form, input, text, single-line, text field, name, title, search]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
note: Added in 5.0.0-alpha.13.
|
|
10
|
+
sections:
|
|
11
|
+
- kind: guidelines
|
|
12
|
+
for: all
|
|
13
|
+
framing: when-to-use
|
|
14
|
+
title: When to use
|
|
15
|
+
items:
|
|
16
|
+
- level: should
|
|
17
|
+
statement: 'For freeform input of short text: names, titles, search queries.'
|
|
18
|
+
- level: should-not
|
|
19
|
+
statement: For longer form, multi-line text where spell check is expected. Use TextArea instead.
|
|
20
|
+
alternatives:
|
|
21
|
+
- to: text-area
|
|
22
|
+
- level: should-not
|
|
23
|
+
statement: For selecting an option from a fixed list. Use Select instead.
|
|
24
|
+
alternatives:
|
|
25
|
+
- to: select
|
|
26
|
+
- kind: guidelines
|
|
27
|
+
for: agent
|
|
28
|
+
framing: when-to-use
|
|
29
|
+
title: When to use
|
|
30
|
+
items:
|
|
31
|
+
- level: should-not
|
|
32
|
+
statement: Don't use TextInput to pick from a fixed set of options. Use Select or Radio instead.
|
|
33
|
+
alternatives:
|
|
34
|
+
- to: select
|
|
35
|
+
- to: radio
|
|
36
|
+
- kind: guidelines
|
|
37
|
+
for: all
|
|
38
|
+
framing: how-to-use
|
|
39
|
+
items:
|
|
40
|
+
- refs:
|
|
41
|
+
- to: forms#pair-with-visible-label
|
|
42
|
+
rel: same-as
|
|
43
|
+
- level: must
|
|
44
|
+
statement: Mark an invalid field with `hasError`. It colors the border and text and sets `aria-invalid="true"` on the input. It renders no message, so add the error text yourself and link it with `aria-describedby`.
|
|
45
|
+
- refs:
|
|
46
|
+
- to: forms#mark-optional-fields
|
|
47
|
+
rel: same-as
|
|
48
|
+
- refs:
|
|
49
|
+
- to: forms#stack-fields-vertically
|
|
50
|
+
rel: same-as
|
|
51
|
+
- level: should
|
|
52
|
+
statement: Use `density="loose"` in forms with wide spacing. `regular` is the default. Give every field in one form the same density, including any Select beside it.
|
|
53
|
+
- refs:
|
|
54
|
+
- to: shared-foundations#error-state-never-disabled
|
|
55
|
+
rel: same-as
|
|
56
|
+
- refs:
|
|
57
|
+
- to: forms#placeholder-not-a-label
|
|
58
|
+
rel: same-as
|
|
59
|
+
- level: must-not
|
|
60
|
+
statement: Don't horizontally stack more than two TextInputs in a row.
|
|
61
|
+
- kind: guidelines
|
|
62
|
+
for: agent
|
|
63
|
+
framing: how-to-use
|
|
64
|
+
items:
|
|
65
|
+
- level: should
|
|
66
|
+
statement: >-
|
|
67
|
+
Set `type` to the kind of text the field takes: `email`, `password`, `search`, `tel`, `url`, `number`, `date`, `time`, `datetime-local`, `month` or `week`. `text` is the default. The right type gives the matching mobile keyboard and browser autofill.
|
|
68
|
+
- level: must-not
|
|
69
|
+
statement: >-
|
|
70
|
+
Don't set `type` to `button`, `checkbox`, `color`, `file`, `hidden`, `image`, `radio`, `range`, `reset` or `submit`. TextInput is a text field and is not styled for those controls. TypeScript does not catch this: the `type` prop still accepts any string. Use Button, Checkbox, Radio or a native element instead.
|
|
71
|
+
- level: must-not
|
|
72
|
+
statement: >-
|
|
73
|
+
Don't set `aria-invalid` on TextInput by hand. TextInput writes `aria-invalid` from `hasError` after your props, so a hand-set value is ignored. Use `hasError`.
|
|
74
|
+
- level: must-not
|
|
75
|
+
statement: >-
|
|
76
|
+
Don't pass layout or spacing props to TextInput. It takes the native input attributes plus `density` and `hasError`, so `margin`, `padding`, `flexGrow` and the like are TypeScript errors. TextInput always fills its container's width. Size it and space it from a wrapping Box or Flex. The native `width` attribute compiles but has no effect on a text field.
|
|
77
|
+
- kind: guidelines
|
|
78
|
+
for: all
|
|
79
|
+
title: Accessibility
|
|
80
|
+
tags: [accessibility]
|
|
81
|
+
items:
|
|
82
|
+
- refs:
|
|
83
|
+
- to: forms#label-available-to-screen-readers
|
|
84
|
+
rel: same-as
|
|
85
|
+
- refs:
|
|
86
|
+
- to: forms#programmatic-name-required
|
|
87
|
+
rel: same-as
|
|
88
|
+
- refs:
|
|
89
|
+
- to: forms#border-contrast
|
|
90
|
+
rel: same-as
|
|
91
|
+
- refs:
|
|
92
|
+
- to: forms#placeholder-contrast
|
|
93
|
+
rel: same-as
|
|
94
|
+
- refs:
|
|
95
|
+
- to: forms#error-described-in-text
|
|
96
|
+
rel: same-as
|
|
97
|
+
- refs:
|
|
98
|
+
- to: forms#error-prop-needs-visible-message
|
|
99
|
+
rel: same-as
|
|
100
|
+
- kind: section
|
|
101
|
+
for: agent
|
|
102
|
+
freeform:
|
|
103
|
+
- title: Form-field pairing (canonical example)
|
|
104
|
+
body: |-
|
|
105
|
+
The canonical form-field pairing. A `Text` with `as="label"` links to the input via `htmlFor` ↔ `id`; the label text is passed as children.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { Text, TextInput, VStack } from '@sanity/ui'
|
|
109
|
+
|
|
110
|
+
<VStack gap={2}>
|
|
111
|
+
<Text as="label" htmlFor="email">Email address</Text>
|
|
112
|
+
<TextInput id="email" type="email" value={email} onChange={(e) => setEmail(e.currentTarget.value)} />
|
|
113
|
+
</VStack>
|
|
114
|
+
```
|
|
115
|
+
alternatives:
|
|
116
|
+
- to: text-area
|
|
117
|
+
- to: select
|
|
118
|
+
refs:
|
|
119
|
+
- href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=29-1895
|
|
120
|
+
rel: design
|
|
121
|
+
role: Figma component
|
|
122
|
+
sourceFiles:
|
|
123
|
+
- platform: react
|
|
124
|
+
file: packages/ui/src/components/text-input/TextInput.tsx
|
|
125
|
+
imports:
|
|
126
|
+
- platform: react
|
|
127
|
+
code: import { TextInput } from '@sanity/ui'
|
|
128
|
+
package: '@sanity/ui'
|
|
129
|
+
traits:
|
|
130
|
+
- traitType: state
|
|
131
|
+
kind: boolean
|
|
132
|
+
id: enabled
|
|
133
|
+
description: Resting state. Backdrop background with a high separator border. The border carries the states below; the background only moves for `disabled`.
|
|
134
|
+
- traitType: state
|
|
135
|
+
kind: boolean
|
|
136
|
+
id: hovered
|
|
137
|
+
description: The border shifts one lightness step — darker in light mode, lighter in dark mode. In the error state it shifts from the error border.
|
|
138
|
+
- traitType: state
|
|
139
|
+
kind: boolean
|
|
140
|
+
id: focused
|
|
141
|
+
description: Focus outline on `:focus-visible`, offset from the border.
|
|
142
|
+
- traitType: state
|
|
143
|
+
kind: boolean
|
|
144
|
+
id: disabled
|
|
145
|
+
description: 'Inert background and a low separator border, with the text in the inert foreground color. `pointer-events: none`, so the field is not clickable.'
|
|
146
|
+
- traitType: state
|
|
147
|
+
kind: boolean
|
|
148
|
+
id: error
|
|
149
|
+
description: Set with the `hasError` prop, which adds `aria-invalid="true"` to the input. The error styling keys off that attribute, so the border turns the error separator color and the text the error foreground color. It carries no message — supply that yourself.
|
|
150
|
+
- traitType: variant
|
|
151
|
+
kind: enum
|
|
152
|
+
id: density
|
|
153
|
+
description: Sets the field's padding. The type size is fixed at body size 1.
|
|
154
|
+
values:
|
|
155
|
+
- id: regular
|
|
156
|
+
description: Default. Horizontal padding {space-2}, vertical padding {space-1}.
|
|
157
|
+
- id: loose
|
|
158
|
+
description: Horizontal padding {space-3}, vertical padding {space-2}. For forms with wide spacing.
|
|
159
|
+
$extensions:
|
|
160
|
+
com.sanity.ui:
|
|
161
|
+
implementationStatus:
|
|
162
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
163
|
+
implemented: true
|
|
164
|
+
migrationGuide:
|
|
165
|
+
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.'
|
|
166
|
+
guidance: |-
|
|
167
|
+
TextInput is now a plain native input. The sizing props and the icon, prefix, suffix and clear-button slots are gone. One `density` prop sets the spacing, and validation is a boolean named `hasError`.
|
|
168
|
+
|
|
169
|
+
### Detailed list of differences
|
|
170
|
+
|
|
171
|
+
| v3 pattern | v5 pattern | Notes |
|
|
172
|
+
| :---- | :---- | :---- |
|
|
173
|
+
| `<TextInput fontSize={2} weight="medium" />` | `<TextInput />` | The type size is fixed at body size 1, in regular weight |
|
|
174
|
+
| `<TextInput padding={3} space={3} />` | `<TextInput density="loose" />` | `density` is `regular` or `loose`. Neither value reproduces a v3 `padding={3}` exactly |
|
|
175
|
+
| `<TextInput radius={2} border={false} />` | `<TextInput />` | The radius is fixed at step 2, and the border is always drawn |
|
|
176
|
+
| `<TextInput customValidity="Required" />` | `<TextInput hasError />` plus your own message | `hasError` sets `aria-invalid` and recolors the border and text. It renders no text |
|
|
177
|
+
| `<TextInput icon={SearchIcon} iconRight={…} />` | `<TextInput />` | No icon slots. Put an icon beside the field, not inside it |
|
|
178
|
+
| `<TextInput prefix="https://" suffix=".com" />` | `<TextInput />` | No prefix or suffix slots |
|
|
179
|
+
| `<TextInput clearButton onClear={…} />` | `<TextInput />` plus your own Button | No built-in clear button |
|
|
180
|
+
| `<TextInput type="search" />` | `<TextInput type="search" />` | Unchanged. Every v3 text type still works, including `search` and `datetime-local` |
|
|
181
|
+
| All other native `<input>` attributes | Forwarded unchanged | Pass them as before |
|
|
182
|
+
|
|
183
|
+
### Breaking changes
|
|
184
|
+
|
|
185
|
+
- **The v3 styling and slot props are TypeScript errors.** `fontSize`, `weight`, `padding`, `space`, `gap`, `radius`, `border`, `icon`, `iconRight`, `suffix`, `clearButton`, `onClear` and `customValidity` are not TextInput props. `prefix` still compiles, because it is a native HTML attribute, but it renders no text.
|
|
186
|
+
- **`customValidity` is replaced by `hasError`.** The old prop set the native validation message. The new one is styling plus `aria-invalid`. You own the message and where it appears.
|
|
187
|
+
- **`type` means text types only.** The type excludes `button`, `checkbox`, `color`, `file`, `hidden`, `image`, `radio`, `range`, `reset` and `submit`, but TypeScript does not enforce it, because the prop still accepts any string. Every text type from v3 still works.
|
|
188
|
+
- **`aria-invalid` follows `hasError`.** A hand-set `aria-invalid` is overwritten. Set `hasError` instead.
|
|
189
|
+
- **The width is no longer yours to set on the component.** TextInput fills its container. Size it from the parent.
|