@gears-frontx/ui-kit 0.4.0-alpha.6 → 0.4.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.
Files changed (46) hide show
  1. package/dist/button.js +60 -57
  2. package/dist/button.js.map +1 -1
  3. package/dist/carousel.js.map +1 -1
  4. package/dist/chunks/button.BWdRnIvz.css +1 -0
  5. package/dist/chunks/combobox.CKhQGu5a.css +1 -0
  6. package/dist/chunks/pagination.CKDEuWt6.css +1 -0
  7. package/dist/chunks/spinner.CLQsj9Ky.css +1 -0
  8. package/dist/chunks/table.CMm41tvy.css +1 -0
  9. package/dist/combobox.js +135 -116
  10. package/dist/combobox.js.map +1 -1
  11. package/dist/components/button/button.d.ts +18 -5
  12. package/dist/components/button/button.d.ts.map +1 -1
  13. package/dist/components/carousel/carousel.d.ts +2 -2
  14. package/dist/components/carousel/carousel.d.ts.map +1 -1
  15. package/dist/components/combobox/combobox.d.ts +12 -1
  16. package/dist/components/combobox/combobox.d.ts.map +1 -1
  17. package/dist/components/pagination/pagination.d.ts +33 -2
  18. package/dist/components/pagination/pagination.d.ts.map +1 -1
  19. package/dist/components/pagination/public.d.ts +1 -1
  20. package/dist/components/pagination/public.d.ts.map +1 -1
  21. package/dist/components/sidebar/sidebar.d.ts +1 -1
  22. package/dist/components/sidebar/sidebar.d.ts.map +1 -1
  23. package/dist/components/spinner/spinner.d.ts +11 -1
  24. package/dist/components/spinner/spinner.d.ts.map +1 -1
  25. package/dist/components/table/table.d.ts +18 -2
  26. package/dist/components/table/table.d.ts.map +1 -1
  27. package/dist/docs/button.md +24 -4
  28. package/dist/docs/combobox.md +147 -0
  29. package/dist/docs/pagination.md +84 -5
  30. package/dist/docs/spinner.md +5 -1
  31. package/dist/docs/table.md +95 -11
  32. package/dist/index.js +198 -195
  33. package/dist/pagination.js +96 -52
  34. package/dist/pagination.js.map +1 -1
  35. package/dist/sidebar.js.map +1 -1
  36. package/dist/spinner.js +30 -27
  37. package/dist/spinner.js.map +1 -1
  38. package/dist/table.js +106 -97
  39. package/dist/table.js.map +1 -1
  40. package/llms.txt +27 -9
  41. package/package.json +1 -1
  42. package/dist/chunks/button.DgUTlW0_.css +0 -1
  43. package/dist/chunks/combobox.DZZ3tHP_.css +0 -1
  44. package/dist/chunks/pagination.bFb5us_w.css +0 -1
  45. package/dist/chunks/spinner.sH6x_1Uf.css +0 -1
  46. package/dist/chunks/table.DR2nFT0x.css +0 -1
@@ -20,6 +20,12 @@ container of `ComboboxChip` pills plus a trailing `ComboboxChipsInput`),
20
20
  and anchor the popup to the chips instead of a single-line field with
21
21
  `useComboboxAnchor()`.
22
22
 
23
+ Composition, select-style: a field that looks like a `Select` but filters like
24
+ a combobox. `ComboboxTrigger variant="select"` is the visible field (the
25
+ chosen value or a placeholder, then a chevron), and the search input moves
26
+ into the popup as `<ComboboxInput showTrigger={false} />`, the first child
27
+ of `ComboboxContent`. See "Select-style trigger" below.
28
+
23
29
  ## When to use
24
30
 
25
31
  - A single value from a long or unbounded list, filterable by typing —
@@ -55,6 +61,16 @@ Both trailing buttons are icon-only, so those two labels ARE their
55
61
  accessible names — override them for any language but English, the same
56
62
  way `Dialog`'s `closeLabel` and `SidebarTrigger`'s `label` work.
57
63
 
64
+ `ComboboxTrigger`:
65
+
66
+ | Prop | Type | Default |
67
+ |------|------|---------|
68
+ | `variant` | `default` \| `select` — `default` is the compact chevron button `ComboboxInput` places in its corner; `select` is a field of its own that looks like `SelectTrigger`: its children (the chosen value or a placeholder), then a chevron it adds itself | `default` |
69
+ | `className` | `string` — merged after the kit class | — |
70
+
71
+ Every other prop is Base UI's `Combobox.Trigger` (`render`, `nativeButton`,
72
+ `disabled`, `aria-*`, ...).
73
+
58
74
  `ComboboxContent` accepts positioning props (`side`, `sideOffset`,
59
75
  `align`, `alignOffset`, `anchor`, plus the escape hatch for fields inside a
60
76
  `transform`/`filter` container: `positionMethod="fixed"`,
@@ -72,6 +88,53 @@ default `'Remove'`) for that button's accessible name — worth naming the
72
88
  chip itself (`removeLabel={`Remove ${label}`}`) once a form carries
73
89
  several.
74
90
 
91
+ ## Select-style trigger
92
+
93
+ `ComboboxTrigger variant="select"` draws the trigger as a field of its own,
94
+ the same height, border, radius, type and states as `SelectTrigger`: the
95
+ children read in the foreground tone once something is chosen and in
96
+ `--muted-foreground` until then (Base UI flags the empty state, so a
97
+ `ComboboxValue placeholder` is enough), a long text value is cut with an
98
+ ellipsis before the chevron, and `aria-invalid` / `disabled` draw the same
99
+ invalid and dimmed looks. The ellipsis needs the value to be inline content
100
+ (text, a `ComboboxValue`, an inline icon in front of it): a block element of
101
+ your own in there is not cut. A multiple select's chips wrap onto further
102
+ lines instead. There is no text field in the trigger: the query is typed into a
103
+ `ComboboxInput showTrigger={false}` placed first in `ComboboxContent`.
104
+ Inside the popup that input fills the popup's width, inset by the same step
105
+ the list pads its items by, with no width floor of its own; anywhere else it
106
+ is only as wide as the field. The popup is anchored to the trigger and as
107
+ wide as it (at least 9rem, like every combobox popup). `ComboboxInput`'s
108
+ `children` are rendered inside the field's
109
+ wrapper, so an adornment such as a search icon can be composed there.
110
+
111
+ The trigger's role is `combobox`, which takes no name from its content, so
112
+ name it: `aria-labelledby` pointing at a visible label, or an `aria-label`.
113
+ A `<label for>` (`FieldLabel htmlFor`) names only the button form; the
114
+ multiple form below renders its trigger as a `div`, which `<label for>`
115
+ cannot name, so there it has to be `aria-labelledby` or `aria-label`. The
116
+ same goes for the search input in the popup.
117
+
118
+ For a multiple select, render the trigger as a `div` and put
119
+ `ComboboxChips` among its children:
120
+ `<ComboboxTrigger variant="select" render={<div />} nativeButton={false}>`.
121
+ A button may not contain the chips' `div`, so `nativeButton={false}` with a
122
+ `div` is what keeps the markup valid. The chips drop their own border, fill
123
+ and padding there, since the trigger already is the field, and the trigger
124
+ grows to hold chips that wrap instead of holding one fixed row. Pressing a
125
+ chip's remove button removes the chip and does not open the popup.
126
+
127
+ The keyboard path to a chip is different here. In the chips-field form the
128
+ search input sits among the chips, so ArrowLeft from it reaches a chip and
129
+ Backspace on an empty query removes the last one. In the select-style form
130
+ the input lives in the popup, outside the chips: ArrowLeft never reaches a
131
+ chip and Backspace on an empty query removes nothing. A chosen value is removed
132
+ by toggling its option off in the list instead (a chosen option is highlighted
133
+ when the popup opens, other options are reached with the arrow keys, and Enter
134
+ toggles the highlighted one). The remove buttons stay out of the tab order on
135
+ purpose: interactive content inside an element with `role="combobox"` is its
136
+ own accessibility anti-pattern, so they are a pointer affordance here.
137
+
75
138
  ## Examples
76
139
 
77
140
  Single-select, filterable, with groups:
@@ -155,6 +218,80 @@ function FrameworkPicker() {
155
218
  }
156
219
  ```
157
220
 
221
+ Select-style, single (the search input is in the popup):
222
+
223
+ ```tsx
224
+ import {
225
+ Combobox,
226
+ ComboboxContent,
227
+ ComboboxEmpty,
228
+ ComboboxInput,
229
+ ComboboxItem,
230
+ ComboboxList,
231
+ ComboboxTrigger,
232
+ ComboboxValue,
233
+ } from '@gears-frontx/ui-kit';
234
+
235
+ <Combobox items={REGIONS}>
236
+ <ComboboxTrigger variant="select" aria-label="Region">
237
+ <ComboboxValue placeholder="Select a region" />
238
+ </ComboboxTrigger>
239
+ <ComboboxContent>
240
+ <ComboboxInput showTrigger={false} aria-label="Search regions" placeholder="Search…" />
241
+ <ComboboxEmpty>No regions found.</ComboboxEmpty>
242
+ <ComboboxList>
243
+ {(region: Region) => (
244
+ <ComboboxItem key={region.value} value={region}>
245
+ {region.label}
246
+ </ComboboxItem>
247
+ )}
248
+ </ComboboxList>
249
+ </ComboboxContent>
250
+ </Combobox>;
251
+ ```
252
+
253
+ Select-style, multiple (chips inside a trigger rendered as a `div`, named by
254
+ its visible label through `aria-labelledby`, since a `<label for>` cannot name
255
+ a `div`):
256
+
257
+ ```tsx
258
+ <>
259
+ <span id="frameworks-label">Frameworks</span>
260
+ <Combobox multiple items={FRAMEWORKS}>
261
+ <ComboboxTrigger
262
+ variant="select"
263
+ render={<div />}
264
+ nativeButton={false}
265
+ aria-labelledby="frameworks-label"
266
+ >
267
+ <ComboboxChips>
268
+ <ComboboxValue>
269
+ {(values: string[]) =>
270
+ values.length === 0
271
+ ? 'Select frameworks'
272
+ : values.map((value) => (
273
+ <ComboboxChip key={value} removeLabel={`Remove ${value}`}>
274
+ {value}
275
+ </ComboboxChip>
276
+ ))
277
+ }
278
+ </ComboboxValue>
279
+ </ComboboxChips>
280
+ </ComboboxTrigger>
281
+ <ComboboxContent>
282
+ <ComboboxInput showTrigger={false} aria-label="Search frameworks" />
283
+ <ComboboxList>
284
+ {(item: string) => (
285
+ <ComboboxItem key={item} value={item}>
286
+ {item}
287
+ </ComboboxItem>
288
+ )}
289
+ </ComboboxList>
290
+ </ComboboxContent>
291
+ </Combobox>
292
+ </>
293
+ ```
294
+
158
295
  ## Not ported from upstream
159
296
 
160
297
  Upstream's own `combobox.tsx` (the shadcn/ui base-variant registry file
@@ -190,3 +327,13 @@ button-based triggers (which never had the zoom problem to begin with).
190
327
  - Do not use a combobox for navigation — that is a menu/link pattern.
191
328
  - Do not omit `items` — without it, object-shaped values render as
192
329
  `[object Object]` in the field instead of their label.
330
+ - Do not use `variant="select"` without the search input in the popup — the
331
+ trigger holds no text field, so there is nowhere to type the query.
332
+ - Do not put `ComboboxChips` in a select-style trigger that is still a
333
+ button — render it as a `div` (`render={<div />}`, `nativeButton={false}`).
334
+ - Do not name that `div` trigger with a `<label for>` / `FieldLabel htmlFor` —
335
+ a `div` is not labelable, so the combobox ends up with no name. Give it
336
+ `aria-labelledby` or `aria-label`.
337
+ - Do not make a chip's remove button tabbable to give keyboard users a way to
338
+ remove a value in the select-style form — remove it by toggling its option
339
+ in the list.
@@ -1,8 +1,9 @@
1
1
  # Pagination
2
2
 
3
- Page-number navigation built from real anchors. No Base UI primitive backs
4
- it: pure styling over semantic markup (`nav` > `ul` > `li`), the same shape
5
- as `Table`/`Breadcrumb`.
3
+ Page-number navigation built from real anchors, with button twins of the
4
+ same parts for paging held in state. No Base UI primitive backs it: pure
5
+ styling over semantic markup (`nav` > `ul` > `li`), the same shape as
6
+ `Table`/`Breadcrumb`.
6
7
 
7
8
  An item is a 28px square at a 6px radius, transparent, with a centred 12/16
8
9
  label in `--muted-foreground` and a 4px gap between items. The active page
@@ -15,6 +16,8 @@ an icon and a label side by side.
15
16
 
16
17
  - Navigating between server-rendered pages of a result set, where each page
17
18
  is a real URL (`<PaginationLink href="?page=2">`).
19
+ - Paging a list held in component state, where changing the page is a state
20
+ update and leaves the URL alone (`<PaginationButton onClick={...}>`).
18
21
 
19
22
  ## When not to use
20
23
 
@@ -32,6 +35,9 @@ an icon and a label side by side.
32
35
  | `PaginationLink` | `<a>` | A page number; square by default |
33
36
  | `PaginationPrevious` | `<a>` | Chevron + "Previous" (hidden below 640px) |
34
37
  | `PaginationNext` | `<a>` | "Next" + chevron (hidden below 640px) |
38
+ | `PaginationButton` | `<button type="button">` | A page number for state-driven paging; the button twin of `PaginationLink` |
39
+ | `PaginationPreviousButton` | `<button type="button">` | The button twin of `PaginationPrevious`; `disabled` at the first page |
40
+ | `PaginationNextButton` | `<button type="button">` | The button twin of `PaginationNext`; `disabled` at the last page |
35
41
  | `PaginationEllipsis` | `<span>` | Collapsed-pages indicator |
36
42
 
37
43
  ## Props (kit level)
@@ -46,12 +52,45 @@ an icon and a label side by side.
46
52
  `PaginationPrevious`/`PaginationNext` accept the same props minus `square`
47
53
  (fixed to `false`), plus `text` to relabel the link.
48
54
 
55
+ Their accessible name follows `text`. With the default text it is "Go to
56
+ previous page" / "Go to next page"; a custom `text` is the name instead,
57
+ because the label is hidden below 640px and the chevron is decorative, so a
58
+ fixed name would leave the words on screen out of it and a voice-control user
59
+ could not say them to press the link. An empty or whitespace-only `text`
60
+ (the icon-only form) keeps the default name. An `aria-label` of your own replaces either; keep the
61
+ visible words in it. The button forms below name themselves the same way.
62
+
63
+ `PaginationButton` takes the same `isActive` and `square`, and every native
64
+ button prop (`onClick`, `disabled`, ...); `type` defaults to `"button"`, so
65
+ it never submits a form it sits in. `PaginationPreviousButton` /
66
+ `PaginationNextButton` mirror `PaginationPrevious` / `PaginationNext`: no
67
+ `square`, no `isActive`, and `text` to relabel them. A disabled button is
68
+ dimmed and inert, which is how a pager marks the ends of its range.
69
+
70
+ | Prop | Type | Default |
71
+ |------|------|---------|
72
+ | `focusableWhenDisabled` | `boolean` — keep the button in the tab order while `disabled`, reported through `aria-disabled` instead of the native attribute (the same prop `Button` has) | `false` |
73
+
74
+ A natively disabled button cannot hold focus, so a keyboard user who pages
75
+ with Previous until page 1 sees focus fall to the page behind it the moment
76
+ the button disables. Pass `focusableWhenDisabled` on Previous and Next in a
77
+ pager that is driven from the keyboard: the button stays where focus is, paints
78
+ the same dimmed look and still runs no click. It is no longer natively
79
+ disabled then, so read `aria-disabled` (or `data-disabled`) rather than the
80
+ `disabled` property to tell.
81
+
82
+ The Previous / Next chevrons mirror under a right-to-left direction, on the
83
+ anchor and the button forms alike.
84
+
49
85
  ## Implementation note
50
86
 
51
87
  Pagination carries its own geometry rather than a `Button` size: the drawn
52
88
  item is 28px with a paint inversion on the active page that no Button
53
- variant renders. The parts are real `<a>` elements, so pagination items stay
54
- crawlable and cmd-clickable.
89
+ variant renders. The link parts are real `<a>` elements, so pagination items
90
+ stay crawlable and cmd-clickable; the button parts paint identically but are
91
+ native `<button>`s, because `PaginationLink` always renders an anchor (it has
92
+ no `render` prop). Pick by what a page change is: a navigation to a URL is a
93
+ link, a state update is a button.
55
94
 
56
95
  ## Examples
57
96
 
@@ -89,11 +128,51 @@ import {
89
128
  </Pagination>
90
129
  ```
91
130
 
131
+ A state-driven pager, with the ends of the range disabled and focus kept on
132
+ a button that has just reached one:
133
+
134
+ ```tsx
135
+ <Pagination>
136
+ <PaginationContent>
137
+ <PaginationItem>
138
+ <PaginationPreviousButton
139
+ disabled={page === 1}
140
+ focusableWhenDisabled
141
+ onClick={() => setPage(page - 1)}
142
+ />
143
+ </PaginationItem>
144
+ {pages.map((n) => (
145
+ <PaginationItem key={n}>
146
+ <PaginationButton isActive={n === page} onClick={() => setPage(n)}>
147
+ {n}
148
+ </PaginationButton>
149
+ </PaginationItem>
150
+ ))}
151
+ <PaginationItem>
152
+ <PaginationNextButton
153
+ disabled={page === pages.length}
154
+ focusableWhenDisabled
155
+ onClick={() => setPage(page + 1)}
156
+ />
157
+ </PaginationItem>
158
+ </PaginationContent>
159
+ </Pagination>
160
+ ```
161
+
92
162
  ## Anti-patterns
93
163
 
94
164
  - Do not wrap a client-side handler in `href="#"` and call
95
165
  `preventDefault()` as the only navigation mechanism — a real `href` keeps
96
166
  the page crawlable and cmd/middle-click-able, matching a genuine link's
97
167
  semantics.
168
+ - Do not use `PaginationButton` for a page that has its own URL — it cannot
169
+ be opened in a new tab or crawled; use `PaginationLink` with the real
170
+ `href`.
98
171
  - Do not set `isActive` on more than one `PaginationLink` at a time — only
99
172
  one page is "current".
173
+ - Do not pass an `aria-label` to `PaginationPrevious`/`PaginationNext` that
174
+ leaves out the words of a custom `text`; leave it off and the name follows
175
+ the text.
176
+ - Do not disable Previous or Next at the end of a range that is paged from the
177
+ keyboard without `focusableWhenDisabled`; the focused button would drop focus
178
+ to the page.
@@ -4,7 +4,7 @@ A spinning loading indicator — lucide's `loader-circle` icon rotating
4
4
  continuously via CSS. No Base UI primitive and no variant axis.
5
5
 
6
6
  Two shapes. Bare, it is that icon and nothing else, at the kit's small icon
7
- step. Given a `label` or a `description`, it becomes the drawn loading
7
+ step (or the large one, `size="lg"`). Given a `label` or a `description`, it becomes the drawn loading
8
8
  block: the glyph centred in a 36 indicator box with its text beneath it.
9
9
 
10
10
  ## When to use
@@ -29,6 +29,7 @@ block: the glyph centred in a 36 indicator box with its text beneath it.
29
29
  | `label` | `ReactNode` - the state, written under the indicator in the drawn monospace micro type; its presence is what composes the block | - |
30
30
  | `description` | `ReactNode` - a second line under the label: what is being waited on, or how long it usually takes | - |
31
31
  | `compact` | `boolean` - the drawn tighter block, a 28 indicator around a 14 glyph instead of 36 around 18; on a bare spinner it takes the glyph to that same 14 | `false` |
32
+ | `size` | `default` \| `lg` - `lg` is the large step: a 32 glyph on a bare spinner, and in the block a 64 indicator around a 32 glyph (the same 2:1 the other steps draw). Wins over `compact` when both are passed | `default` |
32
33
 
33
34
  Every other prop is the indicator `<svg>`'s, `className` included, at both
34
35
  shapes - the layout block the kit adds around it is the kit's own, not a
@@ -70,6 +71,9 @@ import { Spinner } from '@gears-frontx/ui-kit';
70
71
 
71
72
  // Compact, for a panel that cannot give up 36px
72
73
  <Spinner compact label="Loading" />
74
+
75
+ // Large, centred over a region that is loading as a whole
76
+ <Spinner size="lg" />
73
77
  ```
74
78
 
75
79
  ## Anti-patterns
@@ -56,8 +56,12 @@ give the wrapper itself a `max-height` through `containerClassName` or
56
56
  `overflow-y` around `<Table>` instead: a sticky header sticks to its nearest
57
57
  scrolling ancestor, which is Table's own wrapper since it already scrolls
58
58
  horizontally. Your outer div would scroll while the wrapper, with no height
59
- of its own, never does, so the collection view's header would scroll away
60
- with the rows.
59
+ of its own, never does, so a sticky header would scroll away with the rows.
60
+
61
+ To measure the wrapper or drive its scroll position (scroll a row into view,
62
+ read its `clientWidth`), pass `containerRef`: a ref object or a callback ref
63
+ to the wrapper `div`. `ref` itself still lands on the `<table>`, like every
64
+ other prop that is not a wrapper one.
61
65
 
62
66
  A focus stop should announce something: pass `label` to name the wrapper
63
67
  (`role="region"` + `aria-label` — a bare `div`'s `aria-label` is ignored
@@ -67,8 +71,8 @@ non-focusable element while the focusable wrapper stays nameless).
67
71
  Without `label` the wrapper is roleless and nameless as before. Prefer
68
72
  passing it whenever the surrounding page doesn't make the table's purpose
69
73
  obvious the moment focus lands. Beyond `label`, the wrapper takes
70
- `containerClassName` and `containerStyle`, merged after its kit class; it
71
- isn't a separate export.
74
+ `containerClassName` and `containerStyle`, merged after its kit class, and
75
+ `containerRef`; it isn't a separate export.
72
76
 
73
77
  ## Semantics and accessibility
74
78
 
@@ -107,7 +111,7 @@ Taken from the Studio Data Table frame:
107
111
  | Cell inline padding | 16px | `--space-4` |
108
112
  | Row height (one line of text) | 40px | falls out of the padding (16 + 12 + 12); `--control-height-lg` is also pinned as a floor on `.tableCell` so an empty or sub-line cell cannot collapse the row — `height` on a table cell is a floor, not a cap |
109
113
  | Row height (row holding a 32px control) | 56px | falls out of the same padding (32 + 12 + 12) |
110
- | Row rule | 1px | `--border-width` `--border` |
114
+ | Row rule | 1px | `--border-width` `--border`, drawn under each cell (see "Sticky header") |
111
115
 
112
116
  The header is the one place the table leaves Inter: its column labels are
113
117
  mono by design, and that carries through to a header rendered as a button
@@ -174,8 +178,8 @@ other prop rather than driven by a kit-specific prop. Your own logic sets
174
178
  the attribute; the kit only paints it.
175
179
 
176
180
  A row is flat: transparent at rest, packed against its neighbours, with a
177
- single full-bleed 1px `--border` rule under it and no corner radius, ring,
178
- or fill of its own. Every state below is expressed as a full-bleed tint on
181
+ single full-bleed 1px `--border` rule under it (drawn by its cells, see
182
+ "Sticky header") and no corner radius, ring, or fill of its own. Every state below is expressed as a full-bleed tint on
179
183
  that shape — the drawn state language of the Studio Data Table:
180
184
 
181
185
  - `data-state="selected"` — a `--selection-subtle` tint, for a row the
@@ -186,10 +190,13 @@ that shape — the drawn state language of the Studio Data Table:
186
190
  viewer lacks access to.
187
191
  - Hover, and any row containing a descendant that is *currently*
188
192
  `aria-expanded="true"` (e.g. a row-level disclosure toggle, only while
189
- open — a collapsed toggle does not match) — a `--muted` tint, one step
190
- off both backdrops a table meets (`--surface` inside a card,
191
- `--background` bare on the page). A `data-state` tint outranks hover, so
192
- a selected row stays selected-colored under the pointer.
193
+ open — a collapsed toggle does not match) — a `--card-hover` tint, the
194
+ kit's hover step for a raised surface. It differs from both backdrops a
195
+ table meets (`--surface` inside a card, `--background` bare on the page) in
196
+ both themes; `--muted` would not, since the theme draws it equal to
197
+ `--background` in light and to every surface in dark. A `data-state` tint
198
+ outranks hover, so a selected row stays selected-colored under the
199
+ pointer.
193
200
 
194
201
  Because rows carry no fill at rest, the surface behind the table shows
195
202
  through them — put a `Table` on a `Card`, on `DataTable`'s own card, or on
@@ -200,6 +207,48 @@ the container's own bottom border or a footer bar's top border, and a
200
207
  second line there would double it. A `<tfoot>` after the body still gets
201
208
  its separator, since the body is then no longer the last section.
202
209
 
210
+ ## Sticky header
211
+
212
+ `stickyHeader` pins the header cells to the top of the scroll wrapper, so the
213
+ rows scroll beneath them on an opaque `--card` fill. It needs a bounded
214
+ wrapper height to have anything to scroll within (`containerClassName` or
215
+ `containerStyle`, as above). It is independent of `variant`: it brings none
216
+ of the collection view's fixed layout, minimum width or row height, only the
217
+ pinning, and works with `density` too.
218
+
219
+ It is built for ONE header row: every header cell takes `top: 0`, so a
220
+ second `TableRow` of `TableHead` cells would slide under the first rather than
221
+ stack beneath it.
222
+
223
+ In the default variant only the cells of `TableHeader` pin. A `TableHead` in a
224
+ body row (a row header, `scope="row"`) looks the same but scrolls away with its
225
+ row: pinned, it would sit over the column header. The collection variant is not
226
+ covered by this: its own rule still pins every `TableHead`, body-row headings
227
+ included, so avoid a `TableHead` in a body row under `variant="collection"` (a
228
+ known gap).
229
+
230
+ To change the fill, set `--table-header-fill` on the table (through
231
+ `className`) or on an ancestor. The kit reads it with `--card` as the
232
+ fallback and declares it nowhere itself, so a plain class is enough: no
233
+ selector has to outrank the kit's. It applies to `stickyHeader`; the
234
+ `collection` variant keeps its own header fill, also when both are set, so the
235
+ hook does not reach it.
236
+
237
+ ```css
238
+ .invoices { --table-header-fill: var(--surface-elevated); }
239
+ ```
240
+
241
+ It also switches the table from collapsed to separated borders (with no
242
+ spacing). In the collapsed model a border belongs to the table's grid, not
243
+ to the cell, so the rule under a pinned header would stay behind and scroll
244
+ away with the rows; in the separated model it travels with the cell. That is
245
+ why the 1px rule between rows is drawn under each header and body cell
246
+ rather than by the row: a row's own border is ignored once the borders are
247
+ separated, while under the collapsed model the cell rules merge into the
248
+ same single line a row border drew. The look is unchanged either way. A
249
+ border you put on a `TableRow` yourself is not the kit's rule, and is
250
+ ignored by a `stickyHeader` table.
251
+
203
252
  ## Props (kit level)
204
253
 
205
254
  `Table`:
@@ -211,6 +260,8 @@ its separator, since the body is then no longer the last section.
211
260
  | `variant` | `'default'` \| `'collection'` - collection is the fixed-layout view with a sticky 40 px header and 64 px rows | `'default'` |
212
261
  | `containerClassName` | `string` - className for the scroll wrapper; give it a `max-height` to scroll the rows under a sticky header | - |
213
262
  | `containerStyle` | `CSSProperties` - inline style for the same wrapper, e.g. `{ maxHeight: 320 }` | - |
263
+ | `containerRef` | `Ref<HTMLDivElement>` - ref to the scroll wrapper, not the `<table>` (`ref` still lands on the table) | - |
264
+ | `stickyHeader` | `boolean` - pins the `TableHeader` cells (in the default variant; the collection variant pins every `TableHead`) to the top of the scroll wrapper on an opaque fill; needs a bounded wrapper height, and is independent of `variant` | `false` |
214
265
 
215
266
  `TableHead`:
216
267
 
@@ -335,6 +386,39 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@
335
386
  </Table>;
336
387
  ```
337
388
 
389
+ A pinned header that works without the collection view, with the scroll
390
+ wrapper reachable through a ref:
391
+
392
+ ```tsx
393
+ import { useRef } from 'react';
394
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@gears-frontx/ui-kit';
395
+
396
+ function Invoices({ rows }: { rows: string[] }) {
397
+ const containerRef = useRef<HTMLDivElement>(null);
398
+ return (
399
+ <>
400
+ <button type="button" onClick={() => containerRef.current?.scrollTo({ top: 0 })}>
401
+ Back to top
402
+ </button>
403
+ <Table stickyHeader containerRef={containerRef} containerStyle={{ maxHeight: '20rem' }}>
404
+ <TableHeader>
405
+ <TableRow>
406
+ <TableHead>Invoice</TableHead>
407
+ </TableRow>
408
+ </TableHeader>
409
+ <TableBody>
410
+ {rows.map((id) => (
411
+ <TableRow key={id}>
412
+ <TableCell>{id}</TableCell>
413
+ </TableRow>
414
+ ))}
415
+ </TableBody>
416
+ </Table>
417
+ </>
418
+ );
419
+ }
420
+ ```
421
+
338
422
  A row with a leading checkbox column, sized flush against the cell edge by
339
423
  the source's own `:has([role=checkbox])` rule (built into `.tableHead`/
340
424
  `.tableCell`, no extra class needed):