aidos-ui 4.0.0 → 4.0.2
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/.claude/settings.local.json +14 -1
- package/CLAUDE.md +72 -0
- package/dist/BaseButton.js.map +1 -1
- package/dist/BaseLink.js.map +1 -1
- package/dist/BaseListItem.d.ts +1 -1
- package/dist/Calendar.d.ts +2 -2
- package/dist/Card.js +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/DarkMode.js.map +1 -1
- package/dist/DatePicker.js.map +1 -1
- package/dist/Dialog.d.ts +3 -3
- package/dist/Dialog.js +7 -1
- package/dist/Dialog.js.map +1 -1
- package/dist/Dropdown.js.map +1 -1
- package/dist/Icon.d.ts +3 -3
- package/dist/Icon.js +2 -21
- package/dist/Icon.js.map +1 -1
- package/dist/Interactable.js.map +1 -1
- package/dist/NextJSRouterState.js.map +1 -1
- package/dist/OnVisible.d.ts +1 -1
- package/dist/OnVisible.js.map +1 -1
- package/dist/Popover.d.ts +3 -3
- package/dist/Popover.js +3 -1
- package/dist/Popover.js.map +1 -1
- package/dist/Providers.d.ts +2 -2
- package/dist/RangeInput.d.ts +1 -1
- package/dist/RootView.js.map +1 -1
- package/dist/Select.d.ts +0 -1
- package/dist/Storage.d.ts +2 -1
- package/dist/Storage.js.map +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/Text.js.map +1 -1
- package/dist/TextInput.d.ts +3 -2
- package/dist/TextInput.js +13 -4
- package/dist/TextInput.js.map +1 -1
- package/dist/TextPairing.js.map +1 -1
- package/dist/Tooltip.d.ts +2 -2
- package/dist/Tooltip.js +3 -2
- package/dist/Tooltip.js.map +1 -1
- package/dist/aria.js.map +1 -1
- package/dist/hash.js.map +1 -1
- package/dist/jss.d.ts +11 -6
- package/dist/jss.js +47 -2
- package/dist/jss.js.map +1 -1
- package/dist/numberToBase.js.map +1 -1
- package/dist/stateMachineContextFactory.js.map +1 -1
- package/dist/useCookie.js.map +1 -1
- package/dist/useKeyboard.js.map +1 -1
- package/dist/useNavigation.js.map +1 -1
- package/dist/useRefEffect.js.map +1 -1
- package/next-env.d.ts +2 -1
- package/next.config.js +2 -1
- package/package.json +27 -20
- package/src/BaseListItem.tsx +1 -1
- package/src/Calendar.tsx +2 -2
- package/src/Card.tsx +1 -1
- package/src/Dialog.tsx +10 -4
- package/src/Icon.tsx +4 -30
- package/src/Popover.tsx +6 -4
- package/src/Providers.tsx +1 -1
- package/src/RangeInput.tsx +1 -1
- package/src/Storage.tsx +1 -1
- package/src/TextInput.tsx +17 -5
- package/src/Tooltip.tsx +5 -4
- package/src/docs/mdx.tsx +40 -0
- package/src/docs/searchIndex.ts +1 -1
- package/src/jss.tsx +55 -3
- package/src/pages/Badge.mdx +136 -14
- package/src/pages/Button.mdx +121 -63
- package/src/pages/Calendar.mdx +196 -2
- package/src/pages/Card.mdx +123 -47
- package/src/pages/Checkbox.mdx +103 -28
- package/src/pages/Dialog.mdx +172 -7
- package/src/pages/FlexLayout.mdx +185 -51
- package/src/pages/Hashing.mdx +199 -8
- package/src/pages/Icon.mdx +150 -42
- package/src/pages/IconButton.mdx +127 -116
- package/src/pages/Link.mdx +118 -47
- package/src/pages/List.mdx +167 -283
- package/src/pages/ListHeader.mdx +157 -27
- package/src/pages/Popover.mdx +177 -55
- package/src/pages/ProgressBar.mdx +186 -6
- package/src/pages/ProgressCircle.mdx +196 -13
- package/src/pages/RangeInput.mdx +189 -61
- package/src/pages/Tabs.mdx +202 -346
- package/src/pages/Text.mdx +102 -81
- package/src/pages/TextInput.mdx +169 -44
- package/src/pages/TextPairing.mdx +164 -115
- package/src/pages/TimeInput.mdx +142 -37
- package/src/pages/Tooltip.mdx +99 -12
- package/src/pages/_app.tsx +13 -3
- package/src/pages/css-in-js.mdx +196 -83
- package/src/pages/navigation.mdx +122 -20
- package/src/pages/useCookie.mdx +168 -7
- package/src/pages/useKeyboard.mdx +242 -5
- package/src/pages/useNavigation.mdx +244 -16
- package/src/pages/usePromise.mdx +271 -6
- package/src/pages/useRefEffect.mdx +230 -28
- package/tsconfig.json +13 -4
package/src/pages/Calendar.mdx
CHANGED
|
@@ -1,11 +1,97 @@
|
|
|
1
1
|
import { Calendar } from "../Calendar";
|
|
2
2
|
import { Box } from "../Box";
|
|
3
|
+
import { Row } from "../Row";
|
|
4
|
+
import { Column } from "../Column";
|
|
3
5
|
import { Badge } from "../Badge";
|
|
4
6
|
import { Span, H3 } from "../Text";
|
|
7
|
+
import { cssVar } from "../jss";
|
|
5
8
|
|
|
6
9
|
# Calendar
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
A flexible calendar grid component for displaying months. Fully customizable through render callbacks for both header cells (weekday names) and day cells.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
|------|------|---------|-------------|
|
|
19
|
+
| `date` | `Date` | Required | The month to display (uses year and month from this date) |
|
|
20
|
+
| `header` | `(props) => JSX.Element` | Required | Render function for weekday header cells |
|
|
21
|
+
| `cell` | `(props) => JSX.Element` | Required | Render function for day cells |
|
|
22
|
+
| `jss` | `JSS` | - | Custom styles for the calendar grid |
|
|
23
|
+
|
|
24
|
+
### Header render props
|
|
25
|
+
|
|
26
|
+
| Property | Type | Description |
|
|
27
|
+
|----------|------|-------------|
|
|
28
|
+
| `weekday` | `string` | Localized weekday abbreviation (Mon, Tue, etc.) |
|
|
29
|
+
|
|
30
|
+
### Cell render props
|
|
31
|
+
|
|
32
|
+
| Property | Type | Description |
|
|
33
|
+
|----------|------|-------------|
|
|
34
|
+
| `date` | `Date` | The date for this cell |
|
|
35
|
+
| `today` | `boolean` | Whether this date is today |
|
|
36
|
+
| `outOfMonth` | `boolean` | Whether this date is outside the current month |
|
|
37
|
+
| `top` | `boolean` | Whether this cell is in the top row |
|
|
38
|
+
| `bottom` | `boolean` | Whether this cell is in the bottom row |
|
|
39
|
+
| `left` | `boolean` | Whether this cell is in the leftmost column |
|
|
40
|
+
| `right` | `boolean` | Whether this cell is in the rightmost column |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Basic usage
|
|
45
|
+
|
|
46
|
+
<Calendar
|
|
47
|
+
date={new Date()}
|
|
48
|
+
header={({ weekday }) => (
|
|
49
|
+
<Box padding="small" jss={{ textAlign: "center" }}>
|
|
50
|
+
<Span bold color="secondary" size="small">{weekday}</Span>
|
|
51
|
+
</Box>
|
|
52
|
+
)}
|
|
53
|
+
cell={({ today, date, outOfMonth }) => (
|
|
54
|
+
<Box padding="small" relative={true} jss={{ opacity: outOfMonth ? 0.3 : 1, textAlign: "center" }}>
|
|
55
|
+
{today && (
|
|
56
|
+
<Badge
|
|
57
|
+
size="xlarge"
|
|
58
|
+
color="highlight"
|
|
59
|
+
jss={{
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: "50%",
|
|
62
|
+
left: "50%",
|
|
63
|
+
transform: "translate(-50%, -50%)",
|
|
64
|
+
zIndex: 0,
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
<Span jss={{ position: "relative", zIndex: 1 }} color={today ? "light" : "primary"}>
|
|
69
|
+
{date.getDate()}
|
|
70
|
+
</Span>
|
|
71
|
+
</Box>
|
|
72
|
+
)}
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
<Calendar
|
|
77
|
+
date={new Date()}
|
|
78
|
+
header={({ weekday }) => (
|
|
79
|
+
<Box padding="small" jss={{ textAlign: "center" }}>
|
|
80
|
+
<Span bold color="secondary" size="small">{weekday}</Span>
|
|
81
|
+
</Box>
|
|
82
|
+
)}
|
|
83
|
+
cell={({ today, date, outOfMonth }) => (
|
|
84
|
+
<Box padding="small" jss={{ opacity: outOfMonth ? 0.3 : 1 }}>
|
|
85
|
+
{today && <Badge color="highlight" />}
|
|
86
|
+
<Span>{date.getDate()}</Span>
|
|
87
|
+
</Box>
|
|
88
|
+
)}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## With today indicator
|
|
9
95
|
|
|
10
96
|
<Calendar
|
|
11
97
|
date={new Date()}
|
|
@@ -36,7 +122,7 @@ The calendar component is can be used to represent months, and is customisable t
|
|
|
36
122
|
date={new Date()}
|
|
37
123
|
header={({ weekday }) => (
|
|
38
124
|
<Box>
|
|
39
|
-
<
|
|
125
|
+
<H3>{weekday}</H3>
|
|
40
126
|
</Box>
|
|
41
127
|
)}
|
|
42
128
|
cell={({ today, date, outOfMonth }) => (
|
|
@@ -58,3 +144,111 @@ The calendar component is can be used to represent months, and is customisable t
|
|
|
58
144
|
```
|
|
59
145
|
|
|
60
146
|
---
|
|
147
|
+
|
|
148
|
+
## Using position props
|
|
149
|
+
|
|
150
|
+
The cell render props include position information for styling borders and corners:
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
<Calendar
|
|
154
|
+
date={new Date()}
|
|
155
|
+
header={({ weekday }) => <Span>{weekday}</Span>}
|
|
156
|
+
cell={({ date, outOfMonth, top, bottom, left, right }) => (
|
|
157
|
+
<Box
|
|
158
|
+
jss={{
|
|
159
|
+
opacity: outOfMonth ? 0.3 : 1,
|
|
160
|
+
borderTop: top ? "1px solid var(--divider)" : "none",
|
|
161
|
+
borderBottom: bottom ? "1px solid var(--divider)" : "none",
|
|
162
|
+
borderLeft: left ? "1px solid var(--divider)" : "none",
|
|
163
|
+
borderRight: right ? "1px solid var(--divider)" : "none",
|
|
164
|
+
borderTopLeftRadius: top && left ? 8 : 0,
|
|
165
|
+
borderTopRightRadius: top && right ? 8 : 0,
|
|
166
|
+
borderBottomLeftRadius: bottom && left ? 8 : 0,
|
|
167
|
+
borderBottomRightRadius: bottom && right ? 8 : 0,
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<Span>{date.getDate()}</Span>
|
|
171
|
+
</Box>
|
|
172
|
+
)}
|
|
173
|
+
/>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Interactive calendar
|
|
179
|
+
|
|
180
|
+
Create a date picker by adding click handlers:
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
function DatePicker() {
|
|
184
|
+
const [selected, setSelected] = useState(null);
|
|
185
|
+
const [month, setMonth] = useState(new Date());
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<Column gap="medium">
|
|
189
|
+
<Row justify="space-between" align="center">
|
|
190
|
+
<IconButton
|
|
191
|
+
icon="fa-chevron-left"
|
|
192
|
+
onClick={() => setMonth(new Date(month.getFullYear(), month.getMonth() - 1))}
|
|
193
|
+
/>
|
|
194
|
+
<Span bold>
|
|
195
|
+
{month.toLocaleDateString("en-US", { month: "long", year: "numeric" })}
|
|
196
|
+
</Span>
|
|
197
|
+
<IconButton
|
|
198
|
+
icon="fa-chevron-right"
|
|
199
|
+
onClick={() => setMonth(new Date(month.getFullYear(), month.getMonth() + 1))}
|
|
200
|
+
/>
|
|
201
|
+
</Row>
|
|
202
|
+
<Calendar
|
|
203
|
+
date={month}
|
|
204
|
+
header={({ weekday }) => <Span size="small">{weekday}</Span>}
|
|
205
|
+
cell={({ date, outOfMonth, today }) => {
|
|
206
|
+
const isSelected = selected?.toDateString() === date.toDateString();
|
|
207
|
+
return (
|
|
208
|
+
<BaseButton
|
|
209
|
+
bare
|
|
210
|
+
onClick={() => !outOfMonth && setSelected(date)}
|
|
211
|
+
jss={{
|
|
212
|
+
opacity: outOfMonth ? 0.3 : 1,
|
|
213
|
+
backgroundColor: isSelected ? "var(--highlight)" : "transparent",
|
|
214
|
+
borderRadius: "50%",
|
|
215
|
+
}}
|
|
216
|
+
>
|
|
217
|
+
<Span color={isSelected ? "light" : "primary"}>
|
|
218
|
+
{date.getDate()}
|
|
219
|
+
</Span>
|
|
220
|
+
</BaseButton>
|
|
221
|
+
);
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
</Column>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Grid layout
|
|
232
|
+
|
|
233
|
+
The Calendar uses CSS Grid with 7 columns (Mon-Sun). The header row and day cells flow naturally into the grid:
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
// Custom grid styling
|
|
237
|
+
<Calendar
|
|
238
|
+
date={new Date()}
|
|
239
|
+
jss={{
|
|
240
|
+
gap: 4,
|
|
241
|
+
padding: 16,
|
|
242
|
+
backgroundColor: "var(--secondary-background)",
|
|
243
|
+
borderRadius: 12,
|
|
244
|
+
}}
|
|
245
|
+
header={...}
|
|
246
|
+
cell={...}
|
|
247
|
+
/>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Localization
|
|
253
|
+
|
|
254
|
+
Weekday names are automatically localized using `Intl.DateTimeFormat` with UK English locale (week starts Monday). The calendar always displays Monday through Sunday.
|
package/src/pages/Card.mdx
CHANGED
|
@@ -1,71 +1,147 @@
|
|
|
1
1
|
import { Card } from "../Card";
|
|
2
2
|
import { Button } from "../Button";
|
|
3
3
|
import { TextInput } from "../TextInput";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Column } from "../Column";
|
|
5
|
+
import { Row } from "../Row";
|
|
6
|
+
import { H2, H3, P, Span } from "../Text";
|
|
7
|
+
import { Icon } from "../Icon";
|
|
6
8
|
|
|
7
9
|
# Card
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
A container component that groups related content with a distinct visual treatment. Cards provide elevation, background, and rounded corners to create visual hierarchy.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
Card extends all FlexLayout props:
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| `padding` | `Padding` | `"large"` | Internal padding |
|
|
22
|
+
| `gap` | `Gap` | `"large"` | Space between children |
|
|
23
|
+
| `direction` | `"row"` \| `"column"` | `"column"` | Flex direction |
|
|
24
|
+
| `align` | `Align` | - | Cross-axis alignment |
|
|
25
|
+
| `justify` | `Justify` | - | Main-axis alignment |
|
|
26
|
+
| `grow` | `boolean` | - | Allow card to grow |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Basic card
|
|
31
|
+
|
|
32
|
+
<Card>
|
|
33
|
+
<H3>Card title</H3>
|
|
34
|
+
<P>Cards group related content together with visual distinction from the surrounding interface.</P>
|
|
35
|
+
</Card>
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
<Card>
|
|
39
|
+
<H3>Card title</H3>
|
|
40
|
+
<P>Card content goes here...</P>
|
|
41
|
+
</Card>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Contact form example
|
|
10
47
|
|
|
11
48
|
<Card>
|
|
12
|
-
<
|
|
13
|
-
<P>
|
|
49
|
+
<H3>Contact Us</H3>
|
|
50
|
+
<P>Send us a message and we'll get back to you soon.</P>
|
|
14
51
|
<TextInput
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value={null}
|
|
18
|
-
padding={"medium"}
|
|
52
|
+
placeholder="Your email"
|
|
53
|
+
value=""
|
|
19
54
|
type="email"
|
|
20
55
|
onValueChange={() => {}}
|
|
21
56
|
/>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}}
|
|
26
|
-
name="message"
|
|
27
|
-
placeholder="Type your query here..."
|
|
28
|
-
value={null}
|
|
29
|
-
type="text"
|
|
57
|
+
<TextInput
|
|
58
|
+
placeholder="Your message"
|
|
59
|
+
value=""
|
|
30
60
|
onValueChange={() => {}}
|
|
31
61
|
/>
|
|
32
|
-
<Button
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type="submit"
|
|
36
|
-
label="Subscribe"
|
|
37
|
-
color="positive"
|
|
38
|
-
/>
|
|
62
|
+
<Button color="positive" onClick={() => {}}>
|
|
63
|
+
Send Message
|
|
64
|
+
</Button>
|
|
39
65
|
</Card>
|
|
40
66
|
|
|
41
67
|
```js
|
|
42
68
|
<Card>
|
|
43
|
-
<
|
|
44
|
-
<P>
|
|
69
|
+
<H3>Contact Us</H3>
|
|
70
|
+
<P>Send us a message and we'll get back to you soon.</P>
|
|
45
71
|
<TextInput
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
value={null}
|
|
49
|
-
padding={"medium"}
|
|
72
|
+
placeholder="Your email"
|
|
73
|
+
value={email}
|
|
50
74
|
type="email"
|
|
51
|
-
onValueChange={
|
|
75
|
+
onValueChange={setEmail}
|
|
52
76
|
/>
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
name="message"
|
|
58
|
-
placeholder="Type your query here..."
|
|
59
|
-
value={null}
|
|
60
|
-
type="text"
|
|
61
|
-
onValueChange={() => {}}
|
|
62
|
-
/>
|
|
63
|
-
<Button
|
|
64
|
-
jss={{ animation: "all 1s ease-out" }}
|
|
65
|
-
onClick={() => {}}
|
|
66
|
-
type="submit"
|
|
67
|
-
label="Subscribe"
|
|
68
|
-
color="positive"
|
|
77
|
+
<TextInput
|
|
78
|
+
placeholder="Your message"
|
|
79
|
+
value={message}
|
|
80
|
+
onValueChange={setMessage}
|
|
69
81
|
/>
|
|
82
|
+
<Button color="positive" onClick={handleSubmit}>
|
|
83
|
+
Send Message
|
|
84
|
+
</Button>
|
|
70
85
|
</Card>
|
|
71
86
|
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Custom padding and gap
|
|
91
|
+
|
|
92
|
+
<Row gap="medium">
|
|
93
|
+
<Card padding="small" gap="small">
|
|
94
|
+
<Span>Small padding</Span>
|
|
95
|
+
<Span color="secondary">Compact layout</Span>
|
|
96
|
+
</Card>
|
|
97
|
+
<Card padding="xlarge" gap="medium">
|
|
98
|
+
<Span>Large padding</Span>
|
|
99
|
+
<Span color="secondary">Spacious layout</Span>
|
|
100
|
+
</Card>
|
|
101
|
+
</Row>
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
<Card padding="small" gap="small">
|
|
105
|
+
<Span>Compact card</Span>
|
|
106
|
+
</Card>
|
|
107
|
+
|
|
108
|
+
<Card padding="xlarge" gap="large">
|
|
109
|
+
<Span>Spacious card</Span>
|
|
110
|
+
</Card>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Horizontal card
|
|
116
|
+
|
|
117
|
+
Use `direction="row"` for horizontal layouts:
|
|
118
|
+
|
|
119
|
+
<Card direction="row" align="center" gap="medium">
|
|
120
|
+
<Icon icon="fa-user" color="highlight" size="xlarge" />
|
|
121
|
+
<Column gap="none">
|
|
122
|
+
<Span bold>John Doe</Span>
|
|
123
|
+
<Span color="secondary" size="small">Software Engineer</Span>
|
|
124
|
+
</Column>
|
|
125
|
+
</Card>
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
<Card direction="row" align="center" gap="medium">
|
|
129
|
+
<Icon icon="fa-user" color="highlight" size="xlarge" />
|
|
130
|
+
<Column gap="none">
|
|
131
|
+
<Span bold>John Doe</Span>
|
|
132
|
+
<Span color="secondary" size="small">Software Engineer</Span>
|
|
133
|
+
</Column>
|
|
134
|
+
</Card>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Use cases
|
|
140
|
+
|
|
141
|
+
Cards are useful for:
|
|
142
|
+
|
|
143
|
+
- **Forms** - Group related inputs together
|
|
144
|
+
- **Profiles** - Display user or item information
|
|
145
|
+
- **Summaries** - Highlight key metrics or stats
|
|
146
|
+
- **Actions** - Group related actions with context
|
|
147
|
+
- **Content sections** - Separate distinct content areas
|
package/src/pages/Checkbox.mdx
CHANGED
|
@@ -2,55 +2,130 @@ import { Checkbox } from "../Checkbox";
|
|
|
2
2
|
import { StaticCheckbox } from "../StaticCheckbox";
|
|
3
3
|
import { Column } from "../Column";
|
|
4
4
|
import { Row } from "../Row";
|
|
5
|
+
import { Span } from "../Text";
|
|
5
6
|
|
|
6
7
|
# Checkbox
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
A styled checkbox input with custom visual appearance. Built on native HTML checkbox for full accessibility support.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
### Checkbox
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Required | Default | Description |
|
|
18
|
+
|------|------|----------|---------|-------------|
|
|
19
|
+
| `checked` | `boolean` | Yes | - | Whether the checkbox is checked |
|
|
20
|
+
| `onClick` | `() => void` | Yes | - | Called when checkbox is toggled |
|
|
21
|
+
| `size` | `Size` | Yes | - | `"small"` (16px), `"medium"` (20px), `"large"` (24px) |
|
|
22
|
+
|
|
23
|
+
Also accepts standard HTML input attributes.
|
|
24
|
+
|
|
25
|
+
### StaticCheckbox
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Required | Default | Description |
|
|
28
|
+
|------|------|----------|---------|-------------|
|
|
29
|
+
| `checked` | `boolean` | Yes | - | Whether the checkbox appears checked |
|
|
30
|
+
| `size` | `Size` | Yes | - | `"small"`, `"medium"`, `"large"` |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Sizes
|
|
35
|
+
|
|
36
|
+
<Row padding="medium" gap="xlarge" justify="center" align="center">
|
|
37
|
+
<Column gap="small" align="center">
|
|
12
38
|
<Checkbox size="small" checked={true} onClick={() => {}} />
|
|
39
|
+
<Span size="small" color="secondary">small</Span>
|
|
40
|
+
</Column>
|
|
41
|
+
<Column gap="small" align="center">
|
|
13
42
|
<Checkbox size="medium" checked={true} onClick={() => {}} />
|
|
43
|
+
<Span size="small" color="secondary">medium</Span>
|
|
44
|
+
</Column>
|
|
45
|
+
<Column gap="small" align="center">
|
|
14
46
|
<Checkbox size="large" checked={true} onClick={() => {}} />
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<Checkbox size="medium" checked={false} onClick={() => {}} />
|
|
19
|
-
<Checkbox size="large" checked={false} onClick={() => {}} />
|
|
20
|
-
</Row>
|
|
21
|
-
</Column>
|
|
47
|
+
<Span size="small" color="secondary">large</Span>
|
|
48
|
+
</Column>
|
|
49
|
+
</Row>
|
|
22
50
|
|
|
23
51
|
```js
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
<Checkbox size="small" checked={checked} onClick={toggle} />
|
|
53
|
+
<Checkbox size="medium" checked={checked} onClick={toggle} />
|
|
54
|
+
<Checkbox size="large" checked={checked} onClick={toggle} />
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## States
|
|
60
|
+
|
|
61
|
+
<Row padding="medium" gap="xlarge" justify="center" align="center">
|
|
62
|
+
<Column gap="small" align="center">
|
|
32
63
|
<Checkbox size="medium" checked={false} onClick={() => {}} />
|
|
33
|
-
<
|
|
34
|
-
</
|
|
35
|
-
|
|
64
|
+
<Span size="small" color="secondary">unchecked</Span>
|
|
65
|
+
</Column>
|
|
66
|
+
<Column gap="small" align="center">
|
|
67
|
+
<Checkbox size="medium" checked={true} onClick={() => {}} />
|
|
68
|
+
<Span size="small" color="secondary">checked</Span>
|
|
69
|
+
</Column>
|
|
70
|
+
</Row>
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
const [checked, setChecked] = useState(false);
|
|
74
|
+
|
|
75
|
+
<Checkbox
|
|
76
|
+
size="medium"
|
|
77
|
+
checked={checked}
|
|
78
|
+
onClick={() => setChecked(!checked)}
|
|
79
|
+
/>
|
|
36
80
|
```
|
|
37
81
|
|
|
38
82
|
---
|
|
39
83
|
|
|
40
|
-
##
|
|
84
|
+
## StaticCheckbox
|
|
41
85
|
|
|
42
|
-
|
|
86
|
+
Use `StaticCheckbox` when you need just the visual appearance without the underlying `<input>` element. Useful when the checkbox is part of a larger interactive component.
|
|
43
87
|
|
|
44
|
-
<Row padding="medium" gap="
|
|
88
|
+
<Row padding="medium" gap="large" justify="center" align="center">
|
|
45
89
|
<StaticCheckbox size="small" checked={true} />
|
|
46
90
|
<StaticCheckbox size="medium" checked={true} />
|
|
47
91
|
<StaticCheckbox size="large" checked={true} />
|
|
48
92
|
</Row>
|
|
49
93
|
|
|
50
94
|
```js
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
// Visual only - no input element
|
|
96
|
+
<StaticCheckbox size="medium" checked={isSelected} />
|
|
97
|
+
|
|
98
|
+
// Used within a custom list item
|
|
99
|
+
<ListButtonItem
|
|
100
|
+
headline="Option"
|
|
101
|
+
addOn={<StaticCheckbox size="medium" checked={selected} />}
|
|
102
|
+
onClick={toggleSelection}
|
|
103
|
+
/>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## With label
|
|
109
|
+
|
|
110
|
+
Checkboxes are typically paired with labels for better UX:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
<Row gap="small" align="center">
|
|
114
|
+
<Checkbox
|
|
115
|
+
size="medium"
|
|
116
|
+
checked={agreed}
|
|
117
|
+
onClick={() => setAgreed(!agreed)}
|
|
118
|
+
/>
|
|
119
|
+
<Span>I agree to the terms and conditions</Span>
|
|
55
120
|
</Row>
|
|
56
121
|
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Accessibility
|
|
126
|
+
|
|
127
|
+
- Uses native `<input type="checkbox">` for full keyboard and screen reader support
|
|
128
|
+
- Visual checkbox is layered over the hidden input
|
|
129
|
+
- Focus ring appears on keyboard navigation
|
|
130
|
+
- Press animation provides tactile feedback
|
|
131
|
+
- `aria-checked` attribute reflects current state
|