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.
- package/AGENTS.md +483 -0
- package/LICENSE +21 -0
- package/README.md +128 -2
- package/bin/anvilui.mjs +83 -0
- package/dist/colors/colors.d.ts +24 -0
- package/dist/components/Accordion/Accordion.d.ts +36 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
- package/dist/components/AnvilRoot/AnvilContext.d.ts +34 -0
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +56 -0
- package/dist/components/AppBar/AppBar.d.ts +45 -0
- package/dist/components/Avatar/Avatar.d.ts +27 -0
- package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
- package/dist/components/Badge/Badge.d.ts +23 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +41 -0
- package/dist/components/Button/Button.d.ts +35 -0
- package/dist/components/Calendar/Calendar.d.ts +19 -0
- package/dist/components/Card/Card.d.ts +57 -0
- package/dist/components/Carousel/Carousel.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.d.ts +14 -0
- package/dist/components/Chip/Chip.d.ts +46 -0
- package/dist/components/Combobox/Combobox.d.ts +42 -0
- package/dist/components/Confetti/Confetti.d.ts +31 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
- package/dist/components/DateInput/DateInput.d.ts +37 -0
- package/dist/components/Dialog/Dialog.d.ts +56 -0
- package/dist/components/Divider/Divider.d.ts +24 -0
- package/dist/components/FAB/FAB.d.ts +28 -0
- package/dist/components/FAB/magnet.d.ts +2 -0
- package/dist/components/FABMenu/FABMenu.d.ts +55 -0
- package/dist/components/Field/Field.d.ts +36 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +37 -0
- package/dist/components/HoldButton/HoldButton.d.ts +18 -0
- package/dist/components/Icon/Icon.d.ts +21 -0
- package/dist/components/IconButton/IconButton.d.ts +22 -0
- package/dist/components/Input/Input.d.ts +24 -0
- package/dist/components/Kbd/Kbd.d.ts +21 -0
- package/dist/components/List/List.d.ts +35 -0
- package/dist/components/Menu/Menu.d.ts +54 -0
- package/dist/components/Menubar/Menubar.d.ts +17 -0
- package/dist/components/NavigationBar/NavigationBar.d.ts +30 -0
- package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +52 -0
- package/dist/components/NavigationList/NavigationList.d.ts +27 -0
- package/dist/components/NavigationRail/NavigationRail.d.ts +48 -0
- package/dist/components/PinInput/PinInput.d.ts +31 -0
- package/dist/components/Popover/Popover.d.ts +49 -0
- package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
- package/dist/components/Progress/Progress.d.ts +29 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +19 -0
- package/dist/components/Search/Search.d.ts +39 -0
- package/dist/components/Select/Select.d.ts +38 -0
- package/dist/components/Skeleton/Skeleton.d.ts +20 -0
- package/dist/components/Slider/Slider.d.ts +31 -0
- package/dist/components/Snackbar/Snackbar.d.ts +35 -0
- package/dist/components/SplitButton/SplitButton.d.ts +16 -0
- package/dist/components/SquigglyWave/SquigglyWave.d.ts +36 -0
- package/dist/components/Sticker/Sticker.d.ts +21 -0
- package/dist/components/Switch/Switch.d.ts +15 -0
- package/dist/components/Table/Table.d.ts +36 -0
- package/dist/components/Tabs/Tabs.d.ts +32 -0
- package/dist/components/Textarea/Textarea.d.ts +24 -0
- package/dist/components/TimePicker/TimePicker.d.ts +45 -0
- package/dist/components/Toggle/Toggle.d.ts +41 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +50 -0
- package/dist/components/Tooltip/Tooltip.d.ts +23 -0
- package/dist/components/Typography/Typography.d.ts +22 -0
- package/dist/datetime.d.ts +12 -0
- package/dist/dev.d.ts +15 -0
- package/dist/index.cjs +5419 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +3724 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.js +5299 -0
- package/dist/index.js.map +1 -0
- package/dist/morph.d.ts +64 -0
- package/dist/themes/baseTheme.d.ts +5 -0
- package/dist/themes/createTheme.d.ts +22 -0
- package/dist/themes/monochromeTheme.d.ts +5 -0
- package/dist/themes/toCssVariables.d.ts +2 -0
- package/dist/themes/types.d.ts +60 -0
- package/dist/tokens/baseTokens.d.ts +6 -0
- package/dist/tokens/toCssVariables.d.ts +2 -0
- package/dist/tokens/types.d.ts +80 -0
- package/dist/utils.d.ts +4 -0
- package/docs/accordion.md +47 -0
- package/docs/animated-number.md +31 -0
- package/docs/app-bar.md +53 -0
- package/docs/avatar-group.md +35 -0
- package/docs/avatar.md +34 -0
- package/docs/badge.md +41 -0
- package/docs/bottom-sheet.md +65 -0
- package/docs/button.md +63 -0
- package/docs/calendar.md +26 -0
- package/docs/card.md +71 -0
- package/docs/carousel.md +43 -0
- package/docs/checkbox.md +37 -0
- package/docs/chip.md +48 -0
- package/docs/combobox.md +72 -0
- package/docs/composition.md +80 -0
- package/docs/confetti.md +30 -0
- package/docs/context-menu.md +42 -0
- package/docs/date-input.md +41 -0
- package/docs/dialog.md +106 -0
- package/docs/divider.md +31 -0
- package/docs/fab-menu.md +55 -0
- package/docs/fab.md +43 -0
- package/docs/field.md +59 -0
- package/docs/floating-toolbar.md +48 -0
- package/docs/forms.md +81 -0
- package/docs/hold-button.md +32 -0
- package/docs/icon-button.md +54 -0
- package/docs/icons.md +38 -0
- package/docs/input.md +50 -0
- package/docs/kbd.md +25 -0
- package/docs/list.md +65 -0
- package/docs/llms-index.md +82 -0
- package/docs/menu.md +88 -0
- package/docs/menubar.md +34 -0
- package/docs/morph.md +51 -0
- package/docs/navigation-bar.md +48 -0
- package/docs/navigation-drawer.md +72 -0
- package/docs/navigation-list.md +40 -0
- package/docs/navigation-rail.md +53 -0
- package/docs/pin-input.md +38 -0
- package/docs/popover.md +78 -0
- package/docs/preview-card.md +40 -0
- package/docs/progress.md +37 -0
- package/docs/radio-group.md +47 -0
- package/docs/search.md +77 -0
- package/docs/select.md +64 -0
- package/docs/setup.md +106 -0
- package/docs/skeleton.md +33 -0
- package/docs/slider.md +49 -0
- package/docs/snackbar.md +50 -0
- package/docs/split-button.md +44 -0
- package/docs/sticker.md +27 -0
- package/docs/switch.md +44 -0
- package/docs/table.md +66 -0
- package/docs/tabs.md +51 -0
- package/docs/textarea.md +23 -0
- package/docs/theming.md +182 -0
- package/docs/time-picker.md +38 -0
- package/docs/toggle-group.md +70 -0
- package/docs/toggle.md +49 -0
- package/docs/tooltip.md +42 -0
- package/docs/typography.md +41 -0
- package/package.json +65 -5
package/docs/card.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
A rounded surface that groups content. Neutral `container` color by default.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Card, CardTitle, CardContent, CardActions } from 'anvilui'
|
|
7
|
+
import type {
|
|
8
|
+
CardProps,
|
|
9
|
+
CardTitleProps,
|
|
10
|
+
CardContentProps,
|
|
11
|
+
CardActionsProps,
|
|
12
|
+
} from 'anvilui'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Card props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `color` | `ComponentColor` | `'container'` | |
|
|
20
|
+
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
|
|
21
|
+
| `clickable` | `boolean` | `false` | The whole card becomes one button (Base UI Button props: `onClick`, `disabled`, `render`). Buttons and links inside still work on their own. |
|
|
22
|
+
|
|
23
|
+
A plain card takes `<div>` props.
|
|
24
|
+
|
|
25
|
+
## Parts
|
|
26
|
+
|
|
27
|
+
| Part | Renders | Notes |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `CardTitle` | `<div>` styled as h6 | Pass `as="h2"` (etc.) for a real heading; `type` changes the look. [Typography](typography.md) props. |
|
|
30
|
+
| `CardContent` | `<div>` | Padded body. |
|
|
31
|
+
| `CardActions` | `<div>` | Button row aligned to the end. |
|
|
32
|
+
|
|
33
|
+
There is **no** `CardHeader`, `CardFooter`, `CardDescription` or `CardMedia`. Put an `<img>` directly inside the card.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Button, Card, CardActions, CardContent, CardTitle } from 'anvilui'
|
|
37
|
+
|
|
38
|
+
export function Example() {
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
display: 'grid',
|
|
43
|
+
gap: 16,
|
|
44
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<Card>
|
|
48
|
+
<CardTitle as="h2">Storage</CardTitle>
|
|
49
|
+
<CardContent>You've used 80% of your space.</CardContent>
|
|
50
|
+
<CardActions>
|
|
51
|
+
<Button fillType="text">Dismiss</Button>
|
|
52
|
+
<Button>Upgrade</Button>
|
|
53
|
+
</CardActions>
|
|
54
|
+
</Card>
|
|
55
|
+
|
|
56
|
+
<Card
|
|
57
|
+
clickable
|
|
58
|
+
onClick={() => console.log('open')}
|
|
59
|
+
fillType="outlined"
|
|
60
|
+
>
|
|
61
|
+
<CardTitle>Open project</CardTitle>
|
|
62
|
+
<CardContent>Last edited today</CardContent>
|
|
63
|
+
</Card>
|
|
64
|
+
|
|
65
|
+
<Card clickable render={<a href="/billing" />}>
|
|
66
|
+
<CardTitle>Billing</CardTitle>
|
|
67
|
+
</Card>
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
```
|
package/docs/carousel.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Carousel
|
|
2
|
+
|
|
3
|
+
A horizontally scrolling row of items, draggable with a mouse. `aria-label` required.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Carousel, CarouselItem } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Part | Renders | Props |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `Carousel` | `<div role="region">` | `aria-label` (required), `<div>` props |
|
|
12
|
+
| `CarouselItem` | `<div>` | `<div>` props. 240px wide by default; set `style={{ width }}`. |
|
|
13
|
+
|
|
14
|
+
No arrows, dots, autoplay or `index` state.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Carousel, CarouselItem } from 'anvilui'
|
|
18
|
+
|
|
19
|
+
const albums = [
|
|
20
|
+
{ id: 1, title: 'Blue', cover: '/blue.jpg' },
|
|
21
|
+
{ id: 2, title: 'Red', cover: '/red.jpg' },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
export function Example() {
|
|
25
|
+
return (
|
|
26
|
+
<Carousel aria-label="Featured albums">
|
|
27
|
+
{albums.map((a) => (
|
|
28
|
+
<CarouselItem key={a.id}>
|
|
29
|
+
<img
|
|
30
|
+
src={a.cover}
|
|
31
|
+
alt={a.title}
|
|
32
|
+
style={{
|
|
33
|
+
width: '100%',
|
|
34
|
+
height: 180,
|
|
35
|
+
objectFit: 'cover',
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
</CarouselItem>
|
|
39
|
+
))}
|
|
40
|
+
</Carousel>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
```
|
package/docs/checkbox.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
A checkbox. **No `label` prop**: wrap it in a `<label>`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Checkbox } from 'anvilui'
|
|
7
|
+
import type { CheckboxProps } from 'anvilui' // = Base UI Checkbox.Root props
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Props (Base UI Checkbox.Root)
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `checked` / `defaultChecked` | `boolean` | `false` | |
|
|
15
|
+
| `onCheckedChange` | `(checked: boolean, details) => void` | | Not `onChange`. |
|
|
16
|
+
| `indeterminate` | `boolean` | `false` | Shows a dash. |
|
|
17
|
+
| `name`, `value` | `string` | | For forms. |
|
|
18
|
+
| `required`, `disabled`, `readOnly` | `boolean` | `false` | |
|
|
19
|
+
|
|
20
|
+
Base UI docs: `node_modules/@base-ui/react/docs/react/components/checkbox.md`.
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { useState } from 'react'
|
|
24
|
+
import { Checkbox } from 'anvilui'
|
|
25
|
+
|
|
26
|
+
export function Example() {
|
|
27
|
+
const [agreed, setAgreed] = useState(false)
|
|
28
|
+
return (
|
|
29
|
+
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
30
|
+
<Checkbox checked={agreed} onCheckedChange={setAgreed} />I agree to
|
|
31
|
+
the terms
|
|
32
|
+
</label>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
In a list row, put it in `ListItem`'s `start` with `render={<label />}` so the whole row toggles it ([list.md](list.md)).
|
package/docs/chip.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Chip, FilterChip, InputChip
|
|
2
|
+
|
|
3
|
+
Compact elements for actions, filters and entered values.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Chip, FilterChip, InputChip } from 'anvilui'
|
|
7
|
+
import type { ChipProps, FilterChipProps, InputChipProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Component | Is | Own props |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `Chip` | a button (suggestion / quick action) | `startIcon?: MaterialSymbol`; Base UI Button props |
|
|
13
|
+
| `FilterChip` | an on/off toggle with a checkmark | `pressed` / `defaultPressed` / `onPressedChange(pressed, details)`; Base UI Toggle props |
|
|
14
|
+
| `InputChip` | a removable value (`<span>`) | `onRemove: () => void` (required), `removeLabel?: string` (default `'Remove'`), `startIcon?`, `disabled?` |
|
|
15
|
+
|
|
16
|
+
Chips have no `color`, `fillType` or `size` props.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { useState } from 'react'
|
|
20
|
+
import { Chip, FilterChip, InputChip } from 'anvilui'
|
|
21
|
+
|
|
22
|
+
export function Example() {
|
|
23
|
+
const [vegan, setVegan] = useState(false)
|
|
24
|
+
const [tags, setTags] = useState(['react', 'design'])
|
|
25
|
+
return (
|
|
26
|
+
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
|
|
27
|
+
<Chip startIcon="event" onClick={() => console.log('added')}>
|
|
28
|
+
Add to calendar
|
|
29
|
+
</Chip>
|
|
30
|
+
<FilterChip pressed={vegan} onPressedChange={setVegan}>
|
|
31
|
+
Vegan
|
|
32
|
+
</FilterChip>
|
|
33
|
+
{tags.map((tag) => (
|
|
34
|
+
<InputChip
|
|
35
|
+
key={tag}
|
|
36
|
+
removeLabel={`Remove ${tag}`}
|
|
37
|
+
onRemove={() => setTags(tags.filter((t) => t !== tag))}
|
|
38
|
+
>
|
|
39
|
+
{tag}
|
|
40
|
+
</InputChip>
|
|
41
|
+
))}
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- `InputChip` animates out, then calls `onRemove`. Remove the item from your state there; if you keep it, the chip reappears.
|
|
48
|
+
- Lay chips out in a flex row with `gap`.
|
package/docs/combobox.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Combobox, ComboboxItem
|
|
2
|
+
|
|
3
|
+
A text field that filters a list as you type and picks one item. **Children are a render function**, and `items` is the list to filter.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Combobox, ComboboxItem } from 'anvilui'
|
|
7
|
+
import type { ComboboxProps, ComboboxItemProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Combobox props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `items` | `readonly Item[]` | | The options. |
|
|
15
|
+
| `children` | `(item: Item, index: number) => ReactNode` | required | Renders one `ComboboxItem`. |
|
|
16
|
+
| `value` / `defaultValue` | `Item \| null` | | The picked item. |
|
|
17
|
+
| `onValueChange` | `(item: Item \| null, details) => void` | | |
|
|
18
|
+
| `inputValue` / `onInputValueChange` | `string` / `(text, details) => void` | | The typed text. |
|
|
19
|
+
| `itemToStringLabel` | `(item) => string` | | Required for object items. |
|
|
20
|
+
| `label` | `ReactNode` | | Floating label. |
|
|
21
|
+
| `placeholder` | `string` | | |
|
|
22
|
+
| `empty` | `ReactNode` | | Shown when nothing matches; without it the popup hides. |
|
|
23
|
+
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
24
|
+
| `className` | `string` | | On the field wrapper. |
|
|
25
|
+
| `name`, `disabled`, `required`, `filter`, `limit` | | | Base UI Combobox.Root props. |
|
|
26
|
+
|
|
27
|
+
## ComboboxItem props
|
|
28
|
+
|
|
29
|
+
`value: Item` (required), `children` (label), `disabled`.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { useState } from 'react'
|
|
33
|
+
import { Combobox, ComboboxItem } from 'anvilui'
|
|
34
|
+
|
|
35
|
+
type User = { id: number; name: string }
|
|
36
|
+
const users: User[] = [
|
|
37
|
+
{ id: 1, name: 'Ada Lovelace' },
|
|
38
|
+
{ id: 2, name: 'Alan Turing' },
|
|
39
|
+
]
|
|
40
|
+
const fruits = ['Apple', 'Banana', 'Cherry']
|
|
41
|
+
|
|
42
|
+
export function Example() {
|
|
43
|
+
const [user, setUser] = useState<User | null>(null)
|
|
44
|
+
return (
|
|
45
|
+
<div style={{ display: 'grid', gap: 16, width: 320 }}>
|
|
46
|
+
<Combobox label="Fruit" items={fruits} empty="No fruit found">
|
|
47
|
+
{(fruit: string) => (
|
|
48
|
+
<ComboboxItem key={fruit} value={fruit}>
|
|
49
|
+
{fruit}
|
|
50
|
+
</ComboboxItem>
|
|
51
|
+
)}
|
|
52
|
+
</Combobox>
|
|
53
|
+
|
|
54
|
+
<Combobox
|
|
55
|
+
label="Assignee"
|
|
56
|
+
items={users}
|
|
57
|
+
value={user}
|
|
58
|
+
onValueChange={setUser}
|
|
59
|
+
itemToStringLabel={(u: User) => u.name}
|
|
60
|
+
>
|
|
61
|
+
{(u: User) => (
|
|
62
|
+
<ComboboxItem key={u.id} value={u}>
|
|
63
|
+
{u.name}
|
|
64
|
+
</ComboboxItem>
|
|
65
|
+
)}
|
|
66
|
+
</Combobox>
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Base UI docs: `node_modules/@base-ui/react/docs/react/components/combobox.md`.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Composition: `render`, refs, className
|
|
2
|
+
|
|
3
|
+
AnvilUI is built on [Base UI](https://base-ui.com). Base UI patterns apply everywhere.
|
|
4
|
+
|
|
5
|
+
## `render` instead of `asChild`
|
|
6
|
+
|
|
7
|
+
There is **no `asChild`** prop. To render a part as another element or component, pass `render`:
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
Dialog,
|
|
13
|
+
DialogPopup,
|
|
14
|
+
DialogTitle,
|
|
15
|
+
DialogTrigger,
|
|
16
|
+
IconButton,
|
|
17
|
+
Menu,
|
|
18
|
+
MenuItem,
|
|
19
|
+
MenuPopup,
|
|
20
|
+
MenuTrigger,
|
|
21
|
+
} from 'anvilui'
|
|
22
|
+
|
|
23
|
+
export function Example() {
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<Dialog>
|
|
27
|
+
<DialogTrigger render={<Button />}>Open</DialogTrigger>
|
|
28
|
+
<DialogPopup>
|
|
29
|
+
<DialogTitle>Hi</DialogTitle>
|
|
30
|
+
</DialogPopup>
|
|
31
|
+
</Dialog>
|
|
32
|
+
|
|
33
|
+
<Menu>
|
|
34
|
+
<MenuTrigger
|
|
35
|
+
render={<IconButton icon="more_vert" aria-label="More" />}
|
|
36
|
+
/>
|
|
37
|
+
<MenuPopup>
|
|
38
|
+
<MenuItem>Rename</MenuItem>
|
|
39
|
+
</MenuPopup>
|
|
40
|
+
</Menu>
|
|
41
|
+
|
|
42
|
+
{/* A button that's a link: not a <button>, so nativeButton={false} */}
|
|
43
|
+
<Button render={<a href="/settings" />} nativeButton={false}>
|
|
44
|
+
Settings
|
|
45
|
+
</Button>
|
|
46
|
+
</>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- `render` merges props, `className` and `ref` into the element you pass.
|
|
52
|
+
- All Trigger and Close parts (`DialogTrigger`, `DialogClose`, `PopoverTrigger`, `PopoverClose`, `MenuTrigger`, `BottomSheetTrigger`, `BottomSheetClose`, `NavigationDrawerTrigger`) render a **bare, unstyled `<button>`** unless you pass `render`.
|
|
53
|
+
- When `render` swaps a button for a non-button element (`<a>`, `<div>`), add `nativeButton={false}`.
|
|
54
|
+
- Router links: `render={<Link to="/x" />}` (React Router) or `render={<Link href="/x" />}` (Next.js) on nav items, `ListItem`, `PreviewCardTrigger`, `Button` (+ `nativeButton={false}`).
|
|
55
|
+
|
|
56
|
+
## Refs and props
|
|
57
|
+
|
|
58
|
+
- Every component takes `ref` (React 19 `ref` prop) and passes unknown props to its main element.
|
|
59
|
+
- `className` is merged with the library's classes, never replaced. On Base UI-based parts it can also be a function of state: `className={(state) => state.open ? 'open' : ''}`.
|
|
60
|
+
- **Field-like components put `className` on the outer wrapper** (so width and margins work) and `ref` on the input: `Input`, `Textarea`, `DateInput`. `Select`, `Combobox`, `Search` put `className` on the field wrapper; their other props go to the Base UI Root, which renders no element.
|
|
61
|
+
- `Tooltip` puts `className` on the bubble. `FABMenu` puts it on the FAB.
|
|
62
|
+
|
|
63
|
+
## State props
|
|
64
|
+
|
|
65
|
+
Stateful components work controlled or uncontrolled, with Base UI's names:
|
|
66
|
+
|
|
67
|
+
| State | Props | Callback signature |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| value | `value` / `defaultValue` / `onValueChange` | `(value, eventDetails) => void`. The **value**, not an event. |
|
|
70
|
+
| checked | `checked` / `defaultChecked` / `onCheckedChange` | `(checked: boolean, eventDetails) => void` (Checkbox, Switch) |
|
|
71
|
+
| pressed | `pressed` / `defaultPressed` / `onPressedChange` | `(pressed: boolean, eventDetails) => void` (Toggle, FilterChip) |
|
|
72
|
+
| open | `open` / `defaultOpen` / `onOpenChange` | `(open: boolean, eventDetails) => void` (Dialog, Popover, Menu, Select, …) |
|
|
73
|
+
|
|
74
|
+
Because the value comes first, a `useState` setter can be passed directly: `onValueChange={setTab}`, `onCheckedChange={setEnabled}`.
|
|
75
|
+
|
|
76
|
+
There is no `onChange` on Checkbox, Switch, Select, Slider, Tabs, RadioGroup or ToggleGroup. `Input` and `Textarea` take both native `onChange` (an event) and `onValueChange` (a string).
|
|
77
|
+
|
|
78
|
+
## Base UI docs for inherited props
|
|
79
|
+
|
|
80
|
+
Each page lists AnvilUI's own props. Parts also take every prop of the Base UI part they wrap. Those are documented in the installed Base UI package: `node_modules/@base-ui/react/docs/react/components/<name>.md`.
|
package/docs/confetti.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# useConfetti
|
|
2
|
+
|
|
3
|
+
A hook that returns a function firing a burst of confetti in the theme's colors. Does nothing with reduced motion on.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { useConfetti } from 'anvilui'
|
|
7
|
+
import type { ConfettiOptions, ConfettiOrigin } from 'anvilui'
|
|
8
|
+
|
|
9
|
+
const fire = useConfetti()
|
|
10
|
+
fire(origin?: Element | { x: number; y: number }, options?: ConfettiOptions): void
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
| Option | Type | Default |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `count` | `number` | `80` |
|
|
16
|
+
| `angle` | `number` (degrees, 0 = up) | `0` |
|
|
17
|
+
| `spread` | `number` (degrees) | `70` |
|
|
18
|
+
| `power` | `number` | `1` |
|
|
19
|
+
| `colors` | `ComponentColor[]` | `['primary', 'tonal', 'success', 'warning', 'error']` |
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Button, useConfetti } from 'anvilui'
|
|
23
|
+
|
|
24
|
+
export function Celebrate() {
|
|
25
|
+
const fire = useConfetti()
|
|
26
|
+
return <Button onClick={(e) => fire(e.currentTarget)}>Celebrate</Button>
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Without an origin it bursts from the bottom middle of the screen. Must be inside `AnvilRoot`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# ContextMenu
|
|
2
|
+
|
|
3
|
+
A menu that opens at the pointer on right-click (long-press on touch). Content uses `Menu`'s parts.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { ContextMenu, ContextMenuTrigger, MenuPopup, MenuItem } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Part | Renders | Notes |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `ContextMenu` | nothing (state) | `open` / `defaultOpen` / `onOpenChange` |
|
|
12
|
+
| `ContextMenuTrigger` | `<div>` | The area that responds to right-click; `render` to change the element. |
|
|
13
|
+
| `MenuPopup`, `MenuItem`, `MenuGroup`, `MenuSubmenu` | | Same as [Menu](menu.md). |
|
|
14
|
+
|
|
15
|
+
Right-click and long-press only: it can't be opened from the keyboard. Give keyboard users the same actions another way, e.g. a ⋮ [Menu](menu.md) button on each item.
|
|
16
|
+
|
|
17
|
+
Any content works inside the trigger, including `CardTitle` / `CardContent` when it renders a `Card`.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import {
|
|
21
|
+
Card,
|
|
22
|
+
CardContent,
|
|
23
|
+
ContextMenu,
|
|
24
|
+
ContextMenuTrigger,
|
|
25
|
+
MenuItem,
|
|
26
|
+
MenuPopup,
|
|
27
|
+
} from 'anvilui'
|
|
28
|
+
|
|
29
|
+
export function Example() {
|
|
30
|
+
return (
|
|
31
|
+
<ContextMenu>
|
|
32
|
+
<ContextMenuTrigger render={<Card />}>
|
|
33
|
+
<CardContent>Right-click this card</CardContent>
|
|
34
|
+
</ContextMenuTrigger>
|
|
35
|
+
<MenuPopup>
|
|
36
|
+
<MenuItem startIcon="content_copy">Copy</MenuItem>
|
|
37
|
+
<MenuItem startIcon="delete">Delete</MenuItem>
|
|
38
|
+
</MenuPopup>
|
|
39
|
+
</ContextMenu>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# DateInput
|
|
2
|
+
|
|
3
|
+
A text field for a date, typed in the user's locale format or picked from a calendar popup. **The value is a `"YYYY-MM-DD"` string, not a `Date`.**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { DateInput } from 'anvilui'
|
|
7
|
+
import type { DateInputProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| `value` / `defaultValue` | `string \| null` | `null` | `"YYYY-MM-DD"`. |
|
|
13
|
+
| `onValueChange` | `(value: string \| null) => void` | | `null` when cleared. |
|
|
14
|
+
| `label` | `ReactNode` | | Either this or `aria-label`. |
|
|
15
|
+
| `size` | `'small' \| 'normal'` | `'normal'` | |
|
|
16
|
+
| `className` | `string` | | On the wrapper. |
|
|
17
|
+
| `disabled`, `required`, `id`, `onBlur` | | | On the `<input>`. |
|
|
18
|
+
|
|
19
|
+
No `min` / `max` / disabled dates.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { useState } from 'react'
|
|
23
|
+
import { DateInput } from 'anvilui'
|
|
24
|
+
|
|
25
|
+
export function Example() {
|
|
26
|
+
const [start, setStart] = useState<string | null>('2026-11-06')
|
|
27
|
+
return (
|
|
28
|
+
<form>
|
|
29
|
+
<DateInput
|
|
30
|
+
label="Start date"
|
|
31
|
+
value={start}
|
|
32
|
+
onValueChange={setStart}
|
|
33
|
+
/>
|
|
34
|
+
{/* `name` on DateInput would submit the locale-formatted text; submit the ISO value like this */}
|
|
35
|
+
<input type="hidden" name="start" value={start ?? ''} />
|
|
36
|
+
</form>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Convert: `new Date(value + 'T00:00')` for a local `Date`; back with `date.toISOString().slice(0, 10)` (UTC) or format it yourself.
|
package/docs/dialog.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Dialog
|
|
2
|
+
|
|
3
|
+
A modal dialog.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogTrigger,
|
|
9
|
+
DialogPopup,
|
|
10
|
+
DialogTitle,
|
|
11
|
+
DialogDescription,
|
|
12
|
+
DialogActions,
|
|
13
|
+
DialogClose,
|
|
14
|
+
} from 'anvilui'
|
|
15
|
+
import type {
|
|
16
|
+
DialogProps,
|
|
17
|
+
DialogTriggerProps,
|
|
18
|
+
DialogPopupProps,
|
|
19
|
+
DialogTitleProps,
|
|
20
|
+
DialogDescriptionProps,
|
|
21
|
+
DialogActionsProps,
|
|
22
|
+
DialogCloseProps,
|
|
23
|
+
} from 'anvilui'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Parts
|
|
27
|
+
|
|
28
|
+
| Part | Renders | Notes |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `Dialog` | nothing (state) | `open` / `defaultOpen` / `onOpenChange(open, details)`, `modal` (default `true`), `disablePointerDismissal`, `morph` |
|
|
31
|
+
| `DialogTrigger` | bare `<button>` | `render={<Button />}` to style it. Optional when controlled. |
|
|
32
|
+
| `DialogPopup` | portal + backdrop + the dialog box | Put everything else inside. |
|
|
33
|
+
| `DialogTitle` | `<h2>` | Required for accessibility. |
|
|
34
|
+
| `DialogDescription` | `<p>` | |
|
|
35
|
+
| `DialogActions` | `<div>` | The button row at the bottom (the "footer"). |
|
|
36
|
+
| `DialogClose` | bare `<button>` | `render={<Button fillType="text" />}`. |
|
|
37
|
+
|
|
38
|
+
There is **no** `DialogContent`, `DialogOverlay`, `DialogPortal`, `DialogHeader` or `DialogFooter`.
|
|
39
|
+
|
|
40
|
+
`morph` (boolean, default `false`): the dialog grows out of its trigger, best when the trigger is a surface like a clickable `Card`.
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { useState } from 'react'
|
|
46
|
+
import {
|
|
47
|
+
Button,
|
|
48
|
+
Dialog,
|
|
49
|
+
DialogActions,
|
|
50
|
+
DialogClose,
|
|
51
|
+
DialogDescription,
|
|
52
|
+
DialogPopup,
|
|
53
|
+
DialogTitle,
|
|
54
|
+
DialogTrigger,
|
|
55
|
+
Input,
|
|
56
|
+
} from 'anvilui'
|
|
57
|
+
|
|
58
|
+
export function DeleteDialog({ onDelete }: { onDelete: () => void }) {
|
|
59
|
+
return (
|
|
60
|
+
<Dialog>
|
|
61
|
+
<DialogTrigger render={<Button color="error" startIcon="delete" />}>
|
|
62
|
+
Delete
|
|
63
|
+
</DialogTrigger>
|
|
64
|
+
<DialogPopup>
|
|
65
|
+
<DialogTitle>Delete project?</DialogTitle>
|
|
66
|
+
<DialogDescription>This can't be undone.</DialogDescription>
|
|
67
|
+
<DialogActions>
|
|
68
|
+
<DialogClose render={<Button fillType="text" />}>
|
|
69
|
+
Cancel
|
|
70
|
+
</DialogClose>
|
|
71
|
+
<DialogClose
|
|
72
|
+
render={<Button color="error" />}
|
|
73
|
+
onClick={onDelete}
|
|
74
|
+
>
|
|
75
|
+
Delete
|
|
76
|
+
</DialogClose>
|
|
77
|
+
</DialogActions>
|
|
78
|
+
</DialogPopup>
|
|
79
|
+
</Dialog>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Controlled: open it from anywhere, close it after an async action
|
|
84
|
+
export function RenameDialog() {
|
|
85
|
+
const [open, setOpen] = useState(false)
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<Button onClick={() => setOpen(true)}>Rename</Button>
|
|
89
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
90
|
+
<DialogPopup>
|
|
91
|
+
<DialogTitle>Rename</DialogTitle>
|
|
92
|
+
<Input label="Name" autoFocus />
|
|
93
|
+
<DialogActions>
|
|
94
|
+
<DialogClose render={<Button fillType="text" />}>
|
|
95
|
+
Cancel
|
|
96
|
+
</DialogClose>
|
|
97
|
+
<Button onClick={() => setOpen(false)}>Save</Button>
|
|
98
|
+
</DialogActions>
|
|
99
|
+
</DialogPopup>
|
|
100
|
+
</Dialog>
|
|
101
|
+
</>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Opening from a `MenuItem`: control the dialog (`open` state) and set it in the item's `onClick`; don't nest the Dialog inside the menu popup. Base UI docs: `node_modules/@base-ui/react/docs/react/components/dialog.md`.
|
package/docs/divider.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Divider
|
|
2
|
+
|
|
3
|
+
A thin line between groups of content. Renders a separator `<div>`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Divider } from 'anvilui'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Vertical stretches to its flex row's height. |
|
|
12
|
+
| `label` | `ReactNode` | | Text in the middle ("or"). |
|
|
13
|
+
| `squiggly` | `boolean` | `false` | Wavy line. |
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Divider } from 'anvilui'
|
|
17
|
+
|
|
18
|
+
export function Example() {
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<Divider />
|
|
22
|
+
<Divider label="or" />
|
|
23
|
+
<div style={{ display: 'flex', gap: 8, height: 24 }}>
|
|
24
|
+
<span>Left</span>
|
|
25
|
+
<Divider orientation="vertical" />
|
|
26
|
+
<span>Right</span>
|
|
27
|
+
</div>
|
|
28
|
+
</>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
```
|
package/docs/fab-menu.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# FABMenu
|
|
2
|
+
|
|
3
|
+
A FAB that opens a stack of labeled actions. You position it.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { FABMenu, FABMenuItem } from 'anvilui'
|
|
7
|
+
import type { FABMenuProps, FABMenuItemProps } from 'anvilui'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## FABMenu props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `icon` | `MaterialSymbol` | required | Icon while closed. |
|
|
15
|
+
| `aria-label` | `string` | required | |
|
|
16
|
+
| `children` | `FABMenuItem`s | required | |
|
|
17
|
+
| `closeIcon` | `MaterialSymbol` | `'close'` | Icon while open. |
|
|
18
|
+
| `color` | `ComponentColor` | `'primary'` | Items use the role's container shade. |
|
|
19
|
+
| `fillType` | `'filled' \| 'outlined' \| 'text'` | `'filled'` | |
|
|
20
|
+
| `side` | `'top' \| 'bottom' \| 'left' \| 'right' \| 'inline-start' \| 'inline-end'` | `'top'` | |
|
|
21
|
+
| `align` | `'start' \| 'center' \| 'end'` | `'end'` | |
|
|
22
|
+
| `sticky` | `boolean` | `true` | |
|
|
23
|
+
| `className` | `string` | | Goes on the FAB. |
|
|
24
|
+
| `open` / `defaultOpen` / `onOpenChange` | | | Base UI Menu.Root state. |
|
|
25
|
+
|
|
26
|
+
## FABMenuItem props
|
|
27
|
+
|
|
28
|
+
`icon: MaterialSymbol` (required), `children` (label, required), `color?: ComponentColor`, `onClick`, `disabled`, plus Base UI Menu.Item props.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { FABMenu, FABMenuItem } from 'anvilui'
|
|
32
|
+
|
|
33
|
+
export function Example() {
|
|
34
|
+
return (
|
|
35
|
+
<div style={{ position: 'fixed', insetInlineEnd: 16, bottom: 16 }}>
|
|
36
|
+
<FABMenu icon="add" aria-label="Create">
|
|
37
|
+
<FABMenuItem
|
|
38
|
+
icon="description"
|
|
39
|
+
onClick={() => console.log('doc')}
|
|
40
|
+
>
|
|
41
|
+
Document
|
|
42
|
+
</FABMenuItem>
|
|
43
|
+
<FABMenuItem
|
|
44
|
+
icon="folder"
|
|
45
|
+
onClick={() => console.log('folder')}
|
|
46
|
+
>
|
|
47
|
+
Folder
|
|
48
|
+
</FABMenuItem>
|
|
49
|
+
</FABMenu>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Needs `AnvilRoot` (the items portal into it).
|