@maxio-com/react-ui-components 9.16.0 → 9.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +69 -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-textarea.md +187 -0
- package/dist/skills/maxio-react/references/components-forms-textfield.md +254 -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 +15 -2
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Tabs
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Tabs organizes related content into one selected panel at a time.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Tabs to switch between closely related views in the same page or workflow.
|
|
12
|
+
- Use Tabs when one section should be visible at a time and the tab labels make the available sections easy to scan.
|
|
13
|
+
- Use Tabs to keep account, billing, settings, or report subsections grouped under one stable context.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Tabs for navigation between unrelated pages or major app areas. Use SideNav or page navigation instead.
|
|
18
|
+
- Do not use Tabs when users need to compare multiple sections at the same time. Use visible sections, cards, or a table instead.
|
|
19
|
+
- Do not use icon-only tabs unless every tab has an accessible name and the icons are highly recognizable.
|
|
20
|
+
|
|
21
|
+
### Variants
|
|
22
|
+
|
|
23
|
+
Choose the visual treatment that fits the surrounding surface.
|
|
24
|
+
|
|
25
|
+
| Variants | Purpose | Usage notes |
|
|
26
|
+
| :------------ | :---------------------------- | :-------------------------------------------------------------------------- |
|
|
27
|
+
| `line` | Default page-level tabs. | Use for most horizontal tab groups on a plain page or inside a section. |
|
|
28
|
+
| `contained` | Higher-contrast grouped tabs. | Use when tabs need a stronger container relationship or sit in dense areas. |
|
|
29
|
+
| `withDivider` | Adds dividers between tabs. | Use only when neighboring tabs need clearer separation. |
|
|
30
|
+
|
|
31
|
+
### Behavior
|
|
32
|
+
|
|
33
|
+
- **Mouse and touch**: selecting a tab updates the active tab and renders the matching panel.
|
|
34
|
+
- **Keyboard**: Tab moves focus into the tab list. ArrowRight and ArrowLeft move selection across enabled tabs.
|
|
35
|
+
- **Focus management**: the selected tab receives focus after keyboard selection.
|
|
36
|
+
- **Controlled state**: use `index` with `onChange` when the active tab needs to be driven by route state, saved preferences, or another component.
|
|
37
|
+
- **Uncontrolled state**: use `defaultIndex` when Tabs can manage its own selection after the initial render.
|
|
38
|
+
|
|
39
|
+
### Accessibility
|
|
40
|
+
|
|
41
|
+
- Provide `ariaLabel` on `TabList` so the tab group has an accessible name.
|
|
42
|
+
- Keep `Tab` and `TabPanel` order aligned so each tab maps to the panel at the same index.
|
|
43
|
+
- Give icon-only tabs an accessible name with `aria-label`.
|
|
44
|
+
- Do not put disabled tabs in the selected state.
|
|
45
|
+
- Keep focus indicators visible and preserve the built-in arrow-key behavior.
|
|
46
|
+
|
|
47
|
+
### Content
|
|
48
|
+
|
|
49
|
+
- Use short noun labels that describe the panel content, such as "Invoices", "Usage", or "Settings".
|
|
50
|
+
- Keep labels parallel in structure and specific to the current context.
|
|
51
|
+
- Avoid long tab labels that wrap or make the active section hard to scan.
|
|
52
|
+
- Use icons as supporting context; do not rely on icons alone unless the meaning is unmistakable.
|
|
53
|
+
|
|
54
|
+
### Related
|
|
55
|
+
|
|
56
|
+
- **[SideNav](patterns-side-nav.md)**: use for primary navigation across app areas.
|
|
57
|
+
- **[Breadcrumbs](components-breadcrumbs.md)**: use to show page location in a hierarchy.
|
|
58
|
+
- **[ActionList](components-action-list.md)**: use for a vertical list of actions or choices rather than mutually exclusive content panels.
|
|
59
|
+
|
|
60
|
+
## React
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import {
|
|
64
|
+
Tabs,
|
|
65
|
+
TabList,
|
|
66
|
+
Tab,
|
|
67
|
+
TabPanels,
|
|
68
|
+
TabPanel,
|
|
69
|
+
} from '@maxio-com/react-ui-components';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Composition
|
|
73
|
+
|
|
74
|
+
- `Tabs` provides selection state to the tab list and panels.
|
|
75
|
+
- `TabList` renders the horizontal `tablist` and accepts only `Tab` children.
|
|
76
|
+
- `Tab` renders one selectable tab. Use `rightIcon` for a supporting icon or `type="icon"` with `icon` for icon-only tabs.
|
|
77
|
+
- `TabPanels` renders the active panel and accepts only `TabPanel` children.
|
|
78
|
+
- `TabPanel` contains the content for the tab at the same index.
|
|
79
|
+
|
|
80
|
+
Keep the number and order of `Tab` and `TabPanel` children aligned.
|
|
81
|
+
|
|
82
|
+
### State Management
|
|
83
|
+
|
|
84
|
+
Use uncontrolled Tabs for local page state. Use controlled Tabs when selection is driven by routing, persisted preferences, or another component.
|
|
85
|
+
|
|
86
|
+
#### Controlled
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
const Example = () => {
|
|
90
|
+
const [index, setIndex] = React.useState(0);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Tabs index={index} onChange={(idx) => setIndex(idx)}>
|
|
94
|
+
<TabList ariaLabel="Customer account sections">
|
|
95
|
+
<Tab>Overview</Tab>
|
|
96
|
+
<Tab>Invoices</Tab>
|
|
97
|
+
</TabList>
|
|
98
|
+
<TabPanels>
|
|
99
|
+
<TabPanel>Overview content</TabPanel>
|
|
100
|
+
<TabPanel>Invoices content</TabPanel>
|
|
101
|
+
</TabPanels>
|
|
102
|
+
</Tabs>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Uncontrolled
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<Tabs defaultIndex={1}>
|
|
111
|
+
<TabList ariaLabel="Customer account sections">
|
|
112
|
+
<Tab>Overview</Tab>
|
|
113
|
+
<Tab>Invoices</Tab>
|
|
114
|
+
</TabList>
|
|
115
|
+
<TabPanels>
|
|
116
|
+
<TabPanel>Overview content</TabPanel>
|
|
117
|
+
<TabPanel>Invoices content</TabPanel>
|
|
118
|
+
</TabPanels>
|
|
119
|
+
</Tabs>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Imports
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { Body, Icon, Tab, TabList, TabPanel, TabPanels, Tabs } from "@maxio-com/react-ui-components";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Prop Types
|
|
129
|
+
|
|
130
|
+
### Tabs
|
|
131
|
+
|
|
132
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
133
|
+
| --- | --- | --- | --- | --- | --- |
|
|
134
|
+
| `defaultIndex` | `number` | no | `0` | Indicates which tab should be active by default | TypeLiteral |
|
|
135
|
+
| `index` | `number` | no | - | Indicates which tab should be active in controlled mode. | TypeLiteral |
|
|
136
|
+
| `onChange` | `((idx: number \| ((prevIdx: number) => number)) => void)` | no | - | Callback function that is fired when the tab is changed | TabsContext |
|
|
137
|
+
| `variant` | `"line" \| "contained"` | no | `line` | The variant of the tabs. | TabsContext |
|
|
138
|
+
| `withDivider` | `boolean` | no | `false` | Add divider between tabs | TabsContext |
|
|
139
|
+
|
|
140
|
+
## Stories
|
|
141
|
+
|
|
142
|
+
### Default
|
|
143
|
+
|
|
144
|
+
Snippet unavailable: SyntaxError: Expected render to be an arrow function or function expression
|
|
145
|
+
|
|
146
|
+
### Contained
|
|
147
|
+
|
|
148
|
+
Snippet unavailable: SyntaxError: Expected render to be an arrow function or function expression
|
|
149
|
+
|
|
150
|
+
### With Icon
|
|
151
|
+
|
|
152
|
+
Use supporting icons only when they reinforce the visible tab label. The text label remains the accessible name.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const WithIcon = () => <Tabs>
|
|
156
|
+
<TabList ariaLabel="Billing setup sections">
|
|
157
|
+
<Tab rightIcon={<Icon variant="bank" />}>Payment methods</Tab>
|
|
158
|
+
<Tab rightIcon={<Icon variant="address-card" />}>Billing contacts</Tab>
|
|
159
|
+
</TabList>
|
|
160
|
+
<TabPanels>
|
|
161
|
+
<TabPanel>
|
|
162
|
+
<Body>Manage saved bank accounts and cards.</Body>
|
|
163
|
+
</TabPanel>
|
|
164
|
+
<TabPanel>
|
|
165
|
+
<Body>Manage billing contacts and invoice recipients.</Body>
|
|
166
|
+
</TabPanel>
|
|
167
|
+
</TabPanels>
|
|
168
|
+
</Tabs>;
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Bare Icon
|
|
172
|
+
|
|
173
|
+
Use icon-only tabs only in compact interfaces where every icon is recognizable. Provide an accessible name for each tab.
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
const BareIcon = () => <Tabs>
|
|
177
|
+
<TabList ariaLabel="Contact method sections">
|
|
178
|
+
<Tab
|
|
179
|
+
type="icon"
|
|
180
|
+
icon={<Icon variant="address-card" />}
|
|
181
|
+
aria-label="Billing contact" />
|
|
182
|
+
<Tab type="icon" icon={<Icon variant="bank" />} aria-label="Bank account" />
|
|
183
|
+
</TabList>
|
|
184
|
+
<TabPanels>
|
|
185
|
+
<TabPanel>
|
|
186
|
+
<Body>Billing contact details.</Body>
|
|
187
|
+
</TabPanel>
|
|
188
|
+
<TabPanel>
|
|
189
|
+
<Body>Bank account details.</Body>
|
|
190
|
+
</TabPanel>
|
|
191
|
+
</TabPanels>
|
|
192
|
+
</Tabs>;
|
|
193
|
+
```
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Tag
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Tags label non-interactive metadata, statuses, or categories.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Tag to label non-interactive metadata, categories, plans, or statuses.
|
|
12
|
+
- Use Tag in dense layouts such as tables, cards, summaries, and detail headers where a compact label helps users scan.
|
|
13
|
+
- Use sentiment when the label communicates a recognizable state such as success, warning, danger, information, or highlight.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Tag for selectable, dismissible, or clickable values. Use [Chip](components-chip.md) instead.
|
|
18
|
+
- Do not use Tag for urgent page-level messages. Use [Alert](components-notifications-alert.md), [Banner](components-notifications-banner.md), or [Toast](components-notifications-toast.md) instead.
|
|
19
|
+
- Do not use Tag as the only way to explain complex status details. Pair it with nearby text when users need next steps or consequences.
|
|
20
|
+
|
|
21
|
+
### Variants
|
|
22
|
+
|
|
23
|
+
Use kind for visual emphasis and sentiment for status meaning.
|
|
24
|
+
|
|
25
|
+
| Variants | Purpose | Usage notes |
|
|
26
|
+
| :---------- | :---------------------------- | :-------------------------------------------------------------------------- |
|
|
27
|
+
| `primary` | Highest-emphasis tag. | Use sparingly for important statuses that should stand out in a focused UI. |
|
|
28
|
+
| `secondary` | Standard metadata tag. | Use for most statuses and categories in repeated layouts. |
|
|
29
|
+
| `tertiary` | Lowest-emphasis metadata tag. | Use when the tag should support nearby content without adding a fill. |
|
|
30
|
+
|
|
31
|
+
| Sentiment | Purpose | Usage notes |
|
|
32
|
+
| :---------- | :-------------------------- | :--------------------------------------------------------------------- |
|
|
33
|
+
| `info` | Neutral information. | Use for informational states such as trial, draft, or pending review. |
|
|
34
|
+
| `success` | Positive or complete state. | Use for active, paid, completed, approved, or healthy states. |
|
|
35
|
+
| `warning` | Needs attention. | Use when users should notice a state before it becomes blocking. |
|
|
36
|
+
| `danger` | Error or high-risk state. | Use for overdue, failed, inactive, blocked, or destructive states. |
|
|
37
|
+
| `highlight` | Special categorization. | Use for featured, enterprise, promoted, or otherwise notable metadata. |
|
|
38
|
+
|
|
39
|
+
### Accessibility
|
|
40
|
+
|
|
41
|
+
- Use Tag for static text only. Do not attach click handlers or keyboard behavior to the tag container.
|
|
42
|
+
- Make the visible label specific enough to communicate the status without relying on color.
|
|
43
|
+
- Use icons as decorative or supporting visuals only; the label must still carry the meaning.
|
|
44
|
+
- Keep labels short and avoid abbreviations that are not familiar to the audience.
|
|
45
|
+
- Pair tags with nearby explanatory text when a status requires action.
|
|
46
|
+
|
|
47
|
+
### Content
|
|
48
|
+
|
|
49
|
+
- Use one to three words when possible: "Active", "Past due", "Enterprise".
|
|
50
|
+
- Use nouns or short status phrases rather than action labels.
|
|
51
|
+
- Prefer customer-facing language over internal state names.
|
|
52
|
+
- Avoid stacking several tags when one clear status is enough.
|
|
53
|
+
|
|
54
|
+
### Related
|
|
55
|
+
|
|
56
|
+
- **[Chip](components-chip.md)**: use for selected, dismissible, or interactive values.
|
|
57
|
+
- **[Alert](components-notifications-alert.md)**: use for contextual messages that need explanation or action.
|
|
58
|
+
- **[Banner](components-notifications-banner.md)**: use for page-level or product-level announcements.
|
|
59
|
+
|
|
60
|
+
## React
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { Tag } from '@maxio-com/react-ui-components';
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Imports
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { Tag } from "@maxio-com/react-ui-components";
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Prop Types
|
|
73
|
+
|
|
74
|
+
### Tag
|
|
75
|
+
|
|
76
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
77
|
+
| --- | --- | --- | --- | --- | --- |
|
|
78
|
+
| `children` | `ReactNode` | yes | - | React children nodes | TypeLiteral |
|
|
79
|
+
| `kind` | `"primary" \| "secondary" \| "tertiary"` | no | `primary` | Modifier for the tag Kind | TypeLiteral |
|
|
80
|
+
| `leadingIcon` | `string` | no | - | Element allowing leading icon selection | TypeLiteral |
|
|
81
|
+
| `sentiment` | `"danger" \| "info" \| "success" \| "warning" \| "highlight"` | no | - | Modifier for the tag Sentiment | TypeLiteral |
|
|
82
|
+
| `size` | `"sm"` | no | - | Modifier for the size of the tag. Default tag size is `md` | TypeLiteral |
|
|
83
|
+
| `trailingIcon` | `string` | no | - | Element allowing trailing icon selection | TypeLiteral |
|
|
84
|
+
|
|
85
|
+
## Stories
|
|
86
|
+
|
|
87
|
+
### Default
|
|
88
|
+
|
|
89
|
+
Use Tag for short, non-interactive metadata such as customer type, plan status, invoice state, or categorization. Use the visible label as the accessible name.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
const Default = () => <Tag kind="secondary" sentiment="success">Active</Tag>;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Sentiment
|
|
96
|
+
|
|
97
|
+
Use sentiment when the tag communicates a recognizable status. Do not rely on color alone; keep the label specific enough to carry the meaning.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const Sentiment = () => <Tag kind="primary" sentiment="danger">Past due</Tag>;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### With Icon
|
|
104
|
+
|
|
105
|
+
Use icons only when they help identify the tag faster. Icons are supporting visuals; the label still communicates the tag's meaning.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
const WithIcon = () => <Tag kind="tertiary" sentiment="highlight" leadingIcon="briefcase">Enterprise</Tag>;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Small
|
|
112
|
+
|
|
113
|
+
Use small tags in dense areas such as table cells, compact summaries, and metadata rows where the tag should not dominate surrounding content.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
const Small = () => <Tag kind="secondary" sentiment="info" size="sm">Trial</Tag>;
|
|
117
|
+
```
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Tile
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Tile groups concise content in a standalone surface.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Tile for compact, standalone content that should be scanned as one choice or summary.
|
|
12
|
+
- Use Tile when the entire surface should navigate to one destination or perform one clear action.
|
|
13
|
+
- Use Tile for dashboards, setup steps, feature shortcuts, or next-step prompts where the whole surface has the same outcome.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Tile for page sections with headings, body content, and local actions. Use Card instead.
|
|
18
|
+
- Do not use Tile as a generic layout wrapper when the content does not need a visible surface.
|
|
19
|
+
- Do not put multiple links, buttons, or form controls inside an interactive Tile. Use a noninteractive Tile or Card with separate controls instead.
|
|
20
|
+
- Do not use Tile for inline text navigation. Use Link instead.
|
|
21
|
+
|
|
22
|
+
### Behavior
|
|
23
|
+
|
|
24
|
+
- **Mouse and touch**: static tiles do not respond to pointer input. Interactive tiles activate when the tile surface is clicked or tapped.
|
|
25
|
+
- **Keyboard**: link tiles follow native anchor behavior and activate with Enter. Static tiles do not enter the tab order.
|
|
26
|
+
- **Focus management**: keep the visible focus ring intact on interactive tiles and make the tile text describe the destination or action.
|
|
27
|
+
- **Disabled state**: disabled interactive tiles receive disabled styling and suppress React click handling. For HTML usage, keep disabled styling and semantic state attributes synchronized.
|
|
28
|
+
|
|
29
|
+
### Accessibility
|
|
30
|
+
|
|
31
|
+
- Use static `div` markup only when the tile itself is not interactive.
|
|
32
|
+
- Use native `a href` semantics when the tile navigates to another page or resource.
|
|
33
|
+
- Use a native button pattern for hand-authored HTML action tiles so Enter and Space activation work by default.
|
|
34
|
+
- Make the accessible name clear from visible tile content. The heading and summary should describe the destination or action.
|
|
35
|
+
- Do not rely on color alone to communicate disabled or unavailable state. Provide nearby explanatory text when the reason is not obvious.
|
|
36
|
+
- Avoid nesting interactive controls inside an interactive tile because nested click targets create confusing focus and activation behavior.
|
|
37
|
+
|
|
38
|
+
### Content
|
|
39
|
+
|
|
40
|
+
- Lead with a short, specific heading that names the destination, action, or summary.
|
|
41
|
+
- Use supporting copy to explain what happens next or why the tile matters.
|
|
42
|
+
- Keep tile content concise enough to scan in a grid or dashboard.
|
|
43
|
+
- Use disabled copy to explain availability requirements when users can resolve the issue.
|
|
44
|
+
|
|
45
|
+
### Related
|
|
46
|
+
|
|
47
|
+
- **[Card](components-card.md)**: use for grouped page sections with header, body, footer, or local actions.
|
|
48
|
+
- **[Link](components-link.md)**: use for inline or standalone text navigation.
|
|
49
|
+
- **[Button](components-buttons-button.md)**: use for ordinary actions that do not need the whole-surface tile treatment.
|
|
50
|
+
|
|
51
|
+
## React
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Tile } from '@maxio-com/react-ui-components';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Imports
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Tile } from "@maxio-com/react-ui-components";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Prop Types
|
|
64
|
+
|
|
65
|
+
### Tile
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
68
|
+
| --- | --- | --- | --- | --- | --- |
|
|
69
|
+
| `disabled` | `boolean` | no | - | - | TypeLiteral |
|
|
70
|
+
| `href` | `string` | no | - | - | TypeLiteral |
|
|
71
|
+
| `onClick` | `((() => void) & MouseEventHandler<HTMLDivElement>)` | no | - | - | TypeLiteral, DOMAttributes |
|
|
72
|
+
| `target` | `"string"` | no | - | - | TypeLiteral |
|
|
73
|
+
|
|
74
|
+
## Stories
|
|
75
|
+
|
|
76
|
+
### Default
|
|
77
|
+
|
|
78
|
+
Use a static Tile when the content is grouped for scanning but the whole surface does not navigate or trigger an action.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
const Default = () => <Tile onClick={undefined}><div className="maxio-heading-md">Text content</div></Tile>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Navigation
|
|
85
|
+
|
|
86
|
+
Use a link Tile when clicking anywhere on the tile should take users to one destination. Keep the destination clear from the visible content.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
const ClickableHref = () => <Tile href="https://www.maxio.com"><div className="maxio-heading-md">Href</div></Tile>;
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Action
|
|
93
|
+
|
|
94
|
+
Use an action Tile only when the whole surface performs one clear action. Do not place additional interactive elements inside an action Tile.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
const ClickableOnClick = () => <Tile><div className="maxio-heading-md">On click</div></Tile>;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Disabled navigation
|
|
101
|
+
|
|
102
|
+
Use disabled styling when a navigation Tile is temporarily unavailable. Prevent navigation in JavaScript and communicate the unavailable reason near the tile when the reason is not obvious.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
const ClickableHrefDisabled = () => <Tile disabled href="/revenue-recognition"><div className="maxio-heading-md">href disabled</div></Tile>;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Disabled action
|
|
109
|
+
|
|
110
|
+
Use disabled action Tiles only when the action cannot currently be performed. Avoid using disabled tiles for permissions or hidden features that need more explanatory copy.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
const ClickableOnClickDisabled = () => <Tile disabled onClick={action('Disabled tile action')}><div className="maxio-heading-md">onClick disabled</div></Tile>;
|
|
114
|
+
```
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# ToggleComponent
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Toggle lets users turn a setting on or off.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use Toggle for a single setting that can be either on or off.
|
|
12
|
+
- Use Toggle when changing the setting can take effect immediately.
|
|
13
|
+
- Use Toggle for persistent preferences such as notifications, automation, or feature access.
|
|
14
|
+
|
|
15
|
+
#### When Not to Use
|
|
16
|
+
|
|
17
|
+
- Do not use Toggle for one-time actions such as saving, deleting, or submitting. Use Button instead.
|
|
18
|
+
- Do not use Toggle when users must choose one option from a set. Use Radio or Select instead.
|
|
19
|
+
- Do not use Toggle for multi-select lists. Use Checkbox instead.
|
|
20
|
+
|
|
21
|
+
### Behavior
|
|
22
|
+
|
|
23
|
+
- **Mouse and touch**: clicking or tapping the input changes the setting between off and on.
|
|
24
|
+
- **Keyboard**: the native checkbox receives focus in tab order and changes state with Space. The React component also supports Enter.
|
|
25
|
+
- **Focus management**: keep the Maxio focus ring visible on the switch track.
|
|
26
|
+
- **Controlled state**: use `checked` with `onChange` when app state owns the setting. Use `defaultChecked` for simple uncontrolled form use.
|
|
27
|
+
- **Disabled state**: disabled toggles remain visible but cannot be changed.
|
|
28
|
+
|
|
29
|
+
### Accessibility
|
|
30
|
+
|
|
31
|
+
- Keep the native checkbox input as the interactive control.
|
|
32
|
+
- Provide a clear accessible name with visible `valueDescription` text or `aria-label`.
|
|
33
|
+
- Connect visible `valueDescription` labels with `id` and `htmlFor`; the component generates an id when one is not provided.
|
|
34
|
+
- Keep the checkbox state, visual track position, and any persisted setting value synchronized.
|
|
35
|
+
- Do not rely on color alone to communicate on or off state; the track includes iconography as an additional cue.
|
|
36
|
+
|
|
37
|
+
### Content
|
|
38
|
+
|
|
39
|
+
- Label the setting, not the current state. Use "Email notifications" instead of only "On" or "Off".
|
|
40
|
+
- Keep labels short and specific enough to scan in dense settings pages.
|
|
41
|
+
- Place explanatory or eligibility copy near the toggle when a disabled state needs context.
|
|
42
|
+
|
|
43
|
+
### Related
|
|
44
|
+
|
|
45
|
+
- **[Checkbox](components-forms-checkbox.md)**: use for independent selections in a form or list.
|
|
46
|
+
- **[Radio](components-forms-radio-group.md)**: use when users must choose one option from a related set.
|
|
47
|
+
- **[Button](components-buttons-button.md)**: use for actions that run only after activation.
|
|
48
|
+
|
|
49
|
+
## React
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { Toggle } from '@maxio-com/react-ui-components';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### State Management
|
|
56
|
+
|
|
57
|
+
Use `checked` and `onChange` when application state owns the setting.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
const [checked, setChecked] = React.useState(false);
|
|
61
|
+
|
|
62
|
+
<Toggle
|
|
63
|
+
checked={checked}
|
|
64
|
+
onChange={setChecked}
|
|
65
|
+
valueDescription="Email notifications"
|
|
66
|
+
valueDescriptionPosition="right"
|
|
67
|
+
/>;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Use `defaultChecked` when the initial state is enough and the form can read the checkbox value later.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<Toggle
|
|
74
|
+
defaultChecked
|
|
75
|
+
name="auto-renewal"
|
|
76
|
+
valueDescription="Auto-renewal"
|
|
77
|
+
valueDescriptionPosition="left"
|
|
78
|
+
/>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Imports
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { ToggleComponent } from "@maxio-com/react-ui-components";
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Prop Types
|
|
88
|
+
|
|
89
|
+
### Toggle
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
92
|
+
| --- | --- | --- | --- | --- | --- |
|
|
93
|
+
| `aria-label` | `string` | no | - | Aria label for the toggle - should be provided if no valueDescription is provided | TypeLiteral |
|
|
94
|
+
| `checked` | `boolean` | no | - | The state of the toggle | TypeLiteral |
|
|
95
|
+
| `className` | `string` | no | - | Class name for the main container | TypeLiteral |
|
|
96
|
+
| `defaultChecked` | `boolean` | no | - | The state for uncontrolled toggle. | TypeLiteral |
|
|
97
|
+
| `disabled` | `boolean` | no | - | Is the toggle disabled | TypeLiteral |
|
|
98
|
+
| `id` | `string` | no | - | Toggle id - if id not provided then it will be generated automatically | TypeLiteral |
|
|
99
|
+
| `name` | `string` | no | - | Toggle name | TypeLiteral |
|
|
100
|
+
| `onChange` | `((value: boolean, event?: KeyboardEvent<HTMLInputElement> \| ChangeEvent<HTMLInputElement>) => void)` | no | - | The onChange function | TypeLiteral |
|
|
101
|
+
| `valueDescription` | `string` | no | - | Toggle label | TypeLiteral |
|
|
102
|
+
| `valueDescriptionPosition` | `"left" \| "right"` | no | - | Toggle label position | TypeLiteral |
|
|
103
|
+
|
|
104
|
+
## Stories
|
|
105
|
+
|
|
106
|
+
### Default
|
|
107
|
+
|
|
108
|
+
Use Default for a single setting that can be toggled on or off immediately. Prefer a visible label that names the setting instead of only describing the current state.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const Default = ({
|
|
112
|
+
checked = false,
|
|
113
|
+
onChange,
|
|
114
|
+
...props
|
|
115
|
+
}: ToggleProps) => {
|
|
116
|
+
const [isChecked, setIsChecked] = React.useState(Boolean(checked));
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<ToggleComponent
|
|
120
|
+
{...props}
|
|
121
|
+
checked={isChecked}
|
|
122
|
+
onChange={(value, event) => {
|
|
123
|
+
setIsChecked(value);
|
|
124
|
+
onChange?.(value, event);
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Checked
|
|
132
|
+
|
|
133
|
+
Use Checked when the setting is already enabled. Keep the input `checked` state aligned with the visual track position.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
const Checked = ({
|
|
137
|
+
checked = false,
|
|
138
|
+
onChange,
|
|
139
|
+
...props
|
|
140
|
+
}: ToggleProps) => {
|
|
141
|
+
const [isChecked, setIsChecked] = React.useState(Boolean(checked));
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<ToggleComponent
|
|
145
|
+
{...props}
|
|
146
|
+
checked={isChecked}
|
|
147
|
+
onChange={(value, event) => {
|
|
148
|
+
setIsChecked(value);
|
|
149
|
+
onChange?.(value, event);
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Label Left
|
|
157
|
+
|
|
158
|
+
Place the label on the left when the surrounding form reads label first.
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
const LabelLeft = ({
|
|
162
|
+
checked = false,
|
|
163
|
+
onChange,
|
|
164
|
+
...props
|
|
165
|
+
}: ToggleProps) => {
|
|
166
|
+
const [isChecked, setIsChecked] = React.useState(Boolean(checked));
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<ToggleComponent
|
|
170
|
+
{...props}
|
|
171
|
+
checked={isChecked}
|
|
172
|
+
onChange={(value, event) => {
|
|
173
|
+
setIsChecked(value);
|
|
174
|
+
onChange?.(value, event);
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Label Right
|
|
182
|
+
|
|
183
|
+
Place the label on the right when the switch appears before its setting name.
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
const LabelRight = ({
|
|
187
|
+
checked = false,
|
|
188
|
+
onChange,
|
|
189
|
+
...props
|
|
190
|
+
}: ToggleProps) => {
|
|
191
|
+
const [isChecked, setIsChecked] = React.useState(Boolean(checked));
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<ToggleComponent
|
|
195
|
+
{...props}
|
|
196
|
+
checked={isChecked}
|
|
197
|
+
onChange={(value, event) => {
|
|
198
|
+
setIsChecked(value);
|
|
199
|
+
onChange?.(value, event);
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Disabled
|
|
207
|
+
|
|
208
|
+
Use Disabled when a setting is visible but cannot be changed in the current context. Include supporting copy nearby when users need to know why.
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
const Disabled = () => <ToggleComponent
|
|
212
|
+
id="toggle-subscription-paused"
|
|
213
|
+
name="subscription-paused"
|
|
214
|
+
disabled
|
|
215
|
+
checked={false}
|
|
216
|
+
valueDescription="Subscription paused"
|
|
217
|
+
valueDescriptionPosition="right" />;
|
|
218
|
+
```
|