@coinbase/cds-mcp-server 8.29.0 → 8.30.1
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/CHANGELOG.md +8 -0
- package/mcp-docs/mobile/components/SelectChipAlpha.txt +87 -0
- package/mcp-docs/mobile/components/TabbedChipsAlpha.txt +30 -0
- package/mcp-docs/web/components/Chip.txt +1 -1
- package/mcp-docs/web/components/InputChip.txt +1 -1
- package/mcp-docs/web/components/MediaChip.txt +1 -1
- package/mcp-docs/web/components/SelectChip.txt +1 -1
- package/mcp-docs/web/components/SelectChipAlpha.txt +86 -2
- package/mcp-docs/web/components/Sidebar.txt +490 -34
- package/mcp-docs/web/components/TabbedChipsAlpha.txt +35 -1
- package/mcp-docs/web/routes.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,14 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 8.30.1 ((12/12/2025, 03:00 PM PST))
|
|
12
|
+
|
|
13
|
+
This is an artificial version bump with no new change.
|
|
14
|
+
|
|
15
|
+
## 8.30.0 ((12/12/2025, 02:53 PM PST))
|
|
16
|
+
|
|
17
|
+
This is an artificial version bump with no new change.
|
|
18
|
+
|
|
11
19
|
## 8.29.0 ((12/12/2025, 01:12 PM PST))
|
|
12
20
|
|
|
13
21
|
This is an artificial version bump with no new change.
|
|
@@ -289,6 +289,91 @@ function ExampleDescriptions() {
|
|
|
289
289
|
}
|
|
290
290
|
```
|
|
291
291
|
|
|
292
|
+
### With display value
|
|
293
|
+
|
|
294
|
+
Use the `displayValue` prop to override the displayed value and avoid truncation, especially in multi-select scenarios where multiple option labels might be too long to display.
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
function ExampleDisplayValue() {
|
|
298
|
+
const exampleOptions = [
|
|
299
|
+
{ value: '1', label: 'Option 1' },
|
|
300
|
+
{ value: '2', label: 'Option 2' },
|
|
301
|
+
{ value: '3', label: 'Option 3' },
|
|
302
|
+
{ value: '4', label: 'Option 4' },
|
|
303
|
+
{ value: '5', label: 'Option 5' },
|
|
304
|
+
];
|
|
305
|
+
const { value, onChange } = useMultiSelect({ initialValue: [] });
|
|
306
|
+
const displayValue =
|
|
307
|
+
Array.isArray(value) && value.length > 0
|
|
308
|
+
? `${value.length} ${value.length === 1 ? 'option' : 'options'} selected`
|
|
309
|
+
: undefined;
|
|
310
|
+
return (
|
|
311
|
+
<SelectChip
|
|
312
|
+
accessibilityLabel="Select multiple values"
|
|
313
|
+
displayValue={displayValue}
|
|
314
|
+
onChange={onChange}
|
|
315
|
+
options={exampleOptions}
|
|
316
|
+
placeholder="Choose options"
|
|
317
|
+
type="multi"
|
|
318
|
+
value={value}
|
|
319
|
+
/>
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### With max width
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
function ExampleMaxWidth() {
|
|
328
|
+
const exampleOptions = [
|
|
329
|
+
{ value: '1', label: 'Very Long Option Name That Exceeds Default Width' },
|
|
330
|
+
{ value: '2', label: 'Another Extremely Long Option Label' },
|
|
331
|
+
{ value: '3', label: 'Short' },
|
|
332
|
+
{ value: '4', label: 'Medium Length Option' },
|
|
333
|
+
];
|
|
334
|
+
const [value, setValue] = useState<string | null>(null);
|
|
335
|
+
return (
|
|
336
|
+
<VStack gap={2}>
|
|
337
|
+
<VStack gap={1}>
|
|
338
|
+
<Text>Default maxWidth (200px):</Text>
|
|
339
|
+
<SelectChip
|
|
340
|
+
accessibilityLabel="Select a value"
|
|
341
|
+
label="Select a value"
|
|
342
|
+
onChange={setValue}
|
|
343
|
+
options={exampleOptions}
|
|
344
|
+
placeholder="Choose an option"
|
|
345
|
+
value={value}
|
|
346
|
+
/>
|
|
347
|
+
</VStack>
|
|
348
|
+
<VStack gap={1}>
|
|
349
|
+
<Text>Custom maxWidth (150px):</Text>
|
|
350
|
+
<SelectChip
|
|
351
|
+
accessibilityLabel="Select a value"
|
|
352
|
+
label="Select a value"
|
|
353
|
+
maxWidth={150}
|
|
354
|
+
onChange={setValue}
|
|
355
|
+
options={exampleOptions}
|
|
356
|
+
placeholder="Choose an option"
|
|
357
|
+
value={value}
|
|
358
|
+
/>
|
|
359
|
+
</VStack>
|
|
360
|
+
<VStack gap={1}>
|
|
361
|
+
<Text>No maxWidth constraint:</Text>
|
|
362
|
+
<SelectChip
|
|
363
|
+
accessibilityLabel="Select a value"
|
|
364
|
+
label="Select a value"
|
|
365
|
+
maxWidth="100%"
|
|
366
|
+
onChange={setValue}
|
|
367
|
+
options={exampleOptions}
|
|
368
|
+
placeholder="Choose an option"
|
|
369
|
+
value={value}
|
|
370
|
+
/>
|
|
371
|
+
</VStack>
|
|
372
|
+
</VStack>
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
292
377
|
### Disabled
|
|
293
378
|
|
|
294
379
|
```tsx
|
|
@@ -342,6 +427,7 @@ function ExampleDisabled() {
|
|
|
342
427
|
| `defaultOpen` | `boolean` | No | `-` | Initial open state when component mounts (uncontrolled mode) |
|
|
343
428
|
| `disableClickOutsideClose` | `boolean` | No | `-` | Whether clicking outside the dropdown should close it |
|
|
344
429
|
| `disabled` | `boolean` | No | `false` | Toggles input interactability and opacity |
|
|
430
|
+
| `displayValue` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Override the displayed value in the chip control. Useful for avoiding truncation, especially in multi-select scenarios where multiple option labels might be too long to display. When provided, this value takes precedence over the default label generation. |
|
|
345
431
|
| `emptyOptionsLabel` | `string` | No | `-` | Label displayed when there are no options available |
|
|
346
432
|
| `end` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | End-aligned content (e.g., value, status). Replaces the deprecated detail prop. |
|
|
347
433
|
| `endNode` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Adds content to the end of the inner input. Refer to diagram for location of endNode in InputStack component |
|
|
@@ -350,6 +436,7 @@ function ExampleDisabled() {
|
|
|
350
436
|
| `invertColorScheme` | `boolean` | No | `false` | Invert the foreground and background colors to emphasize the Chip. Depending on your theme, it may be dangerous to use this prop in conjunction with transparentWhileInactive. |
|
|
351
437
|
| `label` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Label displayed above the control |
|
|
352
438
|
| `maxSelectedOptionsToShow` | `number` | No | `-` | Maximum number of selected options to show before truncating |
|
|
439
|
+
| `maxWidth` | `string \| number` | No | `200` | If text content overflows, it will get truncated with an ellipsis. |
|
|
353
440
|
| `media` | `ReactElement` | No | `-` | Media rendered at the start of the cell (icon, avatar, image, etc). |
|
|
354
441
|
| `numberOfLines` | `number` | No | `1` | How many lines the text in the chip will be broken into. |
|
|
355
442
|
| `open` | `boolean` | No | `-` | Controlled open state of the dropdown |
|
|
@@ -57,6 +57,35 @@ function ExampleManyTabs() {
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
### With autoScrollOffset
|
|
61
|
+
|
|
62
|
+
:::tip Auto-scroll offset
|
|
63
|
+
The `autoScrollOffset` prop controls the X position offset when auto-scrolling to the active tab. This prevents the active tab from being covered by the overflow gradient on the left side. Try clicking tabs near the edges to see the difference.
|
|
64
|
+
:::
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
function ExampleAutoScrollOffset() {
|
|
68
|
+
const tabs = Array.from({ length: 25 }).map((_, i) => ({
|
|
69
|
+
id: `tab_${i + 1}`,
|
|
70
|
+
label: `Tab ${i + 1}`,
|
|
71
|
+
}));
|
|
72
|
+
const [activeTab, setActiveTab] = useState(tabs[0]);
|
|
73
|
+
return (
|
|
74
|
+
<VStack gap={2}>
|
|
75
|
+
<Text>Default offset (30px)</Text>
|
|
76
|
+
<TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} />
|
|
77
|
+
<Text>Custom offset (60px)</Text>
|
|
78
|
+
<TabbedChips
|
|
79
|
+
activeTab={activeTab}
|
|
80
|
+
onChange={setActiveTab}
|
|
81
|
+
tabs={tabs}
|
|
82
|
+
autoScrollOffset={60}
|
|
83
|
+
/>
|
|
84
|
+
</VStack>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
60
89
|
### Long text tabs
|
|
61
90
|
|
|
62
91
|
```tsx
|
|
@@ -163,6 +192,7 @@ render(<Example />);
|
|
|
163
192
|
| `tabs` | `TabbedChipProps<T>[]` | Yes | `-` | - |
|
|
164
193
|
| `TabComponent` | `FC<TabbedChipProps<T>>` | No | `-` | - |
|
|
165
194
|
| `TabsActiveIndicatorComponent` | `TabsActiveIndicatorComponent` | No | `-` | - |
|
|
195
|
+
| `autoScrollOffset` | `number` | No | `30` | X position offset when auto-scrolling to active tab (to avoid active tab being covered by the overflow gradient on the left side, default: 30px) |
|
|
166
196
|
| `compact` | `boolean` | No | `false` | Turn on to use a compact Chip component for each tab. |
|
|
167
197
|
| `disabled` | `boolean` | No | `-` | Disable interactions on all the tabs. |
|
|
168
198
|
| `gap` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `1` | The spacing between Tabs |
|
|
@@ -158,7 +158,7 @@ function Example() {
|
|
|
158
158
|
| `marginX` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
159
159
|
| `marginY` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
160
160
|
| `maxHeight` | `ResponsiveProp<MaxHeight<string \| number>>` | No | `-` | - |
|
|
161
|
-
| `maxWidth` | `
|
|
161
|
+
| `maxWidth` | `ResponsiveProp<MaxWidth<string \| number>>` | No | `200` | If text content overflows, it will get truncated with an ellipsis. |
|
|
162
162
|
| `minHeight` | `ResponsiveProp<MinHeight<string \| number>>` | No | `-` | - |
|
|
163
163
|
| `minWidth` | `ResponsiveProp<MinWidth<string \| number>>` | No | `-` | - |
|
|
164
164
|
| `noScaleOnPress` | `boolean` | No | `-` | Dont scale element on press. |
|
|
@@ -153,7 +153,7 @@ function Example() {
|
|
|
153
153
|
| `marginX` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
154
154
|
| `marginY` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
155
155
|
| `maxHeight` | `ResponsiveProp<MaxHeight<string \| number>>` | No | `-` | - |
|
|
156
|
-
| `maxWidth` | `
|
|
156
|
+
| `maxWidth` | `ResponsiveProp<MaxWidth<string \| number>>` | No | `200` | If text content overflows, it will get truncated with an ellipsis. |
|
|
157
157
|
| `minHeight` | `ResponsiveProp<MinHeight<string \| number>>` | No | `-` | - |
|
|
158
158
|
| `minWidth` | `ResponsiveProp<MinWidth<string \| number>>` | No | `-` | - |
|
|
159
159
|
| `noScaleOnPress` | `boolean` | No | `-` | Dont scale element on press. |
|
|
@@ -234,7 +234,7 @@ You can override the automatic spacing with custom values if needed.
|
|
|
234
234
|
| `marginX` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
235
235
|
| `marginY` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
236
236
|
| `maxHeight` | `ResponsiveProp<MaxHeight<string \| number>>` | No | `-` | - |
|
|
237
|
-
| `maxWidth` | `
|
|
237
|
+
| `maxWidth` | `ResponsiveProp<MaxWidth<string \| number>>` | No | `200` | If text content overflows, it will get truncated with an ellipsis. |
|
|
238
238
|
| `minHeight` | `ResponsiveProp<MinHeight<string \| number>>` | No | `-` | - |
|
|
239
239
|
| `minWidth` | `ResponsiveProp<MinWidth<string \| number>>` | No | `-` | - |
|
|
240
240
|
| `noScaleOnPress` | `boolean` | No | `-` | Dont scale element on press. |
|
|
@@ -268,7 +268,7 @@ function SelectChipExample() {
|
|
|
268
268
|
| `marginX` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
269
269
|
| `marginY` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
270
270
|
| `maxHeight` | `((MaxHeight<string \| number> \| { base?: MaxHeight<string \| number>; phone?: MaxHeight<string \| number> \| undefined; tablet?: MaxHeight<string \| number> \| undefined; desktop?: MaxHeight<string \| number> \| undefined; }) & MaxHeight<string \| number>) \| undefined` | No | `300` | Can optionally pass a maxHeight. |
|
|
271
|
-
| `maxWidth` | `((
|
|
271
|
+
| `maxWidth` | `((MaxWidth<string \| number> \| { base?: MaxWidth<string \| number>; phone?: MaxWidth<string \| number> \| undefined; tablet?: MaxWidth<string \| number> \| undefined; desktop?: MaxWidth<string \| number> \| undefined; }) & MaxWidth<string \| number>) \| undefined` | No | `200` | If text content overflows, it will get truncated with an ellipsis. Maximum width of input as a percentage string or number converted to pixels. |
|
|
272
272
|
| `minHeight` | `ResponsiveProp<MinHeight<string \| number>>` | No | `-` | - |
|
|
273
273
|
| `minWidth` | `((MinWidth<string \| number> \| { base?: MinWidth<string \| number>; phone?: MinWidth<string \| number> \| undefined; tablet?: MinWidth<string \| number> \| undefined; desktop?: MinWidth<string \| number> \| undefined; }) & MinWidth<string \| number>) \| undefined` | No | `-` | Minimum width of input as a percentage string or number converted to pixels. |
|
|
274
274
|
| `numberOfLines` | `number` | No | `1` | How many lines the text in the chip will be broken into. |
|
|
@@ -273,6 +273,88 @@ function ExampleDescriptions() {
|
|
|
273
273
|
}
|
|
274
274
|
```
|
|
275
275
|
|
|
276
|
+
### With display value
|
|
277
|
+
|
|
278
|
+
Use the `displayValue` prop to override the displayed value and avoid truncation, especially in multi-select scenarios where multiple option labels might be too long to display.
|
|
279
|
+
|
|
280
|
+
```jsx live
|
|
281
|
+
function ExampleDisplayValue() {
|
|
282
|
+
const exampleOptions = [
|
|
283
|
+
{ value: '1', label: 'Option 1' },
|
|
284
|
+
{ value: '2', label: 'Option 2' },
|
|
285
|
+
{ value: '3', label: 'Option 3' },
|
|
286
|
+
{ value: '4', label: 'Option 4' },
|
|
287
|
+
{ value: '5', label: 'Option 5' },
|
|
288
|
+
];
|
|
289
|
+
const { value, onChange } = useMultiSelect({ initialValue: [] });
|
|
290
|
+
const displayValue =
|
|
291
|
+
Array.isArray(value) && value.length > 0
|
|
292
|
+
? `${value.length} ${value.length === 1 ? 'option' : 'options'} selected`
|
|
293
|
+
: undefined;
|
|
294
|
+
return (
|
|
295
|
+
<SelectChip
|
|
296
|
+
controlAccessibilityLabel="Select multiple values"
|
|
297
|
+
displayValue={displayValue}
|
|
298
|
+
onChange={onChange}
|
|
299
|
+
options={exampleOptions}
|
|
300
|
+
placeholder="Choose options"
|
|
301
|
+
type="multi"
|
|
302
|
+
value={value}
|
|
303
|
+
/>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### With max width
|
|
309
|
+
|
|
310
|
+
```jsx live
|
|
311
|
+
function ExampleMaxWidth() {
|
|
312
|
+
const exampleOptions = [
|
|
313
|
+
{ value: '1', label: 'Very Long Option Name That Exceeds Default Width' },
|
|
314
|
+
{ value: '2', label: 'Another Extremely Long Option Label' },
|
|
315
|
+
{ value: '3', label: 'Short' },
|
|
316
|
+
{ value: '4', label: 'Medium Length Option' },
|
|
317
|
+
];
|
|
318
|
+
const [value, setValue] = useState(null);
|
|
319
|
+
return (
|
|
320
|
+
<VStack gap={2}>
|
|
321
|
+
<VStack gap={1}>
|
|
322
|
+
<Text>Default maxWidth (200px):</Text>
|
|
323
|
+
<SelectChip
|
|
324
|
+
accessibilityLabel="Select a value"
|
|
325
|
+
onChange={setValue}
|
|
326
|
+
options={exampleOptions}
|
|
327
|
+
placeholder="Choose an option"
|
|
328
|
+
value={value}
|
|
329
|
+
/>
|
|
330
|
+
</VStack>
|
|
331
|
+
<VStack gap={1}>
|
|
332
|
+
<Text>Custom maxWidth (150px):</Text>
|
|
333
|
+
<SelectChip
|
|
334
|
+
accessibilityLabel="Select a value"
|
|
335
|
+
maxWidth={150}
|
|
336
|
+
onChange={setValue}
|
|
337
|
+
options={exampleOptions}
|
|
338
|
+
placeholder="Choose an option"
|
|
339
|
+
value={value}
|
|
340
|
+
/>
|
|
341
|
+
</VStack>
|
|
342
|
+
<VStack gap={1}>
|
|
343
|
+
<Text>No maxWidth constraint:</Text>
|
|
344
|
+
<SelectChip
|
|
345
|
+
accessibilityLabel="Select a value"
|
|
346
|
+
maxWidth="100%"
|
|
347
|
+
onChange={setValue}
|
|
348
|
+
options={exampleOptions}
|
|
349
|
+
placeholder="Choose an option"
|
|
350
|
+
value={value}
|
|
351
|
+
/>
|
|
352
|
+
</VStack>
|
|
353
|
+
</VStack>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
276
358
|
### Disabled
|
|
277
359
|
|
|
278
360
|
```jsx live
|
|
@@ -285,7 +367,7 @@ function ExampleDisabled() {
|
|
|
285
367
|
];
|
|
286
368
|
const [value, setValue] = useState('1');
|
|
287
369
|
return (
|
|
288
|
-
<
|
|
370
|
+
<VStack gap={2}>
|
|
289
371
|
<SelectChip
|
|
290
372
|
disabled
|
|
291
373
|
accessibilityLabel="Select a value"
|
|
@@ -302,7 +384,7 @@ function ExampleDisabled() {
|
|
|
302
384
|
placeholder="Choose an option"
|
|
303
385
|
value={value}
|
|
304
386
|
/>
|
|
305
|
-
</
|
|
387
|
+
</VStack>
|
|
306
388
|
);
|
|
307
389
|
}
|
|
308
390
|
```
|
|
@@ -329,6 +411,7 @@ function ExampleDisabled() {
|
|
|
329
411
|
| `defaultOpen` | `boolean` | No | `-` | Initial open state when component mounts (uncontrolled mode) |
|
|
330
412
|
| `disableClickOutsideClose` | `boolean` | No | `-` | Whether clicking outside the dropdown should close it |
|
|
331
413
|
| `disabled` | `boolean` | No | `false` | Toggles input interactability and opacity |
|
|
414
|
+
| `displayValue` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Override the displayed value in the chip control. Useful for avoiding truncation, especially in multi-select scenarios where multiple option labels might be too long to display. When provided, this value takes precedence over the default label generation. |
|
|
332
415
|
| `emptyOptionsLabel` | `string` | No | `-` | Label displayed when there are no options available |
|
|
333
416
|
| `end` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | End-aligned content (e.g., value, status). Replaces the deprecated detail prop. |
|
|
334
417
|
| `endNode` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Adds content to the end of the inner input. Refer to diagram for location of endNode in InputStack component |
|
|
@@ -337,6 +420,7 @@ function ExampleDisabled() {
|
|
|
337
420
|
| `invertColorScheme` | `boolean` | No | `false` | Invert the foreground and background colors to emphasize the Chip. Depending on your theme, it may be dangerous to use this prop in conjunction with transparentWhileInactive. |
|
|
338
421
|
| `label` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Label displayed above the control |
|
|
339
422
|
| `maxSelectedOptionsToShow` | `number` | No | `-` | Maximum number of selected options to show before truncating |
|
|
423
|
+
| `maxWidth` | `ResponsiveProp<MaxWidth<string \| number>>` | No | `200` | If text content overflows, it will get truncated with an ellipsis. |
|
|
340
424
|
| `media` | `ReactElement` | No | `-` | Media rendered at the start of the cell (icon, avatar, image, etc). |
|
|
341
425
|
| `numberOfLines` | `number` | No | `1` | How many lines the text in the chip will be broken into. |
|
|
342
426
|
| `open` | `boolean` | No | `-` | Controlled open state of the dropdown |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sidebar
|
|
2
2
|
|
|
3
|
-
A vertical navigation
|
|
3
|
+
A composable and customizable vertical navigation component with support for multiple variants, collapsible states, and custom content areas.
|
|
4
4
|
|
|
5
5
|
## Import
|
|
6
6
|
|
|
@@ -10,12 +10,53 @@ import { Sidebar } from '@coinbase/cds-web/navigation/Sidebar'
|
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Sidebar is a vertical navigation component for accessing different sections of an application. It supports multiple variants, collapsible states, and custom content areas.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### Basics
|
|
16
|
+
|
|
17
|
+
A Sidebar is composed of the following parts:
|
|
18
|
+
|
|
19
|
+
- `Sidebar` - The main container with logo and navigation items
|
|
20
|
+
- `SidebarItem` - Individual navigation items with icon and title
|
|
21
|
+
- `SidebarMoreMenu` - Overflow menu for additional navigation options
|
|
22
|
+
|
|
23
|
+
```jsx live
|
|
24
|
+
function BasicSidebar() {
|
|
25
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
26
|
+
const items = [
|
|
27
|
+
{ title: 'Home', icon: 'home' },
|
|
28
|
+
{ title: 'Assets', icon: 'chartPie' },
|
|
29
|
+
{ title: 'Trade', icon: 'trading' },
|
|
30
|
+
{ title: 'Settings', icon: 'cog' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<HStack alignItems="flex-start" justifyContent="center" overflow="hidden">
|
|
35
|
+
<Sidebar logo={<LogoMark />}>
|
|
36
|
+
{items.map((item, index) => (
|
|
37
|
+
<SidebarItem
|
|
38
|
+
key={item.title}
|
|
39
|
+
active={index === activeIndex}
|
|
40
|
+
icon={item.icon}
|
|
41
|
+
onClick={() => setActiveIndex(index)}
|
|
42
|
+
title={item.title}
|
|
43
|
+
tooltipContent={item.title}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
</Sidebar>
|
|
47
|
+
</HStack>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Variants
|
|
53
|
+
|
|
54
|
+
#### Default
|
|
55
|
+
|
|
56
|
+
Use the Default variant on standard consumer-facing surfaces like Retail where maximum navigation and content space is desired. This variant shows full labels alongside icons.
|
|
16
57
|
|
|
17
58
|
```jsx live
|
|
18
|
-
function
|
|
59
|
+
function DefaultVariant() {
|
|
19
60
|
const items = [
|
|
20
61
|
{ title: 'Home', icon: 'home' },
|
|
21
62
|
{ title: 'Assets', icon: 'chartPie' },
|
|
@@ -44,18 +85,13 @@ function Example() {
|
|
|
44
85
|
return (
|
|
45
86
|
<Pressable
|
|
46
87
|
as="button"
|
|
47
|
-
background="
|
|
88
|
+
background="bgPrimaryWash"
|
|
48
89
|
borderRadius={1000}
|
|
90
|
+
transparentWhileInactive
|
|
49
91
|
width="100%"
|
|
50
92
|
onClick={() => console.log}
|
|
51
93
|
>
|
|
52
|
-
<HStack
|
|
53
|
-
alignItems="center"
|
|
54
|
-
gap={2}
|
|
55
|
-
justifyContent="flex-start"
|
|
56
|
-
padding={2}
|
|
57
|
-
testID="sidebar-item-primary"
|
|
58
|
-
>
|
|
94
|
+
<HStack alignItems="center" gap={2} paddingX={2} paddingY={2}>
|
|
59
95
|
<Icon name="documentation" />
|
|
60
96
|
<Text as="span" font="headline" color="foreground">
|
|
61
97
|
End item
|
|
@@ -73,6 +109,11 @@ function Example() {
|
|
|
73
109
|
</Box>
|
|
74
110
|
}
|
|
75
111
|
renderEnd={renderEnd}
|
|
112
|
+
styles={{
|
|
113
|
+
end: {
|
|
114
|
+
width: '100%',
|
|
115
|
+
},
|
|
116
|
+
}}
|
|
76
117
|
>
|
|
77
118
|
{navItems.map((item, index) => (
|
|
78
119
|
<SidebarItem
|
|
@@ -104,12 +145,77 @@ function Example() {
|
|
|
104
145
|
}
|
|
105
146
|
```
|
|
106
147
|
|
|
107
|
-
|
|
148
|
+
#### Condensed
|
|
108
149
|
|
|
109
|
-
Use
|
|
150
|
+
Use in specialized workflows with complex data displays, such as Exchange and Advanced Trade, where navigation space is minimized to focus on core tasks. This variant displays icons with small labels below.
|
|
110
151
|
|
|
111
152
|
```jsx live
|
|
112
|
-
function
|
|
153
|
+
function CondensedVariant() {
|
|
154
|
+
const items = [
|
|
155
|
+
{ title: 'Spot', icon: 'chartCandles' },
|
|
156
|
+
{ title: 'Futures', icon: 'chartBar' },
|
|
157
|
+
{ title: 'Portfolio', icon: 'chartPie' },
|
|
158
|
+
{ title: 'Orders', icon: 'documentation' },
|
|
159
|
+
{ title: 'For you', icon: 'newsFeed' },
|
|
160
|
+
{ title: 'Earn', icon: 'giftBox' },
|
|
161
|
+
{ title: 'Borrow', icon: 'cash' },
|
|
162
|
+
{ title: 'DeFi', icon: 'defi' },
|
|
163
|
+
];
|
|
164
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
165
|
+
const [moreMenuValue, setMoreMenuValue] = useState();
|
|
166
|
+
const navItems = items.slice(0, 4);
|
|
167
|
+
const moreMenuOptions = items.slice(4);
|
|
168
|
+
const handleMoreMenuChange = (newValue) => {
|
|
169
|
+
const moreIndex =
|
|
170
|
+
moreMenuOptions.findIndex((option) => option.title === newValue) + navItems.length;
|
|
171
|
+
setActiveIndex(moreIndex);
|
|
172
|
+
setMoreMenuValue(newValue);
|
|
173
|
+
};
|
|
174
|
+
const handleItemClick = (index) => {
|
|
175
|
+
setActiveIndex(index);
|
|
176
|
+
setMoreMenuValue(undefined);
|
|
177
|
+
};
|
|
178
|
+
return (
|
|
179
|
+
<HStack alignItems="flex-start" justifyContent="center" overflow="hidden">
|
|
180
|
+
<Sidebar logo={<LogoMark foreground />} variant="condensed">
|
|
181
|
+
{navItems.map((item, index) => (
|
|
182
|
+
<SidebarItem
|
|
183
|
+
key={`sidebar-item--${item.title}`}
|
|
184
|
+
active={index === activeIndex}
|
|
185
|
+
onClick={() => handleItemClick(index)}
|
|
186
|
+
tooltipContent={item.title}
|
|
187
|
+
{...item}
|
|
188
|
+
/>
|
|
189
|
+
))}
|
|
190
|
+
<SidebarMoreMenu
|
|
191
|
+
active={activeIndex >= navItems.length}
|
|
192
|
+
onChange={handleMoreMenuChange}
|
|
193
|
+
tooltipContent="More"
|
|
194
|
+
value={moreMenuValue}
|
|
195
|
+
>
|
|
196
|
+
{moreMenuOptions.map((item) => (
|
|
197
|
+
<SelectOption
|
|
198
|
+
key={`sidebar-more-menu-item--${item.title}`}
|
|
199
|
+
description={item.title}
|
|
200
|
+
media={<Icon name={item.icon} />}
|
|
201
|
+
value={item.title}
|
|
202
|
+
/>
|
|
203
|
+
))}
|
|
204
|
+
</SidebarMoreMenu>
|
|
205
|
+
</Sidebar>
|
|
206
|
+
</HStack>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Collapsed State
|
|
212
|
+
|
|
213
|
+
#### Controlled Collapse
|
|
214
|
+
|
|
215
|
+
Use the `collapsed` prop to control the sidebar's collapsed state. When collapsed, only icons are shown with tooltips for labels.
|
|
216
|
+
|
|
217
|
+
```jsx live
|
|
218
|
+
function ControlledCollapse() {
|
|
113
219
|
const items = [
|
|
114
220
|
{ title: 'Home', icon: 'home' },
|
|
115
221
|
{ title: 'Assets', icon: 'chartPie' },
|
|
@@ -175,46 +281,331 @@ function Example() {
|
|
|
175
281
|
}
|
|
176
282
|
```
|
|
177
283
|
|
|
178
|
-
|
|
284
|
+
#### Auto Collapse
|
|
179
285
|
|
|
180
|
-
Use
|
|
286
|
+
Use the `autoCollapse` prop to automatically collapse the sidebar at or below the tablet breakpoint (768px). This is useful for responsive layouts where the sidebar should adapt to screen size.
|
|
181
287
|
|
|
182
288
|
```jsx live
|
|
183
|
-
function
|
|
289
|
+
function AutoCollapse() {
|
|
184
290
|
const items = [
|
|
185
|
-
{ title: '
|
|
186
|
-
{ title: '
|
|
187
|
-
{ title: '
|
|
188
|
-
{ title: '
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
291
|
+
{ title: 'Home', icon: 'home' },
|
|
292
|
+
{ title: 'Assets', icon: 'chartPie' },
|
|
293
|
+
{ title: 'Trade', icon: 'trading' },
|
|
294
|
+
{ title: 'Settings', icon: 'cog' },
|
|
295
|
+
];
|
|
296
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
297
|
+
|
|
298
|
+
return (
|
|
299
|
+
<HStack alignItems="flex-start" justifyContent="center" overflow="hidden">
|
|
300
|
+
<Sidebar autoCollapse logo={<LogoMark />}>
|
|
301
|
+
{items.map((item, index) => (
|
|
302
|
+
<SidebarItem
|
|
303
|
+
key={item.title}
|
|
304
|
+
active={index === activeIndex}
|
|
305
|
+
icon={item.icon}
|
|
306
|
+
onClick={() => setActiveIndex(index)}
|
|
307
|
+
title={item.title}
|
|
308
|
+
tooltipContent={item.title}
|
|
309
|
+
/>
|
|
310
|
+
))}
|
|
311
|
+
</Sidebar>
|
|
312
|
+
<VStack flexGrow={1} padding={3}>
|
|
313
|
+
<Text color="fgMuted" font="label1">
|
|
314
|
+
Resize the browser window to see the sidebar auto-collapse at the tablet breakpoint.
|
|
315
|
+
</Text>
|
|
316
|
+
</VStack>
|
|
317
|
+
</HStack>
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Custom Content
|
|
323
|
+
|
|
324
|
+
#### Logo
|
|
325
|
+
|
|
326
|
+
The `logo` prop accepts either a React element or a render function that receives the collapsed state. Use the render function when you need different logos for collapsed and expanded states.
|
|
327
|
+
|
|
328
|
+
```jsx live
|
|
329
|
+
function CustomLogo() {
|
|
330
|
+
const items = [
|
|
331
|
+
{ title: 'Home', icon: 'home' },
|
|
332
|
+
{ title: 'Assets', icon: 'chartPie' },
|
|
333
|
+
{ title: 'Trade', icon: 'trading' },
|
|
334
|
+
];
|
|
335
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
336
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
337
|
+
|
|
338
|
+
const renderLogo = (isCollapsed) =>
|
|
339
|
+
isCollapsed ? (
|
|
340
|
+
<LogoMark />
|
|
341
|
+
) : (
|
|
342
|
+
<Box height={32}>
|
|
343
|
+
<SubBrandLogoMark type="commerce" />
|
|
344
|
+
</Box>
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
return (
|
|
348
|
+
<HStack alignItems="flex-start" justifyContent="center" overflow="hidden">
|
|
349
|
+
<Sidebar
|
|
350
|
+
collapsed={collapsed}
|
|
351
|
+
logo={renderLogo}
|
|
352
|
+
renderEnd={() => (
|
|
353
|
+
<IconButton
|
|
354
|
+
name={collapsed ? 'caretRight' : 'caretLeft'}
|
|
355
|
+
onClick={() => setCollapsed(!collapsed)}
|
|
356
|
+
/>
|
|
357
|
+
)}
|
|
358
|
+
>
|
|
359
|
+
{items.map((item, index) => (
|
|
360
|
+
<SidebarItem
|
|
361
|
+
key={item.title}
|
|
362
|
+
active={index === activeIndex}
|
|
363
|
+
icon={item.icon}
|
|
364
|
+
onClick={() => setActiveIndex(index)}
|
|
365
|
+
title={item.title}
|
|
366
|
+
tooltipContent={item.title}
|
|
367
|
+
/>
|
|
368
|
+
))}
|
|
369
|
+
</Sidebar>
|
|
370
|
+
</HStack>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
#### Render End
|
|
376
|
+
|
|
377
|
+
The `renderEnd` prop places content at the bottom of the sidebar. It receives the collapsed state as a parameter, allowing you to adapt the content based on the sidebar's state.
|
|
378
|
+
|
|
379
|
+
```jsx live
|
|
380
|
+
function RenderEndExample() {
|
|
381
|
+
const items = [
|
|
382
|
+
{ title: 'Home', icon: 'home' },
|
|
383
|
+
{ title: 'Assets', icon: 'chartPie' },
|
|
384
|
+
{ title: 'Trade', icon: 'trading' },
|
|
385
|
+
];
|
|
386
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
387
|
+
|
|
388
|
+
const renderEnd = (isCollapsed) => (
|
|
389
|
+
<Pressable
|
|
390
|
+
as="button"
|
|
391
|
+
background="bgPrimaryWash"
|
|
392
|
+
borderRadius={1000}
|
|
393
|
+
transparentWhileInactive
|
|
394
|
+
width="100%"
|
|
395
|
+
onClick={() => alert('Help clicked!')}
|
|
396
|
+
>
|
|
397
|
+
<HStack alignItems="center" gap={2} paddingX={2} paddingY={2}>
|
|
398
|
+
<Icon name="questionCircle" />
|
|
399
|
+
{!isCollapsed && (
|
|
400
|
+
<TextHeadline as="span" color="foreground">
|
|
401
|
+
Help & Support
|
|
402
|
+
</TextHeadline>
|
|
403
|
+
)}
|
|
404
|
+
</HStack>
|
|
405
|
+
</Pressable>
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
return (
|
|
409
|
+
<HStack alignItems="flex-start" justifyContent="center" overflow="hidden">
|
|
410
|
+
<Sidebar
|
|
411
|
+
logo={<LogoMark />}
|
|
412
|
+
renderEnd={renderEnd}
|
|
413
|
+
styles={{
|
|
414
|
+
end: {
|
|
415
|
+
width: '100%',
|
|
416
|
+
},
|
|
417
|
+
}}
|
|
418
|
+
>
|
|
419
|
+
{items.map((item, index) => (
|
|
420
|
+
<SidebarItem
|
|
421
|
+
key={item.title}
|
|
422
|
+
active={index === activeIndex}
|
|
423
|
+
icon={item.icon}
|
|
424
|
+
onClick={() => setActiveIndex(index)}
|
|
425
|
+
title={item.title}
|
|
426
|
+
tooltipContent={item.title}
|
|
427
|
+
/>
|
|
428
|
+
))}
|
|
429
|
+
</Sidebar>
|
|
430
|
+
</HStack>
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Styling
|
|
436
|
+
|
|
437
|
+
Use the `styles` prop to customize specific parts of the sidebar.
|
|
438
|
+
|
|
439
|
+
```jsx live
|
|
440
|
+
function CustomStyles() {
|
|
441
|
+
const items = [
|
|
442
|
+
{ title: 'Home', icon: 'home' },
|
|
443
|
+
{ title: 'Assets', icon: 'chartPie' },
|
|
444
|
+
{ title: 'Trade', icon: 'trading' },
|
|
445
|
+
{ title: 'Settings', icon: 'cog' },
|
|
446
|
+
];
|
|
447
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
448
|
+
|
|
449
|
+
return (
|
|
450
|
+
<HStack alignItems="flex-start" justifyContent="center" overflow="hidden">
|
|
451
|
+
<Sidebar
|
|
452
|
+
logo={<LogoMark />}
|
|
453
|
+
renderEnd={() => (
|
|
454
|
+
<Pressable
|
|
455
|
+
as="button"
|
|
456
|
+
background="bgPrimaryWash"
|
|
457
|
+
borderRadius={1000}
|
|
458
|
+
transparentWhileInactive
|
|
459
|
+
width="100%"
|
|
460
|
+
>
|
|
461
|
+
<HStack alignItems="center" gap={2} paddingX={2} paddingY={2}>
|
|
462
|
+
<Icon name="questionCircle" />
|
|
463
|
+
<TextHeadline as="span">Help</TextHeadline>
|
|
464
|
+
</HStack>
|
|
465
|
+
</Pressable>
|
|
466
|
+
)}
|
|
467
|
+
styles={{
|
|
468
|
+
root: {
|
|
469
|
+
background:
|
|
470
|
+
'linear-gradient(180deg, var(--color-bg) 0%, var(--color-bgAlternate) 100%)',
|
|
471
|
+
},
|
|
472
|
+
logo: { paddingBottom: 32 },
|
|
473
|
+
end: { width: '100%' },
|
|
474
|
+
}}
|
|
475
|
+
>
|
|
476
|
+
{items.map((item, index) => (
|
|
477
|
+
<SidebarItem
|
|
478
|
+
key={item.title}
|
|
479
|
+
active={index === activeIndex}
|
|
480
|
+
icon={item.icon}
|
|
481
|
+
onClick={() => setActiveIndex(index)}
|
|
482
|
+
title={item.title}
|
|
483
|
+
tooltipContent={item.title}
|
|
484
|
+
/>
|
|
485
|
+
))}
|
|
486
|
+
</Sidebar>
|
|
487
|
+
</HStack>
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
You can also use custom class names on the various subcomponents in Sidebar using the `classNames` prop.
|
|
493
|
+
|
|
494
|
+
```jsx
|
|
495
|
+
const customLogoStyles = css`
|
|
496
|
+
padding-bottom: var(--spacing-6);
|
|
497
|
+
`;
|
|
498
|
+
|
|
499
|
+
function CustomClassNamesExample() {
|
|
500
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
501
|
+
const items = [
|
|
502
|
+
{ title: 'Home', icon: 'home' },
|
|
503
|
+
{ title: 'Assets', icon: 'chartPie' },
|
|
504
|
+
{ title: 'Trade', icon: 'trading' },
|
|
505
|
+
{ title: 'Settings', icon: 'cog' },
|
|
506
|
+
];
|
|
507
|
+
|
|
508
|
+
return (
|
|
509
|
+
<Sidebar
|
|
510
|
+
logo={<LogoMark />}
|
|
511
|
+
classNames={{
|
|
512
|
+
logo: customLogoStyles,
|
|
513
|
+
}}
|
|
514
|
+
>
|
|
515
|
+
{items.map((item, index) => (
|
|
516
|
+
<SidebarItem
|
|
517
|
+
key={item.title}
|
|
518
|
+
active={index === activeIndex}
|
|
519
|
+
icon={item.icon}
|
|
520
|
+
onClick={() => setActiveIndex(index)}
|
|
521
|
+
title={item.title}
|
|
522
|
+
tooltipContent={item.title}
|
|
523
|
+
/>
|
|
524
|
+
))}
|
|
525
|
+
</Sidebar>
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Composed Examples
|
|
531
|
+
|
|
532
|
+
#### Application Shell
|
|
533
|
+
|
|
534
|
+
A complete application layout with sidebar navigation, main content area, and responsive behavior.
|
|
535
|
+
|
|
536
|
+
```jsx live
|
|
537
|
+
function ApplicationShell() {
|
|
538
|
+
const items = [
|
|
539
|
+
{ title: 'Dashboard', icon: 'home' },
|
|
540
|
+
{ title: 'Analytics', icon: 'chartPie' },
|
|
541
|
+
{ title: 'Transactions', icon: 'trading' },
|
|
542
|
+
{ title: 'Payments', icon: 'pay' },
|
|
543
|
+
{ title: 'News Feed', icon: 'newsFeed' },
|
|
544
|
+
{ title: 'Rewards', icon: 'giftBox' },
|
|
545
|
+
{ title: 'Lending', icon: 'cash' },
|
|
192
546
|
{ title: 'DeFi', icon: 'defi' },
|
|
193
547
|
];
|
|
194
548
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
195
549
|
const [moreMenuValue, setMoreMenuValue] = useState();
|
|
196
|
-
const navItems = items.slice(0,
|
|
197
|
-
const moreMenuOptions = items.slice(
|
|
550
|
+
const navItems = items.slice(0, 5);
|
|
551
|
+
const moreMenuOptions = items.slice(5);
|
|
552
|
+
|
|
198
553
|
const handleMoreMenuChange = (newValue) => {
|
|
199
554
|
const moreIndex =
|
|
200
555
|
moreMenuOptions.findIndex((option) => option.title === newValue) + navItems.length;
|
|
201
556
|
setActiveIndex(moreIndex);
|
|
202
557
|
setMoreMenuValue(newValue);
|
|
203
558
|
};
|
|
204
|
-
|
|
559
|
+
|
|
560
|
+
const handleItemPress = (index) => {
|
|
205
561
|
setActiveIndex(index);
|
|
206
562
|
setMoreMenuValue(undefined);
|
|
207
563
|
};
|
|
564
|
+
|
|
565
|
+
const currentPage = items[activeIndex]?.title || 'Dashboard';
|
|
566
|
+
|
|
208
567
|
return (
|
|
209
|
-
<HStack alignItems="
|
|
210
|
-
<Sidebar
|
|
568
|
+
<HStack alignItems="stretch" height={400} overflow="hidden">
|
|
569
|
+
<Sidebar
|
|
570
|
+
autoCollapse
|
|
571
|
+
logo={<LogoMark />}
|
|
572
|
+
renderEnd={(isCollapsed) => (
|
|
573
|
+
<VStack gap={1}>
|
|
574
|
+
<Pressable
|
|
575
|
+
as="button"
|
|
576
|
+
background="bgPrimaryWash"
|
|
577
|
+
borderRadius={1000}
|
|
578
|
+
transparentWhileInactive
|
|
579
|
+
width="100%"
|
|
580
|
+
>
|
|
581
|
+
<HStack alignItems="center" gap={2} paddingX={2} paddingY={2}>
|
|
582
|
+
<Icon name="cog" />
|
|
583
|
+
{!isCollapsed && <TextHeadline as="span">Settings</TextHeadline>}
|
|
584
|
+
</HStack>
|
|
585
|
+
</Pressable>
|
|
586
|
+
<Pressable
|
|
587
|
+
as="button"
|
|
588
|
+
background="bgPrimaryWash"
|
|
589
|
+
borderRadius={1000}
|
|
590
|
+
transparentWhileInactive
|
|
591
|
+
width="100%"
|
|
592
|
+
>
|
|
593
|
+
<HStack alignItems="center" gap={2} paddingX={2} paddingY={2}>
|
|
594
|
+
<Avatar size="s" />
|
|
595
|
+
{!isCollapsed && <TextHeadline as="span">Profile</TextHeadline>}
|
|
596
|
+
</HStack>
|
|
597
|
+
</Pressable>
|
|
598
|
+
</VStack>
|
|
599
|
+
)}
|
|
600
|
+
>
|
|
211
601
|
{navItems.map((item, index) => (
|
|
212
602
|
<SidebarItem
|
|
213
|
-
key={
|
|
603
|
+
key={item.title}
|
|
214
604
|
active={index === activeIndex}
|
|
215
|
-
|
|
605
|
+
icon={item.icon}
|
|
606
|
+
onClick={() => handleItemPress(index)}
|
|
607
|
+
title={item.title}
|
|
216
608
|
tooltipContent={item.title}
|
|
217
|
-
{...item}
|
|
218
609
|
/>
|
|
219
610
|
))}
|
|
220
611
|
<SidebarMoreMenu
|
|
@@ -225,7 +616,7 @@ function Example() {
|
|
|
225
616
|
>
|
|
226
617
|
{moreMenuOptions.map((item) => (
|
|
227
618
|
<SelectOption
|
|
228
|
-
key={
|
|
619
|
+
key={item.title}
|
|
229
620
|
description={item.title}
|
|
230
621
|
media={<Icon name={item.icon} />}
|
|
231
622
|
value={item.title}
|
|
@@ -233,6 +624,69 @@ function Example() {
|
|
|
233
624
|
))}
|
|
234
625
|
</SidebarMoreMenu>
|
|
235
626
|
</Sidebar>
|
|
627
|
+
<VStack background="bgAlternate" flexGrow={1} padding={3}>
|
|
628
|
+
<Text as="h1" font="title2">
|
|
629
|
+
{currentPage}
|
|
630
|
+
</Text>
|
|
631
|
+
<Text color="fgMuted" font="body">
|
|
632
|
+
Welcome to the {currentPage.toLowerCase()} page. This is a sample application shell
|
|
633
|
+
demonstrating the Sidebar component with responsive behavior.
|
|
634
|
+
</Text>
|
|
635
|
+
</VStack>
|
|
636
|
+
</HStack>
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
#### Condensed Trading Interface
|
|
642
|
+
|
|
643
|
+
A condensed sidebar optimized for professional trading interfaces with minimal visual footprint.
|
|
644
|
+
|
|
645
|
+
```jsx live
|
|
646
|
+
function TradingInterface() {
|
|
647
|
+
const items = [
|
|
648
|
+
{ title: 'Spot', icon: 'chartCandles' },
|
|
649
|
+
{ title: 'Futures', icon: 'chartBar' },
|
|
650
|
+
{ title: 'Portfolio', icon: 'chartPie' },
|
|
651
|
+
{ title: 'Orders', icon: 'documentation' },
|
|
652
|
+
];
|
|
653
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
654
|
+
|
|
655
|
+
return (
|
|
656
|
+
<HStack>
|
|
657
|
+
<Sidebar logo={<LogoMark foreground />} variant="condensed">
|
|
658
|
+
{items.map((item, index) => (
|
|
659
|
+
<SidebarItem
|
|
660
|
+
key={item.title}
|
|
661
|
+
active={index === activeIndex}
|
|
662
|
+
icon={item.icon}
|
|
663
|
+
onClick={() => setActiveIndex(index)}
|
|
664
|
+
title={item.title}
|
|
665
|
+
/>
|
|
666
|
+
))}
|
|
667
|
+
</Sidebar>
|
|
668
|
+
<VStack background="bgAlternate" flexGrow={1} gap={2} padding={3}>
|
|
669
|
+
<HStack justifyContent="space-between">
|
|
670
|
+
<Text font="title3">BTC/USD</Text>
|
|
671
|
+
<Text color="fgPositive" font="title3">
|
|
672
|
+
$67,432.50
|
|
673
|
+
</Text>
|
|
674
|
+
</HStack>
|
|
675
|
+
<Box
|
|
676
|
+
background="bg"
|
|
677
|
+
borderRadius={200}
|
|
678
|
+
flexGrow={1}
|
|
679
|
+
style={{
|
|
680
|
+
display: 'flex',
|
|
681
|
+
alignItems: 'center',
|
|
682
|
+
justifyContent: 'center',
|
|
683
|
+
}}
|
|
684
|
+
>
|
|
685
|
+
<Text color="fgMuted" font="label1">
|
|
686
|
+
{items[activeIndex].title} Chart Area
|
|
687
|
+
</Text>
|
|
688
|
+
</Box>
|
|
689
|
+
</VStack>
|
|
236
690
|
</HStack>
|
|
237
691
|
);
|
|
238
692
|
}
|
|
@@ -269,6 +723,7 @@ function Example() {
|
|
|
269
723
|
| `borderedTop` | `boolean` | No | `-` | Add a border to the top side of the box. |
|
|
270
724
|
| `borderedVertical` | `boolean` | No | `-` | Add a border to the top and bottom sides of the box. |
|
|
271
725
|
| `bottom` | `ResponsiveProp<Bottom<string \| number>>` | No | `-` | - |
|
|
726
|
+
| `classNames` | `{ root?: string; logo?: string \| undefined; content?: string \| undefined; end?: string \| undefined; } \| undefined` | No | `-` | Custom class names for the sidebar components. |
|
|
272
727
|
| `collapsed` | `boolean` | No | `false` | Use collapsed to show only the logo |
|
|
273
728
|
| `color` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
274
729
|
| `columnGap` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `-` | - |
|
|
@@ -334,6 +789,7 @@ function Example() {
|
|
|
334
789
|
| `right` | `ResponsiveProp<Right<string \| number>>` | No | `-` | - |
|
|
335
790
|
| `rowGap` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `-` | - |
|
|
336
791
|
| `style` | `CSSProperties` | No | `-` | - |
|
|
792
|
+
| `styles` | `{ root?: CSSProperties; logo?: CSSProperties \| undefined; content?: CSSProperties \| undefined; end?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for the sidebar components. |
|
|
337
793
|
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |
|
|
338
794
|
| `textAlign` | `ResponsiveProp<center \| start \| end \| justify>` | No | `-` | - |
|
|
339
795
|
| `textDecoration` | `ResponsiveProp<none \| underline \| overline \| line-through \| underline overline \| underline double>` | No | `-` | - |
|
|
@@ -27,7 +27,7 @@ function ExampleDefault() {
|
|
|
27
27
|
|
|
28
28
|
### Compact
|
|
29
29
|
|
|
30
|
-
```jsx
|
|
30
|
+
```jsx lived
|
|
31
31
|
function ExampleCompactNoStart() {
|
|
32
32
|
const tabs = [
|
|
33
33
|
{ id: 'all', label: 'All' },
|
|
@@ -57,6 +57,39 @@ function ExampleWithPaddles() {
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
### With autoScrollOffset
|
|
61
|
+
|
|
62
|
+
:::tip Auto-scroll offset
|
|
63
|
+
The `autoScrollOffset` prop controls the X position offset when auto-scrolling to the active tab. This prevents the active tab from being covered by the paddle on the left side. Try clicking tabs near the edges to see the difference.
|
|
64
|
+
:::
|
|
65
|
+
|
|
66
|
+
```jsx live
|
|
67
|
+
function ExampleAutoScrollOffset() {
|
|
68
|
+
const tabs = Array.from({ length: 25 }).map((_, i) => ({
|
|
69
|
+
id: `tab_${i + 1}`,
|
|
70
|
+
label: `Tab ${i + 1}`,
|
|
71
|
+
}));
|
|
72
|
+
const [activeTab, setActiveTab] = useState(tabs[0]);
|
|
73
|
+
return (
|
|
74
|
+
<VStack gap={2}>
|
|
75
|
+
<Text as="p" font="body">
|
|
76
|
+
Default offset (50px)
|
|
77
|
+
</Text>
|
|
78
|
+
<TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} />
|
|
79
|
+
<Text as="p" font="body">
|
|
80
|
+
Custom offset (100px)
|
|
81
|
+
</Text>
|
|
82
|
+
<TabbedChips
|
|
83
|
+
activeTab={activeTab}
|
|
84
|
+
onChange={setActiveTab}
|
|
85
|
+
tabs={tabs}
|
|
86
|
+
autoScrollOffset={100}
|
|
87
|
+
/>
|
|
88
|
+
</VStack>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
60
93
|
### With custom sized paddles
|
|
61
94
|
|
|
62
95
|
:::tip Paddle styling
|
|
@@ -187,6 +220,7 @@ render(<Example />);
|
|
|
187
220
|
| `tabs` | `TabbedChipProps<T>[]` | Yes | `-` | - |
|
|
188
221
|
| `TabComponent` | `FC<TabbedChipProps<T>>` | No | `-` | - |
|
|
189
222
|
| `TabsActiveIndicatorComponent` | `TabsActiveIndicatorComponent` | No | `-` | - |
|
|
223
|
+
| `autoScrollOffset` | `number` | No | `50` | X position offset when auto-scrolling to active tab (to avoid active tab being covered by the paddle on the left side, default: 50px) |
|
|
190
224
|
| `background` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
191
225
|
| `classNames` | `{ root?: string; scrollContainer?: string \| undefined; tabs?: string \| undefined; } \| undefined` | No | `-` | - |
|
|
192
226
|
| `compact` | `boolean` | No | `false` | Turn on to use a compact Chip component for each tab. |
|
package/mcp-docs/web/routes.txt
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
- [Stepper](web/components/Stepper.txt): A component that visualizes states within a multi-step process.
|
|
48
48
|
- [SidebarMoreMenu](web/components/SidebarMoreMenu.txt): SidebarMoreMenu provides a dropdown menu for additional navigation options in the Sidebar.
|
|
49
49
|
- [SidebarItem](web/components/SidebarItem.txt): SidebarItem represents a single navigation item within the Sidebar component.
|
|
50
|
-
- [Sidebar](web/components/Sidebar.txt): A vertical navigation
|
|
50
|
+
- [Sidebar](web/components/Sidebar.txt): A composable and customizable vertical navigation component with support for multiple variants, collapsible states, and custom content areas.
|
|
51
51
|
- [SegmentedTabs](web/components/SegmentedTabs.txt): Switches between different views of content.
|
|
52
52
|
- [SectionHeader](web/components/SectionHeader.txt): A header component used to organize and label sections of content, with support for icons, descriptions, and additional content.
|
|
53
53
|
- [Pagination](web/components/Pagination.txt): Pagination is used to navigate through a list of items.
|