anvilui 0.0.0-stage → 0.2.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 (148) hide show
  1. package/AGENTS.md +483 -0
  2. package/LICENSE +21 -0
  3. package/README.md +128 -2
  4. package/bin/anvilui.mjs +83 -0
  5. package/dist/colors/colors.d.ts +24 -0
  6. package/dist/components/Accordion/Accordion.d.ts +36 -0
  7. package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
  8. package/dist/components/AnvilRoot/AnvilContext.d.ts +34 -0
  9. package/dist/components/AnvilRoot/AnvilRoot.d.ts +56 -0
  10. package/dist/components/AppBar/AppBar.d.ts +45 -0
  11. package/dist/components/Avatar/Avatar.d.ts +27 -0
  12. package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
  13. package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
  14. package/dist/components/Badge/Badge.d.ts +23 -0
  15. package/dist/components/BottomSheet/BottomSheet.d.ts +41 -0
  16. package/dist/components/Button/Button.d.ts +35 -0
  17. package/dist/components/Calendar/Calendar.d.ts +19 -0
  18. package/dist/components/Card/Card.d.ts +57 -0
  19. package/dist/components/Carousel/Carousel.d.ts +21 -0
  20. package/dist/components/Checkbox/Checkbox.d.ts +14 -0
  21. package/dist/components/Chip/Chip.d.ts +46 -0
  22. package/dist/components/Combobox/Combobox.d.ts +42 -0
  23. package/dist/components/Confetti/Confetti.d.ts +31 -0
  24. package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
  25. package/dist/components/DateInput/DateInput.d.ts +37 -0
  26. package/dist/components/Dialog/Dialog.d.ts +56 -0
  27. package/dist/components/Divider/Divider.d.ts +24 -0
  28. package/dist/components/FAB/FAB.d.ts +28 -0
  29. package/dist/components/FAB/magnet.d.ts +2 -0
  30. package/dist/components/FABMenu/FABMenu.d.ts +55 -0
  31. package/dist/components/Field/Field.d.ts +36 -0
  32. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +37 -0
  33. package/dist/components/HoldButton/HoldButton.d.ts +18 -0
  34. package/dist/components/Icon/Icon.d.ts +21 -0
  35. package/dist/components/IconButton/IconButton.d.ts +22 -0
  36. package/dist/components/Input/Input.d.ts +24 -0
  37. package/dist/components/Kbd/Kbd.d.ts +21 -0
  38. package/dist/components/List/List.d.ts +35 -0
  39. package/dist/components/Menu/Menu.d.ts +54 -0
  40. package/dist/components/Menubar/Menubar.d.ts +17 -0
  41. package/dist/components/NavigationBar/NavigationBar.d.ts +30 -0
  42. package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +52 -0
  43. package/dist/components/NavigationList/NavigationList.d.ts +27 -0
  44. package/dist/components/NavigationRail/NavigationRail.d.ts +48 -0
  45. package/dist/components/PinInput/PinInput.d.ts +31 -0
  46. package/dist/components/Popover/Popover.d.ts +49 -0
  47. package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
  48. package/dist/components/Progress/Progress.d.ts +29 -0
  49. package/dist/components/RadioGroup/RadioGroup.d.ts +19 -0
  50. package/dist/components/Search/Search.d.ts +39 -0
  51. package/dist/components/Select/Select.d.ts +38 -0
  52. package/dist/components/Skeleton/Skeleton.d.ts +20 -0
  53. package/dist/components/Slider/Slider.d.ts +31 -0
  54. package/dist/components/Snackbar/Snackbar.d.ts +35 -0
  55. package/dist/components/SplitButton/SplitButton.d.ts +16 -0
  56. package/dist/components/SquigglyWave/SquigglyWave.d.ts +36 -0
  57. package/dist/components/Sticker/Sticker.d.ts +21 -0
  58. package/dist/components/Switch/Switch.d.ts +15 -0
  59. package/dist/components/Table/Table.d.ts +36 -0
  60. package/dist/components/Tabs/Tabs.d.ts +32 -0
  61. package/dist/components/Textarea/Textarea.d.ts +24 -0
  62. package/dist/components/TimePicker/TimePicker.d.ts +45 -0
  63. package/dist/components/Toggle/Toggle.d.ts +41 -0
  64. package/dist/components/ToggleGroup/ToggleGroup.d.ts +50 -0
  65. package/dist/components/Tooltip/Tooltip.d.ts +23 -0
  66. package/dist/components/Typography/Typography.d.ts +22 -0
  67. package/dist/datetime.d.ts +12 -0
  68. package/dist/dev.d.ts +15 -0
  69. package/dist/index.cjs +5419 -0
  70. package/dist/index.cjs.map +1 -0
  71. package/dist/index.css +3724 -0
  72. package/dist/index.css.map +1 -0
  73. package/dist/index.d.ts +129 -0
  74. package/dist/index.js +5299 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/morph.d.ts +64 -0
  77. package/dist/themes/baseTheme.d.ts +5 -0
  78. package/dist/themes/createTheme.d.ts +22 -0
  79. package/dist/themes/monochromeTheme.d.ts +5 -0
  80. package/dist/themes/toCssVariables.d.ts +2 -0
  81. package/dist/themes/types.d.ts +60 -0
  82. package/dist/tokens/baseTokens.d.ts +6 -0
  83. package/dist/tokens/toCssVariables.d.ts +2 -0
  84. package/dist/tokens/types.d.ts +80 -0
  85. package/dist/utils.d.ts +4 -0
  86. package/docs/accordion.md +47 -0
  87. package/docs/animated-number.md +31 -0
  88. package/docs/app-bar.md +53 -0
  89. package/docs/avatar-group.md +35 -0
  90. package/docs/avatar.md +34 -0
  91. package/docs/badge.md +41 -0
  92. package/docs/bottom-sheet.md +65 -0
  93. package/docs/button.md +63 -0
  94. package/docs/calendar.md +26 -0
  95. package/docs/card.md +71 -0
  96. package/docs/carousel.md +43 -0
  97. package/docs/checkbox.md +37 -0
  98. package/docs/chip.md +48 -0
  99. package/docs/combobox.md +72 -0
  100. package/docs/composition.md +80 -0
  101. package/docs/confetti.md +30 -0
  102. package/docs/context-menu.md +42 -0
  103. package/docs/date-input.md +41 -0
  104. package/docs/dialog.md +106 -0
  105. package/docs/divider.md +31 -0
  106. package/docs/fab-menu.md +55 -0
  107. package/docs/fab.md +43 -0
  108. package/docs/field.md +59 -0
  109. package/docs/floating-toolbar.md +48 -0
  110. package/docs/forms.md +81 -0
  111. package/docs/hold-button.md +32 -0
  112. package/docs/icon-button.md +54 -0
  113. package/docs/icons.md +38 -0
  114. package/docs/input.md +50 -0
  115. package/docs/kbd.md +25 -0
  116. package/docs/list.md +65 -0
  117. package/docs/llms-index.md +82 -0
  118. package/docs/menu.md +88 -0
  119. package/docs/menubar.md +34 -0
  120. package/docs/morph.md +51 -0
  121. package/docs/navigation-bar.md +48 -0
  122. package/docs/navigation-drawer.md +72 -0
  123. package/docs/navigation-list.md +40 -0
  124. package/docs/navigation-rail.md +53 -0
  125. package/docs/pin-input.md +38 -0
  126. package/docs/popover.md +78 -0
  127. package/docs/preview-card.md +40 -0
  128. package/docs/progress.md +37 -0
  129. package/docs/radio-group.md +47 -0
  130. package/docs/search.md +77 -0
  131. package/docs/select.md +64 -0
  132. package/docs/setup.md +106 -0
  133. package/docs/skeleton.md +33 -0
  134. package/docs/slider.md +49 -0
  135. package/docs/snackbar.md +50 -0
  136. package/docs/split-button.md +44 -0
  137. package/docs/sticker.md +27 -0
  138. package/docs/switch.md +44 -0
  139. package/docs/table.md +66 -0
  140. package/docs/tabs.md +51 -0
  141. package/docs/textarea.md +23 -0
  142. package/docs/theming.md +182 -0
  143. package/docs/time-picker.md +38 -0
  144. package/docs/toggle-group.md +70 -0
  145. package/docs/toggle.md +49 -0
  146. package/docs/tooltip.md +42 -0
  147. package/docs/typography.md +41 -0
  148. package/package.json +65 -5
package/docs/fab.md ADDED
@@ -0,0 +1,43 @@
1
+ # FAB
2
+
3
+ The floating action button: the screen's main action. You position it (usually `position: fixed`, bottom-end).
4
+
5
+ ```ts
6
+ import { FAB } from 'anvilui'
7
+ import type { FABProps } from 'anvilui'
8
+ ```
9
+
10
+ ## Props
11
+
12
+ | Prop | Type | Default | Description |
13
+ | --- | --- | --- | --- |
14
+ | `icon` | `MaterialSymbol` | required | |
15
+ | `label` | `string` | | Visible text: makes it an extended FAB. |
16
+ | `aria-label` | `string` | required without `label` | |
17
+ | `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 40, 56 or 96px. |
18
+ | `color` | `ComponentColor` | `'primary'` | |
19
+ | `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
20
+ | `sticky` | `boolean` | `true` | Drifts toward a nearby mouse cursor. |
21
+
22
+ Takes no children. Also Base UI Button props.
23
+
24
+ ```tsx
25
+ import { FAB } from 'anvilui'
26
+
27
+ export function Example() {
28
+ return (
29
+ <>
30
+ <FAB
31
+ icon="edit"
32
+ aria-label="Compose"
33
+ style={{ position: 'fixed', insetInlineEnd: 16, bottom: 16 }}
34
+ />
35
+ <FAB icon="add" label="New task" color="tonal" />
36
+ </>
37
+ )
38
+ }
39
+ ```
40
+
41
+ `sticky` only adds a small `translate` toward the cursor, so it works with any `position` you set.
42
+
43
+ For a FAB that opens several actions, use [FABMenu](fab-menu.md).
package/docs/field.md ADDED
@@ -0,0 +1,59 @@
1
+ # Field, FieldDescription, FieldError
2
+
3
+ Wraps one control to add helper text, an error message and validation. The control keeps its own `label`. **There is no `FieldLabel`.**
4
+
5
+ ```ts
6
+ import { Field, FieldDescription, FieldError } from 'anvilui'
7
+ import type {
8
+ FieldProps,
9
+ FieldDescriptionProps,
10
+ FieldErrorProps,
11
+ } from 'anvilui'
12
+ ```
13
+
14
+ ## Field props (Base UI Field.Root)
15
+
16
+ | Prop | Type | Default | Description |
17
+ | --- | --- | --- | --- |
18
+ | `name` | `string` | | Form field name (overrides the control's). |
19
+ | `validate` | `(value, formValues) => string \| string[] \| null \| Promise<…>` | | Return an error message, or `null` when valid. |
20
+ | `validationMode` | `'onSubmit' \| 'onBlur' \| 'onChange'` | `'onSubmit'` | When to validate. Outside a `<form>`, use `onBlur` or `onChange`. |
21
+ | `invalid` | `boolean` | | Force the invalid state (e.g. a server error). |
22
+ | `disabled` | `boolean` | | Disables the control. |
23
+
24
+ ## FieldError props
25
+
26
+ | Prop | Type | Description |
27
+ | --- | --- | --- |
28
+ | `match` | `boolean \| keyof ValidityState` | Show only for one problem (`'valueMissing'`, `'typeMismatch'`, …), or `true` to show whenever invalid. |
29
+ | `children` | `ReactNode` | Message. Without it, shows the browser's or `validate`'s message. |
30
+
31
+ `FieldDescription` is helper text; hidden while an error shows.
32
+
33
+ ```tsx
34
+ import { Button, Field, FieldDescription, FieldError, Input } from 'anvilui'
35
+
36
+ export function Example() {
37
+ return (
38
+ <form
39
+ onSubmit={(e) => e.preventDefault()}
40
+ style={{ display: 'grid', gap: 16, width: 320 }}
41
+ >
42
+ <Field
43
+ name="username"
44
+ validate={(value) =>
45
+ String(value).length < 3 ? 'At least 3 characters' : null
46
+ }
47
+ >
48
+ <Input label="Username" required />
49
+ <FieldDescription>Shown on your profile.</FieldDescription>
50
+ <FieldError match="valueMissing">Choose a username.</FieldError>
51
+ <FieldError match="customError" />
52
+ </Field>
53
+ <Button type="submit">Save</Button>
54
+ </form>
55
+ )
56
+ }
57
+ ```
58
+
59
+ Works with `Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Checkbox`, `Switch`, `RadioGroup`, `Slider`. A required checkbox: `<Field name="terms"><label><Checkbox required /> I accept</label><FieldError match="valueMissing">Please accept the terms.</FieldError></Field>`. On a plain `<form>`, a custom `validate` only blocks submit after it has run: use `validationMode="onBlur"` or `"onChange"` (see [forms.md](forms.md)). Base UI docs: `node_modules/@base-ui/react/docs/react/components/field.md`.
@@ -0,0 +1,48 @@
1
+ # FloatingToolbar
2
+
3
+ A floating pill of icon buttons with arrow-key navigation. You position it.
4
+
5
+ ```ts
6
+ import {
7
+ FloatingToolbar,
8
+ FloatingToolbarButton,
9
+ FloatingToolbarSeparator,
10
+ } from 'anvilui'
11
+ ```
12
+
13
+ | Part | Props |
14
+ | --- | --- |
15
+ | `FloatingToolbar` | `aria-label`; `inverseColor?: boolean` (default `false`); Base UI Toolbar.Root props (`orientation`) |
16
+ | `FloatingToolbarButton` | `IconButton` props (`icon`, `aria-label` required). Default `fillType="text"`; `fillType="filled"` makes the highlighted one. |
17
+ | `FloatingToolbarSeparator` | |
18
+
19
+ ```tsx
20
+ import {
21
+ FloatingToolbar,
22
+ FloatingToolbarButton,
23
+ FloatingToolbarSeparator,
24
+ } from 'anvilui'
25
+
26
+ export function Example() {
27
+ return (
28
+ <FloatingToolbar
29
+ aria-label="Formatting"
30
+ style={{
31
+ position: 'fixed',
32
+ bottom: 24,
33
+ left: '50%',
34
+ translate: '-50%',
35
+ }}
36
+ >
37
+ <FloatingToolbarButton icon="format_bold" aria-label="Bold" />
38
+ <FloatingToolbarButton icon="format_italic" aria-label="Italic" />
39
+ <FloatingToolbarSeparator />
40
+ <FloatingToolbarButton
41
+ icon="send"
42
+ aria-label="Send"
43
+ fillType="filled"
44
+ />
45
+ </FloatingToolbar>
46
+ )
47
+ }
48
+ ```
package/docs/forms.md ADDED
@@ -0,0 +1,81 @@
1
+ # Forms
2
+
3
+ Controls are plain form elements: give them `name` and read them with `FormData`, or control them with state. `Field` adds helper text, error messages and validation to one control.
4
+
5
+ ```tsx
6
+ import {
7
+ Button,
8
+ Checkbox,
9
+ Field,
10
+ FieldDescription,
11
+ FieldError,
12
+ Input,
13
+ Select,
14
+ SelectItem,
15
+ Switch,
16
+ Textarea,
17
+ } from 'anvilui'
18
+
19
+ const roles = { viewer: 'Viewer', editor: 'Editor', admin: 'Admin' }
20
+
21
+ export function SignupForm() {
22
+ return (
23
+ <form
24
+ style={{ display: 'grid', gap: 16, maxWidth: 400 }}
25
+ onSubmit={(event) => {
26
+ event.preventDefault()
27
+ const data = new FormData(event.currentTarget)
28
+ console.log(Object.fromEntries(data))
29
+ }}
30
+ >
31
+ <Field name="email">
32
+ <Input label="Email" type="email" required />
33
+ <FieldDescription>
34
+ We'll send a confirmation link.
35
+ </FieldDescription>
36
+ <FieldError />
37
+ </Field>
38
+
39
+ <Field name="role">
40
+ <Select label="Role" items={roles} defaultValue="viewer">
41
+ {Object.entries(roles).map(([value, label]) => (
42
+ <SelectItem key={value} value={value}>
43
+ {label}
44
+ </SelectItem>
45
+ ))}
46
+ </Select>
47
+ </Field>
48
+
49
+ <Textarea label="About you" name="bio" rows={3} />
50
+
51
+ <label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
52
+ <Switch name="newsletter" defaultChecked />
53
+ Send me the newsletter
54
+ </label>
55
+
56
+ <label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
57
+ <Checkbox name="terms" required />I accept the terms
58
+ </label>
59
+
60
+ <Button type="submit">Sign up</Button>
61
+ </form>
62
+ )
63
+ }
64
+ ```
65
+
66
+ Rules:
67
+
68
+ - **`Button` defaults to `type="button"`.** Pass `type="submit"` to submit a form.
69
+ - Text fields (`Input`, `Textarea`, `Select`, `Combobox`, `DateInput`, `TimePicker`) take their own `label`. There is no `FieldLabel` or `Label` component.
70
+ - `Checkbox`, `Switch` and `Radio` have **no `label` prop**. Wrap them in a `<label>` with the text.
71
+ - Put the `name` on `Field` (or on the control when there's no Field).
72
+ - Native rules (`required`, `type="email"`, `minLength`, `pattern`, …) block a plain `<form>`'s submit and show in `FieldError`. This includes `<Checkbox required />` and `<DateInput required />`.
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
+ - Controls that work inside `Field`: `Input`, `Textarea`, `DateInput`, `Select`, `Combobox`, `Checkbox`, `Switch`, `RadioGroup`, `Slider`.
75
+ - `Button loading` disables the button, so it also blocks repeat submits.
76
+ - `Select` with `name` submits the item's `value`, not its label.
77
+ - Server errors: `<Field invalid>` plus `<FieldError match>` with your message (`match` true shows it whenever the field is invalid).
78
+ - Values: `DateInput` and `Calendar` use `"YYYY-MM-DD"`, `TimePicker` `"HH:mm"`, `Slider` a number (or `number[]`).
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`.
80
+
81
+ See [field.md](field.md), [input.md](input.md), [select.md](select.md), [checkbox.md](checkbox.md).
@@ -0,0 +1,32 @@
1
+ # HoldButton
2
+
3
+ A button for destructive actions: press and hold until it fills, instead of a confirm dialog. Releasing early cancels.
4
+
5
+ ```ts
6
+ import { HoldButton } from 'anvilui'
7
+ import type { HoldButtonProps } from 'anvilui'
8
+ ```
9
+
10
+ ## Props
11
+
12
+ All `Button` props except `loading`, plus:
13
+
14
+ | Prop | Type | Default | Description |
15
+ | --- | --- | --- | --- |
16
+ | `onConfirm` | `() => void` | required | Called after holding for `holdDuration`. |
17
+ | `holdDuration` | `number` (ms) | `1500` | |
18
+
19
+ ```tsx
20
+ import { HoldButton } from 'anvilui'
21
+
22
+ export function Example({ onDelete }: { onDelete: () => void }) {
23
+ return (
24
+ <HoldButton color="error" startIcon="delete" onConfirm={onDelete}>
25
+ Hold to delete
26
+ </HoldButton>
27
+ )
28
+ }
29
+ ```
30
+
31
+ - Use `onConfirm`, not `onClick` (`onClick` also fires on a short press).
32
+ - Works with Space/Enter held. Screen reader clicks, which can't hold, confirm immediately.
@@ -0,0 +1,54 @@
1
+ # IconButton
2
+
3
+ A round 40px button with only an icon. `aria-label` is required.
4
+
5
+ ```ts
6
+ import { IconButton } from 'anvilui'
7
+ import type { IconButtonProps } from 'anvilui'
8
+ ```
9
+
10
+ ## Props
11
+
12
+ | Prop | Type | Default | Description |
13
+ | --- | --- | --- | --- |
14
+ | `icon` | `MaterialSymbol` | required | Icon name, e.g. `'delete'`. |
15
+ | `aria-label` | `string` | required | What the button does. |
16
+ | `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
17
+ | `color` | `ComponentColor` | `'primary'` | |
18
+ | `disabled` | `boolean` | `false` | |
19
+
20
+ Takes no `children` and has **no `size` prop** (always 40px). Also takes Base UI Button props and `<button>` attributes.
21
+
22
+ ## Example
23
+
24
+ ```tsx
25
+ import { IconButton, Tooltip } from 'anvilui'
26
+
27
+ export function Example() {
28
+ return (
29
+ <>
30
+ <IconButton icon="add" aria-label="Add" />
31
+ {/* The usual "toolbar" look: no fill, neutral color */}
32
+ <IconButton
33
+ icon="more_vert"
34
+ aria-label="More options"
35
+ fillType="text"
36
+ color="container"
37
+ />
38
+ <Tooltip label="Delete">
39
+ <IconButton
40
+ icon="delete"
41
+ aria-label="Delete"
42
+ fillType="outlined"
43
+ color="error"
44
+ />
45
+ </Tooltip>
46
+ </>
47
+ )
48
+ }
49
+ ```
50
+
51
+ ## Notes
52
+
53
+ - Default is a filled primary circle. For plain icon buttons in bars and lists, use `fillType="text" color="container"`.
54
+ - On/off icon buttons (favorite, bold): `<Toggle icon="favorite" aria-label="Favorite" />` ([toggle.md](toggle.md)).
package/docs/icons.md ADDED
@@ -0,0 +1,38 @@
1
+ # Icons
2
+
3
+ AnvilUI uses **Material Symbols (Rounded)**, an icon font that ships with the package. Icons are **name strings**, not components.
4
+
5
+ ```tsx
6
+ import { Button, Icon, IconButton } from 'anvilui'
7
+
8
+ export function Example() {
9
+ return (
10
+ <>
11
+ <Button startIcon="add">New</Button>
12
+ <IconButton icon="delete" aria-label="Delete" />
13
+ <Icon
14
+ name="favorite"
15
+ style={{ fontSize: 32, color: 'var(--avl-color-error)' }}
16
+ />
17
+ </>
18
+ )
19
+ }
20
+ ```
21
+
22
+ - Names are snake_case Material Symbols names: `home`, `settings`, `arrow_back`, `more_vert`, `delete`, `edit`, `search`, `close`, `check`, `add`, `menu`, `person`, `mail`, `notifications`, `favorite`, `share`, `download`, `upload`, `visibility`, `logout`, `dark_mode`, `light_mode`. Browse: https://fonts.google.com/icons
23
+ - The prop type is `MaterialSymbol` (a union of every valid name), so a typo is a type error. To type your own data: `import type { MaterialSymbol } from 'anvilui'`, e.g. `const nav: { icon: MaterialSymbol; label: string }[] = [...]`. A plain `string` won't type-check.
24
+ - To check a name offline, search the list in `node_modules/material-symbols/index.d.ts` (the `MaterialSymbols` tuple).
25
+ - Don't import icon components from `lucide-react`, `@mui/icons-material` or `react-icons` into `startIcon` / `icon` props. Those props take strings.
26
+ - Props that take icons: `startIcon`, `endIcon` (Button, Toggle, Chip, MenuItem, …), `icon` (IconButton, FAB, Tabs tab, nav items, …), `name` (Icon).
27
+
28
+ ## Icon
29
+
30
+ ```ts
31
+ type IconProps = Omit<React.ComponentProps<'span'>, 'children'> & {
32
+ name: MaterialSymbol // required
33
+ }
34
+ ```
35
+
36
+ - Renders a `<span>`. Size follows `font-size`; color follows `color`.
37
+ - Decorative by default (`aria-hidden`). Give it `aria-label` to make it a labeled image.
38
+ - Takes no children: `<Icon name="home" />`, not `<Icon>home</Icon>`.
package/docs/input.md ADDED
@@ -0,0 +1,50 @@
1
+ # Input
2
+
3
+ A text field with a floating label inside its border.
4
+
5
+ ```ts
6
+ import { Input } from 'anvilui'
7
+ import type { InputProps } from 'anvilui'
8
+ ```
9
+
10
+ ## Props
11
+
12
+ | Prop | Type | Default | Description |
13
+ | --- | --- | --- | --- |
14
+ | `label` | `ReactNode` | | Floating label. |
15
+ | `size` | `'small' \| 'normal'` | `'normal'` | Small's label acts as a placeholder. |
16
+ | `value` / `defaultValue` | `string` | | |
17
+ | `onValueChange` | `(value: string, details) => void` | | The string. |
18
+ | `onChange` | `ChangeEventHandler<HTMLInputElement>` | | The native event also works. |
19
+ | `className` | `string` | | On the **wrapper** `<label>` (width, margins). |
20
+ | `ref` | | | On the `<input>`. |
21
+ | everything else | `<input>` attributes | | `type`, `name`, `placeholder`, `required`, `disabled`, `autoComplete`, … go on the `<input>`. |
22
+
23
+ No `startIcon` / `endIcon` / `error` / `helperText` props. For helper and error text wrap it in a [Field](field.md). For a search bar use [Search](search.md).
24
+
25
+ ```tsx
26
+ import { useState } from 'react'
27
+ import { Field, FieldError, Input } from 'anvilui'
28
+
29
+ export function Example() {
30
+ const [email, setEmail] = useState('')
31
+ return (
32
+ <div style={{ display: 'grid', gap: 16, width: 320 }}>
33
+ <Input label="Name" name="name" defaultValue="Ada" />
34
+ <Field validationMode="onBlur">
35
+ <Input
36
+ label="Email"
37
+ type="email"
38
+ required
39
+ value={email}
40
+ onValueChange={setEmail}
41
+ />
42
+ <FieldError />
43
+ </Field>
44
+ <Input size="small" label="Filter" />
45
+ </div>
46
+ )
47
+ }
48
+ ```
49
+
50
+ The field is `width: 100%`-friendly: give the wrapper a width with `className` or put it in a grid.
package/docs/kbd.md ADDED
@@ -0,0 +1,25 @@
1
+ # Kbd
2
+
3
+ A keyboard key for shortcuts. It presses down while the user holds that key. One `Kbd` per key.
4
+
5
+ ```ts
6
+ import { Kbd } from 'anvilui'
7
+ ```
8
+
9
+ | Prop | Type | Default | Description |
10
+ | --- | --- | --- | --- |
11
+ | `children` | `ReactNode` | | Key text: `'K'`, `'⌘'`, `'Ctrl'`, `'Esc'`, `'↵'`, … |
12
+ | `listen` | `boolean` | `true` | Press down while held. |
13
+ | `listenFor` | `string` | from the text | A `KeyboardEvent.key` value. |
14
+
15
+ ```tsx
16
+ import { Kbd } from 'anvilui'
17
+
18
+ export function Example() {
19
+ return (
20
+ <span>
21
+ Press <Kbd>⌘</Kbd> + <Kbd>K</Kbd> to search
22
+ </span>
23
+ )
24
+ }
25
+ ```
package/docs/list.md ADDED
@@ -0,0 +1,65 @@
1
+ # List, ListItem
2
+
3
+ A column of rows with a label, description and start/end slots. `ListItem` takes **no children**.
4
+
5
+ ```ts
6
+ import { List, ListItem } from 'anvilui'
7
+ import type { ListProps, ListItemProps } from 'anvilui'
8
+ ```
9
+
10
+ ## List props
11
+
12
+ `<ul>` props, plus `divided?: boolean` (lines between items, default `false`).
13
+
14
+ ## ListItem props
15
+
16
+ | Prop | Type | Description |
17
+ | --- | --- | --- |
18
+ | `label` | `ReactNode` | Required. Main text. |
19
+ | `description` | `ReactNode` | Second line(s). |
20
+ | `start` | `ReactNode` | Before: `Icon`, `Avatar`, `Checkbox`. |
21
+ | `end` | `ReactNode` | After: `Switch`, `Badge`, text, `Icon`. |
22
+ | `render` | `ReactElement` | Make the row interactive: `<a href>`, `<button type="button" />`, `<label />` (toggles a control in start/end), a router `Link`. |
23
+
24
+ `end` can hold any control, including a `Toggle` (`<Toggle icon="star" aria-label="Favorite" />`) or `IconButton`; don't combine those with a row `render`, since a button inside a button or label is invalid.
25
+
26
+ Static by default (a `<div>` inside an `<li>`), with no `onClick` behavior of its own: pass `render={<button type="button" />}` for a clickable row.
27
+
28
+ ```tsx
29
+ import { Avatar, Checkbox, Icon, List, ListItem, Switch } from 'anvilui'
30
+
31
+ export function Example() {
32
+ return (
33
+ <List divided>
34
+ <ListItem
35
+ label="Ada Lovelace"
36
+ description="ada@example.com"
37
+ start={<Avatar name="Ada Lovelace" />}
38
+ />
39
+ <ListItem
40
+ label="Dark theme"
41
+ start={<Icon name="dark_mode" />}
42
+ end={<Switch />}
43
+ render={<label />}
44
+ />
45
+ <ListItem
46
+ label="Remember me"
47
+ start={<Checkbox defaultChecked />}
48
+ render={<label />}
49
+ />
50
+ <ListItem
51
+ label="Account"
52
+ end={<Icon name="chevron_right" />}
53
+ render={<a href="/account" />}
54
+ />
55
+ <ListItem
56
+ label="Sign out"
57
+ start={<Icon name="logout" />}
58
+ render={
59
+ <button type="button" onClick={() => console.log('bye')} />
60
+ }
61
+ />
62
+ </List>
63
+ )
64
+ }
65
+ ```
@@ -0,0 +1,82 @@
1
+ # AnvilUI docs index
2
+
3
+ One line per page. Start with [../AGENTS.md](../AGENTS.md). Paths are relative to `node_modules/anvilui/docs/`.
4
+
5
+ ## Guides
6
+
7
+ - [setup.md](setup.md): install, `anvilui/styles.css`, `AnvilRoot`, fonts, Next.js, theme CSS variables
8
+ - [theming.md](theming.md): AnvilRoot props, color mode, `useAnvil`, `createTheme`, theme roles, design tokens
9
+ - [composition.md](composition.md): `render` instead of `asChild`, refs, className, controlled/uncontrolled props
10
+ - [forms.md](forms.md): building forms, `Field` validation, `FormData`, submit buttons
11
+ - [icons.md](icons.md): Material Symbols names, `Icon`, which props take icon names
12
+ - [morph.md](morph.md): `morph()` / `morphBetween()` container transforms
13
+
14
+ ## Buttons and actions
15
+
16
+ - [button.md](button.md): Button with `fillType`, `color`, `size`, icons, `loading`, links
17
+ - [icon-button.md](icon-button.md): IconButton, icon-only round button (`aria-label` required)
18
+ - [split-button.md](split-button.md): SplitButton, a segmented group of buttons
19
+ - [hold-button.md](hold-button.md): HoldButton, press-and-hold to confirm destructive actions
20
+ - [toggle.md](toggle.md): Toggle, an on/off button (text or icon)
21
+ - [toggle-group.md](toggle-group.md): ToggleGroup, a segmented control, single or multiple
22
+ - [fab.md](fab.md): FAB, the floating action button
23
+ - [fab-menu.md](fab-menu.md): FABMenu, a FAB that opens a stack of actions
24
+ - [chip.md](chip.md): Chip, FilterChip, InputChip
25
+
26
+ ## Form controls
27
+
28
+ - [input.md](input.md): Input, text field with floating label
29
+ - [textarea.md](textarea.md): Textarea, multi-line text field
30
+ - [field.md](field.md): Field, FieldDescription, FieldError for helper text and validation
31
+ - [select.md](select.md): Select, SelectItem dropdown (`items` for labels)
32
+ - [combobox.md](combobox.md): Combobox, ComboboxItem, a filterable picker (render-function children)
33
+ - [search.md](search.md): Search, SearchItem, a search bar with suggestions
34
+ - [checkbox.md](checkbox.md): Checkbox (wrap in `<label>`)
35
+ - [switch.md](switch.md): Switch (wrap in `<label>`)
36
+ - [radio-group.md](radio-group.md): RadioGroup, Radio
37
+ - [slider.md](slider.md): Slider, single value or range
38
+ - [date-input.md](date-input.md): DateInput, typed or picked date (`"YYYY-MM-DD"`)
39
+ - [time-picker.md](time-picker.md): TimePicker, dial or typed time (`"HH:mm"`)
40
+ - [calendar.md](calendar.md): Calendar, a month grid
41
+ - [pin-input.md](pin-input.md): PinInput, one box per character for codes
42
+
43
+ ## Overlays and menus
44
+
45
+ - [dialog.md](dialog.md): Dialog and parts (Trigger, Popup, Title, Description, Actions, Close)
46
+ - [bottom-sheet.md](bottom-sheet.md): BottomSheet, a sheet that slides up from the bottom
47
+ - [popover.md](popover.md): Popover, an anchored interactive panel
48
+ - [preview-card.md](preview-card.md): PreviewCard, a hover preview for links
49
+ - [tooltip.md](tooltip.md): Tooltip (`label` + one child element)
50
+ - [menu.md](menu.md): Menu, MenuTrigger, MenuPopup, MenuItem, MenuGroup, submenus
51
+ - [context-menu.md](context-menu.md): ContextMenu, a right-click menu
52
+ - [menubar.md](menubar.md): Menubar, a File/Edit/View row of menus
53
+ - [snackbar.md](snackbar.md): `useSnackbar()` toasts
54
+ - [confetti.md](confetti.md): `useConfetti()` bursts
55
+
56
+ ## Navigation and layout
57
+
58
+ - [app-bar.md](app-bar.md): AppBar, the top bar (`label`, `start`, `end`)
59
+ - [navigation-bar.md](navigation-bar.md): NavigationBar, bottom navigation for mobile
60
+ - [navigation-rail.md](navigation-rail.md): NavigationRail, collapsible side navigation
61
+ - [navigation-list.md](navigation-list.md): NavigationList, a text-only sidebar of links
62
+ - [navigation-drawer.md](navigation-drawer.md): NavigationDrawer, a slide-in side navigation
63
+ - [tabs.md](tabs.md): Tabs, TabsList, TabsTab, TabsPanel
64
+ - [floating-toolbar.md](floating-toolbar.md): FloatingToolbar, a floating pill of icon buttons
65
+ - [card.md](card.md): Card, CardTitle, CardContent, CardActions; clickable cards
66
+ - [list.md](list.md): List, ListItem rows with start/end slots
67
+ - [table.md](table.md): Table and its native-element parts
68
+ - [accordion.md](accordion.md): Accordion, expandable sections
69
+ - [carousel.md](carousel.md): Carousel, a horizontal scroller
70
+ - [divider.md](divider.md): Divider, horizontal, vertical or labeled
71
+ - [typography.md](typography.md): Typography `type` and `as`
72
+
73
+ ## Display
74
+
75
+ - [avatar.md](avatar.md): Avatar, image, initials or icon
76
+ - [avatar-group.md](avatar-group.md): AvatarGroup, overlapping avatars with "+N"
77
+ - [badge.md](badge.md): Badge, a dot or count
78
+ - [progress.md](progress.md): Progress, linear, circular or inline; indeterminate with `value={null}`
79
+ - [skeleton.md](skeleton.md): Skeleton loading placeholders
80
+ - [sticker.md](sticker.md): Sticker, a tilted decorative label
81
+ - [animated-number.md](animated-number.md): AnimatedNumber, a rolling-digit number
82
+ - [kbd.md](kbd.md): Kbd, a keyboard key
package/docs/menu.md ADDED
@@ -0,0 +1,88 @@
1
+ # Menu
2
+
3
+ A dropdown menu of actions.
4
+
5
+ ```ts
6
+ import {
7
+ Menu,
8
+ MenuTrigger,
9
+ MenuPopup,
10
+ MenuItem,
11
+ MenuGroup,
12
+ MenuSubmenu,
13
+ MenuSubmenuTrigger,
14
+ } from 'anvilui'
15
+ ```
16
+
17
+ ## Parts
18
+
19
+ | Part | Renders | Props |
20
+ | --- | --- | --- |
21
+ | `Menu` | nothing (state) | `open` / `defaultOpen` / `onOpenChange`, `modal`, `openOnHover` |
22
+ | `MenuTrigger` | bare `<button>` | `render={<Button />}` or `render={<IconButton icon="more_vert" aria-label="More" />}` |
23
+ | `MenuPopup` | portal + positioner + panel | `side` (default `'bottom'`), `align` (`'start' \| 'center' \| 'end'`), `sideOffset`, `alignOffset` |
24
+ | `MenuItem` | menu item | `onClick`, `startIcon`, `endIcon`, `disabled`, `closeOnClick` (default `true`), `render` |
25
+ | `MenuGroup` | group | Separates items into blocks (use it instead of a separator). |
26
+ | `MenuSubmenu` | nothing (state) | Contains a `MenuSubmenuTrigger` and a `MenuPopup`. |
27
+ | `MenuSubmenuTrigger` | item with an arrow | `startIcon`, children |
28
+
29
+ There is **no** `MenuContent`, `MenuSeparator`, `MenuLabel`, `MenuCheckboxItem` or `DropdownMenu`. Use `onClick` on `MenuItem` (there is no `onSelect`).
30
+
31
+ ## Example
32
+
33
+ ```tsx
34
+ import {
35
+ IconButton,
36
+ Menu,
37
+ MenuGroup,
38
+ MenuItem,
39
+ MenuPopup,
40
+ MenuSubmenu,
41
+ MenuSubmenuTrigger,
42
+ MenuTrigger,
43
+ } from 'anvilui'
44
+
45
+ export function FileMenu({ onDelete }: { onDelete: () => void }) {
46
+ return (
47
+ <Menu>
48
+ <MenuTrigger
49
+ render={
50
+ <IconButton
51
+ icon="more_vert"
52
+ aria-label="More actions"
53
+ fillType="text"
54
+ color="container"
55
+ />
56
+ }
57
+ />
58
+ <MenuPopup align="end">
59
+ <MenuGroup>
60
+ <MenuItem
61
+ startIcon="edit"
62
+ onClick={() => console.log('rename')}
63
+ >
64
+ Rename
65
+ </MenuItem>
66
+ <MenuItem startIcon="content_copy">Duplicate</MenuItem>
67
+ <MenuSubmenu>
68
+ <MenuSubmenuTrigger startIcon="drive_file_move">
69
+ Move to
70
+ </MenuSubmenuTrigger>
71
+ <MenuPopup>
72
+ <MenuItem>Archive</MenuItem>
73
+ <MenuItem>Trash</MenuItem>
74
+ </MenuPopup>
75
+ </MenuSubmenu>
76
+ </MenuGroup>
77
+ <MenuGroup>
78
+ <MenuItem startIcon="delete" onClick={onDelete}>
79
+ Delete
80
+ </MenuItem>
81
+ </MenuGroup>
82
+ </MenuPopup>
83
+ </Menu>
84
+ )
85
+ }
86
+ ```
87
+
88
+ Links in a menu: `<MenuItem render={<a href="/settings" />}>Settings</MenuItem>`. Right-click menus: [context-menu.md](context-menu.md). A row of menus: [menubar.md](menubar.md). Base UI docs: `node_modules/@base-ui/react/docs/react/components/menu.md`.