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/select.md ADDED
@@ -0,0 +1,64 @@
1
+ # Select, SelectItem
2
+
3
+ A dropdown to pick one option (or several with `multiple`). Looks like `Input`.
4
+
5
+ ```ts
6
+ import { Select, SelectItem } from 'anvilui'
7
+ import type { SelectProps, SelectItemProps } from 'anvilui'
8
+ ```
9
+
10
+ ## Select props
11
+
12
+ | Prop | Type | Default | Description |
13
+ | --- | --- | --- | --- |
14
+ | `children` | `SelectItem`s | | |
15
+ | `items` | `Record<string, ReactNode>` or `{ value, label }[]` | | **Pass it** so the field shows the label, not the raw value. |
16
+ | `value` / `defaultValue` | `Value \| null` (array with `multiple`) | | |
17
+ | `onValueChange` | `(value: Value \| null, details) => void` | | The value, not an event. |
18
+ | `label` | `ReactNode` | | Floating label. |
19
+ | `placeholder` | `ReactNode` | | Shown when nothing is selected. |
20
+ | `size` | `'small' \| 'normal'` | `'normal'` | |
21
+ | `multiple` | `boolean` | `false` | |
22
+ | `name`, `required`, `disabled`, `readOnly` | | | |
23
+ | `open` / `defaultOpen` / `onOpenChange` | | | |
24
+ | `itemToStringLabel` | `(value) => string` | | For object values. |
25
+ | `className` | `string` | | On the field wrapper. |
26
+
27
+ Other props go to Base UI `Select.Root`, which renders no element: `id`, `style` and `ref` are not applied. Base UI docs: `node_modules/@base-ui/react/docs/react/components/select.md`.
28
+
29
+ ## SelectItem props
30
+
31
+ `value` (required), `children` (the label), `disabled`.
32
+
33
+ ```tsx
34
+ import { useState } from 'react'
35
+ import { Select, SelectItem } from 'anvilui'
36
+
37
+ const countries = [
38
+ { value: 'us', label: 'United States' },
39
+ { value: 'fr', label: 'France' },
40
+ { value: 'jp', label: 'Japan' },
41
+ ]
42
+
43
+ export function Example() {
44
+ const [country, setCountry] = useState<string | null>('fr')
45
+ return (
46
+ <Select
47
+ label="Country"
48
+ items={countries}
49
+ value={country}
50
+ onValueChange={setCountry}
51
+ className="country-field"
52
+ >
53
+ {countries.map((c) => (
54
+ <SelectItem key={c.value} value={c.value}>
55
+ {c.label}
56
+ </SelectItem>
57
+ ))}
58
+ </Select>
59
+ )
60
+ }
61
+ ```
62
+
63
+ - No `SelectTrigger`, `SelectContent` or `SelectValue` parts: `Select` renders the field and the popup. Only items go inside.
64
+ - For a searchable list use [Combobox](combobox.md).
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). |
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` | `string` | | On the wrapper. |
16
+
17
+ ```tsx
18
+ import { Textarea } from 'anvilui'
19
+
20
+ export function Example() {
21
+ return <Textarea label="Message" name="message" rows={4} />
22
+ }
23
+ ```