@maxio-com/react-ui-components 9.16.0 → 9.16.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/dist/skills/maxio-react/SKILL.md +68 -0
- package/dist/skills/maxio-react/agents/openai.yaml +4 -0
- package/dist/skills/maxio-react/references/components-action-list.md +92 -0
- package/dist/skills/maxio-react/references/components-action-menu.md +162 -0
- package/dist/skills/maxio-react/references/components-avatar.md +66 -0
- package/dist/skills/maxio-react/references/components-breadcrumbs.md +86 -0
- package/dist/skills/maxio-react/references/components-buttons-button.md +170 -0
- package/dist/skills/maxio-react/references/components-buttons-iconbutton.md +102 -0
- package/dist/skills/maxio-react/references/components-card.md +175 -0
- package/dist/skills/maxio-react/references/components-chip.md +151 -0
- package/dist/skills/maxio-react/references/components-data-table.md +344 -0
- package/dist/skills/maxio-react/references/components-drawer.md +293 -0
- package/dist/skills/maxio-react/references/components-flex.md +185 -0
- package/dist/skills/maxio-react/references/components-forms-checkbox.md +257 -0
- package/dist/skills/maxio-react/references/components-forms-combobox.md +250 -0
- package/dist/skills/maxio-react/references/components-forms-radio-group.md +202 -0
- package/dist/skills/maxio-react/references/components-forms-select.md +295 -0
- package/dist/skills/maxio-react/references/components-forms-textfield.md +253 -0
- package/dist/skills/maxio-react/references/components-grid.md +140 -0
- package/dist/skills/maxio-react/references/components-icon.md +169 -0
- package/dist/skills/maxio-react/references/components-link.md +180 -0
- package/dist/skills/maxio-react/references/components-listbox.md +205 -0
- package/dist/skills/maxio-react/references/components-loading-spinner.md +123 -0
- package/dist/skills/maxio-react/references/components-logo.md +91 -0
- package/dist/skills/maxio-react/references/components-notifications-alert.md +103 -0
- package/dist/skills/maxio-react/references/components-notifications-banner.md +173 -0
- package/dist/skills/maxio-react/references/components-notifications-toast.md +155 -0
- package/dist/skills/maxio-react/references/components-pagination.md +115 -0
- package/dist/skills/maxio-react/references/components-popover.md +176 -0
- package/dist/skills/maxio-react/references/components-progressbar.md +98 -0
- package/dist/skills/maxio-react/references/components-segmentedcontrol.md +292 -0
- package/dist/skills/maxio-react/references/components-tabs.md +193 -0
- package/dist/skills/maxio-react/references/components-tag.md +117 -0
- package/dist/skills/maxio-react/references/components-tile.md +114 -0
- package/dist/skills/maxio-react/references/components-toggle.md +218 -0
- package/dist/skills/maxio-react/references/components-tooltip.md +178 -0
- package/dist/skills/maxio-react/references/components-typography-body.md +101 -0
- package/dist/skills/maxio-react/references/components-typography-code.md +72 -0
- package/dist/skills/maxio-react/references/components-typography-display.md +91 -0
- package/dist/skills/maxio-react/references/components-typography-heading.md +88 -0
- package/dist/skills/maxio-react/references/components-typography-label.md +82 -0
- package/dist/skills/maxio-react/references/deprecated-textinput.md +250 -0
- package/dist/skills/maxio-react/references/foundations-dark-mode.md +85 -0
- package/dist/skills/maxio-react/references/foundations-design-tokens-about.md +108 -0
- package/dist/skills/maxio-react/references/foundations-design-tokens-colors-primitive-colors.md +33 -0
- package/dist/skills/maxio-react/references/foundations-design-tokens-colors-semantic-colors.md +11 -0
- package/dist/skills/maxio-react/references/foundations-start-here.md +128 -0
- package/dist/skills/maxio-react/references/patterns-auth-layout.md +318 -0
- package/dist/skills/maxio-react/references/patterns-side-nav.md +182 -0
- package/dist/skills/maxio-react/references/patterns-top-bar.md +214 -0
- package/package.json +2 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# IconButton
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
IconButton is used for buttons that show an icon in place of a text label.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use IconButton for compact actions in dense interfaces such as tables, toolbars, headers, and cards.
|
|
12
|
+
- Use IconButton when the icon is a familiar control and the action can be named clearly with `aria-label`.
|
|
13
|
+
- Use IconButton for icon-only navigation only when the destination still needs button-level emphasis.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use IconButton when visible text is needed to make the action understandable. Use Button instead.
|
|
18
|
+
- Do not use IconButton as a decorative icon. Use Icon when there is no action.
|
|
19
|
+
- Do not rely on a tooltip as the only accessible name. Tooltips may not be available to every user.
|
|
20
|
+
|
|
21
|
+
### Variants
|
|
22
|
+
|
|
23
|
+
IconButton uses the same visual variants as Button. Choose the lowest emphasis that still makes the action easy to find.
|
|
24
|
+
|
|
25
|
+
| Variants | Purpose | Usage notes |
|
|
26
|
+
| :---------- | :------------------------------- | :---------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| `primary` | Highest-emphasis icon action. | Use sparingly for the main compact action in a focused area. |
|
|
28
|
+
| `secondary` | Standard supporting icon action. | Use for most standalone icon-only actions. |
|
|
29
|
+
| `tertiary` | Low-emphasis icon action. | Use for supporting actions in dense interfaces or repeated rows. |
|
|
30
|
+
| `ghost` | Lowest-emphasis icon action. | Use when the action should be available but visually quiet. |
|
|
31
|
+
| `danger` | Destructive or high-risk action. | Use for delete, remove, cancel subscription, and similar actions. Add confirmation when the consequence is not obvious. |
|
|
32
|
+
|
|
33
|
+
### Behavior
|
|
34
|
+
|
|
35
|
+
- **Mouse and touch**: clicking or tapping activates the button once the pointer is released.
|
|
36
|
+
- **Keyboard**: native icon buttons activate with Enter or Space. Anchor icon buttons activate with Enter.
|
|
37
|
+
- **Focus management**: keep the visible focus ring intact and return focus to a sensible place after dialogs or menus close.
|
|
38
|
+
- **Navigation**: use link rendering only when activation changes location or opens another resource.
|
|
39
|
+
- **Loading**: keep the control visible while the action is pending, and provide nearby status text when the icon alone does not explain progress.
|
|
40
|
+
|
|
41
|
+
### Accessibility
|
|
42
|
+
|
|
43
|
+
- Use native `button` semantics for icon-only actions and native `a href` semantics for icon-only navigation.
|
|
44
|
+
- Provide a required `aria-label` that describes the action outcome, such as "Search" or "Delete invoice".
|
|
45
|
+
- Treat the visible icon as decorative unless it is also part of the accessible name.
|
|
46
|
+
- Do not rely on color alone to communicate destructive, disabled, or loading state.
|
|
47
|
+
- Keep focus indicators visible and avoid removing keyboard activation behavior.
|
|
48
|
+
|
|
49
|
+
### Content
|
|
50
|
+
|
|
51
|
+
- Make `aria-label` specific enough to stand alone when read by assistive technology.
|
|
52
|
+
- Start action labels with a verb when possible: "Search", "Edit customer", "Delete invoice".
|
|
53
|
+
- Include the object when repeated IconButtons appear in a list or table.
|
|
54
|
+
- Keep tooltip copy aligned with the `aria-label` when a visible tooltip is provided.
|
|
55
|
+
|
|
56
|
+
### Related
|
|
57
|
+
|
|
58
|
+
- **[Button](components-buttons-button.md)**: use when the action should have a visible text label.
|
|
59
|
+
- **[Icon](components-icon.md)**: use for decorative or noninteractive icons.
|
|
60
|
+
- **[ActionMenu](components-action-menu.md)**: use when several related actions need to be grouped behind one trigger.
|
|
61
|
+
|
|
62
|
+
## React
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { IconButton } from '@maxio-com/react-ui-components';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Imports
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { Icon, IconButton } from "@maxio-com/react-ui-components";
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Prop Types
|
|
75
|
+
|
|
76
|
+
### IconButton
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
79
|
+
| --- | --- | --- | --- | --- | --- |
|
|
80
|
+
| `disabled` | `boolean` | no | - | Determines if the button is disabled | InternalButtonProps |
|
|
81
|
+
| `href` | `string` | no | - | Disallows `href` on button element | InternalButtonProps, InternalLinkProps |
|
|
82
|
+
| `icon` | `ReactNode` | no | - | Displays a trailing icon (depricated) | CommonButtonProps |
|
|
83
|
+
| `leadingElement` | `ReactNode` | no | - | Displays a leading icon | CommonButtonProps |
|
|
84
|
+
| `loading` | `boolean` | no | - | Indicates that the component is in a loading state, typically during asynchronous operations such as data fetching, form submissions, or any action that requires some time to complete | InternalButtonProps |
|
|
85
|
+
| `size` | `"sm" \| "md" \| "lg"` | no | - | Changes the size of the button | CommonButtonProps, TypeLiteral |
|
|
86
|
+
| `trailingElement` | `ReactNode` | no | - | Displays a trailing icon | CommonButtonProps |
|
|
87
|
+
| `value` | `string` | no | - | Button value - must be string for React Aria compatibility | InternalButtonProps |
|
|
88
|
+
| `variant` | `"primary" \| "secondary" \| "tertiary" \| "ghost" \| "danger" \| "skeleton"` | no | - | Changes the button variant | CommonButtonProps |
|
|
89
|
+
|
|
90
|
+
## Stories
|
|
91
|
+
|
|
92
|
+
### Default
|
|
93
|
+
|
|
94
|
+
Use IconButton for compact icon-only actions when surrounding context or an accessible name makes the action clear. Every IconButton must include an `aria-label` that describes the action outcome.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
const Default = () => <IconButton
|
|
98
|
+
aria-label="Search"
|
|
99
|
+
icon={<Icon variant="search" />}
|
|
100
|
+
onClick={action('Clicked')}
|
|
101
|
+
variant="secondary" />;
|
|
102
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
#### When to Use
|
|
8
|
+
|
|
9
|
+
- Use Card to group related content that should be scanned as one unit.
|
|
10
|
+
- Use Card for page sections, settings panels, summaries, and content blocks with local actions.
|
|
11
|
+
- Use Card.Header, Card.Body, and Card.Footer when a grouped section needs a title, content, and actions.
|
|
12
|
+
|
|
13
|
+
#### When Not to Use
|
|
14
|
+
|
|
15
|
+
- Do not use Card as a generic spacing wrapper when the content does not need a visible container.
|
|
16
|
+
- Do not use Card for a whole page layout. Use layout primitives such as Flex or Grid instead.
|
|
17
|
+
|
|
18
|
+
### Variants
|
|
19
|
+
|
|
20
|
+
Choose the surface treatment that matches the card's hierarchy.
|
|
21
|
+
|
|
22
|
+
| Variants | Purpose | Usage notes |
|
|
23
|
+
| :---------- | :--------------------------- | :------------------------------------------------------------- |
|
|
24
|
+
| `primary` | Standard grouped surface. | Use for the main card or focused section within a page area. |
|
|
25
|
+
| `secondary` | Lower-emphasis grouped area. | Use when header and footer should sit behind the card surface. |
|
|
26
|
+
|
|
27
|
+
### Behavior
|
|
28
|
+
|
|
29
|
+
- **Mouse and touch**: Card has no built-in interaction. Interactive controls inside the card keep their own behavior.
|
|
30
|
+
- **Keyboard**: Card does not enter the tab order unless you add focusable content inside it.
|
|
31
|
+
- **Focus management**: do not move focus to the card container; move focus to meaningful headings or controls when needed.
|
|
32
|
+
- **Composition**: keep Card.Header, Card.Body, and Card.Footer in visual reading order when using multiple sections.
|
|
33
|
+
|
|
34
|
+
### Accessibility
|
|
35
|
+
|
|
36
|
+
- Use Card as a visual grouping container, not as a landmark by default.
|
|
37
|
+
- Include a visible heading in Card.Header when the grouped content needs a label.
|
|
38
|
+
- Preserve semantic HTML for the content inside the card, such as headings, lists, tables, forms, links, and buttons.
|
|
39
|
+
- Keep actions in Card.Footer related to the card content they affect.
|
|
40
|
+
- Do not rely on the card surface color alone to communicate status, priority, or selection.
|
|
41
|
+
|
|
42
|
+
### Content
|
|
43
|
+
|
|
44
|
+
- Keep card headings short and specific to the grouped content.
|
|
45
|
+
- Put primary details in Card.Body and supporting actions in Card.Footer.
|
|
46
|
+
- Avoid mixing unrelated topics or actions in the same card.
|
|
47
|
+
- Consider long customer-generated content and make sure it can wrap without hiding actions.
|
|
48
|
+
|
|
49
|
+
### Related
|
|
50
|
+
|
|
51
|
+
- **[Tile](components-tile.md)**: use when the entire surface is clickable or navigates.
|
|
52
|
+
- **[Flex](components-flex.md)**: use for alignment and spacing without adding a bordered container.
|
|
53
|
+
- **[Grid](components-grid.md)**: use for arranging multiple sections in responsive layouts.
|
|
54
|
+
|
|
55
|
+
## React
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { Card } from '@maxio-com/react-ui-components';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Imports
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Body, Button, Card, Flex, Heading } from "@maxio-com/react-ui-components";
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Stories
|
|
68
|
+
|
|
69
|
+
### Default
|
|
70
|
+
|
|
71
|
+
Use Default for a simple static content group. Always wrap the main content in Card.Body so spacing remains consistent if header or footer sections are added later.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
const Default = () => <Card>
|
|
75
|
+
<Card.Body>
|
|
76
|
+
<Body size="sm">Subscription details and supporting context stay grouped in one
|
|
77
|
+
surface.
|
|
78
|
+
</Body>
|
|
79
|
+
</Card.Body>
|
|
80
|
+
</Card>;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### With Header
|
|
84
|
+
|
|
85
|
+
Use WithHeader when the card needs a visible title or section label. The heading level should fit the surrounding page hierarchy.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
const WithHeader = () => <Card>
|
|
89
|
+
<Card.Header>
|
|
90
|
+
<Heading size="sm">Billing summary</Heading>
|
|
91
|
+
</Card.Header>
|
|
92
|
+
<Card.Body>
|
|
93
|
+
<Body size="sm">Review the customer plan, renewal date, and current balance before
|
|
94
|
+
making changes.
|
|
95
|
+
</Body>
|
|
96
|
+
</Card.Body>
|
|
97
|
+
</Card>;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### With Footer
|
|
101
|
+
|
|
102
|
+
Use WithFooter when the card includes actions that apply to the grouped content. Keep footer actions specific to this card.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
const WithFooter = () => <Card>
|
|
106
|
+
<Card.Body>
|
|
107
|
+
<Body size="sm">Send the upcoming invoice reminder after confirming the billing
|
|
108
|
+
contact.
|
|
109
|
+
</Body>
|
|
110
|
+
</Card.Body>
|
|
111
|
+
<Card.Footer>
|
|
112
|
+
<Button variant="primary">Send reminder</Button>
|
|
113
|
+
</Card.Footer>
|
|
114
|
+
</Card>;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Secondary
|
|
118
|
+
|
|
119
|
+
Use Secondary for supporting panels that should sit behind the primary card hierarchy while still grouping related content.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
const Secondary = () => <Card variant="secondary">
|
|
123
|
+
<Card.Body>
|
|
124
|
+
<Body size="sm">Use a quieter surface for supplemental account notes or background
|
|
125
|
+
details.
|
|
126
|
+
</Body>
|
|
127
|
+
</Card.Body>
|
|
128
|
+
</Card>;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Full
|
|
132
|
+
|
|
133
|
+
Use Full when the card has a title, primary content, and local actions. Header, body, and footer sections should remain in that order.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
const Full = () => <Card>
|
|
137
|
+
<Card.Header>
|
|
138
|
+
<Heading size="sm">Payment method</Heading>
|
|
139
|
+
</Card.Header>
|
|
140
|
+
<Card.Body>
|
|
141
|
+
<Body size="sm">Visa ending in 4242 is used for subscription renewals and invoice
|
|
142
|
+
retries.
|
|
143
|
+
</Body>
|
|
144
|
+
</Card.Body>
|
|
145
|
+
<Card.Footer>
|
|
146
|
+
<Flex gap={2} justifyContent="end">
|
|
147
|
+
<Button variant="secondary">Cancel</Button>
|
|
148
|
+
<Button variant="primary">Update method</Button>
|
|
149
|
+
</Flex>
|
|
150
|
+
</Card.Footer>
|
|
151
|
+
</Card>;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Full Secondary
|
|
155
|
+
|
|
156
|
+
Use FullSecondary for lower-emphasis sections that still need the complete header, body, and footer composition.
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
const FullSecondary = () => <Card variant="secondary">
|
|
160
|
+
<Card.Header>
|
|
161
|
+
<Heading size="sm">Account notes</Heading>
|
|
162
|
+
</Card.Header>
|
|
163
|
+
<Card.Body>
|
|
164
|
+
<Body size="sm">Capture internal context that supports the customer record without
|
|
165
|
+
competing with billing tasks.
|
|
166
|
+
</Body>
|
|
167
|
+
</Card.Body>
|
|
168
|
+
<Card.Footer>
|
|
169
|
+
<Flex gap={2} justifyContent="end">
|
|
170
|
+
<Button variant="secondary">Cancel</Button>
|
|
171
|
+
<Button variant="primary">Save notes</Button>
|
|
172
|
+
</Flex>
|
|
173
|
+
</Card.Footer>
|
|
174
|
+
</Card>;
|
|
175
|
+
```
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Chip
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Chip is used for compact, interactive values such as applied filters that can be selected, toggled, or dismissed without leaving the current context.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Chip for compact interactive values, such as applied filters, selected criteria, or removable tokens.
|
|
12
|
+
- Use Chip when the value can be toggled, selected, or dismissed in the current context.
|
|
13
|
+
- Use Chip in toolbars, filter summaries, and dense workflows where a full button would add too much visual weight.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Chip for static labels or status metadata. Use Tag instead.
|
|
18
|
+
- Do not use Chip for primary page actions. Use Button instead.
|
|
19
|
+
- Do not use Chip for navigation to another page or resource. Use Link or Button rendered as a link when stronger emphasis is required.
|
|
20
|
+
|
|
21
|
+
### Behavior
|
|
22
|
+
|
|
23
|
+
- **Mouse and touch**: pressing the chip button toggles selection and calls `onPress`; pressing the dismiss button calls `onDismiss`.
|
|
24
|
+
- **Keyboard**: the chip button and dismiss button are separate tab stops. Native button behavior supports Enter and Space activation.
|
|
25
|
+
- **Focus management**: keep both focus indicators visible. After dismissing a chip, move focus to the next logical control in the owning workflow.
|
|
26
|
+
- **Controlled state**: use `defaultSelected` for uncontrolled state, or pair `isSelected` with `onChange` when another component owns selection.
|
|
27
|
+
- **Dismissal**: provide `dismissLabel` whenever the chip can be dismissed so the icon-only button has an accessible name.
|
|
28
|
+
|
|
29
|
+
### Accessibility
|
|
30
|
+
|
|
31
|
+
- Use native `button` semantics for both the chip control and dismiss control.
|
|
32
|
+
- Provide a visible label that identifies the chip value.
|
|
33
|
+
- Use `aria-pressed` to communicate selected state on the chip button.
|
|
34
|
+
- Give the dismiss button a specific accessible name, such as "Remove Status: Active filter".
|
|
35
|
+
- Do not rely on color alone to communicate selection; preserve the pressed state and visible focus treatment.
|
|
36
|
+
|
|
37
|
+
### Content
|
|
38
|
+
|
|
39
|
+
- Keep labels short and specific, especially when chips appear in groups.
|
|
40
|
+
- Use the value the user selected, such as "Status: Active" or "Plan: Growth".
|
|
41
|
+
- Avoid generic labels like "Filter" when several chips appear together.
|
|
42
|
+
- Write dismiss labels that include the chip value when the visible label is not adjacent in the accessibility tree.
|
|
43
|
+
|
|
44
|
+
### Related
|
|
45
|
+
|
|
46
|
+
- **[Tag](components-tag.md)**: use for static labels, metadata, or statuses.
|
|
47
|
+
- **[Button](components-buttons-button.md)**: use for standalone actions with stronger emphasis.
|
|
48
|
+
- **[DataTable](components-data-table.md)**: chips are often used to summarize applied table filters.
|
|
49
|
+
|
|
50
|
+
## React
|
|
51
|
+
|
|
52
|
+
```jsx
|
|
53
|
+
import { Chip } from '@maxio-com/react-ui-components';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### State Management
|
|
57
|
+
|
|
58
|
+
Chip can manage its own selected state with `defaultSelected`, or it can be controlled with `isSelected` and `onChange`.
|
|
59
|
+
|
|
60
|
+
Use uncontrolled state for a chip that only needs to toggle itself. Use controlled state when selection is owned by another component, such as a filter menu, table toolbar, or saved view.
|
|
61
|
+
|
|
62
|
+
## Imports
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { Chip } from "@maxio-com/react-ui-components";
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Prop Types
|
|
69
|
+
|
|
70
|
+
### Chip
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
73
|
+
| --- | --- | --- | --- | --- | --- |
|
|
74
|
+
| `dismissLabel` | `string` | no | - | An aria-label for the dismiss button | TypeLiteral |
|
|
75
|
+
| `label` | `string` | yes | - | Button's visible label | TypeLiteral |
|
|
76
|
+
| `leadingIcon` | `string` | no | - | Adds a leading icon to the chip | TypeLiteral |
|
|
77
|
+
| `onDismiss` | `(() => void)` | no | - | Callback function when the dismiss button is pressed | TypeLiteral |
|
|
78
|
+
| `title` | `string` | no | - | Adds a title to the chip | TypeLiteral |
|
|
79
|
+
| `trailingIcon` | `string` | no | - | Adds a trailing icon to the chip | TypeLiteral |
|
|
80
|
+
|
|
81
|
+
## Stories
|
|
82
|
+
|
|
83
|
+
### Default
|
|
84
|
+
|
|
85
|
+
Use Chip for a selected, actionable value such as an applied filter. Include a dismiss button when users can remove that value from the current context.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
const Default = (args: any) => {
|
|
89
|
+
const chipProps = {
|
|
90
|
+
...args,
|
|
91
|
+
onDismiss: args?.onDismiss && action('Chip dismissed'),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return <Chip {...chipProps}>{args.label}</Chip>;
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Selected
|
|
99
|
+
|
|
100
|
+
Use the selected state when the chip represents an active toggle, filter, or segmented choice. Keep `aria-pressed` synchronized with the visual selected state in static HTML.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
const Selected = (args: any) => {
|
|
104
|
+
const chipProps = {
|
|
105
|
+
...args,
|
|
106
|
+
defaultSelected: true,
|
|
107
|
+
onDismiss: undefined,
|
|
108
|
+
trailingIcon: undefined,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return <Chip {...chipProps}>{args.label}</Chip>;
|
|
112
|
+
};
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### With Icons
|
|
116
|
+
|
|
117
|
+
Use icons only when they help identify the chip value faster. Icons are supporting visuals; the visible label still provides the accessible name.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
const WithIcons = (args: any) => {
|
|
121
|
+
const chipProps = {
|
|
122
|
+
...args,
|
|
123
|
+
onDismiss: undefined,
|
|
124
|
+
leadingIcon: 'dollar',
|
|
125
|
+
trailingIcon: 'arrow-right',
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return <Chip {...chipProps}>{args.label}</Chip>;
|
|
129
|
+
};
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Controlled
|
|
133
|
+
|
|
134
|
+
Use controlled state when another component owns the selection, such as a filter menu, table toolbar, or saved view. Update `isSelected` from `onChange` so visual and announced state stay in sync.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
const Controlled = (args: any) => {
|
|
138
|
+
const [isSelected, setSelected] = useState(false);
|
|
139
|
+
const chipProps = {
|
|
140
|
+
...args,
|
|
141
|
+
isSelected,
|
|
142
|
+
onDismiss: args?.onDismiss && action('Chip dismissed'),
|
|
143
|
+
onChange: (nextSelected: boolean) => {
|
|
144
|
+
setSelected(nextSelected);
|
|
145
|
+
action('Selected state')(String(nextSelected));
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
return <Chip {...chipProps}>{args.label}</Chip>;
|
|
150
|
+
};
|
|
151
|
+
```
|