@maxio-com/react-ui-components 9.15.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/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- 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
- package/typings/index.d.ts +24 -4
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Menu
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
ActionMenu groups related contextual actions behind a trigger. Use it for secondary row, toolbar, or page actions that should stay available without occupying persistent space.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use ActionMenu when several related actions belong to the same object, row, toolbar, or page area.
|
|
12
|
+
- Use ActionMenu when secondary actions should stay available without taking persistent space.
|
|
13
|
+
- Use ActionMenu when the actions can be described by a single trigger label, such as "Create" or "More actions".
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use ActionMenu for one high-priority action. Use Button or IconButton instead.
|
|
18
|
+
- Do not use ActionMenu for primary navigation. Use SideNav, Tabs, or Link depending on the pattern.
|
|
19
|
+
- Do not use ActionMenu for selectable form values. Use Select or ComboBox instead.
|
|
20
|
+
|
|
21
|
+
### Behavior
|
|
22
|
+
|
|
23
|
+
- **Mouse and touch**: activating the trigger opens or closes the menu. Activating a menu item follows that item's link target.
|
|
24
|
+
- **Keyboard**: the trigger uses native `summary` behavior. Menu items support Arrow Up, Arrow Down, Enter, and Space through ActionList.
|
|
25
|
+
- **Focus management**: the first action is focusable by default. Arrow keys move focus between actions and skip dividers.
|
|
26
|
+
- **Internal state**: use the `Menu` render prop when trigger text or adjacent content needs to respond to `isOpen`.
|
|
27
|
+
- **Alignment**: use end alignment when the trigger sits near a right edge or inside a table row action area.
|
|
28
|
+
|
|
29
|
+
### Accessibility
|
|
30
|
+
|
|
31
|
+
- Use `Menu` to wrap exactly one `MenuButton` and one `MenuList` so ids, open state, and ARIA relationships stay synchronized.
|
|
32
|
+
- Give every `MenuButton` an accessible name. Icon-only triggers must use `aria-label`.
|
|
33
|
+
- Keep `MenuButton` text concise and connected to the actions in the menu.
|
|
34
|
+
- Use menu items for actions or related links only; each item should have a clear label.
|
|
35
|
+
- Keep focus indicators visible and do not remove ActionList keyboard behavior.
|
|
36
|
+
- Do not rely on the chevron or icon alone to communicate the trigger purpose.
|
|
37
|
+
|
|
38
|
+
### Content
|
|
39
|
+
|
|
40
|
+
- Label text triggers with the action family: "Create", "Export", "More actions", or "Subscription actions".
|
|
41
|
+
- Avoid vague labels like "Menu" unless surrounding context supplies the object and action set.
|
|
42
|
+
- Keep item labels action-oriented and specific, such as "Edit invoice" or "Cancel subscription".
|
|
43
|
+
- Use icon-only triggers only where repeated layout context makes the menu purpose obvious.
|
|
44
|
+
|
|
45
|
+
### Related
|
|
46
|
+
|
|
47
|
+
- **[ActionList](components-action-list.md)**: use for the menu item list inside ActionMenu or for standalone action lists.
|
|
48
|
+
- **[Button](components-buttons-button.md)**: use for a single visible action.
|
|
49
|
+
- **[IconButton](components-buttons-iconbutton.md)**: use for a single icon-only action.
|
|
50
|
+
- **[Select](components-forms-select.md)**: use for choosing a form value from a list.
|
|
51
|
+
|
|
52
|
+
## React
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Menu, MenuButton, MenuList } from '@maxio-com/react-ui-components';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### State Management
|
|
59
|
+
|
|
60
|
+
`Menu` owns the open state for the underlying `details` element. Use the render-prop form when content needs to react to that state.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<Menu>
|
|
64
|
+
{({ isOpen }) => (
|
|
65
|
+
<>
|
|
66
|
+
<MenuButton aria-label={isOpen ? 'Close actions' : 'Open actions'}>
|
|
67
|
+
{isOpen ? 'Close actions' : 'Open actions'}
|
|
68
|
+
</MenuButton>
|
|
69
|
+
<MenuList items={items} />
|
|
70
|
+
</>
|
|
71
|
+
)}
|
|
72
|
+
</Menu>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Call `onClose` from custom menu content when an action should dismiss the menu before navigation or follow-up UI appears.
|
|
76
|
+
|
|
77
|
+
## Imports
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Menu, MenuButton, MenuList } from "@maxio-com/react-ui-components";
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Prop Types
|
|
84
|
+
|
|
85
|
+
### Menu
|
|
86
|
+
|
|
87
|
+
No props were emitted by reactDocgenTypescript for this component.
|
|
88
|
+
|
|
89
|
+
## Stories
|
|
90
|
+
|
|
91
|
+
### Default
|
|
92
|
+
|
|
93
|
+
Use the default action menu for a small set of related actions behind a visible text trigger. The trigger needs an accessible name and controls the menu list through generated `aria-controls` and `aria-labelledby` values.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
const Default = () => (
|
|
97
|
+
<Menu>
|
|
98
|
+
<MenuButton aria-label="Create">Create</MenuButton>
|
|
99
|
+
<MenuList items={ITEMS} />
|
|
100
|
+
</Menu>
|
|
101
|
+
);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Button Classes
|
|
105
|
+
|
|
106
|
+
Use MenuButton size and variant props when the trigger needs to match nearby button hierarchy. Keep the menu behavior the same; only the trigger styling changes.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
const ButtonClasses = () => (
|
|
110
|
+
<Menu>
|
|
111
|
+
<MenuButton aria-label="Create" size="lg" variant="ghost">
|
|
112
|
+
Create
|
|
113
|
+
</MenuButton>
|
|
114
|
+
<MenuList items={ITEMS} />
|
|
115
|
+
</Menu>
|
|
116
|
+
);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Internal State
|
|
120
|
+
|
|
121
|
+
Use the render-prop state when the trigger label, adjacent controls, or custom content must react to the open state. Call `onClose` when custom content dismisses the menu.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
const InternalState = () => (
|
|
125
|
+
<Menu>
|
|
126
|
+
{({ isOpen }) => (
|
|
127
|
+
<>
|
|
128
|
+
<MenuButton aria-label={!isOpen ? 'Open' : 'Close'}>
|
|
129
|
+
{!isOpen ? 'Open' : 'Close'}
|
|
130
|
+
</MenuButton>
|
|
131
|
+
<MenuList items={ITEMS} />
|
|
132
|
+
</>
|
|
133
|
+
)}
|
|
134
|
+
</Menu>
|
|
135
|
+
);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Content Align End
|
|
139
|
+
|
|
140
|
+
Use end alignment when the trigger sits near the right edge of a container or in a table row action area, so the menu stays visually connected to the trigger without overflowing nearby content.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
const ContentAlignEnd = () => (
|
|
144
|
+
<Menu>
|
|
145
|
+
<MenuButton aria-label="Create">Create</MenuButton>
|
|
146
|
+
<MenuList alignItemsEnd items={ITEMS} />
|
|
147
|
+
</Menu>
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Icon Menu
|
|
152
|
+
|
|
153
|
+
Use an icon-only action menu in dense toolbars or repeated rows. Always provide an `aria-label` that describes the actions available in the menu.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
const IconMenu = () => (
|
|
157
|
+
<Menu>
|
|
158
|
+
<MenuButton aria-label="Address" iconName="address-card" />
|
|
159
|
+
<MenuList items={ITEMS} />
|
|
160
|
+
</Menu>
|
|
161
|
+
);
|
|
162
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# AvatarComponent
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Avatar is an image that represents a user or organization.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Avatar to represent a known person, account, or user profile.
|
|
12
|
+
- Use Avatar when a compact visual identity cue helps people scan ownership, authorship, or account context.
|
|
13
|
+
|
|
14
|
+
#### When Not to Use
|
|
15
|
+
|
|
16
|
+
- Do not use Avatar for decorative brand, product, or status imagery. Use the more specific component or image treatment for that content.
|
|
17
|
+
- Do not use Avatar when the image is the only way to distinguish a user and no accessible text alternative is available.
|
|
18
|
+
|
|
19
|
+
### Behavior
|
|
20
|
+
|
|
21
|
+
- Avatar is static image content and does not add interaction by itself.
|
|
22
|
+
- Pair Avatar with a Button, IconButton, or Link only when the surrounding pattern is interactive.
|
|
23
|
+
|
|
24
|
+
### Accessibility
|
|
25
|
+
|
|
26
|
+
- Provide `alt` text that identifies the person when the avatar image conveys identity.
|
|
27
|
+
- Use empty `alt=""` when adjacent visible text already identifies the same person and the image would be repetitive.
|
|
28
|
+
- Do not rely on the profile image alone to communicate status, role, or account state.
|
|
29
|
+
- Keep the image source stable enough that a missing avatar does not remove required identity text from the interface.
|
|
30
|
+
|
|
31
|
+
### Content
|
|
32
|
+
|
|
33
|
+
- Use a human-readable name in `alt` text, such as "Profile photo for Alex Morgan".
|
|
34
|
+
- Avoid generic alternatives such as "avatar" or "user image" when the image identifies a specific person.
|
|
35
|
+
|
|
36
|
+
## React
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Avatar } from '@maxio-com/react-ui-components';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Imports
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { AvatarComponent } from "@maxio-com/react-ui-components";
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Prop Types
|
|
49
|
+
|
|
50
|
+
### Avatar
|
|
51
|
+
|
|
52
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
53
|
+
| --- | --- | --- | --- | --- | --- |
|
|
54
|
+
| `alt` | `string` | no | `avatar` | The alt text of the avatar | TypeLiteral |
|
|
55
|
+
| `className` | `string` | no | - | Class name for the main container | TypeLiteral |
|
|
56
|
+
| `src` | `string` | yes | - | The image source of the avatar | TypeLiteral |
|
|
57
|
+
|
|
58
|
+
## Stories
|
|
59
|
+
|
|
60
|
+
### Default
|
|
61
|
+
|
|
62
|
+
Use Avatar to show a known user's profile image in account menus, headers, activity rows, or other identity-focused UI. Provide alt text that names the person when the image identifies them.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
const Default = () => <AvatarComponent src={avatarSrc} alt="Profile photo for Alex Morgan" />;
|
|
66
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Breadcrumbs
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Breadcrumbs show the current page location in a hierarchy and provide links back to parent pages.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Breadcrumbs when users are on a page that belongs to a clear hierarchy.
|
|
12
|
+
- Use Breadcrumbs to help users move back to parent pages without relying on browser history.
|
|
13
|
+
- Use Breadcrumbs in products with deep navigation, nested resources, or detail pages reached from several parent sections.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Breadcrumbs for single-level pages or short flows with no parent hierarchy.
|
|
18
|
+
- Do not use Breadcrumbs as the primary navigation for major product sections. Use SideNav or TopBar navigation instead.
|
|
19
|
+
- Do not use Breadcrumbs to show step progress. Use a stepper or progress pattern instead.
|
|
20
|
+
|
|
21
|
+
### Behavior
|
|
22
|
+
|
|
23
|
+
- **Mouse and touch**: users can activate linked parent items. The current page item is not interactive.
|
|
24
|
+
- **Keyboard**: linked parent items receive focus in document order and activate as normal links.
|
|
25
|
+
- **Focus management**: focus stays on the activated link until navigation occurs. Do not move focus to the current page item.
|
|
26
|
+
- **Current page**: the final item is always the current page and must not include `href`.
|
|
27
|
+
|
|
28
|
+
### Accessibility
|
|
29
|
+
|
|
30
|
+
- Use a named navigation landmark so assistive technology can identify the breadcrumb trail.
|
|
31
|
+
- Use an ordered list so the hierarchy and item order are preserved.
|
|
32
|
+
- Mark the current page item with `aria-current="page"`.
|
|
33
|
+
- Keep the current page item as text instead of a self-link.
|
|
34
|
+
- Keep link text specific enough that each destination is understandable out of context.
|
|
35
|
+
|
|
36
|
+
### Content
|
|
37
|
+
|
|
38
|
+
- Use page or resource names, not instructions such as "Back" or "Previous".
|
|
39
|
+
- Keep labels short and recognizable. Truncate long names only when the full value is available nearby or on the destination page.
|
|
40
|
+
- Start with the broadest useful parent and end with the current page.
|
|
41
|
+
- Avoid including every possible ancestor when the trail becomes too long to scan.
|
|
42
|
+
|
|
43
|
+
### Related
|
|
44
|
+
|
|
45
|
+
- **[Link](components-link.md)**: use for inline navigation outside a breadcrumb trail.
|
|
46
|
+
- **[SideNav](patterns-side-nav.md)**: use for persistent navigation across major product areas.
|
|
47
|
+
- **[TopBar](patterns-top-bar.md)**: use for global navigation, account controls, and product-level actions.
|
|
48
|
+
|
|
49
|
+
## React
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { Breadcrumbs, BreadcrumbsItem } from '@maxio-com/react-ui-components';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Imports
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { Breadcrumbs, BreadcrumbsItem } from "@maxio-com/react-ui-components";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Prop Types
|
|
62
|
+
|
|
63
|
+
### Breadcrumbs
|
|
64
|
+
|
|
65
|
+
No props were emitted by reactDocgenTypescript for this component.
|
|
66
|
+
|
|
67
|
+
## Stories
|
|
68
|
+
|
|
69
|
+
### Default
|
|
70
|
+
|
|
71
|
+
Use Breadcrumbs when the current page sits inside a clear hierarchy. Link parent pages and keep the final item as plain text for the current page.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
const Default = () => <Breadcrumbs>{[
|
|
75
|
+
<BreadcrumbsItem href={'/'} key="link">
|
|
76
|
+
WAI-ARIA Authoring Practices Guide (APG)
|
|
77
|
+
</BreadcrumbsItem>,
|
|
78
|
+
<BreadcrumbsItem href={'/section/'} key="linkb">
|
|
79
|
+
Patterns
|
|
80
|
+
</BreadcrumbsItem>,
|
|
81
|
+
<BreadcrumbsItem href={'/section/subsection'} key="linkc">
|
|
82
|
+
Breadcrumb Pattern
|
|
83
|
+
</BreadcrumbsItem>,
|
|
84
|
+
<BreadcrumbsItem key="linkd">Breadcrumb Example</BreadcrumbsItem>,
|
|
85
|
+
]}</Breadcrumbs>;
|
|
86
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Button helps users complete a task, move through a workflow, or make a clear choice. Use it for page actions by default, and provide `href` only when the button needs to navigate with button-level emphasis.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Button for actions that happen immediately or in response to user input.
|
|
12
|
+
- Use Button for the primary action in a form, modal, toolbar, or page section.
|
|
13
|
+
- Use Button for destructive actions when the action needs stronger visual warning.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Button for plain text navigation. Use Link instead.
|
|
18
|
+
- Do not use Button for icon-only actions. Use IconButton so the accessible name requirement is clear.
|
|
19
|
+
- Do not use multiple primary buttons in the same decision area unless the actions are truly equal choices.
|
|
20
|
+
|
|
21
|
+
### Variants
|
|
22
|
+
|
|
23
|
+
Choose the lowest emphasis that still makes the action easy to find.
|
|
24
|
+
|
|
25
|
+
| Variants | Purpose | Usage notes |
|
|
26
|
+
| :---------- | :------------------------------------ | :---------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| `primary` | Highest-emphasis action. | Use for the main action in a focused area, such as saving a form or continuing a setup flow. |
|
|
28
|
+
| `secondary` | Standard supporting action. | Use for actions that should be easy to find without competing with the primary action. |
|
|
29
|
+
| `tertiary` | Low-emphasis action. | Use for supporting actions in dense interfaces or repeated rows. |
|
|
30
|
+
| `ghost` | Lowest-emphasis action. | Use where 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
|
+
| `skeleton` | Placeholder while content is loading. | Use only as a noninteractive loading placeholder. |
|
|
33
|
+
|
|
34
|
+
### Behavior
|
|
35
|
+
|
|
36
|
+
- **Mouse and touch**: clicking or tapping activates the button once the pointer is released.
|
|
37
|
+
- **Keyboard**: native buttons activate with Enter or Space. Anchor buttons activate with Enter.
|
|
38
|
+
- **Focus management**: keep the visible focus ring intact and return focus to a sensible place after dialogs or menus close.
|
|
39
|
+
- **Navigation**: use link rendering only when activation changes location or opens another resource.
|
|
40
|
+
- **Loading**: keep the button visible while the action is pending so users can connect the progress state to the action they started.
|
|
41
|
+
|
|
42
|
+
### Accessibility
|
|
43
|
+
|
|
44
|
+
- Use native `button` semantics for actions and native `a href` semantics for navigation.
|
|
45
|
+
- Give every button a clear accessible name through visible text. Use IconButton for icon-only controls.
|
|
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
|
+
- Use `disabled` for unavailable native buttons. Use `aria-disabled` only when a non-native or anchor-style control must remain discoverable.
|
|
49
|
+
- Communicate long-running progress near the button or through an appropriate status region when the action affects more than the button itself.
|
|
50
|
+
|
|
51
|
+
### Content
|
|
52
|
+
|
|
53
|
+
- Start labels with a specific verb: "Create invoice", "Save changes", "Delete customer".
|
|
54
|
+
- Make the label describe the outcome, not the gesture. Avoid labels like "Click here" or "Go".
|
|
55
|
+
- Keep labels short enough to scan, but not so short that the outcome is unclear.
|
|
56
|
+
- Keep destructive labels explicit. "Delete invoice" is clearer than "Delete".
|
|
57
|
+
- Avoid changing a label so dramatically in loading state that users cannot recognize which action is pending.
|
|
58
|
+
|
|
59
|
+
### Related
|
|
60
|
+
|
|
61
|
+
- **[IconButton](components-buttons-iconbutton.md)**: use for icon-only actions.
|
|
62
|
+
- **[Link](components-link.md)**: use for plain text navigation in body copy, tables, or lists.
|
|
63
|
+
- **[ActionMenu](components-action-menu.md)**: use when several related actions need to be grouped behind one trigger.
|
|
64
|
+
- **[LoadingSpinner](components-loading-spinner.md)**: use for standalone progress that is not tied to a button action.
|
|
65
|
+
|
|
66
|
+
## React
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { Button } from '@maxio-com/react-ui-components';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Imports
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { Button, Icon } from "@maxio-com/react-ui-components";
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Prop Types
|
|
79
|
+
|
|
80
|
+
### Button
|
|
81
|
+
|
|
82
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
83
|
+
| --- | --- | --- | --- | --- | --- |
|
|
84
|
+
| `disabled` | `boolean` | no | - | Determines if the button is disabled | InternalButtonProps |
|
|
85
|
+
| `fullWidth` | `boolean` | no | `false` | Allows button to expand and fill the available horizontal space within its container | CommonButtonProps |
|
|
86
|
+
| `href` | `string` | no | - | Disallows `href` on button element | InternalButtonProps, InternalLinkProps |
|
|
87
|
+
| `icon` | `ReactNode` | no | - | Displays a trailing icon (depricated) | CommonButtonProps |
|
|
88
|
+
| `leadingElement` | `ReactNode` | no | - | Displays a leading icon | CommonButtonProps |
|
|
89
|
+
| `loading` | `boolean` | no | `false` | 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 |
|
|
90
|
+
| `size` | `"sm" \| "md" \| "lg" \| "xl"` | no | - | Changes the size of the button | CommonButtonProps |
|
|
91
|
+
| `trailingElement` | `ReactNode` | no | - | Displays a trailing icon | CommonButtonProps |
|
|
92
|
+
| `value` | `string` | no | - | Button value - must be string for React Aria compatibility | InternalButtonProps |
|
|
93
|
+
| `variant` | `"primary" \| "secondary" \| "tertiary" \| "ghost" \| "danger" \| "skeleton"` | no | `primary` | Changes the button variant | CommonButtonProps |
|
|
94
|
+
|
|
95
|
+
## Stories
|
|
96
|
+
|
|
97
|
+
### Default
|
|
98
|
+
|
|
99
|
+
Use Button for actions that happen on the current page. Prefer visible labels that describe the result of the action, and use native button behavior for actions.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
const Default = () => <Button onClick={action('Clicked')}>Create invoice</Button>;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### As Link
|
|
106
|
+
|
|
107
|
+
Use Button as navigation only when the destination still needs button-level emphasis, such as a prominent next step in a workflow. Use Link for plain text navigation.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
const AsLink = () => <Button href="/customers/123" variant="secondary">View customer</Button>;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Destructive
|
|
114
|
+
|
|
115
|
+
Use danger variant for actions that remove data, cancel service, or are difficult to reverse. Pair destructive actions with confirmation or recovery guidance when the consequence is not obvious.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
const Destructive = () => <Button onClick={action('Deleted')} variant="danger">Delete invoice</Button>;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Loading
|
|
122
|
+
|
|
123
|
+
Use a loading button after the user starts an action and repeated activation should be prevented. Keep the label connected to the action that is running.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
const Loading = () => <Button loading onClick={action('Submitted')} type="submit">Saving changes</Button>;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### With Elements
|
|
130
|
+
|
|
131
|
+
Use leading or trailing elements to reinforce a visible label.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
const WithElements = () => <Button
|
|
135
|
+
leadingElement={<Icon variant="plus" />}
|
|
136
|
+
trailingElement={<Icon variant="arrow-right" />}>Add subscription
|
|
137
|
+
</Button>;
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Full Width
|
|
141
|
+
|
|
142
|
+
Use full-width buttons in constrained layouts where the action should align to the container width.
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
const FullWidth = () => <div style={{ maxWidth: '20rem' }}>
|
|
146
|
+
<Button fullWidth>Continue
|
|
147
|
+
</Button>
|
|
148
|
+
</div>;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Variants
|
|
152
|
+
|
|
153
|
+
Use variants to set visual emphasis and action tone. Choose the lowest emphasis that still makes the action easy to find.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
const Variants = () => <>
|
|
157
|
+
<Button variant="primary">Primary
|
|
158
|
+
</Button>
|
|
159
|
+
<Button variant="secondary">Secondary
|
|
160
|
+
</Button>
|
|
161
|
+
<Button variant="tertiary">Tertiary
|
|
162
|
+
</Button>
|
|
163
|
+
<Button variant="ghost">Ghost
|
|
164
|
+
</Button>
|
|
165
|
+
<Button variant="danger">Danger
|
|
166
|
+
</Button>
|
|
167
|
+
<Button variant="skeleton">Skeleton
|
|
168
|
+
</Button>
|
|
169
|
+
</>;
|
|
170
|
+
```
|
|
@@ -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
|
+
```
|