anvilui 0.1.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 (144) hide show
  1. package/AGENTS.md +483 -0
  2. package/README.md +60 -40
  3. package/bin/anvilui.mjs +83 -0
  4. package/dist/colors/colors.d.ts +10 -2
  5. package/dist/components/Accordion/Accordion.d.ts +36 -0
  6. package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
  7. package/dist/components/AnvilRoot/AnvilContext.d.ts +22 -2
  8. package/dist/components/AnvilRoot/AnvilRoot.d.ts +44 -6
  9. package/dist/components/AppBar/AppBar.d.ts +13 -2
  10. package/dist/components/Avatar/Avatar.d.ts +6 -2
  11. package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
  12. package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
  13. package/dist/components/Badge/Badge.d.ts +4 -0
  14. package/dist/components/BottomSheet/BottomSheet.d.ts +22 -0
  15. package/dist/components/Button/Button.d.ts +17 -0
  16. package/dist/components/Calendar/Calendar.d.ts +19 -0
  17. package/dist/components/Card/Card.d.ts +36 -0
  18. package/dist/components/Carousel/Carousel.d.ts +21 -0
  19. package/dist/components/Checkbox/Checkbox.d.ts +10 -0
  20. package/dist/components/Chip/Chip.d.ts +25 -2
  21. package/dist/components/Combobox/Combobox.d.ts +48 -0
  22. package/dist/components/Confetti/Confetti.d.ts +31 -0
  23. package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
  24. package/dist/components/DateInput/DateInput.d.ts +39 -0
  25. package/dist/components/Dialog/Dialog.d.ts +32 -0
  26. package/dist/components/Divider/Divider.d.ts +8 -0
  27. package/dist/components/FAB/FAB.d.ts +4 -0
  28. package/dist/components/FAB/magnet.d.ts +2 -0
  29. package/dist/components/FABMenu/FABMenu.d.ts +55 -0
  30. package/dist/components/Field/Field.d.ts +20 -0
  31. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +15 -0
  32. package/dist/components/HoldButton/HoldButton.d.ts +4 -1
  33. package/dist/components/Icon/Icon.d.ts +14 -0
  34. package/dist/components/IconButton/IconButton.d.ts +14 -1
  35. package/dist/components/Input/Input.d.ts +14 -3
  36. package/dist/components/Kbd/Kbd.d.ts +21 -0
  37. package/dist/components/List/List.d.ts +10 -1
  38. package/dist/components/Menu/Menu.d.ts +32 -0
  39. package/dist/components/Menubar/Menubar.d.ts +17 -0
  40. package/dist/components/NavigationBar/NavigationBar.d.ts +10 -0
  41. package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +22 -0
  42. package/dist/components/NavigationList/NavigationList.d.ts +27 -0
  43. package/dist/components/NavigationRail/NavigationRail.d.ts +25 -9
  44. package/dist/components/PinInput/PinInput.d.ts +33 -0
  45. package/dist/components/Popover/Popover.d.ts +30 -2
  46. package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
  47. package/dist/components/Progress/Progress.d.ts +12 -2
  48. package/dist/components/RadioGroup/RadioGroup.d.ts +14 -2
  49. package/dist/components/Search/Search.d.ts +55 -0
  50. package/dist/components/Select/Select.d.ts +21 -4
  51. package/dist/components/Skeleton/Skeleton.d.ts +20 -0
  52. package/dist/components/Slider/Slider.d.ts +7 -1
  53. package/dist/components/Snackbar/Snackbar.d.ts +7 -2
  54. package/dist/components/SplitButton/SplitButton.d.ts +13 -0
  55. package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
  56. package/dist/components/Sticker/Sticker.d.ts +21 -0
  57. package/dist/components/Switch/Switch.d.ts +11 -0
  58. package/dist/components/Table/Table.d.ts +36 -0
  59. package/dist/components/Tabs/Tabs.d.ts +17 -0
  60. package/dist/components/Textarea/Textarea.d.ts +14 -3
  61. package/dist/components/TimePicker/TimePicker.d.ts +47 -0
  62. package/dist/components/Toggle/Toggle.d.ts +42 -0
  63. package/dist/components/ToggleGroup/ToggleGroup.d.ts +16 -4
  64. package/dist/components/Tooltip/Tooltip.d.ts +10 -1
  65. package/dist/components/Typography/Typography.d.ts +13 -1
  66. package/dist/datetime.d.ts +12 -0
  67. package/dist/dev.d.ts +15 -0
  68. package/dist/index.cjs +3365 -654
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.css +1443 -367
  71. package/dist/index.css.map +1 -1
  72. package/dist/index.d.ts +50 -4
  73. package/dist/index.js +3362 -667
  74. package/dist/index.js.map +1 -1
  75. package/dist/themes/baseTheme.d.ts +2 -0
  76. package/dist/themes/createTheme.d.ts +22 -0
  77. package/dist/themes/monochromeTheme.d.ts +2 -0
  78. package/dist/themes/types.d.ts +13 -8
  79. package/dist/tokens/baseTokens.d.ts +4 -0
  80. package/dist/tokens/types.d.ts +34 -0
  81. package/dist/utils.d.ts +4 -0
  82. package/docs/accordion.md +47 -0
  83. package/docs/animated-number.md +31 -0
  84. package/docs/app-bar.md +53 -0
  85. package/docs/avatar-group.md +35 -0
  86. package/docs/avatar.md +34 -0
  87. package/docs/badge.md +41 -0
  88. package/docs/bottom-sheet.md +65 -0
  89. package/docs/button.md +63 -0
  90. package/docs/calendar.md +26 -0
  91. package/docs/card.md +71 -0
  92. package/docs/carousel.md +43 -0
  93. package/docs/checkbox.md +37 -0
  94. package/docs/chip.md +48 -0
  95. package/docs/combobox.md +73 -0
  96. package/docs/composition.md +80 -0
  97. package/docs/confetti.md +30 -0
  98. package/docs/context-menu.md +42 -0
  99. package/docs/date-input.md +42 -0
  100. package/docs/dialog.md +106 -0
  101. package/docs/divider.md +31 -0
  102. package/docs/fab-menu.md +55 -0
  103. package/docs/fab.md +43 -0
  104. package/docs/field.md +59 -0
  105. package/docs/floating-toolbar.md +48 -0
  106. package/docs/forms.md +81 -0
  107. package/docs/hold-button.md +32 -0
  108. package/docs/icon-button.md +55 -0
  109. package/docs/icons.md +38 -0
  110. package/docs/input.md +51 -0
  111. package/docs/kbd.md +25 -0
  112. package/docs/list.md +65 -0
  113. package/docs/llms-index.md +82 -0
  114. package/docs/menu.md +88 -0
  115. package/docs/menubar.md +34 -0
  116. package/docs/morph.md +54 -0
  117. package/docs/navigation-bar.md +48 -0
  118. package/docs/navigation-drawer.md +72 -0
  119. package/docs/navigation-list.md +40 -0
  120. package/docs/navigation-rail.md +53 -0
  121. package/docs/pin-input.md +38 -0
  122. package/docs/popover.md +78 -0
  123. package/docs/preview-card.md +40 -0
  124. package/docs/progress.md +37 -0
  125. package/docs/radio-group.md +64 -0
  126. package/docs/search.md +77 -0
  127. package/docs/select.md +65 -0
  128. package/docs/setup.md +106 -0
  129. package/docs/skeleton.md +33 -0
  130. package/docs/slider.md +49 -0
  131. package/docs/snackbar.md +50 -0
  132. package/docs/split-button.md +44 -0
  133. package/docs/sticker.md +27 -0
  134. package/docs/switch.md +44 -0
  135. package/docs/table.md +66 -0
  136. package/docs/tabs.md +51 -0
  137. package/docs/textarea.md +23 -0
  138. package/docs/theming.md +183 -0
  139. package/docs/time-picker.md +39 -0
  140. package/docs/toggle-group.md +70 -0
  141. package/docs/toggle.md +49 -0
  142. package/docs/tooltip.md +42 -0
  143. package/docs/typography.md +41 -0
  144. package/package.json +25 -5
@@ -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. `DateInput` submits `"YYYY-MM-DD"` and `TimePicker` `"HH:mm"`, not the text they show.
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,55 @@
1
+ # IconButton
2
+
3
+ A round 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
+ | `size` | `'small' \| 'normal' \| 'big'` | `'normal'` | 32, 40 or 48px, like `Button`. |
19
+ | `disabled` | `boolean` | `false` | |
20
+
21
+ Takes no `children`. Also takes Base UI Button props and `<button>` attributes.
22
+
23
+ ## Example
24
+
25
+ ```tsx
26
+ import { IconButton, Tooltip } from 'anvilui'
27
+
28
+ export function Example() {
29
+ return (
30
+ <>
31
+ <IconButton icon="add" aria-label="Add" />
32
+ {/* The usual "toolbar" look: no fill, neutral color */}
33
+ <IconButton
34
+ icon="more_vert"
35
+ aria-label="More options"
36
+ fillType="text"
37
+ color="container"
38
+ />
39
+ <Tooltip label="Delete">
40
+ <IconButton
41
+ icon="delete"
42
+ aria-label="Delete"
43
+ fillType="outlined"
44
+ color="error"
45
+ />
46
+ </Tooltip>
47
+ </>
48
+ )
49
+ }
50
+ ```
51
+
52
+ ## Notes
53
+
54
+ - Default is a filled primary circle. For plain icon buttons in bars and lists, use `fillType="text" color="container"`.
55
+ - 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,51 @@
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
+ | `style` | `CSSProperties` | | On the wrapper too. |
21
+ | `ref` | | | On the `<input>`. |
22
+ | everything else | `<input>` attributes | | `type`, `name`, `placeholder`, `required`, `disabled`, `autoComplete`, … go on the `<input>`. |
23
+
24
+ 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).
25
+
26
+ ```tsx
27
+ import { useState } from 'react'
28
+ import { Field, FieldError, Input } from 'anvilui'
29
+
30
+ export function Example() {
31
+ const [email, setEmail] = useState('')
32
+ return (
33
+ <div style={{ display: 'grid', gap: 16, width: 320 }}>
34
+ <Input label="Name" name="name" defaultValue="Ada" />
35
+ <Field validationMode="onBlur">
36
+ <Input
37
+ label="Email"
38
+ type="email"
39
+ required
40
+ value={email}
41
+ onValueChange={setEmail}
42
+ />
43
+ <FieldError />
44
+ </Field>
45
+ <Input size="small" label="Filter" />
46
+ </div>
47
+ )
48
+ }
49
+ ```
50
+
51
+ 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`.
@@ -0,0 +1,34 @@
1
+ # Menubar
2
+
3
+ A row of menus, like File / Edit / View. Put one `Menu` per entry inside.
4
+
5
+ ```ts
6
+ import { Menubar, Menu, MenuTrigger, MenuPopup, MenuItem } from 'anvilui'
7
+ import type { MenubarProps } from 'anvilui' // Base UI Menubar props
8
+ ```
9
+
10
+ ```tsx
11
+ import { Menu, Menubar, MenuItem, MenuPopup, MenuTrigger } from 'anvilui'
12
+
13
+ export function Example() {
14
+ return (
15
+ <Menubar>
16
+ <Menu>
17
+ <MenuTrigger>File</MenuTrigger>
18
+ <MenuPopup>
19
+ <MenuItem>New</MenuItem>
20
+ <MenuItem>Save</MenuItem>
21
+ </MenuPopup>
22
+ </Menu>
23
+ <Menu>
24
+ <MenuTrigger>Edit</MenuTrigger>
25
+ <MenuPopup>
26
+ <MenuItem>Undo</MenuItem>
27
+ </MenuPopup>
28
+ </Menu>
29
+ </Menubar>
30
+ )
31
+ }
32
+ ```
33
+
34
+ Inside a Menubar, plain `MenuTrigger`s are styled as menubar entries; don't pass `render={<Button />}`.
package/docs/morph.md ADDED
@@ -0,0 +1,54 @@
1
+ # morph and morphBetween
2
+
3
+ Animate one element growing into another while the view changes (Material's container transform), using View Transitions.
4
+
5
+ ```ts
6
+ import { morph, morphBetween } from 'anvilui'
7
+ import type { MorphOptions } from 'anvilui'
8
+
9
+ morph(id: string, update: () => void, options?: MorphOptions): Promise<void>
10
+ morphBetween(from: HTMLElement, update: () => void, getTo: () => HTMLElement | null, options?: MorphOptions): Promise<void>
11
+ type MorphOptions = { duration?: number /* ms */; easing?: string }
12
+ ```
13
+
14
+ ```tsx
15
+ import { useState } from 'react'
16
+ import { Button, Card, CardTitle, morph } from 'anvilui'
17
+
18
+ const albums = [
19
+ { id: 'a1', title: 'Blue' },
20
+ { id: 'a2', title: 'Red' },
21
+ ]
22
+
23
+ export function Albums() {
24
+ const [open, setOpen] = useState<string | null>(null)
25
+
26
+ if (open) {
27
+ return (
28
+ <Card data-morph-id={open} style={{ minHeight: 300 }}>
29
+ <Button onClick={() => morph(open, () => setOpen(null))}>
30
+ Back
31
+ </Button>
32
+ </Card>
33
+ )
34
+ }
35
+ return albums.map((a) => (
36
+ <Card
37
+ key={a.id}
38
+ clickable
39
+ data-morph-id={a.id}
40
+ onClick={() => morph(a.id, () => setOpen(a.id))}
41
+ >
42
+ <CardTitle>{a.title}</CardTitle>
43
+ </Card>
44
+ ))
45
+ }
46
+ ```
47
+
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). 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`.
53
+ - Without View Transitions support, or with reduced motion, `update` just runs.
54
+ - `Dialog` and `Popover` take `morph` (boolean) to do this between their trigger and popup.