anvilui 0.2.0 → 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.
Files changed (45) hide show
  1. package/AGENTS.md +29 -29
  2. package/README.md +42 -89
  3. package/dist/components/Combobox/Combobox.d.ts +8 -2
  4. package/dist/components/DateInput/DateInput.d.ts +5 -3
  5. package/dist/components/IconButton/IconButton.d.ts +5 -3
  6. package/dist/components/Input/Input.d.ts +5 -3
  7. package/dist/components/PinInput/PinInput.d.ts +5 -3
  8. package/dist/components/Progress/Progress.d.ts +4 -1
  9. package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
  10. package/dist/components/Search/Search.d.ts +22 -6
  11. package/dist/components/Select/Select.d.ts +6 -2
  12. package/dist/components/Slider/Slider.d.ts +2 -1
  13. package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
  14. package/dist/components/Textarea/Textarea.d.ts +6 -3
  15. package/dist/components/TimePicker/TimePicker.d.ts +7 -5
  16. package/dist/components/Toggle/Toggle.d.ts +2 -1
  17. package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -2
  18. package/dist/index.cjs +302 -62
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.css +48 -25
  21. package/dist/index.css.map +1 -1
  22. package/dist/index.js +336 -88
  23. package/dist/index.js.map +1 -1
  24. package/dist/themes/types.d.ts +0 -4
  25. package/dist/utils.d.ts +4 -0
  26. package/docs/badge.md +41 -41
  27. package/docs/combobox.md +2 -1
  28. package/docs/composition.md +1 -1
  29. package/docs/date-input.md +4 -3
  30. package/docs/forms.md +1 -1
  31. package/docs/icon-button.md +3 -2
  32. package/docs/input.md +1 -0
  33. package/docs/morph.md +4 -1
  34. package/docs/pin-input.md +1 -1
  35. package/docs/progress.md +37 -37
  36. package/docs/radio-group.md +17 -0
  37. package/docs/search.md +7 -7
  38. package/docs/select.md +3 -2
  39. package/docs/slider.md +49 -49
  40. package/docs/textarea.md +1 -1
  41. package/docs/theming.md +2 -1
  42. package/docs/time-picker.md +3 -2
  43. package/docs/toggle-group.md +1 -1
  44. package/docs/toggle.md +2 -2
  45. package/package.json +2 -2
@@ -13,10 +13,6 @@ export type Theme = {
13
13
  surface: string;
14
14
  /** Text and icons on `surface`. */
15
15
  onSurface: string;
16
- /** @deprecated Renamed to `surface`. Still read if that's missing. */
17
- surfaceVariant?: string;
18
- /** @deprecated Renamed to `onSurface`. Still read if that's missing. */
19
- onSurfaceVariant?: string;
20
16
  /** Borders of inputs and outlined controls. */
21
17
  outline: string;
22
18
  /** Thin lines between content: dividers, table lines, tab underlines. */
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { Ref, RefCallback } from 'react';
2
2
  export declare function cx(...parts: (string | false | null | undefined)[]): string;
3
3
  export declare function withClass<State>(base: string, className: string | ((state: State) => string | undefined) | undefined): (state: State) => string;
4
+ export declare function splitControlProps<P extends object>(props: P): {
5
+ control: Record<string, unknown>;
6
+ rest: P;
7
+ };
4
8
  export declare function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T>;
package/docs/badge.md CHANGED
@@ -1,41 +1,41 @@
1
- # Badge
2
-
3
- A dot or count on the corner of what it wraps, or inline on its own. Error-colored by default. Hidden from screen readers.
4
-
5
- ```ts
6
- import { Badge } from 'anvilui'
7
- ```
8
-
9
- | Prop | Type | Default | Description |
10
- | --- | --- | --- | --- |
11
- | `count` | `number` | | Omit for a dot; `0` hides it. |
12
- | `max` | `number` | `999` | Above shows "999+". |
13
- | `color` | `ComponentColor` | `'error'` | |
14
- | `children` | `ReactNode` | | What it sits on. |
15
-
16
- No `content` / `badgeContent` / `variant`.
17
-
18
- ```tsx
19
- import { Badge, Icon, IconButton } from 'anvilui'
20
-
21
- export function Example() {
22
- return (
23
- <>
24
- <Badge count={3}>
25
- <IconButton
26
- icon="mail"
27
- aria-label="Inbox, 3 unread"
28
- fillType="text"
29
- color="container"
30
- />
31
- </Badge>
32
- <Badge>
33
- <Icon name="notifications" />
34
- </Badge>
35
- <Badge count={12} color="primary" />
36
- </>
37
- )
38
- }
39
- ```
40
-
41
- Put the count in the wrapped element's `aria-label` too. On a non-interactive icon, label the icon: `<Badge count={4}><Icon name="chat_bubble" aria-label="4 comments" /></Badge>`.
1
+ # Badge
2
+
3
+ A dot or count on the corner of what it wraps, or inline on its own. Error-colored by default. Hidden from screen readers.
4
+
5
+ ```ts
6
+ import { Badge } from 'anvilui'
7
+ ```
8
+
9
+ | Prop | Type | Default | Description |
10
+ | --- | --- | --- | --- |
11
+ | `count` | `number` | | Omit for a dot; `0` hides it. |
12
+ | `max` | `number` | `999` | Above shows "999+". |
13
+ | `color` | `ComponentColor` | `'error'` | |
14
+ | `children` | `ReactNode` | | What it sits on. |
15
+
16
+ No `content` / `badgeContent` / `variant`.
17
+
18
+ ```tsx
19
+ import { Badge, Icon, IconButton } from 'anvilui'
20
+
21
+ export function Example() {
22
+ return (
23
+ <>
24
+ <Badge count={3}>
25
+ <IconButton
26
+ icon="mail"
27
+ aria-label="Inbox, 3 unread"
28
+ fillType="text"
29
+ color="container"
30
+ />
31
+ </Badge>
32
+ <Badge>
33
+ <Icon name="notifications" />
34
+ </Badge>
35
+ <Badge count={12} color="primary" />
36
+ </>
37
+ )
38
+ }
39
+ ```
40
+
41
+ Put the count in the wrapped element's `aria-label` too. On a non-interactive icon, label the icon: `<Badge count={4}><Icon name="chat_bubble" aria-label="4 comments" /></Badge>`.
package/docs/combobox.md CHANGED
@@ -21,7 +21,8 @@ import type { ComboboxProps, ComboboxItemProps } from 'anvilui'
21
21
  | `placeholder` | `string` | | |
22
22
  | `empty` | `ReactNode` | | Shown when nothing matches; without it the popup hides. |
23
23
  | `size` | `'small' \| 'normal'` | `'normal'` | |
24
- | `className` | `string` | | On the field wrapper. |
24
+ | `className`, `style` | | | On the field wrapper. |
25
+ | `ref`, `id`, `aria-*`, `data-*` | | | On the text `<input>`. |
25
26
  | `name`, `disabled`, `required`, `filter`, `limit` | | | Base UI Combobox.Root props. |
26
27
 
27
28
  ## ComboboxItem props
@@ -57,7 +57,7 @@ export function Example() {
57
57
 
58
58
  - Every component takes `ref` (React 19 `ref` prop) and passes unknown props to its main element.
59
59
  - `className` is merged with the library's classes, never replaced. On Base UI-based parts it can also be a function of state: `className={(state) => state.open ? 'open' : ''}`.
60
- - **Field-like components put `className` on the outer wrapper** (so width and margins work) and `ref` on the input: `Input`, `Textarea`, `DateInput`. `Select`, `Combobox`, `Search` put `className` on the field wrapper; their other props go to the Base UI Root, which renders no element.
60
+ - **Field-like components split their props** (`Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Search`, `TimePicker`, `PinInput`): `className` and `style` go on the outer wrapper, so width and margins work; `ref`, `id`, `aria-*` and `data-*` go on the control. The control is the `<input>` / `<textarea>`, or the button for `Select` and `TimePicker`. `PinInput`'s `ref` is its group of boxes.
61
61
  - `Tooltip` puts `className` on the bubble. `FABMenu` puts it on the FAB.
62
62
 
63
63
  ## State props
@@ -13,7 +13,8 @@ import type { DateInputProps } from 'anvilui'
13
13
  | `onValueChange` | `(value: string \| null) => void` | | `null` when cleared. |
14
14
  | `label` | `ReactNode` | | Either this or `aria-label`. |
15
15
  | `size` | `'small' \| 'normal'` | `'normal'` | |
16
- | `className` | `string` | | On the wrapper. |
16
+ | `name` | `string` | | Submits `"YYYY-MM-DD"` with the form (also when the name comes from a `Field`). |
17
+ | `className`, `style` | | | On the wrapper; `ref` and other props go on the `<input>`. |
17
18
  | `disabled`, `required`, `id`, `onBlur` | | | On the `<input>`. |
18
19
 
19
20
  No `min` / `max` / disabled dates.
@@ -30,9 +31,9 @@ export function Example() {
30
31
  label="Start date"
31
32
  value={start}
32
33
  onValueChange={setStart}
34
+ name="start"
33
35
  />
34
- {/* `name` on DateInput would submit the locale-formatted text; submit the ISO value like this */}
35
- <input type="hidden" name="start" value={start ?? ''} />
36
+ {/* Submits start=2026-11-06, not the text shown in the field */}
36
37
  </form>
37
38
  )
38
39
  }
package/docs/forms.md CHANGED
@@ -73,7 +73,7 @@ Rules:
73
73
  - Custom rules: `validate={(value) => value ? null : 'Required'}` returns an error string or `null`. A failing `validate` blocks submit once it has run, so on a plain `<form>` use `validationMode="onBlur"` or `"onChange"` with it (the default is `"onSubmit"`). Keep a final check in `onSubmit` for anything that must hold.
74
74
  - Controls that work inside `Field`: `Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Checkbox`, `Switch`, `RadioGroup`, `Slider`.
75
75
  - `Button loading` disables the button, so it also blocks repeat submits.
76
- - `Select` with `name` submits the item's `value`, not its label.
76
+ - `Select` with `name` submits the item's `value`, not its label. `DateInput` submits `"YYYY-MM-DD"` and `TimePicker` `"HH:mm"`, not the text they show.
77
77
  - Server errors: `<Field invalid>` plus `<FieldError match>` with your message (`match` true shows it whenever the field is invalid).
78
78
  - Values: `DateInput` and `Calendar` use `"YYYY-MM-DD"`, `TimePicker` `"HH:mm"`, `Slider` a number (or `number[]`).
79
79
  - There is no form library integration and no `Form` component. A plain `<form>` works. With react-hook-form, use controlled props (`value` + `onValueChange` / `checked` + `onCheckedChange`) in `Controller`.
@@ -1,6 +1,6 @@
1
1
  # IconButton
2
2
 
3
- A round 40px button with only an icon. `aria-label` is required.
3
+ A round button with only an icon. `aria-label` is required.
4
4
 
5
5
  ```ts
6
6
  import { IconButton } from 'anvilui'
@@ -15,9 +15,10 @@ import type { IconButtonProps } from 'anvilui'
15
15
  | `aria-label` | `string` | required | What the button does. |
16
16
  | `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
17
17
  | `color` | `ComponentColor` | `'primary'` | |
18
+ | `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 32, 40 or 48px, like `Button`. |
18
19
  | `disabled` | `boolean` | `false` | |
19
20
 
20
- Takes no `children` and has **no `size` prop** (always 40px). Also takes Base UI Button props and `<button>` attributes.
21
+ Takes no `children`. Also takes Base UI Button props and `<button>` attributes.
21
22
 
22
23
  ## Example
23
24
 
package/docs/input.md CHANGED
@@ -17,6 +17,7 @@ import type { InputProps } from 'anvilui'
17
17
  | `onValueChange` | `(value: string, details) => void` | | The string. |
18
18
  | `onChange` | `ChangeEventHandler<HTMLInputElement>` | | The native event also works. |
19
19
  | `className` | `string` | | On the **wrapper** `<label>` (width, margins). |
20
+ | `style` | `CSSProperties` | | On the wrapper too. |
20
21
  | `ref` | | | On the `<input>`. |
21
22
  | everything else | `<input>` attributes | | `type`, `name`, `placeholder`, `required`, `disabled`, `autoComplete`, … go on the `<input>`. |
22
23
 
package/docs/morph.md CHANGED
@@ -46,6 +46,9 @@ export function Albums() {
46
46
  ```
47
47
 
48
48
  - Give both elements the same `data-morph-id`.
49
- - `update` must change the view **synchronously** (set state, or `navigate(to, { flushSync: true })` in React Router).
49
+ - `update` must change the view **synchronously** (set state, or `navigate(to, { flushSync: true })` in React Router). A view that waits on data or a lazy route has nothing to morph into yet.
50
+ - The box's size, position, background, corners and shadow animate; the content crossfades.
51
+ - It returns a promise that resolves when the morph ends, e.g. to move focus: `await morph(id, close); row.focus()`.
52
+ - `duration` and `easing` default to the theme's `easeLength.slow` and `ease.smooth`.
50
53
  - Without View Transitions support, or with reduced motion, `update` just runs.
51
54
  - `Dialog` and `Popover` take `morph` (boolean) to do this between their trigger and popup.
package/docs/pin-input.md CHANGED
@@ -19,7 +19,7 @@ import type { PinInputProps } from 'anvilui'
19
19
  | `fillType` | `'filled' \| 'outlined'` | `'outlined'` | |
20
20
  | `size` | `'small' \| 'normal'` | `'normal'` | |
21
21
  | `name`, `disabled`, `required`, `autoSubmit` | | | |
22
- | `className` | `string` | | On the wrapper. |
22
+ | `className`, `style` | | | On the wrapper; `ref` goes on the group of boxes. |
23
23
 
24
24
  ```tsx
25
25
  import { PinInput } from 'anvilui'
package/docs/progress.md CHANGED
@@ -1,37 +1,37 @@
1
- # Progress
2
-
3
- A bar or ring showing progress. Needs `label` or `aria-label`.
4
-
5
- ```ts
6
- import { Progress } from 'anvilui'
7
- import type { ProgressProps } from 'anvilui'
8
- ```
9
-
10
- | Prop | Type | Default | Description |
11
- | --- | --- | --- | --- |
12
- | `value` | `number \| null` | | `null` = indeterminate (spinning / sweeping). Required by Base UI: pass `null` explicitly for loading. |
13
- | `min` / `max` | `number` | `0` / `100` | |
14
- | `type` | `'linear' \| 'circular' \| 'inline'` | `'linear'` | `inline` is a ring the size of the text. |
15
- | `squiggly` | `boolean` | `false` | Wavy bar (linear only). |
16
- | `label` | `ReactNode` | | Visible label. Either this or `aria-label`. |
17
- | `aria-label` | `string` | | |
18
-
19
- There is no `Spinner` / `CircularProgress` / `LinearProgress`: use `<Progress type="circular" value={null} aria-label="Loading" />`. For a loading button, use `<Button loading>`.
20
-
21
- ```tsx
22
- import { Progress } from 'anvilui'
23
-
24
- export function Example({ uploaded }: { uploaded: number }) {
25
- return (
26
- <div style={{ display: 'grid', gap: 16, width: 300 }}>
27
- <Progress label="Uploading" value={uploaded} />
28
- <Progress aria-label="Loading" value={null} squiggly />
29
- <Progress type="circular" aria-label="Loading" value={null} />
30
- <span>
31
- Syncing{' '}
32
- <Progress type="inline" aria-label="Syncing" value={null} />
33
- </span>
34
- </div>
35
- )
36
- }
37
- ```
1
+ # Progress
2
+
3
+ A bar or ring showing progress. Needs `label` or `aria-label`.
4
+
5
+ ```ts
6
+ import { Progress } from 'anvilui'
7
+ import type { ProgressProps } from 'anvilui'
8
+ ```
9
+
10
+ | Prop | Type | Default | Description |
11
+ | --- | --- | --- | --- |
12
+ | `value` | `number \| null` | | `null` = indeterminate (spinning / sweeping). Required by Base UI: pass `null` explicitly for loading. |
13
+ | `min` / `max` | `number` | `0` / `100` | |
14
+ | `type` | `'linear' \| 'circular' \| 'inline'` | `'linear'` | `inline` is a ring the size of the text. |
15
+ | `squiggly` | `boolean` | `false` | Wavy bar (linear only). Changing it animates: the wave flattens into the plain bar and back. |
16
+ | `label` | `ReactNode` | | Visible label. Either this or `aria-label`. |
17
+ | `aria-label` | `string` | | |
18
+
19
+ There is no `Spinner` / `CircularProgress` / `LinearProgress`: use `<Progress type="circular" value={null} aria-label="Loading" />`. For a loading button, use `<Button loading>`.
20
+
21
+ ```tsx
22
+ import { Progress } from 'anvilui'
23
+
24
+ export function Example({ uploaded }: { uploaded: number }) {
25
+ return (
26
+ <div style={{ display: 'grid', gap: 16, width: 300 }}>
27
+ <Progress label="Uploading" value={uploaded} />
28
+ <Progress aria-label="Loading" value={null} squiggly />
29
+ <Progress type="circular" aria-label="Loading" value={null} />
30
+ <span>
31
+ Syncing{' '}
32
+ <Progress type="inline" aria-label="Syncing" value={null} />
33
+ </span>
34
+ </div>
35
+ )
36
+ }
37
+ ```
@@ -44,4 +44,21 @@ export function Example() {
44
44
  }
45
45
  ```
46
46
 
47
+ The value type is inferred from `value` / `defaultValue`. With neither, or when you type the props yourself in a wrapper, it's `unknown`: pass the type as `RadioGroupProps<YourValue>`.
48
+
49
+ ```tsx
50
+ import { Radio, RadioGroup, type RadioGroupProps } from 'anvilui'
51
+
52
+ type Plan = 'free' | 'pro'
53
+
54
+ export function PlanPicker(props: RadioGroupProps<Plan>) {
55
+ return (
56
+ <RadioGroup aria-label="Plan" {...props}>
57
+ <label><Radio value="free" /> Free</label>
58
+ <label><Radio value="pro" /> Pro</label>
59
+ </RadioGroup>
60
+ )
61
+ }
62
+ ```
63
+
47
64
  For a compact row of 2–5 options, [ToggleGroup](toggle-group.md) looks better.
package/docs/search.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Search, SearchItem
2
2
 
3
- A Material 3 search bar with a suggestion list. `aria-label` is required. **Children are a render function** over `items`. The value is the typed text.
3
+ A Material 3 search bar, with an optional suggestion list. `aria-label` is required. For suggestions, **children are a render function** over `items`; without children it's a plain search bar. The value is the typed text.
4
4
 
5
5
  ```ts
6
6
  import { Search, SearchItem } from 'anvilui'
@@ -12,14 +12,16 @@ import type { SearchProps, SearchItemProps } from 'anvilui'
12
12
  | Prop | Type | Default | Description |
13
13
  | --- | --- | --- | --- |
14
14
  | `aria-label` | `string` | required | |
15
- | `children` | `(item: Item, index: number) => ReactNode` | required | Renders one `SearchItem`. |
15
+ | `children` | `(item: Item, index: number) => ReactNode` | | Renders one `SearchItem`. Leave out for a plain search bar. |
16
16
  | `items` | `readonly Item[]` | | Suggestions, filtered as you type. Pass `[]` for none. |
17
17
  | `value` / `defaultValue` | `string` | | The typed text. |
18
18
  | `onValueChange` | `(text: string, details) => void` | | |
19
19
  | `placeholder` | `string` | | |
20
20
  | `empty` | `ReactNode` | | Shown when nothing matches. |
21
+ | `color` | `'surface' \| 'container'` | `'surface'` | The bar's background. Use `'container'` on a `surface` panel (drawer, sidebar) so the bar doesn't blend in. No other colors and no `fillType`. |
21
22
  | `clearLabel` | `string` | `'Clear'` | Name of the clear button. |
22
- | `className` | `string` | | On the bar. |
23
+ | `className`, `style` | | | On the bar. |
24
+ | `ref`, `id`, `aria-*`, `data-*` | | | On the text `<input>`. |
23
25
  | `itemToStringValue`, `filter`, `limit`, `openOnInputClick` | | | Base UI Autocomplete.Root props. |
24
26
 
25
27
  ## SearchItem props
@@ -52,7 +54,7 @@ export function Example() {
52
54
  }
53
55
  ```
54
56
 
55
- To filter a page's own content with no suggestion list, pass `items={[]}` and a render function that returns `null`, then filter your data with the typed text:
57
+ To filter a page's own content, leave out `items` and children. It's then a plain search bar (with the clear button) that never opens a list; filter your data with the typed text:
56
58
 
57
59
  ```tsx
58
60
  import { useState } from 'react'
@@ -65,9 +67,7 @@ export function FilterExample() {
65
67
  const shown = people.filter((p) => p.toLowerCase().includes(query.toLowerCase()))
66
68
  return (
67
69
  <>
68
- <Search aria-label="Filter people" placeholder="Filter people" items={[]} value={query} onValueChange={setQuery}>
69
- {() => null}
70
- </Search>
70
+ <Search aria-label="Filter people" placeholder="Filter people" value={query} onValueChange={setQuery} />
71
71
  <List>
72
72
  {shown.map((p) => <ListItem key={p} label={p} />)}
73
73
  </List>
package/docs/select.md CHANGED
@@ -22,9 +22,10 @@ import type { SelectProps, SelectItemProps } from 'anvilui'
22
22
  | `name`, `required`, `disabled`, `readOnly` | | | |
23
23
  | `open` / `defaultOpen` / `onOpenChange` | | | |
24
24
  | `itemToStringLabel` | `(value) => string` | | For object values. |
25
- | `className` | `string` | | On the field wrapper. |
25
+ | `className`, `style` | | | On the field wrapper. |
26
+ | `ref`, `id`, `aria-*`, `data-*` | | | On the field's button. |
26
27
 
27
- Other props go to Base UI `Select.Root`, which renders no element: `id`, `style` and `ref` are not applied. Base UI docs: `node_modules/@base-ui/react/docs/react/components/select.md`.
28
+ Everything else goes to Base UI `Select.Root`. Base UI docs: `node_modules/@base-ui/react/docs/react/components/select.md`.
28
29
 
29
30
  ## SelectItem props
30
31
 
package/docs/slider.md CHANGED
@@ -1,49 +1,49 @@
1
- # Slider
2
-
3
- Pick a number, or a range with several handles. Needs `label` or `aria-label`.
4
-
5
- ```ts
6
- import { Slider } from 'anvilui'
7
- import type { SliderProps } from 'anvilui'
8
- ```
9
-
10
- ## Props
11
-
12
- | Prop | Type | Default | Description |
13
- | --- | --- | --- | --- |
14
- | `label` | `ReactNode` | | Visible label above. Either this or `aria-label`. |
15
- | `aria-label` | `string` | | |
16
- | `value` / `defaultValue` | `number` or `number[]` | | An array makes a range with that many handles. |
17
- | `onValueChange` | `(value, details) => void` | | While dragging. Gets the value, not an event: `number` when `value` is a number, `number[]` when it's an array, so a `useState` setter can be passed directly. |
18
- | `onValueCommitted` | `(value, details) => void` | | On release. |
19
- | `min` / `max` / `step` | `number` | `0` / `100` / `1` | |
20
- | `showValue` | `boolean` | `true` | Value bubble while dragging or focused. |
21
- | `squiggly` | `boolean` | `false` | Wavy track (horizontal only). |
22
- | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Vertical is 160px tall; set height via `className`. |
23
- | `format` | `Intl.NumberFormatOptions` | | Formats the bubble. |
24
- | `disabled`, `name` | | | |
25
-
26
- Base UI docs: `node_modules/@base-ui/react/docs/react/components/slider.md`.
27
-
28
- ```tsx
29
- import { useState } from 'react'
30
- import { Slider } from 'anvilui'
31
-
32
- export function Example() {
33
- const [volume, setVolume] = useState(40)
34
- const [price, setPrice] = useState([20, 80])
35
- return (
36
- <div style={{ display: 'grid', gap: 24, width: 300 }}>
37
- <Slider label="Volume" value={volume} onValueChange={setVolume} />
38
- <Slider
39
- aria-label="Price"
40
- value={price}
41
- onValueChange={setPrice}
42
- min={0}
43
- max={200}
44
- format={{ style: 'currency', currency: 'USD' }}
45
- />
46
- </div>
47
- )
48
- }
49
- ```
1
+ # Slider
2
+
3
+ Pick a number, or a range with several handles. Needs `label` or `aria-label`.
4
+
5
+ ```ts
6
+ import { Slider } from 'anvilui'
7
+ import type { SliderProps } from 'anvilui'
8
+ ```
9
+
10
+ ## Props
11
+
12
+ | Prop | Type | Default | Description |
13
+ | --- | --- | --- | --- |
14
+ | `label` | `ReactNode` | | Visible label above. Either this or `aria-label`. |
15
+ | `aria-label` | `string` | | |
16
+ | `value` / `defaultValue` | `number` or `number[]` | | An array makes a range with that many handles. |
17
+ | `onValueChange` | `(value, details) => void` | | While dragging. Gets the value, not an event: `number` when `value` is a number, `number[]` when it's an array, so a `useState` setter can be passed directly. |
18
+ | `onValueCommitted` | `(value, details) => void` | | On release. |
19
+ | `min` / `max` / `step` | `number` | `0` / `100` / `1` | |
20
+ | `showValue` | `boolean` | `true` | Value bubble while dragging or focused. |
21
+ | `squiggly` | `boolean` | `false` | Wavy track (horizontal only). Changing it animates: the wave flattens into the plain track and back, e.g. `squiggly={playing}` on a media seek bar. |
22
+ | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Vertical is 160px tall; set height via `className`. |
23
+ | `format` | `Intl.NumberFormatOptions` | | Formats the bubble. |
24
+ | `disabled`, `name` | | | |
25
+
26
+ Base UI docs: `node_modules/@base-ui/react/docs/react/components/slider.md`.
27
+
28
+ ```tsx
29
+ import { useState } from 'react'
30
+ import { Slider } from 'anvilui'
31
+
32
+ export function Example() {
33
+ const [volume, setVolume] = useState(40)
34
+ const [price, setPrice] = useState([20, 80])
35
+ return (
36
+ <div style={{ display: 'grid', gap: 24, width: 300 }}>
37
+ <Slider label="Volume" value={volume} onValueChange={setVolume} />
38
+ <Slider
39
+ aria-label="Price"
40
+ value={price}
41
+ onValueChange={setPrice}
42
+ min={0}
43
+ max={200}
44
+ format={{ style: 'currency', currency: 'USD' }}
45
+ />
46
+ </div>
47
+ )
48
+ }
49
+ ```
package/docs/textarea.md CHANGED
@@ -12,7 +12,7 @@ import type { TextareaProps } from 'anvilui'
12
12
  | `label` | `ReactNode` | | Floating label. |
13
13
  | `size` | `'small' \| 'normal'` | `'normal'` | |
14
14
  | `onValueChange` | `(value: string, details) => void` | | Or native `onChange`. |
15
- | `className` | `string` | | On the wrapper. |
15
+ | `className`, `style` | | | On the wrapper; `ref` and other props go on the `<textarea>`. |
16
16
 
17
17
  ```tsx
18
18
  import { Textarea } from 'anvilui'
package/docs/theming.md CHANGED
@@ -100,8 +100,9 @@ export function App() {
100
100
 
101
101
  - `createTheme(primaryHex, { tonal?: hex })` returns `{ light: Theme, dark: Theme }`. Hex only (`'#0B6E4F'` or `'#0B6'`); other formats throw.
102
102
  - `createThemeFromImage(img | File | Blob | url)` returns `Promise<ThemePair>`, browser only. URLs must allow CORS.
103
- - Error, warning and success colors stay the same.
103
+ - Each role keeps the lightness of the base theme, so text stays readable; only hue and colorfulness change. Error, warning and success colors stay the same.
104
104
  - Tweak one role by spreading: `{ ...brand.light, primary: '#…' }`.
105
+ - To switch themes at runtime, keep them in state and pass them as `lightTheme` / `darkTheme`.
105
106
  - Ready-made: `baseLightTheme` / `baseDarkTheme` (purple, the default), `monochromeLightTheme` / `monochromeDarkTheme`.
106
107
 
107
108
  ## Theme roles
@@ -10,7 +10,7 @@ import type { TimePickerProps } from 'anvilui'
10
10
  | Prop | Type | Default | Description |
11
11
  | --- | --- | --- | --- |
12
12
  | `value` / `defaultValue` | `string \| null` | `null` | `"HH:mm"`, e.g. `"07:30"`, `"19:05"`. |
13
- | `onValueChange` | `(value: string) => void` | | On every change. The user can't clear it from the picker; to clear, set `value={null}` yourself (e.g. a Clear button). |
13
+ | `onValueChange` | `(value: string \| null) => void` | | On every change. `null` when the user clears it with the picker's Clear button. |
14
14
  | `type` | `'dial' \| 'input'` | `'dial'` | |
15
15
  | `hourCycle` | `12 \| 24` | user's locale | 12 shows AM/PM. |
16
16
  | `label` | `ReactNode` | | Either this or `aria-label`. |
@@ -18,7 +18,8 @@ import type { TimePickerProps } from 'anvilui'
18
18
  | `size` | `'small' \| 'normal'` | `'normal'` | |
19
19
  | `disabled` | `boolean` | `false` | |
20
20
  | `open` / `defaultOpen` / `onOpenChange` | | | The popup. |
21
- | `className`, other `<div>` props | | | On the wrapper. |
21
+ | `ref`, `id`, `aria-*`, `data-*` | | | On the field's button. |
22
+ | `className`, `style`, other `<div>` props | | | On the wrapper. |
22
23
 
23
24
  ```tsx
24
25
  import { useState } from 'react'
@@ -20,7 +20,7 @@ import type { ToggleGroupProps, ToggleGroupItemProps } from 'anvilui'
20
20
  | `disabled` | `boolean` | | |
21
21
  | `aria-label` / `aria-labelledby` | `string` | | Name the group (both are passed through). |
22
22
 
23
- Single mode is a Base UI RadioGroup; multiple mode is a Base UI ToggleGroup. `Value` is inferred from `value`, so a union-typed `useState<'list' | 'grid'>` setter can be passed straight to `onValueChange`.
23
+ Single mode is a Base UI RadioGroup; multiple mode is a Base UI ToggleGroup. `Value` is inferred from `value`, so a union-typed `useState<'list' | 'grid'>` setter can be passed straight to `onValueChange`. With no `value` / `defaultValue`, or in a wrapper typed with `ToggleGroupProps`, it's `unknown`: write `ToggleGroupProps<'list' | 'grid'>`.
24
24
 
25
25
  ## ToggleGroupItem props
26
26
 
package/docs/toggle.md CHANGED
@@ -17,8 +17,8 @@ import type { ToggleProps } from 'anvilui'
17
17
  | `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | Look while off. |
18
18
  | `children` | `ReactNode` | | Label (text toggle). |
19
19
  | `startIcon`, `endIcon` | `MaterialSymbol` | | Text toggle only. |
20
- | `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | Text toggle only. |
21
- | `icon` | `MaterialSymbol` | | Makes it a round icon toggle. Requires `aria-label`; no children or size. |
20
+ | `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 32, 40 or 48px, for text and icon toggles. |
21
+ | `icon` | `MaterialSymbol` | | Makes it a round icon toggle. Requires `aria-label`; no children. |
22
22
  | `value` | `string` | | Identifies it in a Base UI ToggleGroup. |
23
23
 
24
24
  Either `children` or `icon` + `aria-label`, not both.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "anvilui",
3
- "version": "0.2.0",
4
- "description": "Material 3 style React components built on Base UI. Ships agent docs in AGENTS.md and docs/.",
3
+ "version": "0.3.0",
4
+ "description": "Material 3 Expressive for React, pushed further: playful, accessible components built on Base UI. Ships agent docs in AGENTS.md and docs/.",
5
5
  "author": "itayvak",
6
6
  "license": "MIT",
7
7
  "type": "module",