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
package/docs/setup.md ADDED
@@ -0,0 +1,106 @@
1
+ # Setup
2
+
3
+ Install, import the stylesheet, wrap the app in `AnvilRoot`. All three are required.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install anvilui
9
+ ```
10
+
11
+ | Requirement | Version | Why |
12
+ | --- | --- | --- |
13
+ | `react`, `react-dom` | **19 or newer** | Uses React 19 features (`ref` as a prop, `<Context value>`). React 18 does not work. |
14
+ | A bundler that handles CSS imports from `node_modules` | Vite, Next.js, webpack, Parcel | `anvilui` imports `material-symbols/rounded.css` (the icon font). |
15
+ | `@base-ui/react`, `material-symbols` | installed automatically | Regular dependencies; don't install them yourself. |
16
+
17
+ ## 1. Import the stylesheet once
18
+
19
+ ```ts
20
+ // main.tsx, app/layout.tsx, or your entry file
21
+ import 'anvilui/styles.css'
22
+ ```
23
+
24
+ Without it every component renders unstyled. In development, AnvilRoot logs `[anvilui] The AnvilUI stylesheet isn't loaded` when it's missing.
25
+
26
+ ## 2. Wrap the app in `AnvilRoot`
27
+
28
+ ```tsx
29
+ import { AnvilRoot, Button } from 'anvilui'
30
+ import 'anvilui/styles.css'
31
+
32
+ export function App() {
33
+ return (
34
+ <AnvilRoot defaultColorMode="system" className="app">
35
+ <Button>Hello</Button>
36
+ </AnvilRoot>
37
+ )
38
+ }
39
+ ```
40
+
41
+ `AnvilRoot` is the only provider. It:
42
+
43
+ - defines the theme as CSS variables on its own `<div class="avl-root">`. Styles only apply inside it.
44
+ - is the container that menus, dialogs, popovers, selects and tooltips portal into. Outside it they render unthemed.
45
+ - provides `useSnackbar()` (it renders the snackbar viewport) and shares tooltip delays.
46
+ - holds the color mode (`useAnvil()`).
47
+
48
+ Put it once at the top, around everything (inside `<StrictMode>` is fine). Don't nest it per page, and don't call `useAnvil()` / `useSnackbar()` in the same component that renders it.
49
+
50
+ To theme the whole page, make the root fill the viewport:
51
+
52
+ ```css
53
+ .app {
54
+ min-height: 100vh;
55
+ }
56
+ ```
57
+
58
+ ## 3. Fonts (optional)
59
+
60
+ The default theme uses Google Sans and Google Sans Code and falls back to the system font. AnvilUI does not load fonts. To get them, add to `<head>`:
61
+
62
+ ```html
63
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
64
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
65
+ <link
66
+ rel="stylesheet"
67
+ href="https://fonts.googleapis.com/css2?family=Google+Sans+Code:ital,wght,MONO@0,300..800,1;1,300..800,1&family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap"
68
+ />
69
+ ```
70
+
71
+ Other fonts: pass `tokens={{ font: { main: '...', title: '...', mono: '...' } }}` to AnvilRoot (see [theming.md](theming.md)).
72
+
73
+ ## Next.js (App Router)
74
+
75
+ `AnvilRoot` uses state and effects, so render it from a client component:
76
+
77
+ ```tsx
78
+ 'use client'
79
+ import { AnvilRoot } from 'anvilui'
80
+ import 'anvilui/styles.css'
81
+
82
+ export function Providers({ children }: { children: React.ReactNode }) {
83
+ return <AnvilRoot storageKey="color-mode">{children}</AnvilRoot>
84
+ }
85
+ ```
86
+
87
+ Then use `<Providers>` in `app/layout.tsx` inside `<body>`. Every AnvilUI component is interactive; use them from client components (`'use client'`). With `storageKey`, the saved color mode is applied before the first paint, with no flash.
88
+
89
+ ## Without a bundler
90
+
91
+ Not supported. The package imports CSS and relies on the bundler to replace `process.env.NODE_ENV`.
92
+
93
+ ## Styling your own elements
94
+
95
+ Inside AnvilRoot, theme values are CSS variables you can use in your own CSS:
96
+
97
+ | Need | Variable |
98
+ | --- | --- |
99
+ | page background / text | `var(--avl-color-background)`, `var(--avl-color-on-background)` |
100
+ | secondary text | `var(--avl-color-on-background-muted)` |
101
+ | any theme color | `var(--avl-color-<role>)`, e.g. `--avl-color-primary`, `--avl-color-on-primary`, `--avl-color-surface` |
102
+ | spacing | `var(--avl-spacing-x1)` … `var(--avl-spacing-x20)` (4px steps by default) |
103
+ | radius | `var(--avl-radius-small \| medium \| large \| full)` |
104
+ | font size | `var(--avl-font-size-body \| caption \| label \| h1 … h6)` |
105
+
106
+ There is no `Box`, `Stack`, `Grid` or `Container` component, and no `sx` prop. Use plain elements with `style` or your own CSS for layout.
@@ -0,0 +1,33 @@
1
+ # Skeleton
2
+
3
+ A pulsing placeholder while content loads. Hidden from screen readers; put `aria-busy` on the loading region.
4
+
5
+ ```ts
6
+ import { Skeleton } from 'anvilui'
7
+ ```
8
+
9
+ | Prop | Type | Default | Description |
10
+ | --- | --- | --- | --- |
11
+ | `variant` | `'text' \| 'circular' \| 'rectangular'` | `'text'` | |
12
+ | `animation` | `'pulse' \| 'none'` | `'pulse'` | |
13
+
14
+ Size it with `style` (`width`, `height`). No `width` / `height` props. Renders a `<span>`.
15
+
16
+ ```tsx
17
+ import { Skeleton } from 'anvilui'
18
+
19
+ export function Example() {
20
+ return (
21
+ <div
22
+ aria-busy="true"
23
+ style={{ display: 'flex', gap: 12, alignItems: 'center' }}
24
+ >
25
+ <Skeleton variant="circular" style={{ width: 40, height: 40 }} />
26
+ <div style={{ display: 'grid', gap: 4, flex: 1 }}>
27
+ <Skeleton style={{ width: '40%' }} />
28
+ <Skeleton style={{ width: '70%' }} />
29
+ </div>
30
+ </div>
31
+ )
32
+ }
33
+ ```
package/docs/slider.md ADDED
@@ -0,0 +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). 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
+ ```
@@ -0,0 +1,50 @@
1
+ # useSnackbar
2
+
3
+ Snackbars (toasts) at the bottom of the screen. **A hook, not a component.** AnvilRoot already renders the viewport: don't add a `<Snackbar>`, `<Toaster>` or provider.
4
+
5
+ ```ts
6
+ import { useSnackbar } from 'anvilui'
7
+ import type { SnackbarOptions } from 'anvilui'
8
+
9
+ const snackbar = useSnackbar()
10
+ snackbar.show(options: SnackbarOptions): string // returns the id
11
+ snackbar.close(id?: string): void // no id closes all
12
+ ```
13
+
14
+ ## SnackbarOptions
15
+
16
+ | Field | Type | Default | Description |
17
+ | --- | --- | --- | --- |
18
+ | `message` | `ReactNode` | required | One or two lines. |
19
+ | `action` | `{ label: ReactNode; onClick: () => void }` | | One text button, e.g. Undo. Closes the snackbar. |
20
+ | `closeButton` | `boolean` | `false` | Show ×. |
21
+ | `timeout` | `number` (ms) | `5000` | `0` stays open. |
22
+ | `priority` | `'low' \| 'high'` | `'low'` | `high` is announced immediately. |
23
+ | `onClose` | `() => void` | | |
24
+
25
+ There is no `type` / `variant` / `severity` (success, error). Put the meaning in the message.
26
+
27
+ ```tsx
28
+ import { Button, useSnackbar } from 'anvilui'
29
+
30
+ export function SaveButton() {
31
+ const snackbar = useSnackbar()
32
+ return (
33
+ <Button
34
+ onClick={() =>
35
+ snackbar.show({
36
+ message: 'Draft saved',
37
+ action: {
38
+ label: 'Undo',
39
+ onClick: () => console.log('undo'),
40
+ },
41
+ })
42
+ }
43
+ >
44
+ Save
45
+ </Button>
46
+ )
47
+ }
48
+ ```
49
+
50
+ Call `useSnackbar()` in a component **inside** `<AnvilRoot>`, not in the component that renders it. Up to 3 stack; a 4th pushes out the oldest.
@@ -0,0 +1,44 @@
1
+ # SplitButton
2
+
3
+ Joins `Button`s and `IconButton`s into one segmented group. Renders a `<div role="group">`.
4
+
5
+ ```ts
6
+ import { SplitButton } from 'anvilui'
7
+ import type { SplitButtonProps } from 'anvilui' // = React.ComponentProps<'div'>
8
+ ```
9
+
10
+ No props of its own. Style each button inside yourself; give them all the same `color`, `fillType` and `size`.
11
+
12
+ ```tsx
13
+ import {
14
+ Button,
15
+ IconButton,
16
+ Menu,
17
+ MenuItem,
18
+ MenuPopup,
19
+ MenuTrigger,
20
+ SplitButton,
21
+ } from 'anvilui'
22
+
23
+ export function Example() {
24
+ return (
25
+ <SplitButton aria-label="Save">
26
+ <Button startIcon="save">Save</Button>
27
+ <Menu>
28
+ <MenuTrigger
29
+ render={
30
+ <IconButton
31
+ icon="arrow_drop_down"
32
+ aria-label="More save options"
33
+ />
34
+ }
35
+ />
36
+ <MenuPopup align="end">
37
+ <MenuItem>Save as copy</MenuItem>
38
+ <MenuItem>Save as template</MenuItem>
39
+ </MenuPopup>
40
+ </Menu>
41
+ </SplitButton>
42
+ )
43
+ }
44
+ ```
@@ -0,0 +1,27 @@
1
+ # Sticker
2
+
3
+ A small tilted label like a die-cut sticker ("NEW", "BETA"). Straightens on hover. Renders a `<span>`.
4
+
5
+ ```ts
6
+ import { Sticker } from 'anvilui'
7
+ ```
8
+
9
+ | Prop | Type | Default |
10
+ | --- | --- | --- |
11
+ | `color` | `ComponentColor` | `'primary'` |
12
+ | `startIcon` | `MaterialSymbol` | |
13
+ | `tilt` | `number` (degrees) | `-4` |
14
+
15
+ ```tsx
16
+ import { Sticker } from 'anvilui'
17
+
18
+ export function Example() {
19
+ return (
20
+ <Sticker color="warning" startIcon="bolt">
21
+ NEW
22
+ </Sticker>
23
+ )
24
+ }
25
+ ```
26
+
27
+ For status labels in tables or lists, a `Chip` or plain text fits better; Sticker is decorative.
package/docs/switch.md ADDED
@@ -0,0 +1,44 @@
1
+ # Switch
2
+
3
+ An on/off switch. **No `label` prop**: wrap it in a `<label>`.
4
+
5
+ ```ts
6
+ import { Switch } from 'anvilui'
7
+ import type { SwitchProps } from 'anvilui' // = Base UI Switch.Root props
8
+ ```
9
+
10
+ ## Props (Base UI Switch.Root)
11
+
12
+ | Prop | Type | Default | Description |
13
+ | --- | --- | --- | --- |
14
+ | `checked` / `defaultChecked` | `boolean` | `false` | |
15
+ | `onCheckedChange` | `(checked: boolean, details) => void` | | Not `onChange`. |
16
+ | `name`, `value` | `string` | | For forms. |
17
+ | `required`, `disabled`, `readOnly` | `boolean` | `false` | |
18
+
19
+ ```tsx
20
+ import { useState } from 'react'
21
+ import { List, ListItem, Switch } from 'anvilui'
22
+
23
+ export function Example() {
24
+ const [wifi, setWifi] = useState(true)
25
+ return (
26
+ <>
27
+ <label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
28
+ <Switch checked={wifi} onCheckedChange={setWifi} />
29
+ Wi-Fi
30
+ </label>
31
+
32
+ {/* Settings row: clicking anywhere on the row toggles it */}
33
+ <List>
34
+ <ListItem
35
+ label="Notifications"
36
+ description="Push and email"
37
+ end={<Switch defaultChecked />}
38
+ render={<label />}
39
+ />
40
+ </List>
41
+ </>
42
+ )
43
+ }
44
+ ```
package/docs/table.md ADDED
@@ -0,0 +1,66 @@
1
+ # Table
2
+
3
+ A styled HTML table, `width: 100%` by default. Each part is its native element. No sorting, paging or selection built in. The caption can hold any content, including dynamic text ("3 of 6 users"). There's no visually-hidden helper class: for an actions column, use `<TableHeaderCell><span style={{ position: 'absolute', width: 1, height: 1, overflow: 'hidden', clip: 'rect(0 0 0 0)' }}>Actions</span></TableHeaderCell>`.
4
+
5
+ ```ts
6
+ import {
7
+ Table,
8
+ TableCaption,
9
+ TableHead,
10
+ TableBody,
11
+ TableRow,
12
+ TableHeaderCell,
13
+ TableCell,
14
+ } from 'anvilui'
15
+ ```
16
+
17
+ | Part | Element | Notes |
18
+ | --- | --- | --- |
19
+ | `Table` | `<table>` | Needs a `TableCaption` or `aria-label`. |
20
+ | `TableCaption` | `<caption>` | |
21
+ | `TableHead` | `<thead>` | (not `TableHeader`) |
22
+ | `TableBody` | `<tbody>` | |
23
+ | `TableRow` | `<tr>` | |
24
+ | `TableHeaderCell` | `<th scope="col">` | (not `TableHead`); `scope="row"` for row headers |
25
+ | `TableCell` | `<td>` | |
26
+
27
+ ```tsx
28
+ import {
29
+ Table,
30
+ TableBody,
31
+ TableCaption,
32
+ TableCell,
33
+ TableHead,
34
+ TableHeaderCell,
35
+ TableRow,
36
+ } from 'anvilui'
37
+
38
+ const invoices = [
39
+ { id: 'INV-1', customer: 'Acme', total: '$1,200' },
40
+ { id: 'INV-2', customer: 'Globex', total: '$860' },
41
+ ]
42
+
43
+ export function Example() {
44
+ return (
45
+ <Table>
46
+ <TableCaption>Recent invoices</TableCaption>
47
+ <TableHead>
48
+ <TableRow>
49
+ <TableHeaderCell>Invoice</TableHeaderCell>
50
+ <TableHeaderCell>Customer</TableHeaderCell>
51
+ <TableHeaderCell>Total</TableHeaderCell>
52
+ </TableRow>
53
+ </TableHead>
54
+ <TableBody>
55
+ {invoices.map((inv) => (
56
+ <TableRow key={inv.id}>
57
+ <TableCell>{inv.id}</TableCell>
58
+ <TableCell>{inv.customer}</TableCell>
59
+ <TableCell>{inv.total}</TableCell>
60
+ </TableRow>
61
+ ))}
62
+ </TableBody>
63
+ </Table>
64
+ )
65
+ }
66
+ ```
package/docs/tabs.md ADDED
@@ -0,0 +1,51 @@
1
+ # Tabs
2
+
3
+ Horizontal tabs with a sliding underline.
4
+
5
+ ```ts
6
+ import { Tabs, TabsList, TabsTab, TabsPanel } from 'anvilui'
7
+ import type {
8
+ TabsProps,
9
+ TabsListProps,
10
+ TabsTabProps,
11
+ TabsPanelProps,
12
+ } from 'anvilui'
13
+ ```
14
+
15
+ | Part | Renders | Props |
16
+ | --- | --- | --- |
17
+ | `Tabs` | `<div>` | `value` / `defaultValue` / `onValueChange(value, details)` |
18
+ | `TabsList` | row of tabs | |
19
+ | `TabsTab` | `<button>` | `value` (required), `icon?: MaterialSymbol`, `disabled` |
20
+ | `TabsPanel` | `<div>` | `value` (matches its tab), `keepMounted` |
21
+
22
+ There is **no** `TabsTrigger` or `TabsContent`. Horizontal only (no `orientation`).
23
+
24
+ **Always pass `defaultValue` (or `value`).** Base UI's default is `0`, so with string tab values and no default, no tab is selected.
25
+
26
+ ```tsx
27
+ import { useState } from 'react'
28
+ import { Tabs, TabsList, TabsPanel, TabsTab } from 'anvilui'
29
+
30
+ export function Example() {
31
+ const [tab, setTab] = useState<string>('account')
32
+ return (
33
+ <Tabs value={tab} onValueChange={setTab}>
34
+ <TabsList>
35
+ <TabsTab value="account" icon="person">
36
+ Account
37
+ </TabsTab>
38
+ <TabsTab value="security" icon="lock">
39
+ Security
40
+ </TabsTab>
41
+ </TabsList>
42
+ <TabsPanel value="account" style={{ padding: 16 }}>
43
+ Account settings
44
+ </TabsPanel>
45
+ <TabsPanel value="security" style={{ padding: 16 }}>
46
+ Security settings
47
+ </TabsPanel>
48
+ </Tabs>
49
+ )
50
+ }
51
+ ```
@@ -0,0 +1,23 @@
1
+ # Textarea
2
+
3
+ A multi-line text field. Same API as [Input](input.md), with `<textarea>` attributes (`rows`, …).
4
+
5
+ ```ts
6
+ import { Textarea } from 'anvilui'
7
+ import type { TextareaProps } from 'anvilui'
8
+ ```
9
+
10
+ | Prop | Type | Default | Description |
11
+ | --- | --- | --- | --- |
12
+ | `label` | `ReactNode` | | Floating label. |
13
+ | `size` | `'small' \| 'normal'` | `'normal'` | |
14
+ | `onValueChange` | `(value: string, details) => void` | | Or native `onChange`. |
15
+ | `className`, `style` | | | On the wrapper; `ref` and other props go on the `<textarea>`. |
16
+
17
+ ```tsx
18
+ import { Textarea } from 'anvilui'
19
+
20
+ export function Example() {
21
+ return <Textarea label="Message" name="message" rows={4} />
22
+ }
23
+ ```
@@ -0,0 +1,183 @@
1
+ # Theming and color mode
2
+
3
+ Colors come from a `Theme` (light and dark), everything else from `DesignTokens`. Both are props on `AnvilRoot`.
4
+
5
+ ```ts
6
+ import {
7
+ AnvilRoot,
8
+ useAnvil,
9
+ createTheme,
10
+ createThemeFromImage,
11
+ baseLightTheme,
12
+ baseDarkTheme,
13
+ monochromeLightTheme,
14
+ monochromeDarkTheme,
15
+ baseDesignTokens,
16
+ } from 'anvilui'
17
+ import type {
18
+ Theme,
19
+ ThemePair,
20
+ DesignTokens,
21
+ ColorModeSetting,
22
+ ColorType,
23
+ } from 'anvilui'
24
+ ```
25
+
26
+ ## AnvilRoot props
27
+
28
+ | Prop | Type | Default | Description |
29
+ | --- | --- | --- | --- |
30
+ | `children` | `ReactNode` | required | The app. |
31
+ | `className` | `string` | | Classes for the root `<div>`, e.g. to fill the viewport. |
32
+ | `colorMode` | `'light' \| 'dark' \| 'system'` | | Controlled color mode. Pair with `onColorModeChange`. |
33
+ | `defaultColorMode` | `'light' \| 'dark' \| 'system'` | `'system'` | Starting mode when uncontrolled. `'system'` follows the OS live. |
34
+ | `onColorModeChange` | `(mode: ColorModeSetting) => void` | | Called when the mode changes. |
35
+ | `storageKey` | `string` | | Saves the mode in `localStorage` under this key and restores it (no flash with SSR). |
36
+ | `lightTheme` | `Theme` | `baseLightTheme` | Colors in light mode. |
37
+ | `darkTheme` | `Theme` | `baseDarkTheme` | Colors in dark mode. |
38
+ | `tokens` | `Partial<DesignTokens>` | `baseDesignTokens` | Spacing, radius, fonts, motion, shadows. Each category you pass **replaces** the whole default category. |
39
+
40
+ AnvilRoot renders a `<div>` and takes no other props (no `style`, `id`, `theme`).
41
+
42
+ ## Color mode
43
+
44
+ ```tsx
45
+ import { AnvilRoot, IconButton, useAnvil } from 'anvilui'
46
+
47
+ function ModeToggle() {
48
+ const { colorMode, setColorMode } = useAnvil()
49
+ return (
50
+ <IconButton
51
+ icon={colorMode === 'dark' ? 'light_mode' : 'dark_mode'}
52
+ aria-label="Toggle dark mode"
53
+ fillType="text"
54
+ color="container"
55
+ onClick={() =>
56
+ setColorMode(colorMode === 'dark' ? 'light' : 'dark')
57
+ }
58
+ />
59
+ )
60
+ }
61
+
62
+ export function App() {
63
+ return (
64
+ <AnvilRoot storageKey="color-mode">
65
+ <ModeToggle />
66
+ </AnvilRoot>
67
+ )
68
+ }
69
+ ```
70
+
71
+ `useAnvil()` returns:
72
+
73
+ | Field | Type | Description |
74
+ | --- | --- | --- |
75
+ | `colorMode` | `'light' \| 'dark'` | What's shown now (`'system'` resolved). |
76
+ | `colorModeSetting` | `'light' \| 'dark' \| 'system'` | What was picked. |
77
+ | `setColorMode` | `Dispatch<SetStateAction<ColorModeSetting>>` | Like a `useState` setter. |
78
+ | `lightTheme`, `darkTheme` | `Theme` | The themes in use. |
79
+ | `tokens` | `DesignTokens` | The tokens in use, defaults filled in. |
80
+ | `rootRef` | `RefObject<HTMLDivElement \| null>` | The root element (the portal container). |
81
+
82
+ `useAnvil()` throws outside `AnvilRoot`.
83
+
84
+ ## Custom colors
85
+
86
+ ```tsx
87
+ import { AnvilRoot, Button, createTheme } from 'anvilui'
88
+
89
+ // Module scope (or useMemo): it does color math
90
+ const brand = createTheme('#0B6E4F', { tonal: '#6E4F0B' })
91
+
92
+ export function App() {
93
+ return (
94
+ <AnvilRoot lightTheme={brand.light} darkTheme={brand.dark}>
95
+ <Button>Brand colored</Button>
96
+ </AnvilRoot>
97
+ )
98
+ }
99
+ ```
100
+
101
+ - `createTheme(primaryHex, { tonal?: hex })` returns `{ light: Theme, dark: Theme }`. Hex only (`'#0B6E4F'` or `'#0B6'`); other formats throw.
102
+ - `createThemeFromImage(img | File | Blob | url)` returns `Promise<ThemePair>`, browser only. URLs must allow CORS.
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
+ - Tweak one role by spreading: `{ ...brand.light, primary: '#…' }`.
105
+ - To switch themes at runtime, keep them in state and pass them as `lightTheme` / `darkTheme`.
106
+ - Ready-made: `baseLightTheme` / `baseDarkTheme` (purple, the default), `monochromeLightTheme` / `monochromeDarkTheme`.
107
+
108
+ ## Theme roles
109
+
110
+ `Theme` is an object of color strings. Each `x` has an `onX` for text on it.
111
+
112
+ | Role | Used for |
113
+ | --- | --- |
114
+ | `background` / `onBackground` / `onBackgroundMuted` | Page and body text; muted is secondary text |
115
+ | `container` / `onContainer` | Neutral fills: cards, chips, inputs, "secondary" buttons |
116
+ | `surface` / `onSurface` | Navigation, menus, dialogs, sheets |
117
+ | `primary` / `onPrimary`, `primaryContainer` / `onPrimaryContainer` | Brand color |
118
+ | `tonal` / `onTonal`, `tonalContainer` / `onTonalContainer` | Softer accent: selected states, tonal buttons |
119
+ | `error`, `warning`, `success` (+ `on…`, `…Container`, `on…Container`) | Status colors |
120
+ | `outline` | Borders of inputs and outlined controls |
121
+ | `divider` | Lines between content |
122
+ | `inverseSurface`, `inverseOnSurface`, `inversePrimary` (optional) | Tooltips, snackbars |
123
+ | `shadow`, `scrim` (optional) | Shadow color, dialog backdrop |
124
+
125
+ Each role is a CSS variable in kebab case: `primaryContainer` → `var(--avl-color-primary-container)`.
126
+
127
+ ## Component colors (`color` prop)
128
+
129
+ Components take `color` from these roles only:
130
+
131
+ ```ts
132
+ type ComponentColor =
133
+ | 'primary'
134
+ | 'tonal'
135
+ | 'success'
136
+ | 'warning'
137
+ | 'error'
138
+ | 'container'
139
+ | 'surface'
140
+ type ComponentFillType = 'filled' | 'outlined' | 'text'
141
+ ```
142
+
143
+ There is no `secondary`, `danger`, `destructive`, `info` or `default`. Use `tonal` or `container` for secondary actions and `error` for destructive ones.
144
+
145
+ ## Tokens
146
+
147
+ ```tsx
148
+ import { AnvilRoot, baseDesignTokens } from 'anvilui'
149
+
150
+ export function App() {
151
+ return (
152
+ <AnvilRoot
153
+ tokens={{
154
+ // A category replaces the whole default one, so spread it
155
+ radius: {
156
+ ...baseDesignTokens.radius,
157
+ medium: '8px',
158
+ large: '12px',
159
+ },
160
+ font: {
161
+ main: 'Inter, sans-serif',
162
+ title: 'Inter, sans-serif',
163
+ mono: 'monospace',
164
+ },
165
+ }}
166
+ >
167
+ <main />
168
+ </AnvilRoot>
169
+ )
170
+ }
171
+ ```
172
+
173
+ | Category | Keys | CSS variables |
174
+ | --- | --- | --- |
175
+ | `spacing` | a number (px), default `4` | `--avl-spacing-x1` … `--avl-spacing-x20` |
176
+ | `font` | `main`, `title`, `mono` | `--avl-font-main` … |
177
+ | `fontSize` | `body`, `caption`, `labelSmall`, `label`, `labelLarge`, `h1`–`h6` | `--avl-font-size-label-small` … |
178
+ | `fontWeight` | `regular`, `medium`, `semibold`, `bold` | `--avl-font-weight-bold` … |
179
+ | `radius` | `small`, `medium`, `large`, `button`, `full` | `--avl-radius-medium` … |
180
+ | `shadow` | `small`, `medium`, `large` | `--avl-shadow-small` … |
181
+ | `ease` | `out`, `in`, `smooth`, `bounce` | `--avl-ease-out` … |
182
+ | `easeLength` | `short`, `normal`, `slow` | `--avl-ease-length-short` … |
183
+ | `outlineSize`, `disabledOpacity` | strings | `--avl-outline-size`, `--avl-disabled-opacity` |