@gears-frontx/ui-kit 0.3.0-alpha.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/LICENSE +201 -0
- package/NOTICE +49 -0
- package/README.md +75 -0
- package/dist/badge.d.ts +1 -0
- package/dist/badge.js +42 -0
- package/dist/badge.js.map +1 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +73 -0
- package/dist/button.js.map +1 -0
- package/dist/card.d.ts +1 -0
- package/dist/card.js +54 -0
- package/dist/card.js.map +1 -0
- package/dist/checkbox.d.ts +1 -0
- package/dist/checkbox.js +46 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chunks/badge.ej-3-Xs4.css +1 -0
- package/dist/chunks/button.CKfALaMe.css +1 -0
- package/dist/chunks/card.B0AcyAT1.css +1 -0
- package/dist/chunks/checkbox.Dd6YDr20.css +1 -0
- package/dist/chunks/dialog.D6LS2vnG.css +1 -0
- package/dist/chunks/dropdown-menu.DmDZc5gB.css +1 -0
- package/dist/chunks/field.BNZx8HfN.css +1 -0
- package/dist/chunks/input.CrRQ0OAn.css +1 -0
- package/dist/chunks/label.jrB9zD_G.css +1 -0
- package/dist/chunks/radio-group.1Y6B0lXt.css +1 -0
- package/dist/chunks/select.BmyP2S2q.css +1 -0
- package/dist/chunks/separator.DdRRkJW4.css +1 -0
- package/dist/chunks/skeleton.BhWSzPnI.css +1 -0
- package/dist/chunks/switch.B_ebMSxR.css +1 -0
- package/dist/chunks/table.r8ppNt1W.css +1 -0
- package/dist/chunks/tabs.DqJE9cX3.css +1 -0
- package/dist/chunks/textarea.BKWvs6fD.css +1 -0
- package/dist/chunks/toast.DMl31Mq4.css +1 -0
- package/dist/chunks/tooltip.apA3VWHJ.css +1 -0
- package/dist/components/badge/badge.d.ts +11 -0
- package/dist/components/badge/badge.d.ts.map +1 -0
- package/dist/components/badge/public.d.ts +2 -0
- package/dist/components/badge/public.d.ts.map +1 -0
- package/dist/components/button/button.d.ts +50 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/public.d.ts +2 -0
- package/dist/components/button/public.d.ts.map +1 -0
- package/dist/components/card/card.d.ts +22 -0
- package/dist/components/card/card.d.ts.map +1 -0
- package/dist/components/card/public.d.ts +2 -0
- package/dist/components/card/public.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +6 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/public.d.ts +2 -0
- package/dist/components/checkbox/public.d.ts.map +1 -0
- package/dist/components/dialog/dialog.d.ts +58 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -0
- package/dist/components/dialog/public.d.ts +2 -0
- package/dist/components/dialog/public.d.ts.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +70 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu/public.d.ts +2 -0
- package/dist/components/dropdown-menu/public.d.ts.map +1 -0
- package/dist/components/field/field.d.ts +18 -0
- package/dist/components/field/field.d.ts.map +1 -0
- package/dist/components/field/public.d.ts +2 -0
- package/dist/components/field/public.d.ts.map +1 -0
- package/dist/components/input/input.d.ts +6 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/public.d.ts +2 -0
- package/dist/components/input/public.d.ts.map +1 -0
- package/dist/components/label/label.d.ts +4 -0
- package/dist/components/label/label.d.ts.map +1 -0
- package/dist/components/label/public.d.ts +2 -0
- package/dist/components/label/public.d.ts.map +1 -0
- package/dist/components/radio-group/public.d.ts +2 -0
- package/dist/components/radio-group/public.d.ts.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +11 -0
- package/dist/components/radio-group/radio-group.d.ts.map +1 -0
- package/dist/components/select/public.d.ts +2 -0
- package/dist/components/select/public.d.ts.map +1 -0
- package/dist/components/select/select.d.ts +61 -0
- package/dist/components/select/select.d.ts.map +1 -0
- package/dist/components/separator/public.d.ts +2 -0
- package/dist/components/separator/public.d.ts.map +1 -0
- package/dist/components/separator/separator.d.ts +6 -0
- package/dist/components/separator/separator.d.ts.map +1 -0
- package/dist/components/skeleton/public.d.ts +2 -0
- package/dist/components/skeleton/public.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +4 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/switch/public.d.ts +2 -0
- package/dist/components/switch/public.d.ts.map +1 -0
- package/dist/components/switch/switch.d.ts +11 -0
- package/dist/components/switch/switch.d.ts.map +1 -0
- package/dist/components/table/public.d.ts +2 -0
- package/dist/components/table/public.d.ts.map +1 -0
- package/dist/components/table/table.d.ts +38 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/tabs/public.d.ts +2 -0
- package/dist/components/tabs/public.d.ts.map +1 -0
- package/dist/components/tabs/tabs.d.ts +23 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -0
- package/dist/components/textarea/public.d.ts +2 -0
- package/dist/components/textarea/public.d.ts.map +1 -0
- package/dist/components/textarea/textarea.d.ts +4 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -0
- package/dist/components/toast/public.d.ts +2 -0
- package/dist/components/toast/public.d.ts.map +1 -0
- package/dist/components/toast/toast.d.ts +85 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/tooltip/public.d.ts +2 -0
- package/dist/components/tooltip/public.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +41 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/dialog.d.ts +1 -0
- package/dist/dialog.js +84 -0
- package/dist/dialog.js.map +1 -0
- package/dist/docs/badge.md +82 -0
- package/dist/docs/button.md +102 -0
- package/dist/docs/card.md +131 -0
- package/dist/docs/checkbox.md +55 -0
- package/dist/docs/dialog.md +124 -0
- package/dist/docs/dropdown-menu.md +140 -0
- package/dist/docs/field.md +68 -0
- package/dist/docs/input.md +65 -0
- package/dist/docs/label.md +50 -0
- package/dist/docs/radio-group.md +59 -0
- package/dist/docs/select.md +99 -0
- package/dist/docs/separator.md +119 -0
- package/dist/docs/skeleton.md +143 -0
- package/dist/docs/switch.md +51 -0
- package/dist/docs/table.md +276 -0
- package/dist/docs/tabs.md +124 -0
- package/dist/docs/textarea.md +52 -0
- package/dist/docs/toast.md +153 -0
- package/dist/docs/tooltip.md +134 -0
- package/dist/dropdown-menu.d.ts +1 -0
- package/dist/dropdown-menu.js +183 -0
- package/dist/dropdown-menu.js.map +1 -0
- package/dist/field.d.ts +1 -0
- package/dist/field.js +28 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +1 -0
- package/dist/input.js +30 -0
- package/dist/input.js.map +1 -0
- package/dist/label.d.ts +1 -0
- package/dist/label.js +12 -0
- package/dist/label.js.map +1 -0
- package/dist/radio-group.d.ts +1 -0
- package/dist/radio-group.js +21 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/select.d.ts +1 -0
- package/dist/select.js +175 -0
- package/dist/select.js.map +1 -0
- package/dist/separator.d.ts +1 -0
- package/dist/separator.js +13 -0
- package/dist/separator.js.map +1 -0
- package/dist/skeleton.d.ts +1 -0
- package/dist/skeleton.js +12 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/switch.d.ts +1 -0
- package/dist/switch.js +26 -0
- package/dist/switch.js.map +1 -0
- package/dist/table.d.ts +1 -0
- package/dist/table.js +64 -0
- package/dist/table.js.map +1 -0
- package/dist/tabs.d.ts +1 -0
- package/dist/tabs.js +41 -0
- package/dist/tabs.js.map +1 -0
- package/dist/textarea.d.ts +1 -0
- package/dist/textarea.js +13 -0
- package/dist/textarea.js.map +1 -0
- package/dist/theme.css +485 -0
- package/dist/toast.d.ts +1 -0
- package/dist/toast.js +193 -0
- package/dist/toast.js.map +1 -0
- package/dist/tooltip.d.ts +1 -0
- package/dist/tooltip.js +49 -0
- package/dist/tooltip.js.map +1 -0
- package/llms.txt +148 -0
- package/package.json +85 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# RadioGroup
|
|
2
|
+
|
|
3
|
+
A set of mutually exclusive options. Wraps the Base UI RadioGroup/Radio
|
|
4
|
+
primitives: `role="radiogroup"` container, `role="radio"` items with a
|
|
5
|
+
hidden native input, arrow-key navigation between items, state via
|
|
6
|
+
`data-checked`/`data-unchecked`.
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
|
|
10
|
+
- Choosing exactly one of 2–6 visible options: plan tier, delivery method,
|
|
11
|
+
sort order.
|
|
12
|
+
|
|
13
|
+
## When not to use
|
|
14
|
+
|
|
15
|
+
- More than ~6 options or constrained space — use `select`.
|
|
16
|
+
- Independent on/off options — use `checkbox`.
|
|
17
|
+
- Instant toggles — use `switch`.
|
|
18
|
+
|
|
19
|
+
## Props (kit level)
|
|
20
|
+
|
|
21
|
+
`RadioGroup`:
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Default |
|
|
24
|
+
|------|------|---------|
|
|
25
|
+
| `value` / `defaultValue` | controlled / uncontrolled selected value | — |
|
|
26
|
+
| `onValueChange` | `(value, eventDetails) => void` | — |
|
|
27
|
+
| `name` | form submission via the hidden native input | — |
|
|
28
|
+
| `disabled` | disables the whole group | `false` |
|
|
29
|
+
| `className` | `string` — merged after the kit class | — |
|
|
30
|
+
|
|
31
|
+
`RadioGroupItem`: `value` (required), `disabled`, `className`; other props
|
|
32
|
+
follow Base UI Radio.Root. `aria-invalid` on an item switches its border
|
|
33
|
+
and ring to the destructive color.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { Label, RadioGroup, RadioGroupItem } from '@gears-frontx/ui-kit';
|
|
39
|
+
|
|
40
|
+
<RadioGroup value={tier} onValueChange={setTier} aria-label="Plan tier">
|
|
41
|
+
<Label>
|
|
42
|
+
<RadioGroupItem value="free" /> Free
|
|
43
|
+
</Label>
|
|
44
|
+
<Label>
|
|
45
|
+
<RadioGroupItem value="pro" /> Pro
|
|
46
|
+
</Label>
|
|
47
|
+
<Label>
|
|
48
|
+
<RadioGroupItem value="enterprise" disabled /> Enterprise (contact us)
|
|
49
|
+
</Label>
|
|
50
|
+
</RadioGroup>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Anti-patterns
|
|
54
|
+
|
|
55
|
+
- Do not use radio items outside a `RadioGroup` — keyboard navigation and
|
|
56
|
+
the single-selection contract live on the group.
|
|
57
|
+
- Do not preselect nothing when a default makes sense — an all-unchecked
|
|
58
|
+
radio group is hard to keyboard-focus predictably.
|
|
59
|
+
- Do not use it for yes/no — a single `checkbox` or `switch` reads better.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
A dropdown for picking one value from a list. Wraps the Base UI Select
|
|
4
|
+
primitives; the popup is portalled, keyboard navigation, typeahead, and
|
|
5
|
+
form submission (hidden native input on the root) come from Base UI.
|
|
6
|
+
|
|
7
|
+
Composition: `Select` (root, holds the value) → `SelectTrigger` (+
|
|
8
|
+
`SelectValue` for the current label) → `SelectContent` → `SelectGroup` /
|
|
9
|
+
`SelectLabel` / `SelectItem` / `SelectSeparator`.
|
|
10
|
+
|
|
11
|
+
## When to use
|
|
12
|
+
|
|
13
|
+
- Picking one option from ~7 or more, or when space is tight.
|
|
14
|
+
- Option lists with groups and separators.
|
|
15
|
+
|
|
16
|
+
## When not to use
|
|
17
|
+
|
|
18
|
+
- 2–6 always-visible options — use `radio-group`.
|
|
19
|
+
- Multi-select or search over options — out of MVP scope; compose from
|
|
20
|
+
primitives in the consumer app.
|
|
21
|
+
|
|
22
|
+
## Props (kit level)
|
|
23
|
+
|
|
24
|
+
`Select` (root): `value` / `defaultValue`, `onValueChange`, `name`,
|
|
25
|
+
`disabled`, `required` — see Base UI Select.Root. Always pass `items`
|
|
26
|
+
(`{ value, label }[]`) as well: without it the closed trigger renders the
|
|
27
|
+
raw value instead of the label until the popup has been opened once.
|
|
28
|
+
|
|
29
|
+
`SelectTrigger`:
|
|
30
|
+
|
|
31
|
+
| Prop | Type | Default |
|
|
32
|
+
|------|------|---------|
|
|
33
|
+
| `size` | `default` \| `sm` | `default` |
|
|
34
|
+
| `variant` | `default` \| `filter` — `filter` is the compact toolbar filter chip: 36px tall and the label stays `--muted-foreground` even with a value chosen (in a filter the message is "this narrows the list", not the picked value). Compose the visible label yourself, e.g. `Filter · {count}` | `default` |
|
|
35
|
+
| `className` | `string` — merged after the kit class | — |
|
|
36
|
+
|
|
37
|
+
`SelectValue`: renders the selected item's label. Pass `placeholder`
|
|
38
|
+
directly to `SelectValue` (see example). `SelectContent`
|
|
39
|
+
accepts positioning props (`side`, `sideOffset`, `align`, `alignOffset`,
|
|
40
|
+
`alignItemWithTrigger`, plus the escape hatch for triggers inside a
|
|
41
|
+
`transform`/`filter` container: `positionMethod="fixed"`,
|
|
42
|
+
`collisionBoundary`, `collisionPadding`) and `container` — the popup
|
|
43
|
+
portals to `<body>`
|
|
44
|
+
by default, so if your theme lives on a subtree (`data-theme` on a
|
|
45
|
+
section instead of `<html>`), pass that section as `container` or the
|
|
46
|
+
popup renders with the root theme. `SelectItem` takes `value` (required) and
|
|
47
|
+
`disabled`. `aria-invalid` on the trigger switches its border and ring to
|
|
48
|
+
the destructive color.
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import {
|
|
54
|
+
Select,
|
|
55
|
+
SelectContent,
|
|
56
|
+
SelectGroup,
|
|
57
|
+
SelectItem,
|
|
58
|
+
SelectLabel,
|
|
59
|
+
SelectSeparator,
|
|
60
|
+
SelectTrigger,
|
|
61
|
+
SelectValue,
|
|
62
|
+
} from '@gears-frontx/ui-kit';
|
|
63
|
+
|
|
64
|
+
const REGIONS = [
|
|
65
|
+
{ value: 'eu-central', label: 'Frankfurt' },
|
|
66
|
+
{ value: 'eu-west', label: 'Dublin' },
|
|
67
|
+
{ value: 'us-east', label: 'Virginia' },
|
|
68
|
+
{ value: 'us-west', label: 'Oregon (soon)' },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
<Select value={region} onValueChange={setRegion} items={REGIONS}>
|
|
72
|
+
<SelectTrigger aria-label="Region">
|
|
73
|
+
<SelectValue placeholder="Pick a region" />
|
|
74
|
+
</SelectTrigger>
|
|
75
|
+
<SelectContent>
|
|
76
|
+
<SelectGroup>
|
|
77
|
+
<SelectLabel>Europe</SelectLabel>
|
|
78
|
+
<SelectItem value="eu-central">Frankfurt</SelectItem>
|
|
79
|
+
<SelectItem value="eu-west">Dublin</SelectItem>
|
|
80
|
+
</SelectGroup>
|
|
81
|
+
<SelectSeparator />
|
|
82
|
+
<SelectGroup>
|
|
83
|
+
<SelectLabel>Americas</SelectLabel>
|
|
84
|
+
<SelectItem value="us-east">Virginia</SelectItem>
|
|
85
|
+
<SelectItem value="us-west" disabled>
|
|
86
|
+
Oregon (soon)
|
|
87
|
+
</SelectItem>
|
|
88
|
+
</SelectGroup>
|
|
89
|
+
</SelectContent>
|
|
90
|
+
</Select>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Anti-patterns
|
|
94
|
+
|
|
95
|
+
- Do not put items directly under `SelectContent` without a `SelectGroup`
|
|
96
|
+
— the group carries the list padding.
|
|
97
|
+
- Do not use a select for navigation — that is a menu/link pattern.
|
|
98
|
+
- Do not omit a placeholder or default value — an empty trigger gives the
|
|
99
|
+
user (and the agent) nothing to read.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Separator
|
|
2
|
+
|
|
3
|
+
A thin visual divider between sections of content. A styled Base UI
|
|
4
|
+
`Separator` (`@base-ui/react/separator`) — no variants, just an
|
|
5
|
+
`orientation` prop.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Between stacked sections of a page or panel (a horizontal rule).
|
|
10
|
+
- Between items in a horizontal toolbar or button group (a vertical rule)
|
|
11
|
+
— the kit's `.separator` class carries `flex-shrink: 0` so it never gets
|
|
12
|
+
squeezed to nothing in a tight flex row.
|
|
13
|
+
|
|
14
|
+
## When not to use
|
|
15
|
+
|
|
16
|
+
- Inside a `DropdownMenu` or `Select` popup — use `DropdownMenuSeparator`
|
|
17
|
+
/ `SelectSeparator` instead. Both already wrap this exact same Base UI
|
|
18
|
+
primitive (Menu and Select re-export `Separator` verbatim), but keep
|
|
19
|
+
their own styling scoped to a popup's list (a bleed margin into the
|
|
20
|
+
popup's padding), which this component does not apply. They are not
|
|
21
|
+
aliases of each other — pick the one that matches where the divider
|
|
22
|
+
lives.
|
|
23
|
+
- As a layout spacer — Separator renders a visible 1px line; use CSS gap
|
|
24
|
+
or margin for invisible spacing.
|
|
25
|
+
|
|
26
|
+
## Orientation
|
|
27
|
+
|
|
28
|
+
- `orientation="horizontal"` (default): full width, 1px tall.
|
|
29
|
+
- `orientation="vertical"`: 1px wide, `align-self: stretch` to fill the
|
|
30
|
+
parent's cross-axis height. `align-self` overrides whatever the flex
|
|
31
|
+
parent's own `align-items` is set to (that's its purpose), so a vertical
|
|
32
|
+
Separator stretches to the flex line's height even inside a row with
|
|
33
|
+
`align-items: center` — that combination works. It collapses to 0px
|
|
34
|
+
tall in the two cases where there is no flex-line height to stretch
|
|
35
|
+
into: a non-flex (plain block) parent, where `align-self` has no effect
|
|
36
|
+
at all — no explicit height on that parent fixes this, since there's no
|
|
37
|
+
flex context for `align-self` to act in; make the parent `display: flex`
|
|
38
|
+
(or give the Separator its own height directly) — or a flex row whose
|
|
39
|
+
other items are themselves all zero-height, where giving the row a real
|
|
40
|
+
height is the fix.
|
|
41
|
+
|
|
42
|
+
Base UI stamps both `data-orientation` and `aria-orientation` from this
|
|
43
|
+
prop; the kit's CSS reads `data-orientation` to switch dimensions.
|
|
44
|
+
|
|
45
|
+
## Decorative vs. semantic separators
|
|
46
|
+
|
|
47
|
+
Base UI's `Separator` always renders `role="separator"` with a matching
|
|
48
|
+
`aria-orientation` — there is no `decorative` boolean the way Radix's
|
|
49
|
+
Separator has one. Per WAI-ARIA, `role="separator"` announces a
|
|
50
|
+
structural landmark to assistive tech, which is the right default for a
|
|
51
|
+
divider that actually delineates distinct sections (e.g. between two
|
|
52
|
+
groups of settings). It is the wrong choice for a divider that is purely
|
|
53
|
+
visual and carries no structure of its own (e.g. a hairline between a
|
|
54
|
+
toolbar's icon buttons) — there, override the default by passing
|
|
55
|
+
`aria-hidden="true"` directly (see "Decorative divider" under Examples).
|
|
56
|
+
Decorative is likely the more common case in practice: shadcn's own
|
|
57
|
+
Radix-based styles default their Separator wrapper's `decorative` prop to
|
|
58
|
+
`true`. base-vega's wrapper (and this kit) default to semantic instead
|
|
59
|
+
only because Base UI has no `decorative` prop to default — not because
|
|
60
|
+
decorative dividers are the exception.
|
|
61
|
+
|
|
62
|
+
The override works because Base UI's own `role`/`aria-orientation`
|
|
63
|
+
defaults are merged before the consumer's props, and the consumer's props
|
|
64
|
+
win on conflict — passing `aria-hidden` through to a `Separator` always
|
|
65
|
+
reaches the DOM. Use `aria-hidden="true"` alone, not `role="none"`: Base
|
|
66
|
+
UI sets `aria-orientation` unconditionally, independent of any `role`
|
|
67
|
+
override, and `aria-orientation` on a role that doesn't permit it (such
|
|
68
|
+
as `none`) is an `aria-allowed-attr` violation. `aria-hidden="true"`
|
|
69
|
+
removes the element from the accessibility tree entirely, so the role it
|
|
70
|
+
carries underneath stops mattering.
|
|
71
|
+
|
|
72
|
+
## Props (kit level)
|
|
73
|
+
|
|
74
|
+
| Prop | Type | Default |
|
|
75
|
+
|------|------|---------|
|
|
76
|
+
| `orientation` | `horizontal` \| `vertical` | `horizontal` |
|
|
77
|
+
| `className` | `string` — merged after the kit class | — |
|
|
78
|
+
|
|
79
|
+
All other props are native `<div>` props and are forwarded as-is,
|
|
80
|
+
including `aria-hidden` for the decorative case above.
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { Separator } from '@gears-frontx/ui-kit';
|
|
86
|
+
|
|
87
|
+
// Between stacked sections
|
|
88
|
+
<div>
|
|
89
|
+
<p>Account settings</p>
|
|
90
|
+
<Separator />
|
|
91
|
+
<p>Danger zone</p>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
// Vertical, between toolbar items — the row needs a real height for
|
|
95
|
+
// align-self: stretch to fill (align-items: center works fine here too,
|
|
96
|
+
// align-self overrides it on the Separator itself)
|
|
97
|
+
<div style={{ display: 'flex', alignItems: 'center', height: '1.5rem', gap: '0.5rem' }}>
|
|
98
|
+
<span>Bold</span>
|
|
99
|
+
<Separator orientation="vertical" />
|
|
100
|
+
<span>Italic</span>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
// Decorative divider — purely visual, hidden from assistive tech
|
|
104
|
+
<Separator aria-hidden="true" />
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Anti-patterns
|
|
108
|
+
|
|
109
|
+
- Do not use inside `DropdownMenuContent` or `SelectContent` — use
|
|
110
|
+
`DropdownMenuSeparator` / `SelectSeparator`, which are styled for a
|
|
111
|
+
popup's list, not this component.
|
|
112
|
+
- Do not expect a vertical separator to show up in a plain block
|
|
113
|
+
container, or in a flex row whose other items are themselves
|
|
114
|
+
zero-height — `align-self: stretch` needs a flex/grid parent with a
|
|
115
|
+
real cross-axis size to stretch into. `align-items: center` on the row
|
|
116
|
+
is not the problem; `align-self` on the Separator overrides it either
|
|
117
|
+
way.
|
|
118
|
+
- Do not restyle via inline `style` — brand changes belong in theme
|
|
119
|
+
tokens (`--border` here).
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
A pulsing placeholder shape shown while real content is loading. Skeleton
|
|
4
|
+
has no Base UI primitive — it's a styled `div` with no variants; you size
|
|
5
|
+
and shape it yourself via `className`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- In place of text, an avatar, an image, or a card while its data is still
|
|
10
|
+
loading — size it to roughly match what it stands in for (a line of
|
|
11
|
+
text, a circular avatar, a thumbnail) so the layout doesn't jump once the
|
|
12
|
+
real content arrives.
|
|
13
|
+
- Composed into a larger loading layout — several Skeletons stacked or
|
|
14
|
+
arranged like the content they're standing in for.
|
|
15
|
+
|
|
16
|
+
## When not to use
|
|
17
|
+
|
|
18
|
+
- For a single inline spinner or button-busy state — that's a spinner
|
|
19
|
+
icon, not a placeholder shape (the kit has no standalone spinner
|
|
20
|
+
component to reach for yet; `Toast`'s loading icon is internal to that
|
|
21
|
+
component, not exported).
|
|
22
|
+
- As a permanent empty state — Skeleton communicates "loading now", not
|
|
23
|
+
"nothing here"; use real empty-state content for the latter.
|
|
24
|
+
|
|
25
|
+
## Reduced motion
|
|
26
|
+
|
|
27
|
+
Skeleton pulses via a CSS `animation` (opacity 1 → 0.5 → 1, looping). Under
|
|
28
|
+
`prefers-reduced-motion: reduce` the kit turns the animation off entirely
|
|
29
|
+
and leaves the shape at full opacity — this is a deliberate deviation from
|
|
30
|
+
the shadcn source, whose Tailwind `animate-pulse` utility has no
|
|
31
|
+
reduced-motion handling of its own. The placeholder stays visible either
|
|
32
|
+
way; only the continuous motion is removed for users who have asked their
|
|
33
|
+
OS to minimize it.
|
|
34
|
+
|
|
35
|
+
## Accessibility
|
|
36
|
+
|
|
37
|
+
Skeleton itself carries no ARIA — matching the shadcn source, which adds
|
|
38
|
+
none either, and Base UI, which has no primitive here to default one from.
|
|
39
|
+
Loading semantics belong on the container around your Skeletons, not on
|
|
40
|
+
each one individually — but getting that container right takes three
|
|
41
|
+
pieces together, not just `role="status"` alone:
|
|
42
|
+
|
|
43
|
+
- **`role="status"`** on the container (it already implies
|
|
44
|
+
`aria-live="polite"` — don't also wrap it in a separate `aria-live`
|
|
45
|
+
region; that's redundant and can double-announce the same change).
|
|
46
|
+
- **Visually-hidden text inside that container**, not an `aria-label` on
|
|
47
|
+
it — a live region only announces *changes to its content*, and an
|
|
48
|
+
`aria-label` is the region's accessible name, not content; it doesn't
|
|
49
|
+
change and isn't the announced payload. A `role="status"` div holding
|
|
50
|
+
nothing but Skeleton placeholders and no text has nothing to announce at
|
|
51
|
+
load time no matter what other attributes it carries (see Examples).
|
|
52
|
+
- **`aria-busy` that actually transitions**, `true` while loading and
|
|
53
|
+
`false` once the real content replaces the placeholders. Per WAI-ARIA,
|
|
54
|
+
`aria-busy="true"` tells assistive tech to hold off announcing changes
|
|
55
|
+
inside the region *while it is true* — it does not itself produce an
|
|
56
|
+
announcement, and hardcoding it permanently to `true` means the
|
|
57
|
+
completion is never announced, the opposite of the intended effect. The
|
|
58
|
+
announcement fires on the `true` → `false` transition, so the value has
|
|
59
|
+
to track your real loading state (see Examples).
|
|
60
|
+
|
|
61
|
+
If a particular Skeleton instance is purely decorative filler inside
|
|
62
|
+
content that's already announced some other way, pass `aria-hidden="true"`
|
|
63
|
+
directly to that instance; it forwards like any other native `div` prop.
|
|
64
|
+
|
|
65
|
+
## Props (kit level)
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default |
|
|
68
|
+
|------|------|---------|
|
|
69
|
+
| `className` | `string` — merged after the kit class | — |
|
|
70
|
+
|
|
71
|
+
All other props are native `<div>` props and are forwarded as-is,
|
|
72
|
+
including `aria-hidden` for the decorative case above.
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { Skeleton } from '@gears-frontx/ui-kit';
|
|
78
|
+
|
|
79
|
+
// A line of text
|
|
80
|
+
<Skeleton style={{ height: '1rem', width: '250px' }} />
|
|
81
|
+
|
|
82
|
+
// A circular avatar placeholder
|
|
83
|
+
<Skeleton style={{ height: '3rem', width: '3rem', borderRadius: '9999px' }} />
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { useState } from 'react';
|
|
88
|
+
import { Skeleton } from '@gears-frontx/ui-kit';
|
|
89
|
+
|
|
90
|
+
// A loading card: the container carries the loading semantics, not each
|
|
91
|
+
// shape. `aria-busy` tracks real state and flips to false once `loading`
|
|
92
|
+
// does — a hardcoded `aria-busy="true"` would never announce completion.
|
|
93
|
+
function LoadingCard() {
|
|
94
|
+
const [loading, setLoading] = useState(true);
|
|
95
|
+
// ...fetch real data, then setLoading(false) when it arrives.
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div role="status" aria-busy={loading}>
|
|
99
|
+
{/* Visually hidden, inlined: matches the kit's own .srOnly recipe
|
|
100
|
+
(dialog.module.css), which is module-local to Dialog and not
|
|
101
|
+
exported for reuse here. */}
|
|
102
|
+
<span
|
|
103
|
+
style={{
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
width: 1,
|
|
106
|
+
height: 1,
|
|
107
|
+
padding: 0,
|
|
108
|
+
overflow: 'hidden',
|
|
109
|
+
clipPath: 'inset(50%)',
|
|
110
|
+
whiteSpace: 'nowrap',
|
|
111
|
+
border: 0,
|
|
112
|
+
margin: -1,
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{loading ? 'Loading…' : 'Loaded'}
|
|
116
|
+
</span>
|
|
117
|
+
{loading && (
|
|
118
|
+
<>
|
|
119
|
+
<Skeleton style={{ height: '12rem', width: '100%' }} />
|
|
120
|
+
<Skeleton style={{ height: '1rem', width: '75%', marginTop: '0.5rem' }} />
|
|
121
|
+
<Skeleton style={{ height: '1rem', width: '50%', marginTop: '0.25rem' }} />
|
|
122
|
+
</>
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Anti-patterns
|
|
130
|
+
|
|
131
|
+
- Do not rely on Skeleton itself to announce loading state to assistive
|
|
132
|
+
tech — it has no ARIA of its own; put `role="status"`, accessible text,
|
|
133
|
+
and a real `aria-busy` on the container instead (see Accessibility
|
|
134
|
+
above).
|
|
135
|
+
- Do not hardcode `aria-busy="true"` on that container — a value that
|
|
136
|
+
never becomes `false` means the loading-complete announcement never
|
|
137
|
+
fires. Bind it to your actual loading state.
|
|
138
|
+
- Do not pair `role="status"` with a separate `aria-live` wrapper —
|
|
139
|
+
`role="status"` already implies `aria-live="polite"`; the two together
|
|
140
|
+
risk a duplicated announcement.
|
|
141
|
+
- Do not restyle via the kit's class names — brand changes belong in theme
|
|
142
|
+
tokens (`--muted`, `--radius-md` here); size/shape are the one thing you
|
|
143
|
+
do set per instance, via `className` or inline `style`.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
An on/off toggle with immediate effect. Wraps the Base UI Switch primitive
|
|
4
|
+
(Root + Thumb): renders a `role="switch"` button with a hidden native input
|
|
5
|
+
for forms, state via `data-checked`/`data-unchecked`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Settings that apply the moment they change: enable notifications, dark
|
|
10
|
+
mode, feature flags.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- Options that only apply on form submit — use `checkbox`.
|
|
15
|
+
- Mutually exclusive choices — use `radio-group`.
|
|
16
|
+
|
|
17
|
+
## Props (kit level)
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default |
|
|
20
|
+
|------|------|---------|
|
|
21
|
+
| `checked` / `defaultChecked` | controlled / uncontrolled state | `false` |
|
|
22
|
+
| `onCheckedChange` | `(checked: boolean, eventDetails) => void` | — |
|
|
23
|
+
| `size` | `default` \| `sm` | `default` |
|
|
24
|
+
| `name` / `value` | form submission via the hidden native input | — |
|
|
25
|
+
| `className` | `string` — merged after the kit class | — |
|
|
26
|
+
|
|
27
|
+
Other props follow Base UI Switch.Root (`disabled`, `readOnly`, ...).
|
|
28
|
+
`aria-invalid` switches the border and ring to the destructive color.
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Label, Switch } from '@gears-frontx/ui-kit';
|
|
34
|
+
|
|
35
|
+
// Labelled toggle — nesting gives one click target
|
|
36
|
+
<Label>
|
|
37
|
+
<Switch checked={notify} onCheckedChange={setNotify} /> Email notifications
|
|
38
|
+
</Label>
|
|
39
|
+
|
|
40
|
+
// Compact rows
|
|
41
|
+
<Switch size="sm" defaultChecked aria-label="Enable rule" />
|
|
42
|
+
|
|
43
|
+
// Disabled
|
|
44
|
+
<Switch disabled aria-label="Locked setting" />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Anti-patterns
|
|
48
|
+
|
|
49
|
+
- Do not use a switch when the change needs a confirm/submit step — that is
|
|
50
|
+
`checkbox` semantics.
|
|
51
|
+
- Do not render one without a visible label or `aria-label`.
|