@fragments-sdk/ui 0.17.0 → 0.18.0
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/dist/assets/ui.css +320 -183
- package/dist/components/Header/Header.module.scss.cjs +42 -21
- package/dist/components/Header/Header.module.scss.js +42 -21
- package/dist/components/Header/index.cjs +121 -3
- package/dist/components/Header/index.d.ts +26 -3
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +122 -4
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +42 -42
- package/dist/components/Sidebar/Sidebar.module.scss.js +42 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/fragments.json +1 -1
- package/package.json +3 -3
- package/src/components/Accordion/Accordion.contract.json +169 -0
- package/src/components/Alert/Alert.contract.json +157 -0
- package/src/components/AppShell/AppShell.contract.json +155 -0
- package/src/components/Avatar/Avatar.contract.json +189 -0
- package/src/components/Badge/Badge.contract.json +187 -0
- package/src/components/BentoGrid/BentoGrid.contract.json +135 -0
- package/src/components/Box/Box.contract.json +423 -0
- package/src/components/Breadcrumbs/Breadcrumbs.contract.json +143 -0
- package/src/components/Button/Button.contract.json +205 -0
- package/src/components/ButtonGroup/ButtonGroup.contract.json +140 -0
- package/src/components/Card/Card.contract.json +185 -0
- package/src/components/Chart/Chart.contract.json +129 -0
- package/src/components/Checkbox/Checkbox.contract.json +246 -0
- package/src/components/Chip/Chip.contract.json +212 -0
- package/src/components/CodeBlock/CodeBlock.contract.json +388 -0
- package/src/components/Collapsible/Collapsible.contract.json +154 -0
- package/src/components/ColorPicker/ColorPicker.contract.json +212 -0
- package/src/components/Combobox/Combobox.contract.json +297 -0
- package/src/components/Command/Command.contract.json +165 -0
- package/src/components/ConversationList/ConversationList.contract.json +151 -0
- package/src/components/DataTable/DataTable.contract.json +302 -0
- package/src/components/DatePicker/DatePicker.contract.json +288 -0
- package/src/components/Dialog/Dialog.contract.json +159 -0
- package/src/components/Drawer/Drawer.contract.json +160 -0
- package/src/components/Editor/Editor.contract.json +263 -0
- package/src/components/EmptyState/EmptyState.contract.json +133 -0
- package/src/components/Field/Field.contract.json +157 -0
- package/src/components/Fieldset/Fieldset.contract.json +117 -0
- package/src/components/Form/Form.contract.json +145 -0
- package/src/components/Grid/Grid.contract.json +195 -0
- package/src/components/Header/Header.contract.json +194 -0
- package/src/components/Header/Header.module.scss +99 -0
- package/src/components/Header/index.tsx +191 -10
- package/src/components/Icon/Icon.contract.json +194 -0
- package/src/components/Image/Image.contract.json +209 -0
- package/src/components/Input/Input.contract.json +344 -0
- package/src/components/Link/Link.contract.json +180 -0
- package/src/components/List/List.contract.json +154 -0
- package/src/components/Listbox/Listbox.contract.json +158 -0
- package/src/components/Loading/Loading.contract.json +167 -0
- package/src/components/Markdown/Markdown.contract.json +127 -0
- package/src/components/Menu/Menu.contract.json +177 -0
- package/src/components/Message/Message.contract.json +183 -0
- package/src/components/NavigationMenu/NavigationMenu.contract.json +203 -0
- package/src/components/Pagination/Pagination.contract.json +163 -0
- package/src/components/Popover/Popover.contract.json +163 -0
- package/src/components/Progress/Progress.contract.json +176 -0
- package/src/components/Prompt/Prompt.contract.json +211 -0
- package/src/components/RadioGroup/RadioGroup.contract.json +226 -0
- package/src/components/ScrollArea/ScrollArea.contract.json +131 -0
- package/src/components/Select/Select.contract.json +269 -0
- package/src/components/Separator/Separator.contract.json +143 -0
- package/src/components/Sidebar/Sidebar.contract.json +258 -0
- package/src/components/Sidebar/Sidebar.module.scss +6 -4
- package/src/components/Skeleton/Skeleton.contract.json +166 -0
- package/src/components/Slider/Slider.contract.json +248 -0
- package/src/components/Stack/Stack.contract.json +220 -0
- package/src/components/Table/Table.contract.json +171 -0
- package/src/components/TableOfContents/TableOfContents.contract.json +145 -0
- package/src/components/Tabs/Tabs.contract.json +159 -0
- package/src/components/Text/Text.contract.json +239 -0
- package/src/components/Textarea/Textarea.contract.json +308 -0
- package/src/components/Theme/Theme.contract.json +152 -0
- package/src/components/ThinkingIndicator/ThinkingIndicator.contract.json +165 -0
- package/src/components/Toast/Toast.contract.json +181 -0
- package/src/components/Toggle/Toggle.contract.json +231 -0
- package/src/components/ToggleGroup/ToggleGroup.contract.json +206 -0
- package/src/components/Tooltip/Tooltip.contract.json +214 -0
- package/src/components/VisuallyHidden/VisuallyHidden.contract.json +116 -0
- package/src/index.ts +1 -0
- package/src/tokens/_derive.scss +4 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://usefragments.com/schemas/contract.v1.json",
|
|
3
|
+
"name": "Toast",
|
|
4
|
+
"description": "Brief, non-blocking notification messages",
|
|
5
|
+
"category": "feedback",
|
|
6
|
+
"tags": [
|
|
7
|
+
"notification",
|
|
8
|
+
"alert",
|
|
9
|
+
"message",
|
|
10
|
+
"feedback"
|
|
11
|
+
],
|
|
12
|
+
"status": "stable",
|
|
13
|
+
"sourcePath": "src/components/Toast/index.tsx",
|
|
14
|
+
"exportName": "Toast",
|
|
15
|
+
"propsSummary": [
|
|
16
|
+
"onDismiss: function",
|
|
17
|
+
"title: string",
|
|
18
|
+
"description: string",
|
|
19
|
+
"variant: default|success|error|warning|info (default: default)",
|
|
20
|
+
"duration: number",
|
|
21
|
+
"action: object",
|
|
22
|
+
"id: string",
|
|
23
|
+
"onPause: function",
|
|
24
|
+
"onResume: function"
|
|
25
|
+
],
|
|
26
|
+
"props": {
|
|
27
|
+
"onDismiss": {
|
|
28
|
+
"type": "function",
|
|
29
|
+
"description": "Callback when toast should be dismissed",
|
|
30
|
+
"required": false
|
|
31
|
+
},
|
|
32
|
+
"title": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Toast title",
|
|
35
|
+
"required": false
|
|
36
|
+
},
|
|
37
|
+
"description": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Additional message content",
|
|
40
|
+
"required": false
|
|
41
|
+
},
|
|
42
|
+
"variant": {
|
|
43
|
+
"type": "enum",
|
|
44
|
+
"description": "Visual variant indicating message type",
|
|
45
|
+
"default": "default",
|
|
46
|
+
"required": false,
|
|
47
|
+
"values": [
|
|
48
|
+
"default",
|
|
49
|
+
"success",
|
|
50
|
+
"error",
|
|
51
|
+
"warning",
|
|
52
|
+
"info"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"duration": {
|
|
56
|
+
"type": "number",
|
|
57
|
+
"description": "Auto-dismiss duration in ms (0 = no auto-dismiss)",
|
|
58
|
+
"default": 5000,
|
|
59
|
+
"required": false
|
|
60
|
+
},
|
|
61
|
+
"action": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"description": "Optional action button { label, onClick }",
|
|
64
|
+
"required": false
|
|
65
|
+
},
|
|
66
|
+
"id": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "",
|
|
69
|
+
"required": false
|
|
70
|
+
},
|
|
71
|
+
"onPause": {
|
|
72
|
+
"type": "function",
|
|
73
|
+
"description": "Callback when auto-dismiss timer should pause",
|
|
74
|
+
"required": false
|
|
75
|
+
},
|
|
76
|
+
"onResume": {
|
|
77
|
+
"type": "function",
|
|
78
|
+
"description": "Callback when auto-dismiss timer should resume",
|
|
79
|
+
"required": false
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"usage": {
|
|
83
|
+
"when": [
|
|
84
|
+
"Providing feedback after an action",
|
|
85
|
+
"Showing success/error status of operations",
|
|
86
|
+
"Non-critical information that doesn't require action",
|
|
87
|
+
"Temporary messages that auto-dismiss"
|
|
88
|
+
],
|
|
89
|
+
"whenNot": [
|
|
90
|
+
"Critical errors requiring user action (use Dialog)",
|
|
91
|
+
"Persistent information (use Alert)",
|
|
92
|
+
"Inline validation (use form error states)",
|
|
93
|
+
"System-wide announcements (use Banner)"
|
|
94
|
+
],
|
|
95
|
+
"guidelines": [
|
|
96
|
+
"Keep messages brief and actionable",
|
|
97
|
+
"Use appropriate variant for the message type",
|
|
98
|
+
"Auto-dismiss after reasonable duration (3-5s)",
|
|
99
|
+
"Allow manual dismissal for longer messages",
|
|
100
|
+
"Limit number of simultaneous toasts",
|
|
101
|
+
"useToast() variant helpers accept either (title, description?) or an options object for action/duration/id"
|
|
102
|
+
],
|
|
103
|
+
"accessibility": [
|
|
104
|
+
"Use role=\"alert\" for important messages",
|
|
105
|
+
"Ensure sufficient display time for reading",
|
|
106
|
+
"Don't rely solely on color for meaning",
|
|
107
|
+
"Provide dismiss button with accessible label"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
"examples": [
|
|
111
|
+
{
|
|
112
|
+
"name": "Default",
|
|
113
|
+
"description": "Interactive toast demo - click buttons to trigger toasts (includes helper object syntax example)",
|
|
114
|
+
"code": "<ToastDemoWrapper />"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "Success",
|
|
118
|
+
"description": "Success message variant",
|
|
119
|
+
"code": "<Toast\n title=\"Success!\"\n description=\"Your changes have been saved.\"\n variant=\"success\"\n/>"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "Error",
|
|
123
|
+
"description": "Error message variant",
|
|
124
|
+
"code": "<Toast\n title=\"Error\"\n description=\"Failed to save changes. Please try again.\"\n variant=\"error\"\n/>"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "Warning",
|
|
128
|
+
"description": "Warning message variant",
|
|
129
|
+
"code": "<Toast\n title=\"Warning\"\n description=\"This action cannot be undone.\"\n variant=\"warning\"\n/>"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "Info",
|
|
133
|
+
"description": "Informational message variant",
|
|
134
|
+
"code": "<Toast\n title=\"New Update\"\n description=\"Version 2.0 is now available.\"\n variant=\"info\"\n/>"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "With Action",
|
|
138
|
+
"description": "Toast with an action button",
|
|
139
|
+
"code": "<Toast\n title=\"File deleted\"\n description=\"The file has been moved to trash.\"\n action={{\n label: 'Undo',\n onClick: () => console.log('Undo clicked'),\n }}\n/>"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"relations": [
|
|
143
|
+
{
|
|
144
|
+
"component": "Alert",
|
|
145
|
+
"relationship": "alternative",
|
|
146
|
+
"note": "Use Alert for persistent inline messages"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"component": "Dialog",
|
|
150
|
+
"relationship": "alternative",
|
|
151
|
+
"note": "Use Dialog for messages requiring user action"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"contract": {
|
|
155
|
+
"propsSummary": [
|
|
156
|
+
"title: string - toast title",
|
|
157
|
+
"description: string - additional message",
|
|
158
|
+
"variant: default|success|error|warning|info",
|
|
159
|
+
"duration: number - ms before auto-dismiss",
|
|
160
|
+
"action: { label, onClick } - optional action",
|
|
161
|
+
"ToastInput (useToast): optional id for deterministic creation/replacement flows",
|
|
162
|
+
"useToast().success/error/warning/info: (title, description?) or ({ title, description, action, duration, id })"
|
|
163
|
+
],
|
|
164
|
+
"a11yRules": [
|
|
165
|
+
"A11Y_ALERT_ROLE",
|
|
166
|
+
"A11Y_TARGET_SIZE_MIN"
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
"ai": {
|
|
170
|
+
"compositionPattern": "compound",
|
|
171
|
+
"subComponents": [
|
|
172
|
+
"Provider"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"provenance": {
|
|
176
|
+
"source": "migrated",
|
|
177
|
+
"verified": false,
|
|
178
|
+
"frameworkSupport": "native",
|
|
179
|
+
"extractedAt": "2026-03-13T23:19:06.259Z"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://usefragments.com/schemas/contract.v1.json",
|
|
3
|
+
"name": "Switch",
|
|
4
|
+
"description": "Binary on/off switch for settings and preferences. Provides immediate visual feedback and is ideal for options that take effect instantly.",
|
|
5
|
+
"category": "forms",
|
|
6
|
+
"tags": [
|
|
7
|
+
"switch",
|
|
8
|
+
"toggle",
|
|
9
|
+
"boolean",
|
|
10
|
+
"settings",
|
|
11
|
+
"preference"
|
|
12
|
+
],
|
|
13
|
+
"status": "stable",
|
|
14
|
+
"sourcePath": "src/components/Toggle/index.tsx",
|
|
15
|
+
"exportName": "Switch",
|
|
16
|
+
"propsSummary": [
|
|
17
|
+
"checked: boolean",
|
|
18
|
+
"defaultChecked: boolean",
|
|
19
|
+
"onCheckedChange: function",
|
|
20
|
+
"onChange: function",
|
|
21
|
+
"label: string",
|
|
22
|
+
"helperText: string",
|
|
23
|
+
"description: string",
|
|
24
|
+
"disabled: boolean (default: false)",
|
|
25
|
+
"size: sm|md|lg (default: md)",
|
|
26
|
+
"className: string",
|
|
27
|
+
"name: string",
|
|
28
|
+
"id: string",
|
|
29
|
+
"aria-label: string",
|
|
30
|
+
"aria-labelledby: string",
|
|
31
|
+
"aria-describedby: string"
|
|
32
|
+
],
|
|
33
|
+
"props": {
|
|
34
|
+
"checked": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Whether the switch is in the on state",
|
|
37
|
+
"default": "false",
|
|
38
|
+
"required": false
|
|
39
|
+
},
|
|
40
|
+
"defaultChecked": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"description": "Default checked state (uncontrolled)",
|
|
43
|
+
"required": false
|
|
44
|
+
},
|
|
45
|
+
"onCheckedChange": {
|
|
46
|
+
"type": "function",
|
|
47
|
+
"description": "Called when the switch is toggled: (checked: boolean) => void",
|
|
48
|
+
"required": false
|
|
49
|
+
},
|
|
50
|
+
"onChange": {
|
|
51
|
+
"type": "function",
|
|
52
|
+
"description": "Alias for onCheckedChange: (checked: boolean) => void",
|
|
53
|
+
"required": false
|
|
54
|
+
},
|
|
55
|
+
"label": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "Visible label text",
|
|
58
|
+
"required": false
|
|
59
|
+
},
|
|
60
|
+
"helperText": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Helper text shown below the label (preferred)",
|
|
63
|
+
"required": false
|
|
64
|
+
},
|
|
65
|
+
"description": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Deprecated alias for helperText",
|
|
68
|
+
"required": false
|
|
69
|
+
},
|
|
70
|
+
"disabled": {
|
|
71
|
+
"type": "boolean",
|
|
72
|
+
"description": "Whether the switch is non-interactive",
|
|
73
|
+
"default": "false",
|
|
74
|
+
"required": false
|
|
75
|
+
},
|
|
76
|
+
"size": {
|
|
77
|
+
"type": "enum",
|
|
78
|
+
"description": "Switch track size",
|
|
79
|
+
"default": "md",
|
|
80
|
+
"required": false,
|
|
81
|
+
"values": [
|
|
82
|
+
"sm",
|
|
83
|
+
"md",
|
|
84
|
+
"lg"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"className": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"description": "",
|
|
90
|
+
"required": false
|
|
91
|
+
},
|
|
92
|
+
"name": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"description": "",
|
|
95
|
+
"required": false
|
|
96
|
+
},
|
|
97
|
+
"id": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"description": "",
|
|
100
|
+
"required": false
|
|
101
|
+
},
|
|
102
|
+
"aria-label": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"description": "",
|
|
105
|
+
"required": false
|
|
106
|
+
},
|
|
107
|
+
"aria-labelledby": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"description": "",
|
|
110
|
+
"required": false
|
|
111
|
+
},
|
|
112
|
+
"aria-describedby": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "",
|
|
115
|
+
"required": false
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"usage": {
|
|
119
|
+
"when": [
|
|
120
|
+
"Binary settings that take effect immediately (e.g., dark mode, notifications)",
|
|
121
|
+
"Enabling/disabling features in a settings panel",
|
|
122
|
+
"Options where the result is immediately visible",
|
|
123
|
+
"Mobile-friendly boolean inputs"
|
|
124
|
+
],
|
|
125
|
+
"whenNot": [
|
|
126
|
+
"Multiple options in a group (use checkbox group)",
|
|
127
|
+
"Selection requires form submission to take effect (use checkbox)",
|
|
128
|
+
"Yes/No questions in forms (use radio buttons)",
|
|
129
|
+
"Complex multi-state options (use select or radio)"
|
|
130
|
+
],
|
|
131
|
+
"guidelines": [
|
|
132
|
+
"Switch should always have a visible label explaining what it controls",
|
|
133
|
+
"The \"on\" state should be the positive/enabling action",
|
|
134
|
+
"Changes should take effect immediately - no save button needed",
|
|
135
|
+
"Include helperText for switches whose effect isn't obvious from the label",
|
|
136
|
+
"Group related switches visually in settings panels"
|
|
137
|
+
],
|
|
138
|
+
"accessibility": [
|
|
139
|
+
"Uses role=\"switch\" with aria-checked for proper semantics",
|
|
140
|
+
"Must have an accessible label (visible or aria-label)",
|
|
141
|
+
"Focus indicator must be clearly visible",
|
|
142
|
+
"State change must be announced by screen readers"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"examples": [
|
|
146
|
+
{
|
|
147
|
+
"name": "Default Off",
|
|
148
|
+
"description": "Switch in the off state",
|
|
149
|
+
"code": "<StatefulSwitch label=\"Email notifications\" />",
|
|
150
|
+
"args": {
|
|
151
|
+
"label": "Email notifications"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "Checked",
|
|
156
|
+
"description": "Switch in the on state",
|
|
157
|
+
"code": "<StatefulSwitch checked label=\"Dark mode\" />",
|
|
158
|
+
"args": {
|
|
159
|
+
"checked": true,
|
|
160
|
+
"label": "Dark mode"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "With Helper Text",
|
|
165
|
+
"description": "Switch with explanatory helper text",
|
|
166
|
+
"code": "<StatefulSwitch\n checked\n label=\"Auto-save\"\n helperText=\"Automatically save changes as you type\"\n/>",
|
|
167
|
+
"args": {
|
|
168
|
+
"checked": true,
|
|
169
|
+
"label": "Auto-save",
|
|
170
|
+
"helperText": "Automatically save changes as you type"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "Sizes",
|
|
175
|
+
"description": "Available size variants",
|
|
176
|
+
"code": "<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>\n <StatefulSwitch size=\"sm\" checked label=\"Small switch\" />\n <StatefulSwitch size=\"md\" checked label=\"Medium switch (default)\" />\n <StatefulSwitch size=\"lg\" checked label=\"Large switch\" />\n</div>"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "Disabled States",
|
|
180
|
+
"description": "Non-interactive switches showing both states",
|
|
181
|
+
"code": "<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>\n <Switch disabled label=\"Premium feature (upgrade required)\" />\n <Switch disabled checked label=\"System managed (read-only)\" />\n</div>"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "Settings Panel",
|
|
185
|
+
"description": "Multiple switches in a realistic settings layout",
|
|
186
|
+
"code": "<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '320px' }}>\n <StatefulSwitch\n checked\n label=\"Push notifications\"\n helperText=\"Receive push notifications on your device\"\n />\n <StatefulSwitch\n checked\n label=\"Email digest\"\n helperText=\"Weekly summary of your activity\"\n />\n <StatefulSwitch\n label=\"Marketing emails\"\n helperText=\"Product updates and promotional offers\"\n />\n</div>"
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"relations": [
|
|
190
|
+
{
|
|
191
|
+
"component": "Input",
|
|
192
|
+
"relationship": "sibling",
|
|
193
|
+
"note": "Input handles text/number entry; Switch handles boolean state"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"component": "Checkbox",
|
|
197
|
+
"relationship": "alternative",
|
|
198
|
+
"note": "Use Checkbox when change requires form submission"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"contract": {
|
|
202
|
+
"propsSummary": [
|
|
203
|
+
"checked: boolean - on/off state",
|
|
204
|
+
"onCheckedChange: (checked) => void - state change handler",
|
|
205
|
+
"onChange: (checked) => void - alias for onCheckedChange",
|
|
206
|
+
"label: string - visible label text",
|
|
207
|
+
"helperText: string - helper text below label (preferred)",
|
|
208
|
+
"description: string - deprecated alias for helperText",
|
|
209
|
+
"disabled: boolean - non-interactive state",
|
|
210
|
+
"size: sm|md|lg - switch size"
|
|
211
|
+
],
|
|
212
|
+
"a11yRules": [
|
|
213
|
+
"A11Y_SWITCH_ROLE",
|
|
214
|
+
"A11Y_SWITCH_LABEL",
|
|
215
|
+
"A11Y_SWITCH_FOCUS",
|
|
216
|
+
"A11Y_TARGET_SIZE_MIN"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
"ai": {
|
|
220
|
+
"compositionPattern": "compound",
|
|
221
|
+
"subComponents": [
|
|
222
|
+
"Root"
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
"provenance": {
|
|
226
|
+
"source": "migrated",
|
|
227
|
+
"verified": false,
|
|
228
|
+
"frameworkSupport": "native",
|
|
229
|
+
"extractedAt": "2026-03-13T23:19:06.429Z"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://usefragments.com/schemas/contract.v1.json",
|
|
3
|
+
"name": "ToggleGroup",
|
|
4
|
+
"description": "A group of toggle buttons where only one can be selected at a time. Useful for switching between views, modes, or options.",
|
|
5
|
+
"category": "forms",
|
|
6
|
+
"tags": [
|
|
7
|
+
"toggle",
|
|
8
|
+
"group",
|
|
9
|
+
"fragmented",
|
|
10
|
+
"control",
|
|
11
|
+
"tabs",
|
|
12
|
+
"switch"
|
|
13
|
+
],
|
|
14
|
+
"status": "stable",
|
|
15
|
+
"sourcePath": "src/components/ToggleGroup/index.tsx",
|
|
16
|
+
"exportName": "ToggleGroup",
|
|
17
|
+
"propsSummary": [
|
|
18
|
+
"value: string",
|
|
19
|
+
"defaultValue: string",
|
|
20
|
+
"onChange: function",
|
|
21
|
+
"onValueChange: function",
|
|
22
|
+
"children: node (required)",
|
|
23
|
+
"variant: default|pills|outline|outlined (default: default)",
|
|
24
|
+
"size: sm|md|lg (default: md)",
|
|
25
|
+
"gap: sm|none|xs (default: xs)",
|
|
26
|
+
"selectionMode: single (default: single)"
|
|
27
|
+
],
|
|
28
|
+
"props": {
|
|
29
|
+
"value": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Currently selected value",
|
|
32
|
+
"required": false
|
|
33
|
+
},
|
|
34
|
+
"defaultValue": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Initial selected value (uncontrolled)",
|
|
37
|
+
"required": false
|
|
38
|
+
},
|
|
39
|
+
"onChange": {
|
|
40
|
+
"type": "function",
|
|
41
|
+
"description": "Called with new value when selection changes",
|
|
42
|
+
"required": false
|
|
43
|
+
},
|
|
44
|
+
"onValueChange": {
|
|
45
|
+
"type": "function",
|
|
46
|
+
"description": "Alias for onChange (Radix convention): (value: string) => void",
|
|
47
|
+
"required": false
|
|
48
|
+
},
|
|
49
|
+
"children": {
|
|
50
|
+
"type": "node",
|
|
51
|
+
"description": "ToggleGroup.Item components",
|
|
52
|
+
"required": true
|
|
53
|
+
},
|
|
54
|
+
"variant": {
|
|
55
|
+
"type": "enum",
|
|
56
|
+
"description": "Visual style",
|
|
57
|
+
"default": "default",
|
|
58
|
+
"required": false,
|
|
59
|
+
"values": [
|
|
60
|
+
"default",
|
|
61
|
+
"pills",
|
|
62
|
+
"outline",
|
|
63
|
+
"outlined"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"size": {
|
|
67
|
+
"type": "enum",
|
|
68
|
+
"description": "Size variant",
|
|
69
|
+
"default": "md",
|
|
70
|
+
"required": false,
|
|
71
|
+
"values": [
|
|
72
|
+
"sm",
|
|
73
|
+
"md",
|
|
74
|
+
"lg"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"gap": {
|
|
78
|
+
"type": "enum",
|
|
79
|
+
"description": "Gap between items (pills/outline variants)",
|
|
80
|
+
"default": "xs",
|
|
81
|
+
"required": false,
|
|
82
|
+
"values": [
|
|
83
|
+
"sm",
|
|
84
|
+
"none",
|
|
85
|
+
"xs"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"selectionMode": {
|
|
89
|
+
"type": "enum",
|
|
90
|
+
"description": "Selection behavior",
|
|
91
|
+
"default": "single",
|
|
92
|
+
"required": false,
|
|
93
|
+
"values": [
|
|
94
|
+
"single"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"usage": {
|
|
99
|
+
"when": [
|
|
100
|
+
"Switching between mutually exclusive views or modes",
|
|
101
|
+
"Selecting one option from a small set (2-5 options)",
|
|
102
|
+
"Fragmented controls like view switchers",
|
|
103
|
+
"Filter or sort options"
|
|
104
|
+
],
|
|
105
|
+
"whenNot": [
|
|
106
|
+
"Multiple selections allowed (use Checkbox group)",
|
|
107
|
+
"Many options (use Select or RadioGroup)",
|
|
108
|
+
"Navigation between pages (use Tabs)",
|
|
109
|
+
"On/off toggle (use Switch component)"
|
|
110
|
+
],
|
|
111
|
+
"guidelines": [
|
|
112
|
+
"Keep options to 2-5 items for clarity",
|
|
113
|
+
"Use clear, concise labels",
|
|
114
|
+
"Consider icons for common actions (grid/list view)",
|
|
115
|
+
"Ensure adequate touch targets on mobile"
|
|
116
|
+
],
|
|
117
|
+
"accessibility": [
|
|
118
|
+
"Uses role=\"radiogroup\" for single-selection semantics",
|
|
119
|
+
"Each item has role=\"radio\" with aria-checked",
|
|
120
|
+
"Keyboard navigable with Tab and arrow keys",
|
|
121
|
+
"Focus visible on active item"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"examples": [
|
|
125
|
+
{
|
|
126
|
+
"name": "Default",
|
|
127
|
+
"description": "Basic toggle group",
|
|
128
|
+
"code": "<ToggleGroup value={value} onChange={setValue}>\n <ToggleGroup.Item value=\"left\">Left</ToggleGroup.Item>\n <ToggleGroup.Item value=\"center\">Center</ToggleGroup.Item>\n <ToggleGroup.Item value=\"right\">Right</ToggleGroup.Item>\n</ToggleGroup>"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "Pills Variant",
|
|
132
|
+
"description": "Pill-shaped toggle buttons",
|
|
133
|
+
"code": "<ToggleGroup value={value} onChange={setValue} variant=\"pills\">\n <ToggleGroup.Item value=\"all\">All</ToggleGroup.Item>\n <ToggleGroup.Item value=\"active\">Active</ToggleGroup.Item>\n <ToggleGroup.Item value=\"completed\">Completed</ToggleGroup.Item>\n</ToggleGroup>"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "Outline Variant",
|
|
137
|
+
"description": "Outlined toggle buttons",
|
|
138
|
+
"code": "<ToggleGroup value={value} onChange={setValue} variant=\"outlined\">\n <ToggleGroup.Item value=\"day\">Day</ToggleGroup.Item>\n <ToggleGroup.Item value=\"week\">Week</ToggleGroup.Item>\n <ToggleGroup.Item value=\"month\">Month</ToggleGroup.Item>\n</ToggleGroup>"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "Uncontrolled",
|
|
142
|
+
"description": "Use defaultValue for simple single-select state",
|
|
143
|
+
"code": "<ToggleGroup defaultValue=\"list\">\n <ToggleGroup.Item value=\"grid\">Grid</ToggleGroup.Item>\n <ToggleGroup.Item value=\"list\">List</ToggleGroup.Item>\n</ToggleGroup>"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "Sizes",
|
|
147
|
+
"description": "Different size variants",
|
|
148
|
+
"code": "<ToggleGroup value={value} onChange={setValue} size=\"sm\">\n <ToggleGroup.Item value=\"a\">Small</ToggleGroup.Item>\n <ToggleGroup.Item value=\"b\">Size</ToggleGroup.Item>\n</ToggleGroup>\n<ToggleGroup value={value} onChange={setValue} size=\"md\">\n <ToggleGroup.Item value=\"a\">Medium</ToggleGroup.Item>\n <ToggleGroup.Item value=\"b\">Size</ToggleGroup.Item>\n</ToggleGroup>"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "View Switcher",
|
|
152
|
+
"description": "Common pattern for switching between views",
|
|
153
|
+
"code": "<ToggleGroup value={view} onChange={setView} size=\"sm\">\n <ToggleGroup.Item value=\"grid\"><GridIcon /></ToggleGroup.Item>\n <ToggleGroup.Item value=\"list\"><ListIcon /></ToggleGroup.Item>\n</ToggleGroup>"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "With Disabled Item",
|
|
157
|
+
"description": "Toggle group with a disabled option",
|
|
158
|
+
"code": "<ToggleGroup value={value} onChange={setValue}>\n <ToggleGroup.Item value=\"basic\">Basic</ToggleGroup.Item>\n <ToggleGroup.Item value=\"pro\">Pro</ToggleGroup.Item>\n <ToggleGroup.Item value=\"enterprise\" disabled>Enterprise</ToggleGroup.Item>\n</ToggleGroup>"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"relations": [
|
|
162
|
+
{
|
|
163
|
+
"component": "RadioGroup",
|
|
164
|
+
"relationship": "alternative",
|
|
165
|
+
"note": "RadioGroup for form-style single selection"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"component": "Tabs",
|
|
169
|
+
"relationship": "alternative",
|
|
170
|
+
"note": "Tabs for content panel switching"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"component": "Switch",
|
|
174
|
+
"relationship": "sibling",
|
|
175
|
+
"note": "Switch for single on/off control"
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"contract": {
|
|
179
|
+
"propsSummary": [
|
|
180
|
+
"value?: string - controlled selected value",
|
|
181
|
+
"defaultValue?: string - initial selected value (uncontrolled)",
|
|
182
|
+
"onChange: (value: string) => void - change handler (or onValueChange)",
|
|
183
|
+
"children: ToggleGroup.Item[] - toggle items",
|
|
184
|
+
"variant: default|pills|outline|outlined - visual style (outlined aliases outline)",
|
|
185
|
+
"size: sm|md - size variant",
|
|
186
|
+
"gap: none|xs|sm - spacing",
|
|
187
|
+
"selectionMode: single (default: single)"
|
|
188
|
+
],
|
|
189
|
+
"a11yRules": [
|
|
190
|
+
"A11Y_GROUP_ROLE",
|
|
191
|
+
"A11Y_KEYBOARD_ACCESSIBLE"
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
"ai": {
|
|
195
|
+
"compositionPattern": "compound",
|
|
196
|
+
"subComponents": [
|
|
197
|
+
"Item"
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"provenance": {
|
|
201
|
+
"source": "migrated",
|
|
202
|
+
"verified": false,
|
|
203
|
+
"frameworkSupport": "native",
|
|
204
|
+
"extractedAt": "2026-03-13T23:19:07.233Z"
|
|
205
|
+
}
|
|
206
|
+
}
|