@gecko-ui-kit/react 0.0.0-stage → 0.3.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/README.md CHANGED
@@ -1,3 +1,1860 @@
1
- # Temporary Holding Version
1
+ # @gecko-ui-kit/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Every [Gecko UI Kit](https://woraphondev.github.io/UI-Package/playground/) piece as a React component: buttons, forms,
4
+ pickers, data display, charts, text and scroll motion, overlays and the app shell. Made for Next.js (App Router):
5
+ every component renders on the server and wakes up in the browser, and comes with TypeScript types.
6
+
7
+ ```bash
8
+ npm install gsap @gecko-ui-kit/react
9
+ ```
10
+ It brings the other Gecko packages with it. `react` and `react-dom` 18 or newer come from your app.
11
+
12
+ ## Set up (Next.js)
13
+
14
+ Load the CSS once, in the root layout, in this order:
15
+
16
+ ```tsx
17
+ // app/layout.tsx
18
+ import '@gecko-ui-kit/tokens/style.css' // variables + small reset (first)
19
+ import '@gecko-ui-kit/motion/motion.css'
20
+ import '@gecko-ui-kit/components/style.css'
21
+ import '@gecko-ui-kit/overlays/style.css'
22
+ import '@gecko-ui-kit/shell/style.css' // only if you use the app shell
23
+ import './globals.css' // your own styles last
24
+ ```
25
+
26
+ Then use the components anywhere, in server or client components:
27
+
28
+ ```tsx
29
+ // app/bikes/page.tsx
30
+ import { Card, Tag, Button } from '@gecko-ui-kit/react'
31
+
32
+ export default function Bikes() {
33
+ return (
34
+ <Card title="Honda Click 125" sub="Plate 1กข 1234" right={<Tag tone="good">Available</Tag>}>
35
+ <Button variant="primary" icon="calendar">Book</Button>
36
+ </Card>
37
+ )
38
+ }
39
+ ```
40
+
41
+ Pieces you control with state need a client component, as usual in Next.js:
42
+
43
+ ```tsx
44
+ 'use client'
45
+ import { useState } from 'react'
46
+ import { Segmented, DateRange, toast } from '@gecko-ui-kit/react'
47
+
48
+ export function BookingFilters() {
49
+ const [view, setView] = useState('list')
50
+ return <>
51
+ <Segmented value={view} onChange={setView} options={[['list', 'List', 'list'], ['calendar', 'Calendar', 'calendar']]} />
52
+ <DateRange onChange={(range) => toast(`From ${range.start}`)} />
53
+ </>
54
+ }
55
+ ```
56
+
57
+ Works the same in Vite, Remix or any React 18+ app: just import the CSS in your entry file.
58
+
59
+ ## Fit it into an app that already has its own look
60
+
61
+ - **Nothing clashes.** Every class Gecko draws starts with `gk-` (`gk-btn`, `gk-card`, `gk-is-open`) and every CSS
62
+ variable with `--gk-` (`--gk-accent`), so your own `.btn`, `.card` or `--accent` keep working as before.
63
+ - **The reset stays inside Gecko.** `tokens/style.css` only resets Gecko's own elements; your `body`, links and buttons
64
+ are left alone. Want Gecko to set the page font, background and focus ring too? Add `@gecko-ui-kit/tokens/page.css`.
65
+ - **Match your theme** by setting variables after the imports (in your own CSS):
66
+
67
+ ```css
68
+ :root {
69
+ --gk-font: 'Prompt', system-ui, sans-serif;
70
+ --gk-bg: #eef1f6; --gk-card: #ffffff; --gk-line: #e2e6ee; --gk-ink: #1a1a1a; --gk-muted: #595959;
71
+ --gk-accent: #006ce4; --gk-accent-2: #0057b8; --gk-accent-soft: #ebf3ff; /* main buttons, links, focus */
72
+ --gk-selected: #ffb700; --gk-selected-ink: #1a1a1a; /* the chosen segment, chip, tab line and page */
73
+ --gk-r-card: 14px; --gk-r-btn: 10px; --gk-r-field: 10px; --gk-r-tag: 6px; --gk-r-badge: 6px; --gk-r-pill: 10px;
74
+ --gk-w-strong: 500; --gk-w-semibold: 600; /* lighter buttons and labels */
75
+ }
76
+ ```
77
+ Corners: `--gk-r-btn`, `--gk-r-iconbtn`, `--gk-r-field`, `--gk-r-chip`, `--gk-r-check`, `--gk-r-tag`, `--gk-r-badge`,
78
+ `--gk-r-pill` (segmented), `--gk-r-card`, `--gk-r-kpi`, `--gk-r-pop`, `--gk-r-toast`. Weights: `--gk-w-light` 300,
79
+ `--gk-w-medium` 500, `--gk-w-label` 550, `--gk-w-semibold` 600, `--gk-w-strong` 650, `--gk-w-bold` 700, `--gk-w-heavy` 750,
80
+ `--gk-w-black` 800. `--gk-selected` / `--gk-selected-ink` are unset by default (each piece keeps its own look).
81
+
82
+ ## Phone apps (PWA, Capacitor)
83
+
84
+ The kit works in a phone app made from your Next.js site: a PWA, or the site wrapped by Capacitor. Let the page run
85
+ under the notch and home bar, and the app frame, phone sheets, toasts and tab bar keep clear of them on their own:
86
+ ```js
87
+ // app/layout.js
88
+ export const viewport = { width: 'device-width', initialScale: 1, viewportFit: 'cover' }
89
+ ```
90
+ The room comes from `--gk-safe-t`, `--gk-safe-r`, `--gk-safe-b`, `--gk-safe-l` (0 on desktop); set them yourself if
91
+ your native shell already pads for the notch. React Native does not draw with HTML and CSS, so the kit does not run there.
92
+
93
+ ## How the components behave
94
+
95
+ - **Same look as the vanilla kit.** Each component draws the same HTML (same classes) as its vanilla piece, or runs the
96
+ vanilla piece inside an element React leaves alone, so the CSS, motion and accessibility are identical.
97
+ - **Value props.** A piece with a value takes `value` + `onChange` (controlled) or `defaultValue` (uncontrolled).
98
+ A new `value` updates the piece in place (it animates to it); it does not rebuild it.
99
+ - **Callbacks are always fresh.** Pass inline arrow functions freely: they never cause a rebuild, and the piece always
100
+ calls the latest one.
101
+ - **Your content is React.** Titles, card bodies, modal and drawer bodies, popover and tooltip content, slides, steps,
102
+ kanban cards… take React nodes. Nothing asks you for HTML strings, except a few `render(value) → string` callbacks
103
+ for many small cells (data grid), which say so in their types.
104
+ - **Refs.** Markup pieces give the DOM element. Pieces that the vanilla code builds (DataGrid, Calendar, Rating…) give
105
+ their handle (`ref.current.set(4)`, `ref.current.el`), the same methods as the vanilla API.
106
+ - **Server rendering.** Markup pieces render fully on the server. Pieces the vanilla code builds render an empty slot on
107
+ the server and appear when the page wakes up. Nothing reads `window` or `localStorage` while rendering.
108
+ - **Reduced motion** is honoured everywhere, as in the vanilla kit.
109
+ - **Texts** shown by a piece come from a `words` prop (English by default), e.g. `words={{ loading: 'กำลังโหลด…' }}`.
110
+ - **Any motion helper** without its own component can run on your own element with `useMotion`:
111
+ `const ref = useMotion(rise, [])` then `<ul ref={ref}>…</ul>`.
112
+
113
+ ## Components
114
+
115
+ - [Basics](#basics): `Button`, `IconButton`, `Spinner`, `Tag`, `Badge`, `Avatar`, `AvatarGroup`, `Cell`, `Card`, `Kpi`, `Empty`, `Table`, `Meter`, `Ring`, `Steps`, `Bars`, `Field`, `Input`, `Textarea`
116
+ - [Controls](#controls): `Switch`, `Segmented`, `Checkbox`, `Tabs`, `Chips`, `Range`, `Swatch`, `SearchBox`, `Select`, `Otp`
117
+ - [Forms](#forms): `MultiSelect`, `Combobox`, `TagsInput`, `RangeSlider`, `Stepper`, `Rating`, `RadioCards`, `SubscribeForm`, `PasswordMeter`, `PasswordToggle`, `AuthForm`, `SignaturePad`, `PhotoUpload`, `FileDrop`, `PricingToggle`, `DateRange`, `TimePicker`, `Wizard`, `useValidation`
118
+ - [Data display](#data-display): `Accordion`, `Carousel`, `BeforeAfter`, `Tree`, `DataGrid`, `VirtualList`, `Timeline`, `Calendar`, `SwipeItem`, `SwipeActions`, `Kanban`, `Notifications`, `Activity`, `Pagination`, `Breadcrumbs`, `Skeleton`, `Alert`
119
+ - [Action buttons](#action-buttons): `LikeButton`, `BellSwitch`, `PayButton`, `SpeedDial`, `Typing`
120
+ - [Charts](#charts): `LineChart`, `Donut`, `Gauge`, `Leaderboard`, `Heatmap`
121
+ - [Text & scroll motion](#text--scroll-motion): `TextReveal`, `Typewriter`, `Rotator`, `Shine`, `Highlighter`, `ScrollReveal`, `BlurIn`, `ScrollProgress`, `Odometer`, `CountUp`
122
+ - [Motion wrappers](#motion-wrappers): `Rise`, `Magnetic`, `Lift`, `Tilt`, `Spotlight`, `Marquee`, `useMotion`
123
+ - [Interactive effects](#interactive-effects): `Indicator`, `PageSwap`, `useFeedback`, `useFlash`, `useTick`, `ConfettiButton`, `useConfetti`, `Sortable`, `ThemeToggle`, `useTheme`, `SendButton`, `DeleteButton`, `DownloadButton`, `HoldButton`, `ExpandSearch`, `LiquidTabs`, `Burger`
124
+ - [Overlays](#overlays): `Modal`, `Drawer`, `confirm`, `useConfirm`, `Popover`, `Menu`, `ContextMenu`, `Tooltip`, `toast`, `CookieBanner`, `LoadingBar`, `useLoadingBar`, `CommandPalette`, `Tour`, `Lightbox`, `LightboxGallery`
125
+ - [App shell](#app-shell): `AppShell`, `Sidebar`, `Topbar`, `PageHeader`, `MobileTabbar`
126
+
127
+ ## Basics
128
+
129
+ ### Button
130
+ A button with a look (variant), a size and an optional icon; `busy` locks it and shows a spinner while it works.
131
+ ```tsx
132
+ <Button variant="primary" icon="check" busy={saving} busyText="Saving…" onClick={saveBooking}>Save booking</Button>
133
+ ```
134
+ - `variant`: `primary` `dark` `ghost` `danger` · `size`: `sm` `lg`
135
+ - `icon`, `iconRight`: an icon name or any node · `block`: full width · `magnetic`: leans toward the mouse
136
+ - `busy`, `busyText`: working state (disabled, `aria-busy`, spinner) · every `<button>` prop works
137
+
138
+ ### IconButton
139
+ A square button that shows only an icon; the label is read by screen readers.
140
+ ```tsx
141
+ <IconButton icon="bell" label="Notifications" onClick={openInbox} />
142
+ <IconButton icon="heart" label="Favourite bike" pressed={fav} onChange={setFav} size="sm" />
143
+ ```
144
+ - `icon`, `label` (aria-label), `size: 'sm'`
145
+ - `pressed` / `defaultPressed` + `onChange(pressed)`: an on/off button (`aria-pressed`, pops when pressed)
146
+
147
+ ### Spinner
148
+ The orbit loader: a comet circling a faint ring; with reduced motion it breathes instead.
149
+ ```tsx
150
+ {loading ? <Spinner size={36} label="Loading bookings…" stack /> : <BookingList />}
151
+ ```
152
+ - `size` (px or CSS length, the ring is 1em), `tone` (`accent` `ink` `muted` `good` `warn` `bad` `current`), `speed` (s per lap)
153
+ - `label`, `stack` (label under the ring), `track`, `decorative` (hidden from screen readers), `words: { loading }`
154
+
155
+ ### Tag
156
+ A small coloured status label.
157
+ ```tsx
158
+ <Tag tone={booking.paid ? 'good' : 'warn'}>{booking.paid ? 'Paid' : 'Unpaid'}</Tag>
159
+ ```
160
+ - `tone`: `good` `warn` `bad` `accent` `plain` · `dot` (default true) · `icon` instead of the dot
161
+
162
+ ### Badge
163
+ A small round count.
164
+ ```tsx
165
+ <Button variant="ghost">Inbox <Badge tone="accent">{unread}</Badge></Button>
166
+ ```
167
+ - `tone: 'accent'` · children: the number
168
+
169
+ ### Avatar
170
+ A round avatar with initials in one of eight colours; without a name it is an empty "open slot".
171
+ ```tsx
172
+ <Avatar name="Pim Wong" tone="teal" size="lg" online />
173
+ <Avatar /> {/* nobody assigned yet */}
174
+ ```
175
+ - `name` (tooltip, initials), `ini`, `tone` (`indigo` `teal` `rose` `amber` `violet` `green` `slate` `sky`)
176
+ - `size`: `sm` `lg` · `online`: green dot
177
+
178
+ ### AvatarGroup
179
+ Small overlapping avatars, then "+N".
180
+ ```tsx
181
+ <AvatarGroup people={task.assignees} max={4} />
182
+ ```
183
+ - `people`: `{ id?, name, ini?, tone? }[]` · `max` (default 4)
184
+
185
+ ### Cell
186
+ An avatar with a name and a small line under it, for lists and table cells.
187
+ ```tsx
188
+ <Cell name={rider.name} tone="rose" sub={rider.phone} />
189
+ ```
190
+ - `name`, `ini`, `tone`, `online` · `sub`: any node
191
+
192
+ ### Card
193
+ A white panel with an optional head (title, small line, things on the right); `lift` rises on hover.
194
+ ```tsx
195
+ <Card title="Today" sub={`${bookings.length} bookings`} right={<Button size="sm" variant="ghost">See all</Button>} lift>
196
+ <BookingList items={bookings} />
197
+ </Card>
198
+ ```
199
+ - `title`, `sub`, `right`: any nodes (the head shows when `title` is set) · `flush`: no padding · `lift`
200
+ - `CardHead` draws just the head row (`title`, `sub`, `right`)
201
+
202
+ ### Kpi
203
+ A number tile: a caption, a big value and a small line.
204
+ ```tsx
205
+ <div className="gk-kpis">
206
+ <Kpi label="Bikes out" value={12} sub="of 20" />
207
+ <Kpi label="Revenue" value="฿48,250" sub="This month" tone="good" />
208
+ </div>
209
+ ```
210
+ - `label`, `value`, `sub`: any nodes · `tone`: `accent` `good` `bad`
211
+
212
+ ### Empty
213
+ What to show when a list has nothing in it.
214
+ ```tsx
215
+ <Empty icon="search" title={`No bikes match “${q}”`} body="Check the spelling or try a shorter word."
216
+ action={<Button size="sm" icon="close" onClick={() => setQ('')}>Clear search</Button>} />
217
+ ```
218
+ - `icon`, `title`, `body`, `action`: nodes
219
+
220
+ ### Table
221
+ A table styled by `.gk-table`, inside `.gk-table-wrap` so it scrolls sideways on phones. Give it columns and rows, or write the `<thead>`/`<tbody>` yourself.
222
+ ```tsx
223
+ <Card title="Bookings" flush>
224
+ <Table rows={bookings} rowKey="id" slideRows columns={[
225
+ { key: 'rider', title: 'Rider', render: (b) => <Cell name={b.rider} sub={b.phone} /> },
226
+ { key: 'status', title: 'Status', render: (b) => <Tag tone={b.paid ? 'good' : 'warn'}>{b.paid ? 'Paid' : 'Unpaid'}</Tag> },
227
+ { key: 'days', title: 'Days', align: 'right' },
228
+ ]} />
229
+ </Card>
230
+ ```
231
+ - `columns`: `{ key, title, align: 'right', render(row) }[]` · `rows` · `rowKey` (field or function) · `foot`: `<tr>`s for a `<tfoot>`
232
+ - `slideRows`: rows slide in when they first appear · `wrap` (default true)
233
+
234
+ ### Meter
235
+ A thin bar that fills from zero, and glides when the value changes.
236
+ ```tsx
237
+ <Meter value={task.done / task.total} tone={late ? 'warn' : undefined} />
238
+ ```
239
+ - `value`: 0 to 1 · `tone`: `good` `warn` `bad` · `delay`
240
+
241
+ ### Ring
242
+ A round progress ring with a label in the middle; it sweeps on from the last value.
243
+ ```tsx
244
+ <Ring value={0.72} size={80} stroke={8} label="72%" />
245
+ ```
246
+ - `value`: 0 to 1 · `size` (56), `stroke` (6) · `label`: any node
247
+
248
+ ### Steps
249
+ A row of numbered steps: done ones get a tick, the bar fills up to the current one, the new dot pops.
250
+ ```tsx
251
+ <Steps labels={['Bike', 'Dates', 'Extras', 'Pay']} now={step} />
252
+ ```
253
+ - `labels`: nodes · `now`: the current step from 0
254
+
255
+ ### Bars
256
+ A small column chart: bars grow up from the baseline, then morph when the values change.
257
+ ```tsx
258
+ <Bars values={perDay} labels={['Mon', 'Tue', 'Wed', 'Thu', 'Fri']} showValues height={160} />
259
+ ```
260
+ - `values`, `max` (default: the biggest), `labels`, `showValues`, `format(value)`
261
+ - `highlightTop` (default true), `height` (210), `label` for screen readers
262
+
263
+ ### Field
264
+ A label above a control and a small hint under it.
265
+ ```tsx
266
+ <Field label="Phone" hint="We text the pick-up code here." invalid={!!error}>
267
+ <Input type="tel" value={phone} onChange={(e) => setPhone(e.target.value)} />
268
+ </Field>
269
+ ```
270
+ - `label`, `hint`: nodes · `invalid`: red border and hint
271
+
272
+ ### Input
273
+ A text input with the kit's look; every `<input>` prop works.
274
+ ```tsx
275
+ <Input type="email" placeholder="you@shop.com" size="sm" />
276
+ ```
277
+ - `size: 'sm'` · all `<input>` props
278
+
279
+ ### Textarea
280
+ A text area with the same look; `autoGrow` makes it taller with each line, up to a limit.
281
+ ```tsx
282
+ <Field label="Note for the mechanic"><Textarea rows={1} autoGrow={6} value={note} onChange={(e) => setNote(e.target.value)} /></Field>
283
+ ```
284
+ - `autoGrow`: `true` (6 lines) or a number of lines · `size: 'sm'` · all `<textarea>` props
285
+
286
+ ## Controls
287
+
288
+ Each control works controlled (`value` / `checked` + `onChange`) or uncontrolled (`defaultValue` / `defaultChecked`).
289
+
290
+ ### Switch
291
+ An on/off switch; the knob springs across.
292
+ ```tsx
293
+ <Switch checked={settings.sms} onChange={(on) => save({ sms: on })} label="SMS reminders" />
294
+ ```
295
+ - `checked` / `defaultChecked`, `onChange(checked, event)`, `label` (aria-label)
296
+
297
+ ### Segmented
298
+ A row of options where exactly one is picked; the thumb stretches to the new choice.
299
+ ```tsx
300
+ <Segmented options={[['list', 'List', 'list'], ['board', 'Board', 'cards']]} value={view} onChange={setView} />
301
+ ```
302
+ - `options`: `[value, label, icon?, count?]`, `{ value, label, icon, count, disabled }` or strings · `value` / `defaultValue` · `onChange(value)` · `size: 'sm'`
303
+ - `count` — a number after the label, e.g. `['free', 'Free', null, 4]` shows **Free 4**
304
+
305
+ ### Checkbox
306
+ A tick box that pops when ticked.
307
+ ```tsx
308
+ <Checkbox checked={task.done} onChange={(done) => updateTask(task.id, { done })} label={task.title} />
309
+ ```
310
+ - `checked` / `defaultChecked`, `onChange(checked, event)`, `label` (aria-label)
311
+
312
+ ### Tabs
313
+ Tab buttons with a line that stretches to the selected one; a count shows as a badge.
314
+ ```tsx
315
+ <Tabs items={[['all', 'All tasks'], ['mine', 'Mine', myCount], ['done', 'Done']]} value={tab} onChange={setTab} />
316
+ ```
317
+ - `items`: `[value, label, count?]`, `{ value, label, count, disabled }` or strings · `value` / `defaultValue` · `onChange(value)` · `name`
318
+
319
+ ### Chips
320
+ Pill buttons for filters: one picked, or several with `multi`.
321
+ ```tsx
322
+ <Chips options={[['all', 'All'], ['scooter', 'Scooters', 'moto'], ['ebike', 'E-bikes', 'bike']]} value={kind} onChange={setKind} />
323
+ <Chips multi options={['morning', 'day', 'late']} value={shifts} onChange={setShifts} />
324
+ ```
325
+ - `options` (like Segmented) · `multi` · `value` / `defaultValue` (an array with `multi`) · `onChange(value | values)`
326
+
327
+ ### Range
328
+ A slider with a filled track (it fills up from zero when first shown) and a springy thumb.
329
+ ```tsx
330
+ <Field label="Days" hint={`${days} days`}><Range min={1} max={14} value={days} onChange={setDays} /></Field>
331
+ ```
332
+ - `min`, `max`, `step` · `value` / `defaultValue` (number) · `onChange(value, event)`
333
+
334
+ ### Swatch
335
+ A colour picker drawn as a round swatch; it pops when a colour is picked.
336
+ ```tsx
337
+ <Swatch value={label.colour} onChange={(c) => setLabel({ ...label, colour: c })} aria-label="Label colour" />
338
+ ```
339
+ - `value` / `defaultValue` (`'#rrggbb'`) · `onChange(value, event)`
340
+
341
+ ### SearchBox
342
+ A text field with a magnifying glass; Enter searches, an empty box shakes.
343
+ ```tsx
344
+ <SearchBox placeholder="Search bikes…" value={q} onChange={setQ} onSearch={(text) => router.push(`/bikes?q=${encodeURIComponent(text)}`)} />
345
+ ```
346
+ - `placeholder` (also the aria-label) · `value` / `defaultValue` · `onChange(value)` · `onSearch(text)` · `size: 'sm'`
347
+ - `className` / `style` go on the box, other props on the `<input>`; `ref` is the `<input>`
348
+
349
+ ### Select
350
+ The animated dropdown: a real `<select>` (forms and `FormData` keep working) shown as a button whose list pops out, with a highlight that follows the mouse and the arrow keys.
351
+ ```tsx
352
+ <Field label="Assign to">
353
+ <Select name="owner" value={owner} onChange={setOwner} options={[
354
+ { group: 'Design', options: [['pim', 'Pim Wong'], ['ann', 'Ann Ko']] },
355
+ { group: 'Engineering', options: [['tom', 'Tom Lee'], ['max', 'Max Ru']] },
356
+ ]} />
357
+ </Field>
358
+ ```
359
+ - `options`: `[value, label, icon?]`, `{ value, label, icon, disabled }`, strings, or `{ group, options }` (labels are text, icons are icon names)
360
+ - `value` / `defaultValue` (default: the first option) · `onChange(value, event)` · `size: 'sm'` · `disabled`, `name`, …
361
+ - `ref` is the `<select>`; `dropdown(ref.current)` from `@gecko-ui-kit/overlays` gives `{ open, close, sync }`
362
+
363
+ ### Otp
364
+ A code field with one box per character: typing moves on, Backspace goes back, paste or the phone's code autofill fills every box. Return the answer from `onComplete` to play it.
365
+ ```tsx
366
+ <Otp length={6} split autoFocus onComplete={async (code) => (await api.verifyPhone(code)).ok} />
367
+ ```
368
+ - `length` (6), `split`, `mask` (PIN dots), `letters` (A–Z too), `label`, `name`
369
+ - `onComplete(code, el)`: return / resolve `true` (green wave, then a tick) or `false` (shake, then clear) · `gather`, `clear`
370
+ - `value` / `defaultValue`, `onChange(code)` · `disabled` · `ref` is the `.gk-otp` element (`otpState` / `otpClear` work on it)
371
+
372
+ ## Forms
373
+
374
+ Every piece with a value works two ways: pass `value` + `onChange` to control it, or `defaultValue` to let it keep its own.
375
+ A new `value` is applied in place (the piece animates to it, nothing is rebuilt, and `onChange` is not called).
376
+ `ref` gives the piece's handle (its methods, plus `el`). Changing an option that has no in-place method builds the piece again.
377
+
378
+ ### MultiSelect
379
+ Pick several people, labels or options; each pick flies up into the field as a chip.
380
+ ```tsx
381
+ const [who, setWho] = useState<string[]>(['ploy']);
382
+ <MultiSelect
383
+ options={[{ value: 'ploy', label: 'Ploy', person: true }, { value: 'tom', label: 'Tom', person: true }]}
384
+ value={who} onChange={setWho} max={3} placeholder="Assign to…" />
385
+ ```
386
+ - `options` (strings or `{ value, label, sub, group, person, color, icon, disabled }`), `value` / `defaultValue`
387
+ - `max`, `creatable`, `closeOnSelect`, `name`, `disabled`, `words`
388
+ - `onChange(values, options, ms)`, `onCreate(option, ms)`; ref: `set`, `add`, `remove`, `clear`, `open`, `setOptions`
389
+
390
+ ### Combobox
391
+ A text field you type into to find one option; it can ask your server instead of a fixed list.
392
+ ```tsx
393
+ <Combobox label="Pick-up branch" options={branches} value={branch} onChange={(v) => setBranch(v)} />
394
+ <Combobox label="Customer" source={(q, { signal }) => fetch(`/api/customers?q=${q}`, { signal }).then((r) => r.json())} />
395
+ ```
396
+ - `options` or `source(query, { signal })`, `value` / `defaultValue`
397
+ - `clearable`, `allowCustom`, `minChars`, `debounce`, `maxResults`, `name`, `label`, `disabled`, `words`
398
+ - `onChange(value, option, cb)`, `onInput(text, cb)`
399
+
400
+ ### TagsInput
401
+ Type words and each one becomes a tag; a comma or Enter makes a tag, pasting a list makes many.
402
+ ```tsx
403
+ <TagsInput value={labels} onChange={setLabels} suggestions={['bug', 'design', 'mobile']} max={5} />
404
+ ```
405
+ - `value` / `defaultValue`, `suggestions`, `max`, `unique`, `separators`
406
+ - `validate(text) → true | 'message'`, `transform(text)`, `name`, `disabled`, `words`
407
+ - `onChange(tags, ti)`; ref: `add`, `remove`, `clear`, `set`
408
+
409
+ ### RangeSlider
410
+ Two thumbs for a low and a high value, with an optional histogram behind the track.
411
+ ```tsx
412
+ <RangeSlider label="Price per day" min={0} max={2000} step={50} value={price} onChange={setPrice}
413
+ format={(v) => `฿${v.toLocaleString()}`} histogram={[2, 5, 9, 4, 1]} />
414
+ ```
415
+ - `min`, `max`, `step`, `value` / `defaultValue` (`[low, high]`), `minGap`
416
+ - `format`, `parse`, `marks`, `histogram`, `inputs`, `name`, `label`, `disabled`, `words`
417
+ - `onInput(value, rs)` while dragging, `onChange(value, rs)` when it settles
418
+
419
+ ### Stepper
420
+ − and + around a number whose digits roll like an odometer.
421
+ ```tsx
422
+ <Stepper value={days} onChange={setDays} min={1} max={30} unit={(n) => (n === 1 ? 'day' : 'days')} />
423
+ ```
424
+ - `value` / `defaultValue`, `min`, `max` (applied in place), `step`
425
+ - `unit`, `prefix`, `format`, `locale`, `size`, `name`, `disabled`, `words`
426
+ - `onChange(value, st)`; ref: `set`, `stepBy`, `setRange`
427
+
428
+ ### Rating
429
+ Stars (or hearts) to give a score, or to show one read-only.
430
+ ```tsx
431
+ <Rating value={score} onChange={setScore} labels={['Bad', 'Poor', 'Okay', 'Good', 'Great']} />
432
+ <Rating defaultValue={4.6} readOnly size="sm" />
433
+ ```
434
+ - `value` / `defaultValue`, `max`, `half`, `readOnly` (applied in place), `clearable`
435
+ - `icon`, `size`, `labels`, `showValue`, `name`, `disabled`, `words`
436
+ - `onChange(value, r)`; ref: `set`, `setReadOnly`
437
+
438
+ ### RadioCards
439
+ Choices drawn as cards (real radio buttons underneath), exactly one picked.
440
+ ```tsx
441
+ <RadioCards label="Choose a bike" value={bike} onChange={setBike} options={[
442
+ { value: 'scoot', title: 'Scooter 125', desc: 'Easy in town', price: '฿350 / day', icon: 'moto' },
443
+ { value: 'big', title: 'Scooter 160', desc: 'For two', price: '฿550 / day', badge: 'Popular' },
444
+ ]} />
445
+ ```
446
+ - `options` (`{ value, title, desc, price, icon, badge, disabled }`), `value` / `defaultValue`
447
+ - `label`, `hideLabel`, `layout` (`list` | `grid`), `min`, `name`, `required`, `disabled`, `words`
448
+ - `onChange(value, option, plan)`
449
+
450
+ ### SubscribeForm
451
+ One email field and a button; the button grows into the thank-you message.
452
+ ```tsx
453
+ <SubscribeForm icon="mail" words={{ button: 'Join the waitlist' }}
454
+ onSubmit={async (email) => { const r = await fetch('/api/waitlist', { method: 'POST', body: email }); if (!r.ok) throw new Error('Try again later.'); }} />
455
+ ```
456
+ - `defaultValue`, `name`, `icon`, `layout` (`row` | `stack`), `validate(email)`, `resetAfter`, `words`
457
+ - `onSubmit(email, sub)` — resolve (a string replaces the thanks text) or reject to show the error; ref: `setError`, `reset`, `state`
458
+
459
+ ### PasswordMeter
460
+ A password field with the strength meter after it: bars, a checklist that ticks off and a padlock.
461
+ ```tsx
462
+ const [pw, setPw] = useState('');
463
+ <div className="gk-field">
464
+ <label htmlFor="team-pw">Password for the team account</label>
465
+ <PasswordMeter id="team-pw" value={pw} onValueChange={setPw} reveal min={10} onChange={(s) => setCanSave(s.valid)} />
466
+ </div>
467
+ ```
468
+ - The meter: `rules` (`{ id, test, label }`), `min`, `minScore`, `score`, `reveal`, `list`, `lock`, `words`, `onChange({ score, level, valid, rules }, pw)`
469
+ - The text: `value` / `defaultValue` + `onValueChange(text, event)`; every other prop (`id`, `name`, `placeholder`…) goes on the `<input>`
470
+ - ref: `score`, `level`, `valid`, `rules`, `check()`, `reveal(on)`
471
+
472
+ ### PasswordToggle
473
+ A password field with a show / hide eye inside it (drawn by React, so it renders fully on the server).
474
+ ```tsx
475
+ <PasswordToggle name="password" autoComplete="current-password" onToggle={(shown) => track(shown)} />
476
+ ```
477
+ - `shown` / `defaultShown`, `onToggle(shown)`, `words: { show, hide }`
478
+ - Every other prop goes on the `<input>`; ref is the `<input>`
479
+
480
+ ### AuthForm
481
+ One card for signing in and creating an account, with checks, a strength meter and a busy button.
482
+ ```tsx
483
+ <AuthForm fields={{ confirm: true }} onForgot={(email) => sendResetLink(email)}
484
+ onSubmit={async (values, mode) => {
485
+ const r = await fetch(`/api/${mode === 'up' ? 'sign-up' : 'sign-in'}`, { method: 'POST', body: JSON.stringify(values) });
486
+ if (r.status === 401) throw Object.assign(new Error('That password isn’t right.'), { field: 'password' });
487
+ }} />
488
+ ```
489
+ - `mode` / `defaultMode` (`in` | `up`), `fields`, `meter`, `min`, `values` (filled in when it mounts), `validate`, `words`
490
+ - `onSubmit(values, mode, f)`, `onModeChange(mode, f)`, `onForgot(email, f)`; ref: `setMode`, `setError`, `reset`, `values`
491
+
492
+ ### SignaturePad
493
+ Sign with a finger, pen or mouse; the ink is thinner when you move fast.
494
+ ```tsx
495
+ const sig = useRef<Mounted<SignaturePadHandle>>(null);
496
+ <SignaturePad ref={sig} onChange={(empty) => setSigned(!empty)} words={{ hint: 'Sign here' }} />
497
+ <Button onClick={() => saveAgreement(sig.current!.toJSON(), sig.current!.toImage({ background: '#fff' }))}>Sign and send</Button>
498
+ <SignaturePad readOnly tools={false} defaultValue={agreement.strokes} />
499
+ ```
500
+ - `color`, `width`, `pressure`, `guide`, `tools`, `readOnly`, `defaultValue` (saved `toJSON()` data), `words`
501
+ - `onChange(isEmpty, sig)`, `onEnd(sig)`; ref: `undo`, `clear`, `replay`, `toJSON`, `fromJSON`, `toImage`, `toSVG`
502
+ - Changing `readOnly` or another option keeps what was signed
503
+
504
+ ### PhotoUpload
505
+ Drop, pick or paste photos; each tile uploads with a ring and can be dragged to reorder (the first is the cover).
506
+ ```tsx
507
+ <PhotoUpload max={8} defaultValue={bike.photos}
508
+ upload={(file, { progress, signal }) => uploadPhoto(file, { onProgress: progress, signal })}
509
+ onChange={(items) => setPhotos(items)} />
510
+ ```
511
+ - `accept`, `max`, `maxSize` (MB), `value` / `defaultValue` (already uploaded: `[{ url }]`), `upload`, `concurrent`, `resize`
512
+ - `cover`, `sortable`, `readOnly`, `capture`, `words`
513
+ - `onChange(items, up)`, `onReject`, `onUploaded`, `onError`; ref: `value`, `settled()`, `add`, `remove`, `move`, `open`
514
+
515
+ ### FileDrop
516
+ A drop zone that lists each file with its own progress bar, tick or error.
517
+ ```tsx
518
+ <FileDrop accept=".pdf,image/*" maxSize={10 * 1024 * 1024} upload={(file, { progress, signal }) => sendReceipt(file, progress, signal)}
519
+ onChange={(files) => setReceipts(files)} />
520
+ ```
521
+ - `accept`, `multiple`, `maxSize` (bytes), `maxFiles`, `upload`, `auto`, `concurrent`, `compact`, `words`
522
+ - `onChange(files, fd)`, `onError(problem, fd)`; ref: `files`, `value`, `add`, `retry`, `cancel`, `clear`, `browse`, `upload()`
523
+
524
+ ### PricingToggle
525
+ Plan cards with a monthly / yearly switch; every price rolls to its new number.
526
+ ```tsx
527
+ <PricingToggle value={period} onChange={setPeriod} locale="th-TH" format={{ style: 'currency', currency: 'THB', maximumFractionDigits: 0 }}
528
+ plans={[{ id: 'shop', name: 'Shop', price: { month: 390, year: 290 }, features: ['20 bikes'], action: 'Choose Shop', featured: true }]}
529
+ onSelect={(plan, period) => router.push(`/checkout?plan=${plan.id}&period=${period}`)} />
530
+ ```
531
+ - `plans`, `periods`, `value` / `defaultValue`, `format`, `locale`, `motion` (`roll` | `count`), `strike`, `words`
532
+ - `onChange(periodId, prices)`, `onSelect(plan, periodId, prices)`
533
+ - Plan texts are plain strings (the piece draws them)
534
+
535
+ ### DateRange
536
+ A month calendar to pick a start and an end (or one date), counting the days or nights.
537
+ ```tsx
538
+ <DateRange value={dates} onChange={(r) => setDates(r)} count="days" min={today} disabled={bookedDays} months={2} />
539
+ ```
540
+ - `mode` (`range` | `single`), `value` / `defaultValue` (`{ start, end }` or one date; `'YYYY-MM-DD'` or `Date`)
541
+ - `months`, `min`, `max`, `disabled`, `count`, `minDays`, `maxDays`, `blockSpan`, `presets`, `locale`, `weekStart`, `words`
542
+ - `onChange({ start, end, count }, dp)` (end is null until it is picked), `onInvalid(reason, dp)`
543
+
544
+ ### TimePicker
545
+ A wheel or a grid of time slots.
546
+ ```tsx
547
+ <TimePicker look="slots" min="09:00" max="18:00" value={pickUp} onChange={setPickUp} disabled={takenSlots} />
548
+ ```
549
+ - `look` (`wheel` | `slots`), `value` / `defaultValue` (`'HH:MM'`), `step`, `min`, `max`, `disabled` (applied in place), `hour12`, `words`
550
+ - `onChange(value, tp)`; ref: `set`, `setDisabled`, `format`
551
+
552
+ ### Wizard
553
+ A long form split into steps that slide sideways; each step's content is your own React.
554
+ ```tsx
555
+ <Wizard words={{ finish: 'Book' }} onFinish={(values) => book(values)} steps={[
556
+ { id: 'bike', title: 'Bike', content: <BikePicker /> },
557
+ { id: 'rider', title: 'Rider', content: <><label className="gk-field"><span>Phone</span><input className="gk-input" name="phone" required /></label></> },
558
+ { id: 'pay', title: 'Payment', content: <PaymentStep />, validate: () => (paid ? true : 'Choose how to pay.') },
559
+ ]} />
560
+ ```
561
+ - `steps` (`{ id, title, sub, content, optional, validate(panel, wz) }`), `index` (controlled) or `start`
562
+ - `linear`, `header` (`steps` | `bar` | `none`), `level`, `label`, `words`
563
+ - `onStep(index, wz)`, `onFinish(values, wz)`; ref: `next()`, `back()`, `go(i)`, `reset()`, `values`
564
+ - Without `validate`, the browser's own checks run on the step's fields (`required`, `type="email"`…)
565
+
566
+ ### useValidation
567
+ The red-field pattern from the Validation page (`.gk-field.gk-is-bad`, the reason in `.gk-field__hint`, a small shake) as a hook.
568
+ It is a pattern, not a piece: you draw the fields, the hook keeps the messages.
569
+ ```tsx
570
+ const v = useValidation({
571
+ name: (x) => (x.trim() ? '' : 'Please type your name.'),
572
+ email: (x) => (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x) ? '' : 'That email looks incomplete.'),
573
+ });
574
+ <label className={cx('field', v.errors.email && 'is-bad')}>
575
+ <span>Email</span>
576
+ <input className="gk-input" type="email" {...v.field('email')} />
577
+ <small className="gk-field__hint">{v.errors.email || 'We send one email when we launch.'}</small>
578
+ </label>
579
+ <Button variant="primary" onClick={() => v.validate() && join(v.values())}>Join the waitlist</Button>
580
+ ```
581
+ - A rule gets `(value, values)` and returns `''` (fine) or the message
582
+ - `v.field(name)` → `name`, `ref`, `onInput`, `aria-invalid` for the input; `v.validate()` marks and shakes the bad fields, true when all are fine
583
+ - `v.errors`, `v.check(name)`, `v.setError(name, message)` (e.g. a server answer), `v.reset()`, `v.values()`
584
+ - Options: `{ live: true }` re-checks a red field on every key, `{ shake: true }`
585
+
586
+ ## Data display
587
+
588
+ These components wrap the vanilla data pieces. The vanilla code builds and animates each piece inside one
589
+ element, and React draws your own content (panels, slides, cards, rows, messages) into it. Data that changes
590
+ (rows, events, cards, items) is applied in place, so the piece's own motion plays: a new card grows in and a
591
+ removed booking folds away. Pass a `ref` to get the piece's handle (its methods, plus `el`).
592
+
593
+ ### Accordion
594
+ A list of headings that open to show more. The panel grows open and the chevron turns.
595
+
596
+ ```tsx
597
+ <Accordion
598
+ defaultValue={['deposit']}
599
+ items={[
600
+ { id: 'helmet', title: 'Is a helmet included?', content: <p>Yes, two helmets come with every bike.</p> },
601
+ { id: 'deposit', title: 'Deposit', sub: 'Returned at drop-off', content: <DepositInfo bike={bike} /> },
602
+ ]}
603
+ />
604
+ ```
605
+ - `items`: `{ id, title, sub, icon, badge, content, open, disabled }`. `content` and `title` can be any React content.
606
+ - `value` / `defaultValue`: the open ids. `onChange(openIds)` · `onToggle(id, open)`.
607
+ - `multiple`, `collapsible`, `look: 'lines' | 'cards'`, `marker: 'chevron' | 'plus'`, `level`.
608
+
609
+ ### Carousel
610
+ Slides you swipe, drag or step through. The current dot stretches into a pill.
611
+
612
+ ```tsx
613
+ <Carousel perView={{ 0: 1, 640: 2, 960: 3 }} peek={40} label="Bikes">
614
+ {bikes.map((b) => <BikeCard key={b.id} bike={b} />)}
615
+ </Carousel>
616
+ ```
617
+ - Each child is one slide. `value` / `defaultValue`: the slide index. `onChange(index)`.
618
+ - `perView`, `gap`, `peek`, `focus`, `rewind`, `autoplay` (ms), `arrows`, `dots`, `label`, `words`.
619
+
620
+ ### BeforeAfter
621
+ Two pictures on top of each other, with a divider you drag to wipe between them.
622
+
623
+ ```tsx
624
+ <BeforeAfter
625
+ before={<img src="/repairs/42-before.jpg" alt="Scratched side panel" />}
626
+ after={<img src="/repairs/42-after.jpg" alt="Repaired side panel" />}
627
+ hint
628
+ />
629
+ ```
630
+ - `before`, `after`: React content. `value` / `defaultValue`: 0–100 (default 50). `onChange(value)` while it moves.
631
+ - `hover`, `hint`, `labels`, `ratio` ('4/3'), `step`, `words`.
632
+
633
+ ### Tree
634
+ Nested items that open and close, like folders, with keyboard support and optional checkboxes.
635
+
636
+ ```tsx
637
+ <Tree
638
+ label="Fleet"
639
+ items={[{ id: 'scooters', label: 'Scooters', open: true, children: [{ id: 'click', label: 'Honda Click' }] }]}
640
+ value={picked}
641
+ onSelect={(ids) => setPicked(ids)}
642
+ />
643
+ ```
644
+ - `items`: `{ id, label, icon, badge, children, open, disabled }` (`children: true` loads with `load(item)`).
645
+ - `value` / `defaultValue`: selected ids. `checked`: ticked ids (with `checkable`). Both change in place.
646
+ - `select: 'single' | 'multiple' | 'none'`, `lines`, `icons`. `onSelect(ids, item)` · `onCheck(ids)` · `onToggle(id, open)` · `onActivate(item)`.
647
+
648
+ ### DataGrid
649
+ A table people can search, filter, sort, page through and edit in place. Rows glide when the order changes.
650
+
651
+ ```tsx
652
+ <DataGrid
653
+ columns={[
654
+ { key: 'plate', label: 'Plate' },
655
+ { key: 'model', label: 'Model', type: 'select', options: ['Click', 'NMAX'], filter: true },
656
+ { key: 'rate', label: 'Rate / day', type: 'number', align: 'right', edit: true },
657
+ ]}
658
+ rows={bikes}
659
+ onChange={(row, key, value) => saveBike(row.id, { [key]: value })}
660
+ />
661
+ ```
662
+ - `rows` changes are applied in place with `setRows()`. Nothing happens when they already match what is on screen.
663
+ - `search`, `pageSize`, `select`, `add`, `remove`, `density`, `stripes`. `onChange(row, key, value, old)` · `onAdd(row)` · `onRemove(rows)`.
664
+ - `columns[].render(value, row)` returns trusted HTML. Escape app text yourself, or use `format` for plain text.
665
+
666
+ ### VirtualList
667
+ Thousands of rows, but only the ones you can see are in the page.
668
+
669
+ ```tsx
670
+ <VirtualList
671
+ items={customers}
672
+ rowHeight={56}
673
+ height={480}
674
+ selectable
675
+ renderItem={(c) => <CustomerRow customer={c} />}
676
+ onSelect={(c) => openCustomer(c.id)}
677
+ />
678
+ ```
679
+ - `renderItem(item, index)` draws a row with React. You can also use `render(item, index)`, which returns trusted HTML or a Node.
680
+ - `items` changes are applied in place with `update()`. `value` / `defaultValue`: the key of the picked row.
681
+ - `rowHeight` (px or `'auto'`), `estimate`, `height`, `overscan`, `key(item)`, `label`. `onSelect(item, index)` · `onRange(range)`.
682
+
683
+ ### Timeline
684
+ A booking timeline: rows of things you rent against days. Drag a bar to move it, or stretch it from either end.
685
+
686
+ ```tsx
687
+ <Timeline
688
+ title="Bookings"
689
+ rows={bikes.map((b) => ({ id: b.id, label: b.name, sub: b.plate }))}
690
+ items={bookings}
691
+ days={14}
692
+ onChange={(booking) => saveBooking(booking)}
693
+ />
694
+ ```
695
+ - `items`: `{ id, row, start, end, label, status, color, edit }`. Changes are applied in place (bars glide and grow).
696
+ - `from`, `days`, `locale`, `edit`, `overlap`, `minDays`, `now`, `late`, `sub(item, days)`. `onChange(item, before)` · `onOpen(item)` · `onAdd({ row, start })` · `onClash(item, other)`.
697
+
698
+ ### Calendar
699
+ A month calendar with events as small chips. It slides from month to month, and you can drag events to other days.
700
+
701
+ ```tsx
702
+ <Calendar
703
+ events={bookings.map((b) => ({ id: b.id, title: b.bike, start: b.from, end: b.to, tone: 'good' }))}
704
+ value={day}
705
+ onDay={(date) => setDay(date)}
706
+ draggable
707
+ onMove={(ev, start, end) => moveBooking(ev.id, start, end)}
708
+ />
709
+ ```
710
+ - `value` / `defaultValue`: the picked day. `month`: the month on show. `events`: applied with `setEvents()`. All three change in place.
711
+ - `weekStart`, `locale` (`'th'` gives Thai with the Buddhist year), `maxPerDay`, `selectable`, `draggable`, `size`.
712
+ - `onMonth(date)` · `onDay(date, events)` · `onEvent(event)` · `onMove(event, start, end)` (return false to put it back).
713
+
714
+ ### SwipeItem and SwipeActions
715
+ List rows you slide sideways to show buttons behind them (archive, delete…). A long swipe runs the edge button.
716
+
717
+ ```tsx
718
+ <SwipeActions className="gk-card gk-card--flush" onAction={(action, ctx) => {
719
+ if (action === 'cancel') toast('Booking cancelled', { undo: () => ctx.undo() });
720
+ }}>
721
+ {bookings.map((b) => (
722
+ <SwipeItem key={b.id} id={b.id}
723
+ end={[{ id: 'cancel', label: 'Cancel', icon: 'trash', tone: 'bad', remove: true }, { id: 'call', label: 'Call', icon: 'phone' }]}>
724
+ <BookingRow booking={b} />
725
+ </SwipeItem>
726
+ ))}
727
+ </SwipeActions>
728
+ ```
729
+ - `SwipeItem`: `id`, `start` (pull right), `end` (pull left), `look: 'both' | 'icons' | 'labels'`, `label`. Children are the row.
730
+ - `SwipeActions`: `full`, `fullAt`, `single`, `haptic`. `onAction(action, ctx)`: ctx is `{ row, id, action, undo() }`. `onOpen(row, side)` · `onClose(row)`.
731
+ - A row with `remove: true` slides off and is hidden. Remove it from your list when you are done, or call `ctx.undo()` to bring it back.
732
+
733
+ ### Kanban
734
+ Columns of cards you drag between columns or up and down. A picked-up card hangs from where you hold it.
735
+
736
+ ```tsx
737
+ <Kanban
738
+ columns={[{ id: 'todo', title: 'To do' }, { id: 'doing', title: 'Doing', limit: 3 }, { id: 'done', title: 'Done' }]}
739
+ cards={tasks}
740
+ renderCard={(t) => <TaskCard task={t} />}
741
+ onMove={(card, { to, index }) => moveTask(card.id, to, index)}
742
+ />
743
+ ```
744
+ - `renderCard(card)` draws each card with React. Leave it out to get the built-in card (`tags`, `title`, `text`).
745
+ - `cards` changes are applied in place: new cards grow in, removed ones fold away, moved ones slide.
746
+ - `strictLimit`, `canDrop(card, column)`. `onMove(card, { from, to, index })` (return false to put it back) · `onOpen(card)` · `onAdd(column)`.
747
+
748
+ ### Notifications
749
+ A notification feed, newest first and grouped by day. New ones slide in at the top, and unread dots fade when read.
750
+
751
+ ```tsx
752
+ <Notifications
753
+ items={notes}
754
+ onOpen={(n) => markRead(n.id)}
755
+ onAction={async (n, action) => { await api.answer(n.id, action); return action === 'accept' ? 'Accepted' : 'Declined'; }}
756
+ />
757
+ ```
758
+ - `items`: `{ id, time, title, body, person, icon, tone, read, actions, href }`. Changes are applied in place.
759
+ - `filter: 'all' | 'unread'`, `group`, `header`, `tabs`, `markAll`, `dismissible`, `height`, `plain`, `locale`.
760
+ - `onOpen(item)` · `onAction(item, actionId)` · `onDismiss(item)` · `onChange(unreadCount)`.
761
+
762
+ ### Activity
763
+ An activity timeline: who did what, and when. The line draws down, and new events push in at the top.
764
+
765
+ ```tsx
766
+ <Activity
767
+ locale="th"
768
+ items={[{ id: 'a1', who: { name: 'Pim' }, what: 'returned the Honda Click', time: returnedAt, icon: 'check', tone: 'good' }]}
769
+ />
770
+ ```
771
+ - `items`: `{ id, time, who, what, title, detail, icon, tone }`. New ones at the top are added with the push-down motion.
772
+ - `marks: 'auto' | 'icon' | 'avatar' | 'dot'`, `latest`, `max`, `intro`, `locale`, `format(date)`, `refresh`.
773
+
774
+ ### Pagination
775
+ Page numbers with previous and next arrows. The highlight stretches from number to number.
776
+
777
+ ```tsx
778
+ <Pagination total={240} pageSize={size} value={page} onChange={(p, s) => { setPage(p); setSize(s); }} />
779
+ ```
780
+ - `value` / `defaultValue`: the page (from 1). `total` changes are applied in place. `onChange(page, pageSize)`.
781
+ - `pageSize`, `sizes`, `siblings`, `boundaries`, `info`, `look: 'numbers' | 'simple'`, `compact`, `words`.
782
+
783
+ ### Breadcrumbs
784
+ The path to the current page. A long path folds its middle steps into “…”.
785
+
786
+ ```tsx
787
+ <Breadcrumbs
788
+ items={[{ label: 'Fleet', href: '/fleet' }, { label: 'Scooters', href: '/fleet/scooters' }, { label: 'Honda Click' }]}
789
+ onNavigate={(item, i, e) => { if (item.href) { e.preventDefault(); router.push(item.href); } }}
790
+ />
791
+ ```
792
+ - `items`: `{ label, href, icon, id }`. A new path is set like a route change: shared steps stay, new ones slide in.
793
+ - `max`, `separator: 'chevron' | 'slash' | 'dot'`, `size`. `onNavigate(item, index, event)`.
794
+
795
+ ### Skeleton
796
+ Grey placeholders in the shape of what is loading. When loading ends, the real rows rise into their place.
797
+
798
+ ```tsx
799
+ <Skeleton look="list" rows={4} loading={!riders} label="Riders">
800
+ {riders && <RiderList riders={riders} />}
801
+ </Skeleton>
802
+ ```
803
+ - Children are the real content. When `loading` turns false the content is revealed. Set it back to true to show the placeholders again.
804
+ - `look: 'list' | 'card' | 'text' | 'table' | 'custom'`, `rows`, `avatar`, `media`, `lines`, `cols`, `shimmer`, `label`.
805
+
806
+ ### Alert
807
+ A message in the page: saved, couldn't save, a warning. Tone and text changes cross-fade and slide.
808
+
809
+ ```tsx
810
+ <Alert tone="bad" title="Couldn't save the booking" dismissible open={showError} onClose={() => setShowError(false)}
811
+ actions={[{ label: 'Try again', primary: true, run: () => saveBooking() }]}>
812
+ The Honda Click is already booked on <b>4–6 Dec</b>.
813
+ </Alert>
814
+ ```
815
+ - Children are the message. `tone`, `title`, `icon` and `actions` change in place.
816
+ - `open: false` folds it away, and `true` grows it back. `onClose()` runs after ✕ or Esc closes it.
817
+ - `look: 'soft' | 'outline' | 'solid' | 'banner'`, `dismissible`, `words`.
818
+
819
+ ## Action buttons
820
+
821
+ ### LikeButton
822
+
823
+ A like, star or bookmark button that pops (or fills) when it turns on, with a count that rolls up and down.
824
+
825
+ ```tsx
826
+ 'use client';
827
+ import { LikeButton } from '@gecko-ui-kit/react';
828
+
829
+ export function SaveBike({ bike }: { bike: { id: string; saved: boolean; saves: number } }) {
830
+ return (
831
+ <LikeButton
832
+ kind="bookmark"
833
+ defaultPressed={bike.saved}
834
+ count={bike.saves}
835
+ // return the request: if it fails, the button goes back and shakes
836
+ onChange={(on) => fetch(`/api/bikes/${bike.id}/save`, { method: on ? 'PUT' : 'DELETE' })
837
+ .then((r) => { if (!r.ok) throw new Error(String(r.status)); })}
838
+ />
839
+ );
840
+ }
841
+ ```
842
+
843
+ - `kind`: `'heart'` (default), `'star'` or `'bookmark'`.
844
+ - `pressed` (controlled) or `defaultPressed`. Controlled: set it from `onChange`, and set it back yourself if your request fails.
845
+ - `count`: a number shows a rolling count; a new value (for example from the server) rolls to it.
846
+ - `label` / `onLabel`, `iconOnly`, `size` (`'sm'` `''` `'lg'`), `tone`, `format(n)`, `words`.
847
+ - `onChange(pressed, count, handle)`: return a promise; if it fails, the button goes back with a shake.
848
+ - `ref` → `{ pressed, count, set(on), toggle(), setCount(n), el }`.
849
+
850
+ ### BellSwitch
851
+
852
+ A notification switch: turning it on rings the bell, turning it off draws a slash across it. `BellButton` is the same component.
853
+
854
+ ```tsx
855
+ const [alerts, setAlerts] = useState(true);
856
+ const bell = useRef<Mounted<BellHandle>>(null);
857
+ useEffect(() => onNewBooking(() => bell.current?.ring()), []);
858
+
859
+ <BellSwitch ref={bell} label="Booking alerts" on={alerts}
860
+ onChange={(on) => { setAlerts(on); return saveSetting('booking-alerts', on); }} />
861
+ ```
862
+
863
+ - `on` (controlled) or `defaultOn`.
864
+ - `label` (any React node; a string with `iconOnly`), `iconOnly`, `tone`, `words: { label, on, off }`.
865
+ - `onChange(on, handle)`: return a promise; if it fails, it switches back with a shake.
866
+ - `ref` → `{ on, set(on), toggle(), ring(), el }`: `ring()` when something new comes in.
867
+
868
+ ### PayButton
869
+
870
+ A checkout button: a card swipes through, "Processing", then "Paid" with a tick, or red "Try again" when the payment fails.
871
+
872
+ ```tsx
873
+ <PayButton
874
+ label={<>Pay <b>฿{total}</b></>}
875
+ block
876
+ onPay={async () => {
877
+ const r = await fetch('/api/checkout', { method: 'POST', body: JSON.stringify(cart) });
878
+ if (!r.ok) throw new Error('Card declined');
879
+ return r.json(); // resolves = paid
880
+ }}
881
+ onDone={(receipt) => router.push(`/bookings/${(receipt as { id: string }).id}`)}
882
+ onFail={(error) => setCardError(String(error))}
883
+ />
884
+ ```
885
+
886
+ - `onPay(handle)`: resolve = paid; throw, reject or return `false` = failed.
887
+ - `onDone(result, handle)`, `onFail(error, handle)`.
888
+ - `label` (any React node), `variant` (`'dark'` default, `'primary'`), `size` (`'lg'` default), `block`, `icon` (`'card'`, `''` for none).
889
+ - `card` (the swipe, default on), `minBusy` (1.4 s), `back` (3 s; `0` stays "Paid"), `words`.
890
+ - `ref` → `{ state, pay(), reset(), el }`.
891
+
892
+ ### SpeedDial
893
+
894
+ A round + button that fans out a few labelled quick actions.
895
+
896
+ ```tsx
897
+ <SpeedDial
898
+ fixed
899
+ actions={[
900
+ { id: 'booking', label: 'New booking', icon: 'calendar' },
901
+ { id: 'bike', label: 'Add a bike', icon: 'plus' },
902
+ { id: 'note', label: 'Write a note', icon: 'edit' },
903
+ ]}
904
+ onSelect={(a) => router.push(`/new/${a.id}`)}
905
+ />
906
+ ```
907
+
908
+ - `actions`: `{ id, label, icon }` (icon name or `<svg>` string); a new list is swapped in place.
909
+ - `direction` (`'up'` / `'down'`), `side` (`'right'` / `'left'`), `labels`, `fixed`, `icon`, `words: { label, actions }`.
910
+ - `onSelect(action, handle)`, `onToggle(open, handle)`.
911
+ - `ref` → `{ isOpen, open(), close(), toggle(), setActions(list), el }`.
912
+
913
+ ### Typing
914
+
915
+ Three bouncing dots in a chat bubble, with "Pim is typing…".
916
+
917
+ ```tsx
918
+ <Typing visible={typingNames.length > 0} names={typingNames} />
919
+ ```
920
+
921
+ - `visible`: shows or hides it in place (the row opens and closes, `collapse`).
922
+ - `names`: `'Pim'` or `['Pim', 'Mali']`; changes in place.
923
+ - `text`, `bubble`, `size` (`'sm'` `''` `'lg'`), `tone` (`'muted'` `'accent'` `'ink'`), `collapse`, `words: { anon, one, two, many }`.
924
+ - `ref` → `{ visible, text, show(), hide(), set(names), el }`.
925
+
926
+ ## Charts
927
+
928
+ New data never draws these charts again from zero: lines morph, slices change size, the needle swings and rows
929
+ glide to their new places. Pass new arrays as props; that is all.
930
+
931
+ ### LineChart
932
+
933
+ A line or area chart of one or more series over the same labels, with a crosshair, a tooltip and legend keys.
934
+
935
+ ```tsx
936
+ <LineChart
937
+ label="Rental income by month"
938
+ labels={['Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
939
+ series={[
940
+ { name: 'Walk-in', data: walkIn },
941
+ { name: 'Booked online', data: online, tone: 'teal' },
942
+ ]}
943
+ height={240}
944
+ format={(v) => `฿${v.toLocaleString()}`}
945
+ />
946
+ ```
947
+
948
+ - `labels`, `series: [{ name, data, tone, hidden }]` (`null` in data leaves a gap): new ones morph in place.
949
+ - `area`, `smooth`, `stacked`, `height`, `yMin`, `yMax`, `ticks`, `grid`, `dots` (`'hover'` / `true` / `false`), `tooltip`, `legend`.
950
+ - `format(v)`, `axisFormat(v)`, `label`, `words`, `onPoint(index, info, handle)`.
951
+ - `ref` → `{ labels, series, update(), highlight(i), toggle(name, on?), el }`.
952
+
953
+ ### Donut
954
+
955
+ Parts of a whole as a ring of slices, with the total in the middle.
956
+
957
+ ```tsx
958
+ <Donut
959
+ label="Bikes out today"
960
+ data={[
961
+ { label: 'Scooters', value: 48 },
962
+ { label: 'E-bikes', value: 20, tone: 'teal' },
963
+ { label: 'City bikes', value: 12 },
964
+ ]}
965
+ centre="Bikes"
966
+ onSelect={(i, item) => setFilter(item?.label ?? null)}
967
+ />
968
+ ```
969
+
970
+ - `data: [{ label, value, tone }]`: new data morphs the slices (matched by label).
971
+ - `size`, `thickness`, `gap`, `legend` (`'right'` / `'bottom'` / `false`), `sort`, `format(v)`, `centre`, `label`, `words`.
972
+ - `onSelect(index, item, handle)` (index -1 when cleared).
973
+ - `ref` → `{ data, total, selected, set(data), select(index | label | -1), el }`.
974
+
975
+ ### Gauge
976
+
977
+ One number on a half-circle dial, like today's bookings against a daily goal.
978
+
979
+ ```tsx
980
+ <Gauge
981
+ value={todaySales}
982
+ max={12000}
983
+ goal={10000}
984
+ label="Today's rentals"
985
+ format={(v) => `฿${v.toLocaleString()}`}
986
+ zones={[{ to: 4000, tone: 'bad' }, { to: 8000, tone: 'warn' }, { to: 12000, tone: 'good' }]}
987
+ />
988
+ ```
989
+
990
+ - `value`: a new value swings the needle from where it is now.
991
+ - `min`, `max`, `goal`, `zones: [{ to, tone, label }]`, `tone`, `format(v)`, `label`, `size`, `needle`, `ends`, `words`.
992
+ - `ref` → `{ value, set(v), el }`.
993
+
994
+ ### Leaderboard
995
+
996
+ A ranked list with a bar under each row; when the numbers change the rows glide to their new ranks.
997
+
998
+ ```tsx
999
+ <Leaderboard
1000
+ label="Tasks done this week"
1001
+ max={5}
1002
+ items={team.map((p) => ({ id: p.id, label: p.name, sub: p.role, value: p.done, avatar: { name: p.name } }))}
1003
+ />
1004
+ ```
1005
+
1006
+ - `items: [{ id, label, value, sub, avatar }]`: new items glide, bars stretch and numbers count.
1007
+ - `max` (rows shown, 0 = all), `format(v)`, `bars`, `medals`, `label`, `words`.
1008
+ - `ref` → `{ items, set(items), el }`.
1009
+
1010
+ ### Heatmap
1011
+
1012
+ A calendar of small squares, one per day, darker on busier days.
1013
+
1014
+ ```tsx
1015
+ const [day, setDay] = useState<Date | null>(null);
1016
+
1017
+ <Heatmap
1018
+ data={bookings.map((b) => ({ date: b.day, value: b.count }))} // 'YYYY-MM-DD' or Date
1019
+ weeks={26}
1020
+ value={day}
1021
+ onSelect={(d) => setDay(d.date)}
1022
+ format={(v) => `${v} bookings`}
1023
+ />
1024
+ ```
1025
+
1026
+ - `data: [{ date, value }]`: new data re-shades every square in a ripple. (A function `(date) => number` is read once at the start.)
1027
+ - `value` picks a day in place (`defaultValue` only at the start); `onSelect(day, handle)` with `day = { date, value, level }`.
1028
+ - `end` (default today), `weeks`, `weekStart`, `levels`, `tone`, `format(v)`, `locale`, `words`.
1029
+ - The scroll area reaches 4px past its box (room for the focus ring): give its container a little padding.
1030
+ - `ref` → `{ value, set(data), select(date | null), el }`.
1031
+
1032
+ ## Text & scroll motion
1033
+
1034
+ Text that moves: letters that roll up, typed words, a word that keeps changing, a band of light, marker strokes,
1035
+ blocks that arrive on scroll, rolling numbers. Each component draws its first state on the server (so the text is
1036
+ in the HTML), then the motion takes over in the browser. Changing a prop (new text, new words, a new value)
1037
+ updates the piece in place. Every motion respects reduced motion.
1038
+
1039
+ ### TextReveal
1040
+
1041
+ A headline whose letters roll up out of a mask, one after another (`title()`); a new text plays again in place.
1042
+
1043
+ ```tsx
1044
+ <TextReveal as="h1" stagger={0.022} tilt={6}>{`Bikes for every trip, ${city}`}</TextReveal>
1045
+ ```
1046
+
1047
+ - `children` — the text (a string). Changing it plays the reveal again (`retitle()`).
1048
+ - `delay`, `stagger` (0.022), `tilt` (6°), `duration` (0.85).
1049
+ - `as` — the element (`'span'` by default: use `'h1'`, `'h2'`…). ref → the element.
1050
+
1051
+ ### Typewriter
1052
+
1053
+ Text typed letter by letter behind a caret; several phrases are deleted and typed in turn. Screen readers hear the whole list once.
1054
+
1055
+ ```tsx
1056
+ <h2>We rent <Typewriter phrases={['scooters', 'city bikes', 'e-bikes']} caret="bar" /></h2>
1057
+ <Typewriter as="p" loop={false} speed={0.03}>Your bike is booked for Friday at 9 am.</Typewriter>
1058
+ ```
1059
+
1060
+ - `phrases` — the list (or one phrase as children). A new list deletes the current phrase and types the new ones.
1061
+ - `speed` (0.06 s a letter), `jitter`, `eraseSpeed`, `erase` (`'backspace'` | `'select'`), `hold`, `gap`, `delay`, `loop`.
1062
+ - `caret` (`'bar'` | `'block'` | `'underscore'` | `false`), `locale`, `label`, `whenVisible`, `paused`.
1063
+ - `onPhrase(i, text)`. ref → `{ phrase, play(), pause(), restart(), set(list), el }`.
1064
+
1065
+ ### Rotator
1066
+
1067
+ One word in a sentence keeps changing; its slot glides to the new width so the sentence moves over smoothly.
1068
+
1069
+ ```tsx
1070
+ <h2>Rent a <Rotator words={['scooter', 'city bike', 'e-bike']} effect="roll" pill /> by the hour</h2>
1071
+ ```
1072
+
1073
+ - `words` — the list. A new list starts again from the first word.
1074
+ - `effect` (`'roll'` | `'drop'` | `'slide'` | `'blur'` | `'letters'`), `every` (2.2 s), `duration`, `ease`, `stagger`.
1075
+ - `pill` — a soft highlight box behind the word. `index` — show this word; `auto={false}` to drive it yourself; `paused`.
1076
+ - `onChange(i, word)`. ref → `{ index, next(), go(i), play(), pause(), set(words), el }`.
1077
+
1078
+ ### Shine
1079
+
1080
+ A slanted band of light sweeps across the letters, like light on a shiny sign. The text stays real text.
1081
+
1082
+ ```tsx
1083
+ <Shine as="h2" look="gradient" trigger="loop">Summer rides, 20% off</Shine>
1084
+ <Shine look="ink" trigger="hover" tabIndex={0}>Loading your bookings…</Shine>
1085
+ ```
1086
+
1087
+ - `look` (`'gradient'` | `'ink'` | `'color'`), `trigger` (`'loop'` | `'view'` | `'hover'`).
1088
+ - `duration` (1.4), `repeatDelay` (1.8), `delay`, `ease`, `angle` (110°), `width` (12), `color`.
1089
+ - CSS only, no React needed: `<span className="gk-shine gk-shine--ink gk-shine--loop">…</span>`.
1090
+
1091
+ ### Highlighter
1092
+
1093
+ A marker stroke draws behind the words in `<mark>`, one after another, when the paragraph scrolls into view.
1094
+
1095
+ ```tsx
1096
+ <Highlighter tone="amber">
1097
+ Every rental comes with <mark>a free helmet</mark> and <mark>a lock</mark>.
1098
+ </Highlighter>
1099
+ ```
1100
+
1101
+ - `look` (`'marker'` | `'underline'`), `tone` (`accent amber green rose sky violet`) or `color`.
1102
+ - `trigger` (`'view'` | `'now'` | `'manual'`), `threshold` (0.6), `once`, `duration`, `stagger`, `delay`, `ease`, `selector`.
1103
+ - `active` — with `trigger="manual"`: `true` draws the strokes, `false` clears them.
1104
+
1105
+ ### ScrollReveal
1106
+
1107
+ Blocks (or their words) wait out of sight and arrive as they scroll into view: fade, rise, slide, zoom or blur.
1108
+
1109
+ ```tsx
1110
+ <ScrollReveal effect="rise"><BookingSummary booking={b} /></ScrollReveal>
1111
+
1112
+ <ScrollReveal items=":scope > article" effect="slide" x={-40}>
1113
+ {steps.map((s) => <article key={s.id}><h4>{s.title}</h4><p>{s.text}</p></article>)}
1114
+ </ScrollReveal>
1115
+
1116
+ <ScrollReveal as="p" words effect="blur">Pick a bike, choose your days and ride.</ScrollReveal>
1117
+ ```
1118
+
1119
+ - Without `items` the element itself is revealed (and hidden in the server HTML until then, no flash).
1120
+ `items` — a selector inside: each match is revealed, top to bottom; items added later are revealed too.
1121
+ - `effect`, `words`, `y`, `x`, `scale`, `blur`, `duration`, `stagger`, `wordStagger`, `delay`, `ease`.
1122
+ - `once` (false = play every time), `threshold` (0.2), `rootMargin`, `root` (the scrolling box: element, ref or selector).
1123
+ - `onEnter(el)`, `onLeave(el)`. ref → the element.
1124
+
1125
+ ### BlurIn
1126
+
1127
+ The words of a paragraph come into focus one after another, right away (for a hero already on screen).
1128
+
1129
+ ```tsx
1130
+ <BlurIn as="p" blur={12} stagger={0.05}>Slow mornings, fresh coffee and a bike waiting at the door.</BlurIn>
1131
+ ```
1132
+
1133
+ - `blur` (10 px), `y` (25), `duration` (0.7), `stagger` (0.04), `delay`, `ease`. A new text plays again.
1134
+
1135
+ ### ScrollProgress
1136
+
1137
+ A thin line that fills as the page (or a scrolling box) is read.
1138
+
1139
+ ```tsx
1140
+ <ScrollProgress style={{ position: 'sticky', top: 0 }} />
1141
+ <ScrollProgress root={panelRef} onChange={(p) => setRead(Math.round(p * 100))} />
1142
+ ```
1143
+
1144
+ - `root` — the scrolling box (default the page). `onChange(progress)` with 0…1.
1145
+ - Colour and height: `--gk-scroll-progress-c`, `--gk-scroll-progress-h`.
1146
+
1147
+ ### Odometer
1148
+
1149
+ A number that rolls digit by digit like a car's meter; only the digits that change spin.
1150
+
1151
+ ```tsx
1152
+ <Odometer value={yearly ? 1990 : 2490} format={{ style: 'currency', currency: 'THB', minimumFractionDigits: 0, maximumFractionDigits: 0 }} locale="th-TH" />
1153
+ ```
1154
+
1155
+ - `value` — a number (or a ready-made string). A new value rolls in place.
1156
+ - `format` (Intl options or `(v) => text`), `locale`, `duration` (0.9), `stagger` (0.06), `direction` (`'auto'` | `'up'` | `'down'`), `ease`.
1157
+ - `from` — roll in from this value on mount.
1158
+
1159
+ ### CountUp
1160
+
1161
+ A number that counts up on mount, and from the number on screen to the new one when it changes.
1162
+
1163
+ ```tsx
1164
+ <div className="gk-kpi"><small>Revenue today</small><b><CountUp value={stats.revenue} prefix="฿" tick /></b></div>
1165
+ <CountUp value={4.8} decimals={1} suffix=" / 5" />
1166
+ ```
1167
+
1168
+ - `value`, `from` (0), `duration` (1.2), `delay`.
1169
+ - `prefix`, `suffix`, `decimals`, `locale` ('en-US'), or your own `format(v)`.
1170
+ - `tick` — tint the number green going up, red going down.
1171
+
1172
+ ## Motion wrappers
1173
+
1174
+ Motions that wrap elements you already have: entrances for lists and grids, hover effects, a 3D tilt, a spotlight
1175
+ across cards and an endless marquee. Hover effects only run with a mouse or trackpad, and nothing moves with reduced
1176
+ motion. Everything is cleaned up when the component unmounts.
1177
+
1178
+ ### Rise
1179
+
1180
+ Lists and grids arrive one item after another; items added later arrive the same way.
1181
+
1182
+ ```tsx
1183
+ <Rise className="bike-grid" stagger={0.06}>
1184
+ {bikes.map((b) => <BikeCard key={b.id} bike={b} />)}
1185
+ </Rise>
1186
+
1187
+ <Rise kind="slide" x={-24}>{tasks.map((t) => <TaskRow key={t.id} task={t} />)}</Rise>
1188
+ <Rise kind="deal" tilt={4}>{shifts.map((s) => <ShiftCard key={s.id} shift={s} />)}</Rise>
1189
+ {open && <Rise kind="reveal"><p>Works mornings this week.</p></Rise>}
1190
+ ```
1191
+
1192
+ - `kind` — `'rise'` (fade in and float up), `'slide'` (from a side), `'deal'` (tilted cards), `'reveal'` (a small fade-down of the element itself).
1193
+ - `y`, `x`, `stagger`, `delay`, `duration`, `tilt`. `items` — a selector inside instead of the direct children.
1194
+ - `animateNew` (true) — children added later arrive too. To play everything again, change the `key`.
1195
+
1196
+ ### Magnetic
1197
+
1198
+ The element leans toward the pointer while it hovers and springs back when it leaves.
1199
+
1200
+ ```tsx
1201
+ <Magnetic strength={0.3}><Button variant="primary" iconRight="arrowR">Book a bike</Button></Magnetic>
1202
+ <Magnetic as="a" href="/bikes" className="gk-btn" magnet={1.5}>See all bikes</Magnetic>
1203
+ ```
1204
+
1205
+ - `strength` (0.2), `strengthY` (0.28), `magnet` — a multiplier for this element.
1206
+ - `<Button magnetic>` does the same for a single button.
1207
+
1208
+ ### Lift
1209
+
1210
+ The element rises a few pixels while the pointer is over it: “you can click this”.
1211
+
1212
+ ```tsx
1213
+ <Lift as="article" y={-6} className="gk-card project-card">…</Lift>
1214
+ ```
1215
+
1216
+ - `y` — px it moves (-4). Pair it with a deeper shadow in your CSS (`:hover { box-shadow: var(--gk-shadow-2) }`).
1217
+
1218
+ ### Tilt
1219
+
1220
+ The card leans toward the pointer in 3D with a soft glare; layers marked `data-depth` float above it.
1221
+
1222
+ ```tsx
1223
+ <Tilt as="article" className="gk-card" max={12} glare>
1224
+ <img data-depth="30" src="/bikes/e-bike.png" alt="" />
1225
+ <h3 data-depth="14">City e-bike</h3>
1226
+ </Tilt>
1227
+ ```
1228
+
1229
+ - `max` (12°), `scale` (1.03), `perspective` (900), `glare` (true), `parallax` (0.25), `follow` (0.35), `spring` (1).
1230
+ - Keep `overflow` visible on the card, or the layers flatten.
1231
+
1232
+ ### Spotlight
1233
+
1234
+ A soft light follows the pointer across a group of cards and lights up their edges; keyboard focus pulls it too.
1235
+
1236
+ ```tsx
1237
+ <Spotlight className="plans" size={300}>
1238
+ {plans.map((p) => <div key={p.id} className="gk-card">{p.name} · {p.price}</div>)}
1239
+ </Spotlight>
1240
+ ```
1241
+
1242
+ - `size` (240 px), `follow` (0.2 s), `border` (true), `fill` (true), `focus` (true), `items` (default: the children).
1243
+ - Colour: `--gk-spot-c`; edge: `--gk-spot-ring`.
1244
+
1245
+ ### Marquee
1246
+
1247
+ An endless sideways strip of logos or items; hover or focus slows it to a stop.
1248
+
1249
+ ```tsx
1250
+ const pause = useRef<HTMLButtonElement>(null);
1251
+
1252
+ <Marquee aria-label="Shops that ride with us" speed={50} gap={48} button={pause}>
1253
+ {partners.map((p) => <img key={p.id} src={p.logo} alt={p.name} height={28} />)}
1254
+ </Marquee>
1255
+ <button ref={pause} className="gk-btn gk-btn--sm">⏸</button>
1256
+ ```
1257
+
1258
+ - Each child becomes one item (`<li>` in a `<ul>`; `listAs` to change).
1259
+ - `speed` (50 px/s), `direction`, `gap`, `fade` change in place; `pauseOnHover` (true), `paused`.
1260
+ - `button` — a pause / play button (element, ref or selector); `words` — its labels.
1261
+ - ref → `{ play(), pause(), toggle(), paused, refresh(), el }`.
1262
+
1263
+ ### useMotion — any other helper
1264
+
1265
+ Helpers without a component of their own (`flash`, `tick`, `pop`, `shake`, `wiggle`, `swap`, `count`, `retitle`,
1266
+ `indicator`…) run on an element you render with `useMotion` from the core. It runs after mount, again when the
1267
+ options (or deps) change, and stops the tween or handle on unmount.
1268
+
1269
+ ```tsx
1270
+ import { useMotion } from '@gecko-ui-kit/react';
1271
+ import { rise, shake, tilt } from '@gecko-ui-kit/motion';
1272
+
1273
+ // a function of the element; the deps array plays it again
1274
+ const list = useMotion((el) => rise(el.querySelectorAll('.gk-row'), { stagger: 0.04 }), [rows.length]);
1275
+ <div ref={list}>{rows.map((r) => <div key={r.id} className="gk-row">{r.name}</div>)}</div>
1276
+
1277
+ // play it when something happens
1278
+ const err = useMotion((el) => (error ? shake(el) : undefined), [error]);
1279
+ <p ref={err} className="field-error">{error}</p>
1280
+
1281
+ // a helper that takes (el, options): options are compared by content
1282
+ const card = useMotion(tilt, { max: 8, glare: false });
1283
+ <article ref={card} className="gk-card">…</article>
1284
+ ```
1285
+
1286
+ ## Interactive effects
1287
+
1288
+ ### Indicator
1289
+ A highlight that stretches toward the newly active item, then snaps into place (sidebar pills, tab lines, segmented thumbs).
1290
+
1291
+ ```tsx
1292
+ import { Indicator } from '@gecko-ui-kit/react';
1293
+
1294
+ const [page, setPage] = useState('bikes');
1295
+ <Indicator as="nav" active={page} radius={99} className="gk-menu">
1296
+ {['bikes', 'bookings', 'returns'].map((p) => (
1297
+ <button key={p} aria-current={page === p ? 'page' : undefined} onClick={() => setPage(p)}>{p}</button>
1298
+ ))}
1299
+ </Indicator>
1300
+ ```
1301
+ - `active`: anything that changes when the active item changes; the pill goes to the child with `aria-current`, `aria-selected="true"`, `aria-pressed="true"` or `.gk-is-active` (`selector` to change it).
1302
+ - `radius` (13; 99 = round ends), `line` (an underline), `lead` / `trail` / `cross` (seconds per edge).
1303
+ - `pillClassName` / `pillStyle` style the pill (default: the accent colour). `as` picks the element.
1304
+ - Hook form for your own markup: `const pill = useIndicator(page, { radius: 99 })`, then `<span ref={pill} className="gk-menu__pill" />` as a child of the menu.
1305
+
1306
+ ### PageSwap
1307
+ A page transition: when `swapKey` changes, the old page steps back and fades, then the new one slides in from the side you are heading to.
1308
+
1309
+ ```tsx
1310
+ 'use client';
1311
+ import { usePathname } from 'next/navigation';
1312
+ import { PageSwap } from '@gecko-ui-kit/react';
1313
+
1314
+ export default function Template({ children }: { children: React.ReactNode }) {
1315
+ const path = usePathname();
1316
+ return <PageSwap swapKey={path} dir={1}>{children}</PageSwap>;
1317
+ }
1318
+ ```
1319
+ - `swapKey`: the page's identity (route, tab id). `dir`: `1` forward, `-1` back.
1320
+ - `leave` (blocks that drop out: `.gk-card, .gk-kpi, .lane, [data-swap]`), `head` (header parts that lift away).
1321
+ - `timing`: `{ out, in, shift, enter }` for this swap only. `onSwap(view)` runs when the new page is in.
1322
+
1323
+ ### useFeedback · useFlash · useTick
1324
+ Tiny answers to what the user just did: a pop for a press, a shake for "no", a wiggle for a new alert, a flash or tint when a value changes.
1325
+
1326
+ ```tsx
1327
+ import { useFeedback, useFlash, useTick } from '@gecko-ui-kit/react';
1328
+
1329
+ const fb = useFeedback<HTMLFormElement>();
1330
+ const totalRef = useFlash(days * 250); // bounces when the price changes
1331
+ const daysRef = useTick(days); // green when it goes up, red when down
1332
+
1333
+ <form ref={fb.ref} onSubmit={(e) => { e.preventDefault(); if (!phone) fb.shake(); }}>
1334
+ <button type="button" onClick={(e) => { fb.pop(e); setDays(days + 1); }}>+1 day</button>
1335
+ <b ref={daysRef}>{days}</b> days · <b ref={totalRef}>฿{days * 250}</b>
1336
+ </form>
1337
+ ```
1338
+ - `fb.pop()`, `fb.shake()`, `fb.wiggle()`, `fb.flash()`, `fb.tick(up)`: run on `fb.ref`, or on an element / ref / event you pass (`onClick={fb.pop}` pops the clicked button).
1339
+ - Tweens are stopped when the component unmounts. With reduced motion only the colour changes stay.
1340
+
1341
+ ### ConfettiButton · useConfetti
1342
+ A burst of paper that shoots up from a button and flutters down over the page (a few sparkles with reduced motion).
1343
+
1344
+ ```tsx
1345
+ import { ConfettiButton, useConfetti } from '@gecko-ui-kit/react';
1346
+
1347
+ <ConfettiButton variant="primary" icon="sparkle" count={150} onClick={finishProject}>Mark as done</ConfettiButton>
1348
+
1349
+ const fire = useConfetti({ spread: 120 });
1350
+ async function pay(e: React.MouseEvent) { await charge(); fire(e); } // from the clicked button
1351
+ ```
1352
+ - Options: `count` (120), `spread` (100°), `angle` (90 = up), `velocity`, `colors`, `shapes`, `gravity`, `duration` (3 s), `zIndex`, `reduced` (`'sparkle'` | `'none'`).
1353
+ - `ConfettiButton` takes every `Button` prop too; `onDone` runs when the last piece has landed. Call `event.preventDefault()` in `onClick` to skip the burst.
1354
+ - `confetti(origin, options)` is the vanilla function itself; bursts from `useConfetti` stop when the component unmounts.
1355
+
1356
+ ### Sortable
1357
+ A list you reorder by dragging (mouse at once, touch after a long press): the card lifts and tilts, the others slide aside, and it lands with a squash. React keeps the order.
1358
+
1359
+ ```tsx
1360
+ import { Sortable } from '@gecko-ui-kit/react';
1361
+
1362
+ const [lanes, setLanes] = useState({ todo: tasksTodo, doing: [], done: [] });
1363
+ <div className="board">
1364
+ {Object.entries(lanes).map(([id, tasks]) => (
1365
+ <Sortable key={id} group="board" className="lane" items={tasks} getKey={(t) => t.id}
1366
+ onReorder={(next) => setLanes((l) => ({ ...l, [id]: next }))}
1367
+ renderItem={(t) => <div className="kcard">{t.title}</div>}>
1368
+ <h3>{id}</h3>
1369
+ </Sortable>
1370
+ ))}
1371
+ </div>
1372
+ ```
1373
+ - `items` + `onReorder(next, { item, from, to, fromList, toList })` (controlled) or `defaultItems`.
1374
+ - `getKey` (a stable key), `renderItem(item, index)`, `onItemClick(item)` (pressed without moving).
1375
+ - `group`: lists with the same group pass items to each other (kanban lanes); `children` are drawn inside the drop zone, before the items.
1376
+ - `lift` (`{ scale, rotation }` in your hand), `squash`, `rotate`, `handle` (a selector to drag from), `as` / `itemAs` / `itemClassName`.
1377
+ - Buttons, inputs and links inside a card do not start a drag. Give cards `cursor: grab; user-select: none` in your CSS.
1378
+
1379
+ ### ThemeToggle · useTheme
1380
+ A round moon / sun button that switches light ↔ dark with a circular reveal growing from the button, and a hook for your own controls.
1381
+
1382
+ ```tsx
1383
+ import { ThemeToggle, useTheme } from '@gecko-ui-kit/react';
1384
+
1385
+ <ThemeToggle onChange={(t) => saveUserPref(t)} />
1386
+
1387
+ const [theme, setTheme] = useTheme();
1388
+ <button onClick={(e) => setTheme(theme === 'dark' ? 'light' : 'dark', e)}>Night mode</button>
1389
+ ```
1390
+ - `storageKey` (`'gecko:theme'`; `''` = don't save), `duration` (450 ms), `easing`, `label` (`'Switch theme'`).
1391
+ - `useTheme()` returns `'light'` on the server and the real theme in the browser (no mismatch); it also applies a saved choice if `<html>` has none.
1392
+ - To avoid a flash on load in Next.js, set it before React starts: `<html suppressHydrationWarning>` and in `<head>`
1393
+ `<script dangerouslySetInnerHTML={{ __html: "try{var t=localStorage.getItem('gecko:theme');if(t)document.documentElement.dataset.theme=t}catch(e){}" }} />`.
1394
+
1395
+ ### SendButton
1396
+ A send button whose plane winds back and flies off with a dotted trail; the button turns green and "Sent" rolls in with a tick.
1397
+
1398
+ ```tsx
1399
+ import { SendButton } from '@gecko-ui-kit/react';
1400
+
1401
+ <SendButton variant="primary" path="loop" onClick={sendReminder}>Send reminder</SendButton>
1402
+
1403
+ // play it when the server says OK:
1404
+ <SendButton variant="primary" type="submit" sent={status === 'sent'}>Send</SendButton>
1405
+ ```
1406
+ - A click plays it (unless `onClick` calls `preventDefault()`) and it comes back after `back` seconds (2.4; 0 = stays).
1407
+ - `sent` (controlled): `true` flies it off, `false` brings it back.
1408
+ - `done` ('Sent'), `path` (`'up'` | `'straight'` | `'loop'`), `trail`, `duration`, `onDone(button)`; plus `variant`, `size`, `icon` and any button prop.
1409
+
1410
+ ### DeleteButton
1411
+ A delete button whose bin opens its lid and eats its own label letter by letter, chews, and shows "Deleted".
1412
+
1413
+ ```tsx
1414
+ import { DeleteButton } from '@gecko-ui-kit/react';
1415
+
1416
+ <DeleteButton variant="danger" size="sm" back={0} onDone={() => removeBooking(id)}>Delete</DeleteButton>
1417
+ ```
1418
+ - The label is text (`children`, 'Delete'). A click plays it (unless `onClick` calls `preventDefault()`); `deleted` makes it controlled.
1419
+ - `done` ('Deleted'), `order` (`'first'` | `'last'` letter jumps first), `chew`, `back` (2.4 s; 0 = stays), `onDone(button)`.
1420
+
1421
+ ### DownloadButton
1422
+ A download button whose own outline is the progress bar; it glows, fills and draws a tick when done.
1423
+
1424
+ ```tsx
1425
+ import { DownloadButton } from '@gecko-ui-kit/react';
1426
+
1427
+ const [p, setP] = useState<number | null | undefined>();
1428
+ const [state, setState] = useState<'done' | 'failed'>();
1429
+ <DownloadButton variant="primary" progress={p} state={state} onClick={() => startDownload(setP, setState)}>
1430
+ Invoice PDF
1431
+ </DownloadButton>
1432
+ ```
1433
+ - `progress`: 0–1 fills the outline, `null` = size unknown (a segment chases round), `undefined` = not started.
1434
+ - `state`: `'loading'` (default once `progress` is set), `'done'`, `'failed'` (red + shake), `'idle'` (back to start).
1435
+ - `label(p)` (the text while loading, default '40%'), `wait` ('Preparing…'), `done` ('Done'), `fail` ('Try again'), `back` (seconds after done before it resets), `width` (outline px).
1436
+
1437
+ ### HoldButton
1438
+ For actions that must not happen by accident: press and hold, colour floods the button, and only a full hold confirms.
1439
+
1440
+ ```tsx
1441
+ import { HoldButton } from '@gecko-ui-kit/react';
1442
+
1443
+ <HoldButton tone="bad" icon="trash" hint="Hold to delete" done="Deleted" onConfirm={() => deleteBike(bike.id)}>
1444
+ Delete bike
1445
+ </HoldButton>
1446
+ <HoldButton look="ring" tone="warn" icon="lock" onConfirm={signOutEverywhere}>Sign out everywhere</HoldButton>
1447
+ ```
1448
+ - `onConfirm(button, handle)` instead of `onClick`; `onCancel(button, handle, progress)` when let go too early.
1449
+ - `duration` (1.2 s), `look` (`'fill'` | `'ring'`: a circle round a round icon button; the label becomes its accessible name), `tone` (`'bad'` | `'accent'` | `'good'` | `'warn'`).
1450
+ - `hint` ('Hold to confirm'), `done` ('Done'), `back` (seconds before it resets; 0 = stays), `haptic`, `confirmed` (controlled).
1451
+
1452
+ ### ExpandSearch
1453
+ A round magnifier that stretches into a search field, types its hint in and draws a close ×; Escape clears, then closes.
1454
+
1455
+ ```tsx
1456
+ import { ExpandSearch } from '@gecko-ui-kit/react';
1457
+
1458
+ const [q, setQ] = useState('');
1459
+ <ExpandSearch placeholder="Search bikes…" width={280} shortcut="/" value={q} onChange={setQ} onSearch={(text) => router.push(`/bikes?q=${encodeURIComponent(text)}`)} />
1460
+ ```
1461
+ - `value` / `defaultValue` + `onChange(text)`; `onSearch(text)` on Enter or a click on the magnifier.
1462
+ - `open` / `defaultOpen` + `onOpen` / `onClose`. `width` (260, or any CSS width), `typing`, `autoClose`, `shortcut` (a key that opens it from anywhere, e.g. `'/'`).
1463
+ - `look` (`'outline'` | `'quiet'`), `size` (`'md'` | `'sm'`), `label` ('Search'), `closeLabel`, `name` ('q').
1464
+
1465
+ ### LiquidTabs
1466
+ A tab bar where the bar and a bubble over the active tab move like one liquid; the active icon rides up into the bubble.
1467
+
1468
+ ```tsx
1469
+ import Link from 'next/link';
1470
+ import { LiquidTabs } from '@gecko-ui-kit/react';
1471
+
1472
+ <LiquidTabs label="Main" linkAs={Link} value={active} onChange={setActive} items={[
1473
+ { label: 'Home', icon: 'home', href: '/' },
1474
+ { label: 'Bikes', icon: 'box', href: '/bikes' },
1475
+ { label: 'Trips', icon: 'calendar', href: '/trips' },
1476
+ ]} />
1477
+ ```
1478
+ - `items`: `{ label, icon, href? }` (an `href` makes it a link; `linkAs={Link}` for Next.js).
1479
+ - `value` / `defaultValue`: the active index; `onChange(index, tabElement)` on click or arrow keys.
1480
+ - `mode` (`'dip'` | `'glide'`), `splash`, `labels` (false = icons only), `goo` (false = plain shapes), `label` (the nav's name).
1481
+
1482
+ ### Burger
1483
+ A menu button whose three lines turn into an ✕ and back; React owns `open`.
1484
+
1485
+ ```tsx
1486
+ import { Burger } from '@gecko-ui-kit/react';
1487
+
1488
+ const [open, setOpen] = useState(false);
1489
+ <Burger open={open} onToggle={setOpen} controls="main-menu" words={{ open: 'เปิดเมนู', close: 'ปิดเมนู' }} />
1490
+ <nav id="main-menu" hidden={!open}>…</nav>
1491
+ ```
1492
+ - `open` / `defaultOpen` + `onToggle(open, button)` (a click, or Escape when `escape` is on).
1493
+ - `words` (`{ open: 'Open menu', close: 'Close menu' }`), `duration` (0.45 s), `controls` (the menu's id), `size`, `iconClassName` (size the lines with `--gk-burger-w`, `--gk-burger-h`, `--gk-burger-t`).
1494
+
1495
+ ## Overlays
1496
+
1497
+ Things that pop up over the page. The vanilla `@gecko-ui-kit/overlays` code still opens, places, animates and
1498
+ stacks them; your React content is drawn inside. Esc closes the newest one (installed once, the first time one opens).
1499
+
1500
+ ### Modal
1501
+
1502
+ A dialog in the middle of the screen that zooms out of the button that opened it (a bottom sheet on phones).
1503
+
1504
+ ```tsx
1505
+ const [open, setOpen] = useState(false);
1506
+ const editBtn = useRef<HTMLButtonElement>(null);
1507
+
1508
+ <Button ref={editBtn} icon="edit" onClick={() => setOpen(true)}>Edit bike</Button>
1509
+ <Modal open={open} onClose={() => setOpen(false)} anchor={editBtn} title="Edit bike" sub="Honda Click · กข 1234"
1510
+ footer={<><Button onClick={() => setOpen(false)}>Cancel</Button><Button variant="primary" onClick={save}>Save</Button></>}>
1511
+ <BikeForm bike={bike} />
1512
+ </Modal>
1513
+ ```
1514
+
1515
+ - `open` / `onClose()` — closing from inside (✕, scrim, Esc) calls `onClose`; set `open` to false there.
1516
+ - `title`, `sub` — text or React nodes; they may change while it is open.
1517
+ - `size` — `''`, `'sm'` or `'lg'`. `anchor` — element or ref it zooms out of. `footer` — buttons at the bottom.
1518
+ - `words` — `{ close }`, the ✕ button's label for screen readers (default `'Close'`), e.g. `words={{ close: 'ปิด' }}`.
1519
+
1520
+ ### Drawer
1521
+
1522
+ A panel that slides in from the side (a bottom sheet on phones); its content drifts up as it lands.
1523
+
1524
+ ```tsx
1525
+ <Drawer open={!!rider} onClose={() => setRider(null)} title={rider?.name} sub={`Rider since ${rider?.since}`}
1526
+ head={<span className="gk-av gk-av--teal">{rider?.initials}</span>} footer={<Button variant="primary">Message</Button>}>
1527
+ <RiderBookings id={rider?.id} />
1528
+ </Drawer>
1529
+ ```
1530
+
1531
+ - `open` / `onClose()`, `title`, `sub`, `footer`, `words` — as in Modal.
1532
+ - `head` — something before the title (an avatar). `side` — `'right'` (default) or `'left'`.
1533
+ - Opening a drawer closes any other drawer (its `onClose` runs).
1534
+
1535
+ ### confirm / useConfirm
1536
+
1537
+ An “are you sure?” dialog you `await`: `true` for OK, `false` for Cancel, ✕, scrim or Esc.
1538
+
1539
+ ```tsx
1540
+ const confirm = useConfirm();
1541
+
1542
+ async function cancelBooking(b: Booking) {
1543
+ if (!(await confirm({ title: `Cancel booking #${b.id}?`, body: 'The rider gets a full refund.', ok: 'Cancel booking', danger: true }))) return;
1544
+ await api.cancel(b.id);
1545
+ toast('Booking cancelled', { tone: 'good' });
1546
+ }
1547
+ ```
1548
+
1549
+ - `title`, `body`, `ok`, `cancel` — plain text (safe for your data). `danger` — red OK button. `anchor` — zooms out of it.
1550
+ - `confirm()` works anywhere; `useConfirm()` also closes a dialog that is still open when the component unmounts.
1551
+
1552
+ ### Popover
1553
+
1554
+ A small panel that pops out of its trigger (the one child), with its origin pointing back at it.
1555
+
1556
+ ```tsx
1557
+ <Popover align="end" label="Share" className="gk-pop--wide"
1558
+ content={(close) => <ShareBooking id={booking.id} onCopied={() => { close(); toast('Link copied', { icon: 'copy' }); }} />}>
1559
+ <Button icon="send">Share</Button>
1560
+ </Popover>
1561
+ ```
1562
+
1563
+ - `content` — React nodes, or `(close) => nodes`.
1564
+ - Clicking the trigger toggles it; a click outside, Esc or a resize closes it.
1565
+ - `open` + `onOpenChange(open)` to control it, or `defaultOpen`. `align` — `'start' | 'center' | 'end'`. `className`, `label`.
1566
+ - `ref` → `{ open(), close(), isOpen, el }`.
1567
+
1568
+ ### Menu
1569
+
1570
+ A popover with a ready-made list of actions that slide in; ↑ ↓ move between them.
1571
+
1572
+ ```tsx
1573
+ <Menu align="end" items={[
1574
+ { section: 'Booking' },
1575
+ { icon: 'edit', label: 'Edit', kbd: 'E', run: () => edit(b) },
1576
+ { icon: 'copy', label: 'Duplicate', run: () => duplicate(b) },
1577
+ '-',
1578
+ { icon: 'trash', label: 'Cancel booking', danger: true, run: () => cancelBooking(b) },
1579
+ ]}>
1580
+ <Button icon="more" aria-label="More" />
1581
+ </Menu>
1582
+ ```
1583
+
1584
+ - `items` — `{ label, icon, kbd, danger, run(trigger) }`, `{ section: 'Heading' }`, or `'-'` for a line.
1585
+ - `onSelect(item, index)` — after any action (after its `run`). `align`, `className`, `label`. `ref` → `{ open(), close(), isOpen }`.
1586
+
1587
+ ### ContextMenu
1588
+
1589
+ The menu you get with a right-click, a long-press on touch screens or Shift+F10. It grows from the pointer and has submenus and ticks.
1590
+
1591
+ ```tsx
1592
+ <ContextMenu as="tbody" selector="tr[data-id]"
1593
+ items={(event, row) => [
1594
+ { section: `Booking #${row.dataset.id}` },
1595
+ { icon: 'edit', label: 'Edit', kbd: 'E', run: () => edit(row.dataset.id) },
1596
+ { label: 'Move to', items: bikes.map((bike) => ({ label: bike.name, run: () => move(row.dataset.id, bike.id) })) },
1597
+ { label: 'Paid', checked: isPaid(row.dataset.id), run: (_el, item) => setPaid(row.dataset.id, item.checked) },
1598
+ '-',
1599
+ { icon: 'trash', label: 'Cancel', danger: true, run: () => cancelBooking(row.dataset.id) },
1600
+ ]}>
1601
+ {bookings.map((b) => <tr key={b.id} data-id={b.id}>…</tr>)}
1602
+ </ContextMenu>
1603
+ ```
1604
+
1605
+ - `items` — a list, or `(event, el) => list` on every open (return `[]` to get the browser's own menu).
1606
+ Rows: `{ label, icon, kbd, hint, disabled, danger, checked, items, run(el, item) }`, `{ section }`, `'-'`.
1607
+ - `checked` rows flip on a copy (never your data): `run` / `onSelect` get the new value in `item.checked`.
1608
+ - `selector`, `longPress` (ms, 0 = off), `nativeOnShift`, `icons`, `shortcuts`, `words: { label }`, `onSelect(item, el)`, `onOpen`, `onClose`.
1609
+ - `as` — the wrapper element (default `div`). `ref` → `{ open(x, y, el?), close(), isOpen, menu, el }`.
1610
+
1611
+ ### Tooltip
1612
+
1613
+ A small label that fades in under (or beside) an element on hover or keyboard focus. Hidden on phones.
1614
+
1615
+ ```tsx
1616
+ <Tooltip text="Edit booking"><Button icon="edit" aria-label="Edit booking" /></Tooltip>
1617
+ <Tooltip text={<>Somchai K.<br />Mechanic</>} side="right"><span className="gk-av gk-av--teal" tabIndex={0}>SK</span></Tooltip>
1618
+ ```
1619
+
1620
+ - `text` — a string (a `\n` makes a second line) or React nodes. `side` — `'below'` (default) or `'right'`.
1621
+ - `disabled` — turn it off for now. Inside an element with `data-tips-right` it opens to the right.
1622
+ - For plain HTML elements you can still use `data-tip="…"` with `initTips()` from `@gecko-ui-kit/overlays`.
1623
+
1624
+ ### toast
1625
+
1626
+ A short message that pops up at the bottom and goes away by itself. A plain function: call it from anywhere.
1627
+
1628
+ ```tsx
1629
+ toast('Booking saved', { tone: 'good' });
1630
+ toast('Bike moved to the workshop', { icon: 'tool', undo: () => moveBack(bike) });
1631
+ const close = toast('Uploading photos…', { duration: 60000 }); // close() when done
1632
+ ```
1633
+
1634
+ - `tone` — `''`, `'good'`, `'warn'` or `'bad'`. `icon` — an icon name. `duration` — ms (default 4200).
1635
+ - `undo` — adds an Undo button; `undoLabel`, `undoneText`. The text is shown as plain text (safe for your data).
1636
+
1637
+ ### CookieBanner
1638
+
1639
+ Asks once which cookies a visitor allows, remembers the answer and stays away until you raise `version`.
1640
+
1641
+ ```tsx
1642
+ const cookies = useRef<CookieBannerHandle>(null);
1643
+
1644
+ <CookieBanner ref={cookies} policy="/privacy" position="end"
1645
+ onChange={(choices) => { if (choices.analytics) loadAnalytics(); }} />
1646
+ <footer><button onClick={() => cookies.current?.open({ settings: true })}>Cookie settings</button></footer>
1647
+ ```
1648
+
1649
+ - `categories` — `{ id, label, text, required }[]` (default: necessary, analytics, marketing). Optional ones start off.
1650
+ - `storageKey` (default `'gecko:consent'`, `''` = never saved), `version`, `show` (`'auto'` or `false`), `position` (`'bottom' | 'start' | 'end'`), `mount`, `policy`, `words`.
1651
+ - `onChange(choices, { action, at })`. `ref` → `{ choices, allowed(id), open({ settings }), close(), reset(), visible, el }`.
1652
+
1653
+ ### LoadingBar / useLoadingBar
1654
+
1655
+ The thin line along the top of the page while something loads. Quick loads never show it.
1656
+
1657
+ ```tsx
1658
+ // with a state
1659
+ const [isPending, startTransition] = useTransition();
1660
+ <LoadingBar active={isPending} />
1661
+
1662
+ // or by hand
1663
+ const bar = useLoadingBar({ color: 'var(--gk-good)' });
1664
+ async function save() { bar.start(); try { await api.save(booking); bar.done(); } catch { bar.fail(); } }
1665
+ ```
1666
+
1667
+ - `<LoadingBar active>` starts when `active` turns true and finishes when it turns false.
1668
+ - `useLoadingBar(options)` → `{ start(), done(all?), fail(), set(0..1), inc(n), value, loads, active, el }`, the same object for the component's life.
1669
+ - Options: `mount` (element, ref or selector; default the window), `height`, `color`, `trickle`, `delay`, `label`, `words`.
1670
+
1671
+ ### CommandPalette
1672
+
1673
+ The ⌘K search window: type, move with the arrow keys, Enter picks, Esc closes.
1674
+
1675
+ ```tsx
1676
+ <CommandPalette open={open} onClose={() => setOpen(false)} placeholder="Search bikes and riders…"
1677
+ search={(q) => [
1678
+ { label: 'Bikes', items: bikes.filter((b) => b.name.toLowerCase().includes(q)).map((b) => ({ title: b.name, sub: b.plate, icon: 'bike', run: () => router.push(`/bikes/${b.id}`) })) },
1679
+ { label: 'Riders', items: riders.filter((r) => r.name.toLowerCase().includes(q)).map((r) => ({ title: r.name, sub: r.phone, icon: 'user', run: () => openRider(r) })) },
1680
+ ]} />
1681
+ ```
1682
+
1683
+ - `search(q)` → groups `{ label, items: [{ title, sub, icon, run }] }`; `q` is trimmed and lowercased.
1684
+ - `open` / `onClose()`, `onSelect(item)`, `placeholder`, `emptyTitle`, `emptyBody`.
1685
+ - Inside `<AppShell>`, ⌘K already opens a palette with your pages; add groups with its `search` prop.
1686
+
1687
+ ### Tour
1688
+
1689
+ A walk-through: the page dims except a spotlight around each stop, and a bubble explains it. ← → move, Esc ends.
1690
+
1691
+ ```tsx
1692
+ const searchRef = useRef<HTMLButtonElement>(null);
1693
+
1694
+ <Tour open={touring} onEnd={(finished) => { setTouring(false); if (finished) markTourSeen(); }} steps={[
1695
+ { title: 'Welcome to MotoRent', text: 'A one-minute look around.' },
1696
+ { target: searchRef, title: 'Find a bike', text: 'Search by name or plate number.' },
1697
+ { target: '#calendar', title: 'Bookings', content: <p>Drag a booking to <b>move</b> it to another bike.</p> },
1698
+ ]} />
1699
+ ```
1700
+
1701
+ - `steps` — `{ target, title, text, content, placement, padding, radius }`. `target`: a ref, element or selector
1702
+ (missing → skipped; none → bubble in the middle). `content`: React nodes instead of `text`.
1703
+ - `open`, `start`, `onStep(index, step)`, `onEnd(finished)` (setting `open` to false ends it quietly).
1704
+ - `placement`, `padding`, `radius`, `backdrop`, `scroll`, `words`. `ref` → `{ start(i), next(), prev(), go(i), stop(), index, active }`.
1705
+
1706
+ ### Lightbox
1707
+
1708
+ Full-screen photos that grow out of their thumbnail and shrink back into it. Swipe, zoom, drag down to close.
1709
+
1710
+ ```tsx
1711
+ const thumbs = useRef<(HTMLImageElement | null)[]>([]);
1712
+ const [shown, setShown] = useState(-1);
1713
+
1714
+ {bike.photos.map((p, i) => <img key={p.id} ref={(el) => { thumbs.current[i] = el; }} src={p.thumb} alt={p.alt} onClick={() => setShown(i)} />)}
1715
+ <Lightbox open={shown >= 0} index={Math.max(0, shown)} onChange={setShown} onClose={() => setShown(-1)}
1716
+ items={bike.photos.map((p, i) => ({ src: p.big, alt: p.alt, caption: p.caption, from: thumbs.current[i] }))} />
1717
+ ```
1718
+
1719
+ - `items` — image addresses or `{ src, alt, caption, w, h, from }` (`from`: the thumbnail element, ref or selector).
1720
+ - `open`, `index` (changing it while open moves there), `onChange(index)`, `onClose(index)`, `zoom`, `maxZoom`, `words`.
1721
+
1722
+ ### LightboxGallery
1723
+
1724
+ The no-state version: wrap links to big images and clicking one opens its whole group.
1725
+
1726
+ ```tsx
1727
+ <LightboxGallery className="photos">
1728
+ {bike.photos.map((p) => <a key={p.id} href={p.big} data-lightbox="bike" data-caption={p.caption}><img src={p.thumb} alt={p.alt} /></a>)}
1729
+ </LightboxGallery>
1730
+ ```
1731
+
1732
+ - Elements with the same `data-lightbox` value form one gallery; image from `href`, `data-src` or the inner `<img>`.
1733
+ - `selector`, `zoom`, `maxZoom`, `words`, `onChange`, `onClose`, `as`.
1734
+
1735
+ ## App shell
1736
+
1737
+ The app frame — sidebar, topbar, page header, phone tab bar — for a Next.js app. These components draw the same
1738
+ markup as `createShell()` (so they render on the server), but the router is Next's: you pass the current path and
1739
+ `onNavigate`, and your pages are ordinary React children.
1740
+
1741
+ ### AppShell
1742
+
1743
+ The whole frame around your pages: Sidebar, Topbar, the page in `<main class="gk-view">`, the phone tab bar, the ⌘K
1744
+ palette, keyboard shortcuts and the opening animation. When the path changes, the new page slides in from the
1745
+ direction of travel.
1746
+
1747
+ ```tsx
1748
+ // app/(app)/layout.tsx
1749
+ 'use client';
1750
+ import Link from 'next/link';
1751
+ import { usePathname, useRouter } from 'next/navigation';
1752
+ import { AppShell } from '@gecko-ui-kit/react';
1753
+
1754
+ const nav = [
1755
+ { label: 'Shop', items: [
1756
+ { id: 'today', label: 'Today', icon: 'today', href: '/' },
1757
+ { id: 'bikes', label: 'Bikes', icon: 'layers', subs: [['fleet', 'Fleet'], ['repairs', 'Repairs']] }, // /bikes/fleet, /bikes/repairs
1758
+ { id: 'bookings', label: 'Bookings', icon: 'rota', count: () => pending.length },
1759
+ ] },
1760
+ { label: 'People', items: [{ id: 'riders', label: 'Riders', icon: 'people' }] },
1761
+ ];
1762
+
1763
+ export default function Layout({ children }: { children: React.ReactNode }) {
1764
+ const router = useRouter();
1765
+ return (
1766
+ <AppShell brand={{ name: 'MotoRent', sub: 'Chiang Mai' }} nav={nav} end={[{ id: 'settings', label: 'Settings', icon: 'settings' }]}
1767
+ user={{ name: 'Pim Wong', role: 'Manager', menu: [{ icon: 'user', label: 'Profile', run: () => router.push('/profile') }] }}
1768
+ path={usePathname()} onNavigate={(href) => router.push(href)} link={Link} storageKey="motorent"
1769
+ top={{ search: { placeholder: 'Search bikes…' }, bell: { count: unread, onClick: openInbox }, primary: { label: 'New booking', run: newBooking } }}
1770
+ search={(q) => [{ label: 'Bikes', items: findBikes(q).map((b) => ({ title: b.name, sub: b.plate, icon: 'layers', run: () => router.push(`/bikes/${b.id}`) })) }]}>
1771
+ {children}
1772
+ </AppShell>
1773
+ );
1774
+ }
1775
+ ```
1776
+
1777
+ - `nav` (groups of `{ id, label, icon, href, count, subs, blurb, tabs }`), `end` (items pinned to the bottom), `brand`, `user`.
1778
+ An item's address is `href`, else `/${id}` (`base` adds a prefix); a sub-page's is `/${id}/${subId}`.
1779
+ - `path` — the current path (`usePathname()`); `onNavigate(href)` — called by every link, menu, the palette and keys; `link` — e.g. Next's `Link`.
1780
+ - `top` — `{ search: { placeholder, onOpen } | false, theme, bell: { count, onClick }, primary: { label, icon, run }, extra }`. `crumbsRoot`.
1781
+ - `tabbar` (ids for the phone tab bar), `tabs`, `intro`, `shortcuts`, `keys: [{ key, label, run }]`, `search(q)`, `storageKey`, `railBreakpoint`, `mobile`, `words`.
1782
+ - `useShell()` inside it → `{ route, path, navigate, palette(), shortcuts(), intro(), setRail(b), isRail() }`.
1783
+ - Put `shellBootScript({ storageKey })` in an inline `<script>` in your `<head>` so the saved theme and rail are set before the first paint
1784
+ (and add `suppressHydrationWarning` to `<html>`). Set the page title with Next's `metadata`.
1785
+
1786
+ ### Sidebar
1787
+
1788
+ The main menu: a pill stretches to the current item, the open section unfolds its sub-pages, counts flash when
1789
+ they change, and it collapses to a rail of icons with a flyout on hover. On phones it is a drawer.
1790
+
1791
+ ```tsx
1792
+ <Sidebar brand={{ name: 'Friday', sub: 'Projects', icon: 'logo' }} nav={nav} end={end} user={me}
1793
+ path={pathname} onNavigate={(href) => router.push(href)} storageKey="friday" />
1794
+ ```
1795
+
1796
+ - Same `nav`, `end`, `path`, `base`, `home`, `onNavigate`, `link`, `words` as AppShell; `brand`, `user`, `storageKey`, `railBreakpoint`, `mobile`.
1797
+ - Clicking the open item folds its sub-pages instead of navigating. The `[` key and the panel button switch the rail (inside AppShell).
1798
+ - `ref` → `{ setRail(rail), isRail(), el }`.
1799
+
1800
+ ### Topbar
1801
+
1802
+ The bar above the page: breadcrumbs from the route, a search button, your own buttons, a theme switch that
1803
+ spreads from the button, a bell whose badge pops when the number goes up, and one main action.
1804
+
1805
+ ```tsx
1806
+ <Topbar nav={nav} path={pathname} onNavigate={router.push} crumbsRoot="Friday"
1807
+ search={{ placeholder: 'Search projects…', onOpen: () => setSearching(true) }}
1808
+ bell={{ count: unread, onClick: (button) => openInbox(button) }}
1809
+ primary={{ label: 'New project', icon: 'plus', run: () => setCreating(true) }}>
1810
+ <TimerButton />
1811
+ </Topbar>
1812
+ ```
1813
+
1814
+ - `crumbsRoot`, `search` (`false` hides it), `theme` (`false` hides it), `bell: { count, onClick(button) }`, `primary: { label, icon, tip, run(button) }`.
1815
+ - `children` go before the theme switch. The menu button (phones) opens the Sidebar drawer.
1816
+
1817
+ ### PageHeader
1818
+
1819
+ The top of a page: an eyebrow, a big title whose letters roll up (again when it changes), a line of text,
1820
+ buttons on the right, and tabs with an underline that stretches to the chosen tab.
1821
+
1822
+ ```tsx
1823
+ // app/(app)/bikes/repairs/page.tsx — inside AppShell the Bikes sub-pages become link tabs by themselves
1824
+ <PageHeader eyebrow="Workshop" title="Repairs" sub="Bikes in the workshop this week."
1825
+ actions={<Button variant="primary" icon="plus">Book a repair</Button>} counts={{ repairs: waiting.length }} />
1826
+
1827
+ // your own tabs (buttons)
1828
+ <PageHeader title="Project Apollo" tabs={[['board', 'Board'], ['list', 'List'], ['files', 'Files', 4]]} value={view} onTabChange={setView} />
1829
+ ```
1830
+
1831
+ - `title` (text), `eyebrow`, `sub`, `actions` (React nodes).
1832
+ - `tabs` — `[{ id, label, count, href }]` or `[id, label, count?, href?]`; with `href` they are links, without they are buttons (`value` + `onTabChange(id)`).
1833
+ Inside AppShell, leave it out to get the current item's sub-pages; `tabs={false}` hides them. `counts: { tabId: n }` adds badges.
1834
+ - Letters are split by grapheme, so Thai vowels and tone marks stay on their letter.
1835
+
1836
+ ### MobileTabbar
1837
+
1838
+ On phones (760px and below) a tab bar at the bottom with your main sections; a soft highlight stretches to the
1839
+ current one and “More” lists the rest. Hidden on wider screens.
1840
+
1841
+ ```tsx
1842
+ <MobileTabbar nav={nav} end={end} path={pathname} onNavigate={router.push} tabbar={['today', 'bikes', 'bookings', 'riders']} />
1843
+ ```
1844
+
1845
+ - `tabbar` — ids that get a tab (default: the first four items). The rest go under “More” (`words.more`).
1846
+
1847
+ ## Helpers
1848
+
1849
+ - `useMotion(fn, options | deps)`: run any `@gecko-ui-kit/motion` helper on an element you render; it is cleaned up
1850
+ on unmount.
1851
+ - `useControllable(value, defaultValue, onChange)`: the controlled / uncontrolled pattern the components use.
1852
+ - `mounted(name, mountFn, spec)` and `enhancer(name, motionFn, spec)`: turn your own vanilla-style piece into a
1853
+ component the same way this package does (see `src/core.js`).
1854
+ - `<Icon name="bike" />`: any icon from `@gecko-ui-kit/icons`.
1855
+
1856
+ ## Tests
1857
+
1858
+ `npm run check:react` in the repo draws every component on the server, hydrates it in a browser inside React
1859
+ StrictMode on a desktop (light) and a phone (dark, reduced motion), clicks and types through it, unmounts it and checks
1860
+ nothing is left behind. It runs on every push.