@antadesign/anta 0.3.26 → 0.3.28
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/README.md +26 -28
- package/dist/anta_helpers.d.ts +8 -0
- package/dist/anta_helpers.js +18 -0
- package/dist/box-types.d.ts +1 -1
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +36 -42
- package/dist/capture-types.d.ts +156 -0
- package/dist/components/Banner.js +2 -2
- package/dist/components/Box.d.ts +15 -0
- package/dist/components/Box.js +3 -11
- package/dist/components/Button.js +2 -2
- package/dist/components/Capture.d.ts +39 -0
- package/dist/components/Capture.js +36 -0
- package/dist/components/Card.js +2 -2
- package/dist/components/Checkbox.d.ts +10 -11
- package/dist/components/Checkbox.js +5 -13
- package/dist/components/Expander.js +2 -2
- package/dist/components/Input.js +2 -2
- package/dist/components/InputTime.js +2 -2
- package/dist/components/Loader.js +2 -1
- package/dist/components/MenuItem.d.ts +7 -8
- package/dist/components/MenuItem.js +4 -4
- package/dist/components/Progress.js +2 -2
- package/dist/components/RadioGroup.d.ts +12 -13
- package/dist/components/RadioGroup.js +7 -23
- package/dist/components/Select.d.ts +12 -7
- package/dist/components/Select.js +4 -3
- package/dist/components/SelectFaceted.d.ts +7 -5
- package/dist/components/SelectFaceted.js +4 -3
- package/dist/components/Slider.js +3 -3
- package/dist/components/Steps.css +1 -1
- package/dist/components/Switch.d.ts +7 -8
- package/dist/components/Switch.js +3 -11
- package/dist/components/Tabs.js +2 -2
- package/dist/components/Tag.d.ts +7 -9
- package/dist/components/Tag.js +2 -2
- package/dist/components/Text.js +2 -2
- package/dist/components/Title.js +2 -2
- package/dist/components/capture-props.d.ts +30 -0
- package/dist/components/capture-props.js +44 -0
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-box.d.ts +1 -1
- package/dist/elements/a-box.js +11 -3
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-button.d.ts +7 -9
- package/dist/elements/a-calendar.css +1 -1
- package/dist/elements/a-capture.css +1 -0
- package/dist/elements/a-capture.d.ts +10 -0
- package/dist/elements/a-capture.js +24 -0
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-checkbox.js +4 -4
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.js +1 -0
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.js +5 -7
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.js +4 -6
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.js +6 -9
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.js +1 -0
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +3 -4
- package/dist/elements/a-tooltip.js +0 -1
- package/dist/elements/capture-input.d.ts +5 -0
- package/dist/elements/capture-input.js +609 -0
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/general_types.d.ts +56 -23
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/dist/jsx-runtime.d.ts +2 -1
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +1 -0
- package/dist/theme-antune.css +1 -0
- package/dist/tokens.css +1 -1
- package/docs/accessibility.md +24 -0
- package/docs/changelog.md +79 -0
- package/docs/colors.md +141 -0
- package/docs/comparison.md +463 -28
- package/docs/components/avatar.md +13 -17
- package/docs/components/banner.md +13 -27
- package/docs/components/box.md +226 -154
- package/docs/components/breadcrumbs.md +49 -12
- package/docs/components/button.md +48 -37
- package/docs/components/capture.md +345 -0
- package/docs/components/card.md +17 -38
- package/docs/components/checkbox.md +27 -50
- package/docs/components/dialog.md +14 -36
- package/docs/components/expander.md +15 -40
- package/docs/components/icon.md +111 -9
- package/docs/components/input-autocomplete.md +9 -11
- package/docs/components/input-date.md +33 -23
- package/docs/components/input-time.md +15 -23
- package/docs/components/input.md +27 -76
- package/docs/components/loader.md +7 -5
- package/docs/components/menu.md +75 -80
- package/docs/components/progress.md +10 -14
- package/docs/components/radio.md +28 -46
- package/docs/components/select-faceted.md +8 -25
- package/docs/components/select.md +33 -105
- package/docs/components/slider.md +16 -21
- package/docs/components/steps.md +38 -8
- package/docs/components/switch.md +16 -19
- package/docs/components/tabs.md +52 -40
- package/docs/components/tag.md +15 -24
- package/docs/components/text.md +10 -23
- package/docs/components/title.md +7 -8
- package/docs/components/toaster.md +6 -3
- package/docs/components/tooltip.md +13 -23
- package/docs/index.md +3 -1
- package/docs/install-config.md +42 -8
- package/docs/normalization.md +48 -3
- package/docs/packages/stickers.md +56 -0
- package/docs/theming.md +362 -14
- package/package.json +7 -4
- package/dist/components/InputDate.module.css +0 -1
- package/dist/components/Select.module.css +0 -1
- package/dist/components/SelectFaceted.module.css +0 -1
- package/dist/theme-anta.css +0 -1
- /package/dist/{search-index.json → capture-types.js} +0 -0
|
@@ -52,42 +52,30 @@ field converts it (18 → 6 PM).
|
|
|
52
52
|
<InputDate size="large" label="Large" time defaultValue="2026-06-15T09:00" />
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
## InputDate props
|
|
56
|
+
|
|
55
57
|
| Prop | Type | Default | Description |
|
|
56
58
|
|------|------|---------|-------------|
|
|
57
59
|
| `clearable?` | boolean | — | Show a clear button once the field has a value. |
|
|
58
60
|
| `defaultValue?` | string | — | Initial value for the uncontrolled case. |
|
|
59
61
|
| `disabled?` | boolean | — | Disable the field and the calendar. |
|
|
60
|
-
| `hint?` | ReactNode | — | Helper text under the field. Replaced by a format hint while the entry is
|
|
61
|
-
|
|
62
|
-
| `
|
|
63
|
-
for 24-hour. Omit to follow the locale (`en-US` → 12-hour, most others → 24). |
|
|
64
|
-
| `icon?` | false \| IconShape | calendar-days | Leading icon at the start of the field — the calendar affordance. Pass
|
|
65
|
-
another shape to change it, or `false` to drop it. |
|
|
62
|
+
| `hint?` | ReactNode | — | Helper text under the field. Replaced by a format hint while the entry is unrecognized. |
|
|
63
|
+
| `hour12?` | boolean | — | Force the time cycle when `time` is on: `true` for 12-hour (AM/PM), `false` for 24-hour. Omit to follow the locale (`en-US` → 12-hour, most others → 24). |
|
|
64
|
+
| `icon?` | false \| IconShape | calendar-days | Leading icon at the start of the field — the calendar affordance. Pass another shape to change it, or `false` to drop it. |
|
|
66
65
|
| `label?` | ReactNode | — | Field label, above the control. |
|
|
67
|
-
| `locale?` | string | navigator.language | BCP-47 locale driving the display format, the placeholder mask, parsing order,
|
|
68
|
-
and the calendar. |
|
|
66
|
+
| `locale?` | string | navigator.language | BCP-47 locale driving the display format, the placeholder mask, parsing order, and the calendar. |
|
|
69
67
|
| `max?` | string | — | Latest selectable date (ISO). |
|
|
70
|
-
| `min?` | string | — | Earliest selectable date (ISO). Earlier days disable, and a typed date before
|
|
71
|
-
it stays uncommitted. |
|
|
68
|
+
| `min?` | string | — | Earliest selectable date (ISO). Earlier days disable, and a typed date before it stays uncommitted. |
|
|
72
69
|
| `name?` | string | — | Form field name — the ISO value submits under this key. |
|
|
73
70
|
| `offset?` | number | 4 | Gap in pixels between the field and the calendar menu. |
|
|
74
|
-
| `onValueChange?` | (value, attrs) => void | — | Fired after the value resolves (a recognized entry, a calendar pick, a time
|
|
75
|
-
change, or a clear), with the new ISO value (`''` when cleared) and a
|
|
76
|
-
`{ value, name }` snapshot. An unrecognized entry does not fire it. |
|
|
71
|
+
| `onValueChange?` | (value, attrs) => void | — | Fired after the value resolves (a recognized entry, a calendar pick, a time change, or a clear), with the new ISO value (`''` when cleared) and a `{ value, name }` snapshot. An unrecognized entry does not fire it. |
|
|
77
72
|
| `placeholder?` | string | the locale's format mask (e.g. `MM/DD/YYYY`, `MM/DD/YYYY HH:MM` with `time`) | Placeholder shown when empty. |
|
|
78
|
-
| `placement?` | 'left' \| 'right' \| 'bottom' \| 'top' \| 'bottom-start' \| 'bottom-end' \| 'top-start' \| 'top-end' \| 'right-start' \| 'right-end' \| 'left-start' \| 'left-end' | bottom-start | Preferred placement of the calendar menu relative to the field. Same values as
|
|
79
|
-
`Menu`; it auto-flips and clamps when space runs out. |
|
|
73
|
+
| `placement?` | 'left' \| 'right' \| 'bottom' \| 'top' \| 'bottom-start' \| 'bottom-end' \| 'top-start' \| 'top-end' \| 'right-start' \| 'right-end' \| 'left-start' \| 'left-end' | bottom-start | Preferred placement of the calendar menu relative to the field. Same values as `Menu`; it auto-flips and clamps when space runs out. |
|
|
80
74
|
| `round?` | boolean \| number \| string | — | Round the field corners — `true` for fully round, or a number / CSS length. |
|
|
81
75
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Field size. Also sizes the calendar and the time row. |
|
|
82
76
|
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | neutral | Validation/feedback tone. An unrecognized entry forces `critical` until fixed. |
|
|
83
|
-
| `time?` | boolean | — | Include a time. The value becomes ISO `YYYY-MM-DDTHH:mm`, the field parses a
|
|
84
|
-
|
|
85
|
-
shows a time row (hours : minutes, an AM/PM toggle in 12-hour locales, then a
|
|
86
|
-
Done button) under the calendar. Picking a day keeps the menu open so you can
|
|
87
|
-
set the time. |
|
|
88
|
-
| `value?` | string | — | Controlled value — ISO `YYYY-MM-DD` (or `YYYY-MM-DDTHH:mm` with `time`), `''`
|
|
89
|
-
for empty. Pair with `onValueChange`; the field and calendar follow it and a
|
|
90
|
-
pick only *requests* a change. |
|
|
77
|
+
| `time?` | boolean | — | Include a time. The value becomes ISO `YYYY-MM-DDTHH:mm`, the field parses a trailing time after a space (`06/15/2026 14:30`, `… 2:30pm`), and the menu shows a time row (hours : minutes, an AM/PM toggle in 12-hour locales, then a Done button) under the calendar. Picking a day keeps the menu open so you can set the time. |
|
|
78
|
+
| `value?` | string | — | Controlled value — ISO `YYYY-MM-DD` (or `YYYY-MM-DDTHH:mm` with `time`), `''` for empty. Pair with `onValueChange`; the field and calendar follow it and a pick only *requests* a change. |
|
|
91
79
|
|
|
92
80
|
## Calendar
|
|
93
81
|
|
|
@@ -336,6 +324,26 @@ Tracking the cursor, painting the grid from `buildMonth`, and re-rendering on
|
|
|
336
324
|
`navigate` is what the React `Calendar` packages, plus the year/month jump menu,
|
|
337
325
|
which uses the same `Menu` composition shown on the [Menu](./menu.md) page.
|
|
338
326
|
|
|
327
|
+
## Calendar props
|
|
328
|
+
|
|
329
|
+
| Prop | Type | Default | Description |
|
|
330
|
+
|------|------|---------|-------------|
|
|
331
|
+
| `aria-label?` | string | — | Accessible name for the grid (defaults to the visible month heading). |
|
|
332
|
+
| `defaultValue?` | string | — | Initial selected date for the uncontrolled case (ISO `YYYY-MM-DD`). |
|
|
333
|
+
| `disabled?` | boolean | — | Disable the whole calendar (not focusable or selectable). |
|
|
334
|
+
| `focusSignal?` | number | — | Move keyboard focus onto the active day. Change this to a new value (e.g. increment a counter) to focus the cursor cell — `InputDate` bumps it when the calendar is opened from the field by keyboard (ArrowDown), so focus lands in the grid. The initial value never focuses; only a change does. |
|
|
335
|
+
| `locale?` | string | navigator.language | BCP-47 locale tag driving first-day-of-week, weekday, and month names. |
|
|
336
|
+
| `max?` | string | — | Latest selectable date (ISO `YYYY-MM-DD`) — later days render disabled. |
|
|
337
|
+
| `min?` | string | — | Earliest selectable date (ISO `YYYY-MM-DD`) — earlier days render disabled. |
|
|
338
|
+
| `name?` | string | — | Form field name — the selected ISO date submits under this key. |
|
|
339
|
+
| `onChange?` | (event) => void | — | Fired *after* the selection changes (post-apply). Not cancelable; for a controlled calendar it fires once you've updated `value`. |
|
|
340
|
+
| `onStateChange?` | (event, detail) => void | — | Fired whenever the selection changes — event-first. `detail` is `{ next, prev, reason }`: `next` / `prev` are ISO date strings (`null` = none); `reason` is `'user'` \| `'reset'` \| `'restore'`. A `'user'` pick fires *before* applying and is **cancelable** — `event.preventDefault()` vetoes it (uncontrolled), or in controlled mode answer by updating `value`. `'reset'` / `'restore'` are not cancelable. |
|
|
341
|
+
| `onValueChange?` | (event, attrs) => void | — | Like `onChange`, but with a `{ value, name }` snapshot as the second argument, matching `Input`. |
|
|
342
|
+
| `size?` | 'small' \| 'medium' \| 'large' | 'medium' | Size of the whole calendar — scales the day cells, the chevrons, and the weekday / month-heading type together (uses Button's `small` / `medium` / `large` scale). |
|
|
343
|
+
| `value?` | string | — | Controlled selected date — ISO `YYYY-MM-DD`. When provided, the application controls selection: the grid follows this prop and a pick only *requests* a change via `onStateChange`. Leave undefined for uncontrolled. |
|
|
344
|
+
|
|
345
|
+
## Web Component
|
|
346
|
+
|
|
339
347
|
`InputDate` has no host element. Rebuilding its text parsing, dropdown calendar,
|
|
340
348
|
localized day grid, month navigation, keyboard navigation, and focus management
|
|
341
349
|
in vanilla JavaScript is significant work, even with Anta's `buildMonth` and
|
|
@@ -361,6 +369,8 @@ field treatments.
|
|
|
361
369
|
<input data-anta type="week" name="sprint-week" value="2026-W25">
|
|
362
370
|
```
|
|
363
371
|
|
|
372
|
+
## Styling
|
|
373
|
+
|
|
364
374
|
The calendar is **light DOM**, so everything is plain CSS, with no shadow parts or
|
|
365
375
|
hidden internals. The days and chevrons are real `<a-button>`s, so their colors,
|
|
366
376
|
hover, focus ring, and selected look come from the Button styles and theme
|
|
@@ -66,47 +66,39 @@ range is clamped to the nearest bound as you step or leave the field, and flags
|
|
|
66
66
|
<InputTime label="Office hours" size="large" min="09:00" max="17:00" defaultValue="09:30" />
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
## InputTime props
|
|
70
|
+
|
|
69
71
|
| Prop | Type | Default | Description |
|
|
70
72
|
|------|------|---------|-------------|
|
|
71
73
|
| `autoFocus?` | boolean | — | Focus this field when its containing `Dialog` opens. |
|
|
72
|
-
| `children?` | ReactNode | — | Extra content rendered under the field, above the hint (a no-box child like
|
|
73
|
-
a `<Tooltip>` takes no space and anchors to the field). |
|
|
74
|
+
| `children?` | ReactNode | — | Extra content rendered under the field, above the hint (a no-box child like a `<Tooltip>` takes no space and anchors to the field). |
|
|
74
75
|
| `clearable?` | boolean | — | Show a clear button once the field has a value. |
|
|
75
76
|
| `defaultValue?` | string | — | Initial value for the uncontrolled case (24-hour `"HH:mm"`). |
|
|
76
77
|
| `dimActions?` | boolean | — | Dim the trailing adornments at rest; they brighten on hover / focus. |
|
|
77
78
|
| `disabled?` | boolean | — | Disable the field. |
|
|
78
79
|
| `hint?` | ReactNode | — | Message below the field. `status` recolors it and prefixes a glyph. |
|
|
79
|
-
| `hour12?` | boolean | — | Force the clock: `true` = 12-hour (AM/PM), `false` = 24-hour. Omit to follow
|
|
80
|
-
the
|
|
81
|
-
| `
|
|
82
|
-
|
|
83
|
-
| `
|
|
84
|
-
|
|
85
|
-
| `locale?` | string | navigator.language | BCP-47 locale driving the clock (12h vs 24h), segment order, separator, and
|
|
86
|
-
the AM/PM text. |
|
|
87
|
-
| `max?` | string | — | Latest allowed time, 24-hour `"HH:mm"`. A complete value above it is clamped
|
|
88
|
-
down (on step / blur) and flagged `rangeOverflow`. |
|
|
89
|
-
| `min?` | string | — | Earliest allowed time, 24-hour `"HH:mm"`. A complete value below it is
|
|
90
|
-
clamped up (on step / blur) and flagged `rangeUnderflow` for form validity. |
|
|
80
|
+
| `hour12?` | boolean | — | Force the clock: `true` = 12-hour (AM/PM), `false` = 24-hour. Omit to follow the locale. |
|
|
81
|
+
| `icon?` | false \| IconShape | clock | Leading icon at the start of the field — the clock affordance. Pass another shape to change it, or `false` to drop it. |
|
|
82
|
+
| `label?` | ReactNode | — | Field label, shown above the control and used as the segment group's accessible name. |
|
|
83
|
+
| `locale?` | string | navigator.language | BCP-47 locale driving the clock (12h vs 24h), segment order, separator, and the AM/PM text. |
|
|
84
|
+
| `max?` | string | — | Latest allowed time, 24-hour `"HH:mm"`. A complete value above it is clamped down (on step / blur) and flagged `rangeOverflow`. |
|
|
85
|
+
| `min?` | string | — | Earliest allowed time, 24-hour `"HH:mm"`. A complete value below it is clamped up (on step / blur) and flagged `rangeUnderflow` for form validity. |
|
|
91
86
|
| `name?` | string | — | Form field name — the 24-hour value submits under this key. |
|
|
92
87
|
| `onBlur?` | (e) => void | — | Fires when the field loses focus. |
|
|
93
88
|
| `onClearInput?` | (e) => void | — | Fires after the built-in clear button has cleared the field. |
|
|
94
89
|
| `onFocus?` | (e) => void | — | Fires when the field gains focus. |
|
|
95
|
-
| `onValueChange?` | (event, attrs) => void | — | Fires on every edit (`input`), with the native event + an `attrs` snapshot
|
|
96
|
-
(`value`, `name`, `empty`, `valid`, `validationMessage`). Also fires on
|
|
97
|
-
`change` (blur) and on clear. |
|
|
90
|
+
| `onValueChange?` | (event, attrs) => void | — | Fires on every edit (`input`), with the native event + an `attrs` snapshot (`value`, `name`, `empty`, `valid`, `validationMessage`). Also fires on `change` (blur) and on clear. |
|
|
98
91
|
| `required?` | boolean | — | Mark the field required (drives native validity). |
|
|
99
92
|
| `round?` | boolean \| number \| string | — | Fully-round the field, or a custom radius (`number` px / CSS length). |
|
|
100
93
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Size variant. small=24px, medium=28px, large=32px tall. |
|
|
101
|
-
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | — | Validation / feedback tone. Only `critical` marks the field invalid; the
|
|
102
|
-
|
|
103
|
-
| `
|
|
104
|
-
shape to override, or `false` to drop it). |
|
|
105
|
-
| `tone?` | string | — | Custom accent color — any literal CSS color tints the resting + hover
|
|
106
|
-
border (focus ring stays `--focus-ring`); `status` overrides for validation. |
|
|
94
|
+
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | — | Validation / feedback tone. Only `critical` marks the field invalid; the others are advisory. Omit (or `neutral`) for a plain field. |
|
|
95
|
+
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph before the `hint` when `status` is set (per-status default; pass a shape to override, or `false` to drop it). |
|
|
96
|
+
| `tone?` | string | — | Custom accent color — any literal CSS color tints the resting + hover border (focus ring stays `--focus-ring`); `status` overrides for validation. |
|
|
107
97
|
| `trailing?` | ReactNode | — | Content pinned to the end of the field (after the clear button). |
|
|
108
98
|
| `value?` | string | — | Controlled value — 24-hour `"HH:mm"`. Pair with `onValueChange`. |
|
|
109
99
|
|
|
100
|
+
## Web Component
|
|
101
|
+
|
|
110
102
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
111
103
|
|
|
112
104
|
Slots supply the field label and leading icon.
|
package/docs/components/input.md
CHANGED
|
@@ -424,106 +424,55 @@ wraps to fewer columns as it narrows. Resize the preview to see it reflow.
|
|
|
424
424
|
`}</style>
|
|
425
425
|
```
|
|
426
426
|
|
|
427
|
-
|
|
427
|
+
## Component props
|
|
428
428
|
|
|
429
429
|
| Prop | Type | Default | Description |
|
|
430
430
|
|------|------|---------|-------------|
|
|
431
|
-
| `autoComplete?` | 'off' \| 'on' \| 'name' \| 'username' \| 'email' \| 'current-password' \| 'new-password' \| 'one-time-code' \| 'tel' \| 'url' \| (string & {}) | — | Native autocomplete token. Overrides the value derived from `type`
|
|
432
|
-
(`email` / `tel` / `url`) — set it for the cases `type` can't express, e.g.
|
|
433
|
-
`username`, `current-password`, `new-password`, `one-time-code`, or `off`. |
|
|
431
|
+
| `autoComplete?` | 'off' \| 'on' \| 'name' \| 'username' \| 'email' \| 'current-password' \| 'new-password' \| 'one-time-code' \| 'tel' \| 'url' \| (string & {}) | — | Native autocomplete token. Overrides the value derived from `type` (`email` / `tel` / `url`) — set it for the cases `type` can't express, e.g. `username`, `current-password`, `new-password`, `one-time-code`, or `off`. |
|
|
434
432
|
| `autoFocus?` | boolean | — | Focus this field when its containing `Dialog` opens. |
|
|
435
|
-
| `children?` | ReactNode | — | Extra content rendered directly under the field, above the hint/error (it
|
|
436
|
-
|
|
437
|
-
space and anchors to the field — consistent with how tooltips attach
|
|
438
|
-
to any other element. Use the named `leading` / `trailing` props for
|
|
439
|
-
in-field content. |
|
|
440
|
-
| `clearable?` | boolean | — | Show a clear button as the first trailing item once the field has a
|
|
441
|
-
value. |
|
|
433
|
+
| `children?` | ReactNode | — | Extra content rendered directly under the field, above the hint/error (it pushes the message down). A no-box child like an Anta `<Tooltip>` takes no space and anchors to the field — consistent with how tooltips attach to any other element. Use the named `leading` / `trailing` props for in-field content. |
|
|
434
|
+
| `clearable?` | boolean | — | Show a clear button as the first trailing item once the field has a value. |
|
|
442
435
|
| `defaultValue?` | string | — | Initial value for the uncontrolled case. |
|
|
443
|
-
| `dimActions?` | boolean | — | Dim the `leading` / `trailing` adornments at rest; they brighten to full
|
|
444
|
-
when the field is hovered or focused (a quiet-until-engaged affordance for
|
|
445
|
-
trailing actions). |
|
|
436
|
+
| `dimActions?` | boolean | — | Dim the `leading` / `trailing` adornments at rest; they brighten to full when the field is hovered or focused (a quiet-until-engaged affordance for trailing actions). |
|
|
446
437
|
| `disabled?` | boolean | — | Disable the field. |
|
|
447
|
-
| `hint?` | ReactNode | — | Message below the field. Neutral helper text by default; `status` recolors
|
|
448
|
-
it and prefixes the matching glyph. |
|
|
438
|
+
| `hint?` | ReactNode | — | Message below the field. Neutral helper text by default; `status` recolors it and prefixes the matching glyph. |
|
|
449
439
|
| `inputMode?` | 'none' \| 'text' \| 'decimal' \| 'numeric' \| 'tel' \| 'search' \| 'email' \| 'url' | — | Virtual-keyboard hint. Overrides the value derived from `type`. |
|
|
450
|
-
| `label?` | ReactNode | — | Field label, shown above the control. A string is rendered with the
|
|
451
|
-
label type scale; pass a node for full control. Associated with the
|
|
452
|
-
control as its accessible name (the element mirrors the label text to
|
|
453
|
-
`aria-label`, since `<label for>` can't cross the shadow boundary). |
|
|
440
|
+
| `label?` | ReactNode | — | Field label, shown above the control. A string is rendered with the label type scale; pass a node for full control. Associated with the control as its accessible name (the element mirrors the label text to `aria-label`, since `<label for>` can't cross the shadow boundary). |
|
|
454
441
|
| `leading?` | ReactNode | — | Content pinned to the start of the field (e.g. an icon). |
|
|
455
442
|
| `max?` | number \| string | — | |
|
|
456
443
|
| `maxLength?` | number | — | Max input length. |
|
|
457
|
-
| `maxRows?` | number | — | Cap the autogrow height (in rows) of a `multiline` field with no `rows`.
|
|
458
|
-
Omit for unbounded growth. |
|
|
444
|
+
| `maxRows?` | number | — | Cap the autogrow height (in rows) of a `multiline` field with no `rows`. Omit for unbounded growth. |
|
|
459
445
|
| `min?` | number \| string | — | Min / max / step — for `type="number"`. |
|
|
460
446
|
| `minLength?` | number | — | Min input length. |
|
|
461
|
-
| `multiline?` | boolean | — | Render a `<textarea>` instead of an `<input>`. Without `rows` it grows
|
|
462
|
-
with its content from one line (capped by `maxRows` if set). Autogrow uses
|
|
463
|
-
CSS `field-sizing` where supported (Chrome/Edge, Safari ≥ 26.2) and falls
|
|
464
|
-
back to a built-in JS resize elsewhere (Firefox, older Safari), so it grows
|
|
465
|
-
in every browser. |
|
|
447
|
+
| `multiline?` | boolean | — | Render a `<textarea>` instead of an `<input>`. Without `rows` it grows with its content from one line (capped by `maxRows` if set). Autogrow uses CSS `field-sizing` where supported (Chrome/Edge, Safari ≥ 26.2) and falls back to a built-in JS resize elsewhere (Firefox, older Safari), so it grows in every browser. |
|
|
466
448
|
| `name?` | string | — | Form field name — submitted with the form via ElementInternals. |
|
|
467
449
|
| `onBlur?` | (e) => void | — | Fires when the field loses focus. |
|
|
468
|
-
| `onChange?` | (e) => void | — | Fires on **commit** (blur / Enter) — the platform `change` semantics, **not**
|
|
469
|
-
|
|
470
|
-
the
|
|
471
|
-
(both) for live updates. Read `e.target.value`. |
|
|
472
|
-
| `onClearClick?` | (e) => void | — | Fires when the built-in clear button (`clearable`) is clicked, *before*
|
|
473
|
-
the field is cleared. Call `e.preventDefault()` to keep the current value
|
|
474
|
-
— the clear is cancelled and `onClearInput` won't fire. Backed by the
|
|
475
|
-
element's cancelable, bubbling `clearclick` event. |
|
|
476
|
-
| `onClearInput?` | (e) => void | — | Fires after the built-in clear button (`clearable`) has cleared the field
|
|
477
|
-
— so `onInput` / `onChange` fire too — making this useful for reacting
|
|
478
|
-
specifically to a clear. Doesn't fire if `onClearClick` cancelled the
|
|
479
|
-
clear. Backed by the element's bubbling `clearinput` event. |
|
|
450
|
+
| `onChange?` | (e) => void | — | Fires on **commit** (blur / Enter) — the platform `change` semantics, **not** React's per-keystroke `onChange`. This is a web component, so `onChange` keeps the native meaning; reach for `onInput` (every keystroke) or `onValueChange` (both) for live updates. Read `e.target.value`. |
|
|
451
|
+
| `onClearClick?` | (e) => void | — | Fires when the built-in clear button (`clearable`) is clicked, *before* the field is cleared. Call `e.preventDefault()` to keep the current value — the clear is cancelled and `onClearInput` won't fire. Backed by the element's cancelable, bubbling `clearclick` event. |
|
|
452
|
+
| `onClearInput?` | (e) => void | — | Fires after the built-in clear button (`clearable`) has cleared the field — so `onInput` / `onChange` fire too — making this useful for reacting specifically to a clear. Doesn't fire if `onClearClick` cancelled the clear. Backed by the element's bubbling `clearinput` event. |
|
|
480
453
|
| `onFocus?` | (e) => void | — | Fires when the field gains focus. |
|
|
481
454
|
| `onInput?` | (e) => void | — | Fires on every keystroke. Read `e.target.value`. |
|
|
482
|
-
| `onValueChange?` | (event, attrs) => void | — | Unified value-change handler — the easy path for state. Fires on `input`
|
|
483
|
-
*and* `change` (and on clear), with the native `event` plus a convenience
|
|
484
|
-
`attrs` snapshot (`value`, `name`, `empty`, `valid`, `validationMessage`) so
|
|
485
|
-
you can do `setForm(s => ({ ...s, [attrs.name]: attrs.value }))` without
|
|
486
|
-
digging into the event. Use `event.type` to tell a live edit (`input`) from
|
|
487
|
-
a commit (`change`); read `id` / `type` / `className` off `event.target`. |
|
|
455
|
+
| `onValueChange?` | (event, attrs) => void | — | Unified value-change handler — the easy path for state. Fires on `input` *and* `change` (and on clear), with the native `event` plus a convenience `attrs` snapshot (`value`, `name`, `empty`, `valid`, `validationMessage`) so you can do `setForm(s => ({ ...s, [attrs.name]: attrs.value }))` without digging into the event. Use `event.type` to tell a live edit (`input`) from a commit (`change`); read `id` / `type` / `className` off `event.target`. |
|
|
488
456
|
| `pattern?` | string | — | Validation pattern (single-line). |
|
|
489
457
|
| `placeholder?` | string | — | Placeholder shown when empty. |
|
|
490
458
|
| `readOnly?` | boolean | — | Make the field read-only. |
|
|
491
459
|
| `required?` | boolean | — | Mark the field required (drives native validity). |
|
|
492
|
-
| `role?` | string | — | ARIA `role` for the field — e.g. `combobox` when the input drives a
|
|
493
|
-
|
|
494
|
-
| `
|
|
495
|
-
|
|
496
|
-
a circle to match (it isn't sized by a custom field value). |
|
|
497
|
-
| `rows?` | number | — | Fixed visible row count — a constant-height `<textarea>` (implies
|
|
498
|
-
`multiline`). |
|
|
499
|
-
| `size?` | 'small' \| 'medium' \| 'large' | medium | Size variant. small=24px, medium=28px, large=32px tall; the type scale and
|
|
500
|
-
icon track the size (small 13/16 + 14px icon · medium 15/20 + 16px ·
|
|
501
|
-
large 17/22 + 18px). |
|
|
460
|
+
| `role?` | string | — | ARIA `role` for the field — e.g. `combobox` when the input drives a suggestion `listbox` (see `InputAutocomplete`). Left unset by default. |
|
|
461
|
+
| `round?` | boolean \| number \| string | — | Fully-round the field (`border-radius: 999px`). Pass a `number` (px) or a CSS length string for a custom radius. The `clearable` × button always rounds to a circle to match (it isn't sized by a custom field value). |
|
|
462
|
+
| `rows?` | number | — | Fixed visible row count — a constant-height `<textarea>` (implies `multiline`). |
|
|
463
|
+
| `size?` | 'small' \| 'medium' \| 'large' | medium | Size variant. small=24px, medium=28px, large=32px tall; the type scale and icon track the size (small 13/16 + 14px icon · medium 15/20 + 16px · large 17/22 + 18px). |
|
|
502
464
|
| `spellCheck?` | boolean | — | Toggle native spell-checking. |
|
|
503
|
-
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | — | Validation / feedback tone — colors the border + `hint` and prefixes a
|
|
504
|
-
|
|
505
|
-
submission, `:state(invalid)`); `success` / `warning` / `info` / `brand`
|
|
506
|
-
are advisory and stay valid. Omit (or `neutral`) for a plain field. |
|
|
507
|
-
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph shown before the `hint` when `status` is set. Each status has a
|
|
508
|
-
default (critical → `warning-diamond`, warning → `warning-triangle`,
|
|
509
|
-
success → `circle-check`, info → `info`, brand → `circle-small-solid`); pass a
|
|
510
|
-
shape to override, or `false` to drop it. `neutral` has no default glyph. |
|
|
465
|
+
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | — | Validation / feedback tone — colors the border + `hint` and prefixes a glyph. Only `critical` marks the field invalid (`aria-invalid`, blocks form submission, `:state(invalid)`); `success` / `warning` / `info` / `brand` are advisory and stay valid. Omit (or `neutral`) for a plain field. |
|
|
466
|
+
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph shown before the `hint` when `status` is set. Each status has a default (critical → `warning-diamond`, warning → `warning-triangle`, success → `circle-check`, info → `info`, brand → `circle-small-solid`); pass a shape to override, or `false` to drop it. `neutral` has no default glyph. |
|
|
511
467
|
| `step?` | number \| string | — | |
|
|
512
|
-
| `tone?` | string | — | Custom accent color — any literal CSS color tints the resting + hover
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
| `
|
|
516
|
-
clear button when `clearable`. |
|
|
517
|
-
| `truncate?` | boolean | true | Ellipsize an overflowing single-line value. Read-only inputs already do
|
|
518
|
-
this; pass `false` when an editable field should show the full value. |
|
|
519
|
-
| `type?` | 'text' \| 'search' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'number' | text | Single-line input type. Ignored when `multiline`. `search` is a
|
|
520
|
-
**wrapper-only** shorthand: it defaults a leading search icon and a clear
|
|
521
|
-
button (both overridable — pass your own `leading`, or `clearable={false}`)
|
|
522
|
-
and sets `inputmode="search"`, but the DOM input stays `type="text"`. The
|
|
523
|
-
native `search` type never reaches the element, so the browser's own
|
|
524
|
-
clear/search affordances never appear — Anta owns that chrome. |
|
|
468
|
+
| `tone?` | string | — | Custom accent color — any literal CSS color tints the resting + hover border (focus ring stays the global `--focus-ring`). For consistency with the other controls' custom-tone knob; a `status` still overrides for validation. |
|
|
469
|
+
| `trailing?` | ReactNode | — | Content pinned to the end of the field (e.g. icons, buttons), after the clear button when `clearable`. |
|
|
470
|
+
| `truncate?` | boolean | true | Ellipsize an overflowing single-line value. Read-only inputs already do this; pass `false` when an editable field should show the full value. |
|
|
471
|
+
| `type?` | 'text' \| 'search' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'number' | text | Single-line input type. Ignored when `multiline`. `search` is a **wrapper-only** shorthand: it defaults a leading search icon and a clear button (both overridable — pass your own `leading`, or `clearable={false}`) and sets `inputmode="search"`, but the DOM input stays `type="text"`. The native `search` type never reaches the element, so the browser's own clear/search affordances never appear — Anta owns that chrome. |
|
|
525
472
|
| `value?` | string | — | Controlled value. Pair with `onChange` / `onInput`. |
|
|
526
473
|
|
|
474
|
+
## Web Component
|
|
475
|
+
|
|
527
476
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
528
477
|
|
|
529
478
|
Slots hold the label, hint, and controls around the native field.
|
|
@@ -568,6 +517,8 @@ their `size` attribute, so Anta does not reuse it. `round` and a custom-color
|
|
|
568
517
|
<input data-anta type="reset" value="Reset">
|
|
569
518
|
```
|
|
570
519
|
|
|
520
|
+
## Styling
|
|
521
|
+
|
|
571
522
|
Reach for the props first: **`status`** sets a validation tone (border + message),
|
|
572
523
|
**`tone`** a custom accent color for the border (any CSS color), **`size`** the
|
|
573
524
|
dimensions. The focus ring is the global [`--focus-ring`](../colors.md#focus-ring).
|
|
@@ -52,18 +52,18 @@ label, state, and semantics.
|
|
|
52
52
|
|
|
53
53
|
Use `<Loader>` when you need a value, speed, or accessible loading status.
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
## Component props
|
|
56
56
|
|
|
57
57
|
| Prop | Type | Default | Description |
|
|
58
58
|
|------|------|---------|-------------|
|
|
59
|
-
| `label?` | string | — | Accessible name for a standalone loader. Without a label, the loader is
|
|
60
|
-
decorative so nearby status text remains the single announcement. |
|
|
59
|
+
| `label?` | string | — | Accessible name for a standalone loader. Without a label, the loader is decorative so nearby status text remains the single announcement. |
|
|
61
60
|
| `max?` | number | 100 | Upper bound of the range. |
|
|
62
61
|
| `size?` | number | 16 | Width and height in pixels. |
|
|
63
62
|
| `speed?` | number | 0.75 | Seconds per rotation. Pass a positive number. |
|
|
64
63
|
| `tone?` | LoaderTone | — | Color tone for the loader. Omit it to use the standard text-3 color. |
|
|
65
|
-
| `value?` | number \| false | — | Current progress value. Omit this prop, or pass `false`, for an
|
|
66
|
-
|
|
64
|
+
| `value?` | number \| false | — | Current progress value. Omit this prop, or pass `false`, for an indeterminate rotating gradient. |
|
|
65
|
+
|
|
66
|
+
## Web Component
|
|
67
67
|
|
|
68
68
|
Use a raw `<a-loader>` when you are not using the JSX wrapper. Set its size,
|
|
69
69
|
speed, and determinate percentage with CSS custom properties. `value` selects
|
|
@@ -92,6 +92,8 @@ the static ring; `--loader-value` is the percentage it shows.
|
|
|
92
92
|
When the value is unknown, omit `value` and give a standalone loader an
|
|
93
93
|
accessible name. Mark a loader beside visible status text with `aria-hidden`.
|
|
94
94
|
|
|
95
|
+
## Styling
|
|
96
|
+
|
|
95
97
|
The standalone Loader uses the quiet `--text-3` color by default. Set `color`
|
|
96
98
|
directly when it needs a deliberate semantic or one-off color; the `loader`
|
|
97
99
|
icon alias inherits its parent control’s color.
|
package/docs/components/menu.md
CHANGED
|
@@ -49,9 +49,8 @@ action. Pass **any CSS color** for a one-off custom tone — its hue and chroma
|
|
|
49
49
|
kept while the lightness is pinned to match the brand text (resolved through
|
|
50
50
|
`--menu-item-tone-source`).
|
|
51
51
|
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
(`Select` uses it to tone the chosen row).
|
|
52
|
+
`toneScope="selected"` applies `tone` **only while the row is `selected`** — an
|
|
53
|
+
unselected row stays neutral. `Select` uses the same pair to tone chosen rows.
|
|
55
54
|
|
|
56
55
|
```tsx
|
|
57
56
|
<Menu>
|
|
@@ -366,6 +365,8 @@ chevron stay centered on the row, so it composes with a trailing counter.
|
|
|
366
365
|
</Menu>
|
|
367
366
|
```
|
|
368
367
|
|
|
368
|
+
## MenuItemCopy
|
|
369
|
+
|
|
369
370
|
`MenuItemCopy` is a row that copies to the clipboard when chosen: `copy` for a
|
|
370
371
|
string, `copyNode` for a DOM region, or `copyUrl` for the current URL. It composes
|
|
371
372
|
a `<MenuItem>` with a slotted `<a-copy>` element that performs the write, and
|
|
@@ -390,89 +391,32 @@ navigating links.
|
|
|
390
391
|
|
|
391
392
|
| Prop | Type | Default | Description |
|
|
392
393
|
|------|------|---------|-------------|
|
|
393
|
-
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most
|
|
394
|
-
notably the nested `<Menu>` for a submenu parent. |
|
|
394
|
+
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most notably the nested `<Menu>` for a submenu parent. |
|
|
395
395
|
| `copiedLabel?` | string | Copied | Text in the successful no-icon confirmation. |
|
|
396
396
|
| `copy?` | string | — | Text copied to the clipboard on activation. |
|
|
397
|
-
| `copyNode?` | boolean \| string | — | Copy a DOM node as rich text (`text/html`) + plain text. `true` copies
|
|
398
|
-
the nearest ancestor marked `data-copy-source`; a string is a CSS
|
|
399
|
-
selector for an ancestor region (`closest`). The copy control is stripped
|
|
400
|
-
from the copied output. |
|
|
397
|
+
| `copyNode?` | boolean \| string | — | Copy a DOM node as rich text (`text/html`) + plain text. `true` copies the nearest ancestor marked `data-copy-source`; a string is a CSS selector for an ancestor region (`closest`). The copy control is stripped from the copied output. |
|
|
401
398
|
| `copyUrl?` | true | — | Copy the current page URL (`location.href`). |
|
|
402
399
|
| `copyWithUrl?` | boolean | — | Prefix the copied text with `// URL: <current page URL>`. |
|
|
403
|
-
| `disabled?` | boolean | — | Disable the item: greyed out, not focusable for activation, no close. A
|
|
404
|
-
|
|
405
|
-
| `hint?` | ReactNode | — | Secondary text under the label — explanatory copy, like `RadioGroup`'s
|
|
406
|
-
option `hint`. Requires `label` (it stacks in a column beneath it). Muted
|
|
407
|
-
(`--text-3`) and tracks the row's `tone`. A string, or any node. |
|
|
400
|
+
| `disabled?` | boolean | — | Disable the item: greyed out, not focusable for activation, no close. A disabled link also drops its `href`, so it can't navigate. |
|
|
401
|
+
| `hint?` | ReactNode | — | Secondary text under the label — explanatory copy, like `RadioGroup`'s option `hint`. Requires `label` (it stacks in a column beneath it). Muted (`--text-3`) and tracks the row's `tone`. A string, or any node. |
|
|
408
402
|
| `icon?` | IconShape | — | Leading icon shape. |
|
|
409
|
-
| `iconPlacement?` | 'leading' \| 'trailing' \| 'none' | 'leading' | Where the copy glyph sits relative to the label — or `'none'` to omit it.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
| `
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
| `indeterminate?` | boolean | — | Only meaningful with `selectionIndicator="checkbox"`: render the box in the
|
|
416
|
-
mixed state (`aria-checked="mixed"`) — e.g. a "Select all" row when some but
|
|
417
|
-
not all of its options are selected. |
|
|
418
|
-
| `indicator?` | React.ReactNode | — | Replace the built-in selection-indicator *visual* with your own node,
|
|
419
|
-
rendered at the **leading** edge (where the checkbox / radio sit). Pair with
|
|
420
|
-
`selectionIndicator` to keep the semantics — the row stays the control and
|
|
421
|
-
carries `role` + `aria-checked`; only the drawn mark changes. Suppresses the
|
|
422
|
-
built-in checkbox / radio and the trailing `check` glyph. The node is made
|
|
423
|
-
passive (aria-hidden, no pointer events) so the row receives the click. |
|
|
424
|
-
| `kbd?` | string | — | Trailing shortcut hint, e.g. `"⌘E"`. Anta translates it to
|
|
425
|
-
`aria-keyshortcuts` and hides the visual glyphs from assistive technology.
|
|
426
|
-
Use `+` within a chord and spaces between shortcuts (`"⌘K ⌘S"` becomes
|
|
427
|
-
`"Meta+K Meta+S"`). Pass `aria-keyshortcuts` to override the translation.
|
|
428
|
-
This does not bind the shortcut. |
|
|
429
|
-
| `label?` | ReactNode | — | The item's text. Usually a string, but any node is accepted — e.g. a filtered
|
|
430
|
-
`Select` bolds the matched substring. Omit and pass `children` for richer
|
|
431
|
-
content. |
|
|
403
|
+
| `iconPlacement?` | 'leading' \| 'trailing' \| 'none' | 'leading' | Where the copy glyph sits relative to the label — or `'none'` to omit it. Without a glyph, a successful copy shows a confirmation label near the pointer and leaves the row unchanged. |
|
|
404
|
+
| `iconTrailing?` | IconShape | — | A trailing icon. On a `submenu` item this **overrides** the default chevron (omit it to keep the chevron); on a normal item it's the trailing glyph (omit for none). |
|
|
405
|
+
| `indeterminate?` | boolean | — | Only meaningful with `selectionIndicator="checkbox"`: render the box in the mixed state (`aria-checked="mixed"`) — e.g. a "Select all" row when some but not all of its options are selected. |
|
|
406
|
+
| `indicator?` | React.ReactNode | — | Replace the built-in selection-indicator *visual* with your own node, rendered at the **leading** edge (where the checkbox / radio sit). Pair with `selectionIndicator` to keep the semantics — the row stays the control and carries `role` + `aria-checked`; only the drawn mark changes. Suppresses the built-in checkbox / radio and the trailing `check` glyph. The node is made passive (aria-hidden, no pointer events) so the row receives the click. |
|
|
407
|
+
| `kbd?` | string | — | Trailing shortcut hint, e.g. `"⌘E"`. Anta translates it to `aria-keyshortcuts` and hides the visual glyphs from assistive technology. Use `+` within a chord and spaces between shortcuts (`"⌘K ⌘S"` becomes `"Meta+K Meta+S"`). Pass `aria-keyshortcuts` to override the translation. This does not bind the shortcut. |
|
|
408
|
+
| `label?` | ReactNode | — | The item's text. Usually a string, but any node is accepted — e.g. a filtered `Select` bolds the matched substring. Omit and pass `children` for richer content. |
|
|
432
409
|
| `onCopied?` | (ok) => void | — | Fires after the copy attempt with whether it succeeded. |
|
|
433
|
-
| `onCopyRequest?` | () => void | — | Refresh a dynamic `copy` value before activation. Set the new string in
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
| `
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
| `
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
alongside the navigation. Receives the event plus a `{ value, label }`
|
|
444
|
-
detail. |
|
|
445
|
-
| `role?` | string | — | ARIA role override. Defaults to the role implied by `selectionIndicator`
|
|
446
|
-
(`menuitem` / `menuitemcheckbox` / `menuitemradio`); set it to reparent the
|
|
447
|
-
row under a different container role — e.g. `option` inside a `listbox`. |
|
|
448
|
-
| `selected?` | boolean | — | Mark the item as selected. On a plain row (no `selectionIndicator`) this is
|
|
449
|
-
a persistent background tint, the same resting fill a pressed row shows —
|
|
450
|
-
also the way to flag the current page on a link item. On a checkable row
|
|
451
|
-
(`selectionIndicator` set) it instead drives the leading `checkbox` / `radio`
|
|
452
|
-
indicator and the row's `aria-checked`. |
|
|
453
|
-
| `selectionIndicator?` | 'checkbox' \| 'radio' \| 'check' | — | Turn the row into a checkable item, driven by `selected` (the row stays the
|
|
454
|
-
control and carries `aria-checked`):
|
|
455
|
-
- `'checkbox'` → `role="menuitemcheckbox"`, a leading passive `<a-checkbox>`
|
|
456
|
-
(before `icon`); the tint is dropped (the box carries state).
|
|
457
|
-
- `'radio'` → `role="menuitemradio"`, a leading passive `<a-radio>`; tint dropped.
|
|
458
|
-
- `'check'` → `role="menuitemradio"`, a trailing check glyph on the selected
|
|
459
|
-
row *and* the background tint (the canonical single-select look).
|
|
460
|
-
Omit for a plain row (the default). |
|
|
461
|
-
| `submenu?` | boolean | — | Marks this item as a submenu parent: adds the trailing chevron and
|
|
462
|
-
`aria-haspopup="menu"`. Nest the flyout as a `<Menu>` child. |
|
|
463
|
-
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Semantic tone — colors the label, icon, and hover/selected tint (and the
|
|
464
|
-
`checkbox`/`radio` indicator, which adopts it). A named tone, or any literal
|
|
465
|
-
CSS color (`'#ff1493'`, `'rebeccapurple'`) for a one-off custom tone whose
|
|
466
|
-
hue + chroma are kept while the lightness is pinned to match the brand text.
|
|
467
|
-
`critical` is the destructive action; `neutral` (the default) is the standard
|
|
468
|
-
gray. |
|
|
469
|
-
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Like `tone`, but applied only while the row is `selected` — an unselected row
|
|
470
|
-
stays neutral. The whole selected row (label, icon, tint, and the `checkbox` /
|
|
471
|
-
`radio` indicator) takes the tone. Same value set as `tone`; on a selected row
|
|
472
|
-
`toneSelected` wins over `tone` when both are set. |
|
|
473
|
-
| `value?` | string \| number | — | An opaque value identifying this item, handed back in `onSelect`'s detail
|
|
474
|
-
so a shared handler can tell which row was chosen without a per-item
|
|
475
|
-
closure. |
|
|
410
|
+
| `onCopyRequest?` | () => void | — | Refresh a dynamic `copy` value before activation. Set the new string in application state so the next render updates `copy`. Return values are ignored. Fires on pointerdown and Enter/Space keydown. |
|
|
411
|
+
| `onMouseDown?` | (event) => void | — | Raw `mousedown` on the row. Mainly to `preventDefault()` so the row doesn't take focus on a mouse press — e.g. a combobox option keeping focus in its input field while the click still selects. |
|
|
412
|
+
| `onSelect?` | (event, detail) => void | — | Activation handler — fires when *this* item is chosen (click / Enter / Space), unless it's `disabled`. It does **not** fire for a submenu parent (clicking that opens the flyout, which isn't a selection) nor for a selection bubbling up from a nested submenu. On a link item it fires alongside the navigation. Receives the event plus a `{ value, label }` detail. |
|
|
413
|
+
| `role?` | string | — | ARIA role override. Defaults to the role implied by `selectionIndicator` (`menuitem` / `menuitemcheckbox` / `menuitemradio`); set it to reparent the row under a different container role — e.g. `option` inside a `listbox`. |
|
|
414
|
+
| `selected?` | boolean | — | Mark the item as selected. On a plain row (no `selectionIndicator`) this is a persistent background tint, the same resting fill a pressed row shows — also the way to flag the current page on a link item. On a checkable row (`selectionIndicator` set) it instead drives the leading `checkbox` / `radio` indicator and the row's `aria-checked`. |
|
|
415
|
+
| `selectionIndicator?` | 'checkbox' \| 'radio' \| 'check' | — | Turn the row into a checkable item, driven by `selected` (the row stays the control and carries `aria-checked`): - `'checkbox'` → `role="menuitemcheckbox"`, a leading passive `<a-checkbox>` (before `icon`); the tint is dropped (the box carries state). - `'radio'` → `role="menuitemradio"`, a leading passive `<a-radio>`; tint dropped. - `'check'` → `role="menuitemradio"`, a trailing check glyph on the selected row *and* the background tint (the canonical single-select look). Omit for a plain row (the default). |
|
|
416
|
+
| `submenu?` | boolean | — | Marks this item as a submenu parent: adds the trailing chevron and `aria-haspopup="menu"`. Nest the flyout as a `<Menu>` child. |
|
|
417
|
+
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Semantic tone — colors the label, icon, and hover/selected tint (and the `checkbox`/`radio` indicator, which adopts it). A named tone, or any literal CSS color (`'#ff1493'`, `'rebeccapurple'`) for a one-off custom tone whose hue + chroma are kept while the lightness is pinned to match the brand text. `critical` is the destructive action; `neutral` (the default) is the standard gray. |
|
|
418
|
+
| `toneScope?` | ToneScope | 'all' | Apply `tone` to every row state, or only while the row is selected. In `selected` scope, an unselected row and its checkbox/radio indicator stay neutral. |
|
|
419
|
+
| `value?` | string \| number | — | An opaque value identifying this item, handed back in `onSelect`'s detail so a shared handler can tell which row was chosen without a per-item closure. |
|
|
476
420
|
|
|
477
421
|
## Keyboard
|
|
478
422
|
|
|
@@ -506,6 +450,55 @@ call `event.preventDefault()` to keep the menu as-is (e.g. block a dismiss).
|
|
|
506
450
|
Controlled, the menu never self-moves — apply `detail.next` to `open` to accept,
|
|
507
451
|
or do nothing to reject. (Submenus are always uncontrolled, regardless of `open`.)
|
|
508
452
|
|
|
453
|
+
## Menu props
|
|
454
|
+
|
|
455
|
+
| Prop | Type | Default | Description |
|
|
456
|
+
|------|------|---------|-------------|
|
|
457
|
+
| `autoWidth?` | boolean | — | Size the menu to its content instead of flooring its width to the trigger. A root menu is never narrower than its trigger by default; set this for a content menu under a wide trigger (e.g. a calendar below a full-width field) so it wraps its content and left-aligns under the trigger. |
|
|
458
|
+
| `children?` | ReactNode | — | The menu's contents: `MenuItem`, `MenuSeparator`, `MenuGroup`, or any custom element. |
|
|
459
|
+
| `context?` | boolean | — | Open on right-click (the `contextmenu` event) of the trigger region instead of a left click, positioned at the pointer. |
|
|
460
|
+
| `coord?` | boolean | — | Open at the pointer coordinates rather than aligned to the trigger box. Pairs naturally with `context`; on its own it positions a left-click menu at the cursor. |
|
|
461
|
+
| `inset?` | number \| string | 4 | Inner inset for the scroll body and named header/footer content. A number is pixels; a CSS length string is used as written. |
|
|
462
|
+
| `nohover?` | boolean | — | Submenu-only (a `<Menu>` nested inside a `MenuItem`); ignored on a root menu. Submenus open on hover by default (with intent timing) as well as on click — set `nohover` to make this submenu click-only. Hover-intent is mouse-only regardless: on touch (and pen) a submenu always opens on tap and stays open until dismissed. |
|
|
463
|
+
| `offset?` | number | 4 | Gap in pixels between the trigger and the menu. |
|
|
464
|
+
| `onactivedescendant?` | (e) => void | — | Combobox-mode cursor report (raw element event). Fires when the active option changes as arrow keys move the cursor while focus stays in a `[data-menu-search]` filter field; `detail.id` is the active option's `id` (`null` when none). The reactive layer that renders the field reflects this onto its `aria-activedescendant` — the element can't write that light-DOM attribute itself. Passed straight through to the element. |
|
|
465
|
+
| `onStateChange?` | (event, detail) => void | — | Fired before the open state changes — on open, and on every dismiss (Esc, outside-click, scroll, selecting an item). `event` is the cancelable `statechange`; `detail.next`/`detail.prev` are the requested/previous open state (booleans). It's the declarative way to observe a menu, and the handler you pair with `open` to drive a controlled menu (apply `detail.next` to `open`). Uncontrolled, `event.preventDefault()` vetoes the transition (e.g. keep the menu open). |
|
|
466
|
+
| `open?` | boolean | — | Controlled open state. Omit for the default **uncontrolled** menu (it opens/closes itself via its triggers). Pass a boolean to **control** it: the menu's visibility follows `open`, and user dismiss (Esc, outside-click, select) fires `onStateChange` *without* self-closing — you update `open` in response. Submenus are always uncontrolled regardless of this. See STATEFUL-COMPONENTS.md. |
|
|
467
|
+
| `placement?` | 'bottom-start' \| 'bottom-end' \| 'top-start' \| 'top-end' \| 'bottom' \| 'top' \| 'right-start' \| 'right-end' \| 'left-start' \| 'left-end' \| 'right' \| 'left' | bottom-start | Preferred placement relative to the trigger. `bottom` / `top` place the menu below / above; `right` / `left` place it beside (like a submenu flyout). The cross-axis suffix (`-start` / `-end`) aligns the near / far edges, and no suffix centers on the trigger. The menu flips to the opposite side when the preferred one lacks room, and clamps to the viewport. |
|
|
468
|
+
| `role?` | string | menu | ARIA role of the menu surface. |
|
|
469
|
+
| `round?` | boolean \| number \| string | — | Round the menu: the container softens to a 20px radius and its items go fully round. A `number` (px) or CSS length string tunes the container radius only — items stay full pills. |
|
|
470
|
+
| `stopPropagation?` | boolean \| string \| string[] | — | Contain events so they don't bubble out of the menu to ancestor handlers (e.g. a clickable row the menu sits in). Selecting an item is always contained; this extends it to whole event types. `true` contains `click`; pass an event name or list (`"click pointerdown"`) to contain those. |
|
|
471
|
+
|
|
472
|
+
## MenuItem props
|
|
473
|
+
|
|
474
|
+
| Prop | Type | Default | Description |
|
|
475
|
+
|------|------|---------|-------------|
|
|
476
|
+
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most notably the nested `<Menu>` for a submenu parent. |
|
|
477
|
+
| `disabled?` | boolean | — | Disable the item: greyed out, not focusable for activation, no close. A disabled link also drops its `href`, so it can't navigate. |
|
|
478
|
+
| `download?` | string \| boolean | — | Download the resource instead of navigating: `true` / `''` uses the resource's default filename, a string overrides it. |
|
|
479
|
+
| `hint?` | ReactNode | — | Secondary text under the label — explanatory copy, like `RadioGroup`'s option `hint`. Requires `label` (it stacks in a column beneath it). Muted (`--text-3`) and tracks the row's `tone`. A string, or any node. |
|
|
480
|
+
| `href?` | string | — | Renders the item as `<a role="menuitem" data-anta-menu-item href>`. |
|
|
481
|
+
| `icon?` | IconShape | — | Leading icon shape. |
|
|
482
|
+
| `iconTrailing?` | IconShape | — | A trailing icon. On a `submenu` item this **overrides** the default chevron (omit it to keep the chevron); on a normal item it's the trailing glyph (omit for none). |
|
|
483
|
+
| `indeterminate?` | boolean | — | Only meaningful with `selectionIndicator="checkbox"`: render the box in the mixed state (`aria-checked="mixed"`) — e.g. a "Select all" row when some but not all of its options are selected. |
|
|
484
|
+
| `indicator?` | React.ReactNode | — | Replace the built-in selection-indicator *visual* with your own node, rendered at the **leading** edge (where the checkbox / radio sit). Pair with `selectionIndicator` to keep the semantics — the row stays the control and carries `role` + `aria-checked`; only the drawn mark changes. Suppresses the built-in checkbox / radio and the trailing `check` glyph. The node is made passive (aria-hidden, no pointer events) so the row receives the click. |
|
|
485
|
+
| `kbd?` | string | — | Trailing shortcut hint, e.g. `"⌘E"`. Anta translates it to `aria-keyshortcuts` and hides the visual glyphs from assistive technology. Use `+` within a chord and spaces between shortcuts (`"⌘K ⌘S"` becomes `"Meta+K Meta+S"`). Pass `aria-keyshortcuts` to override the translation. This does not bind the shortcut. |
|
|
486
|
+
| `label?` | ReactNode | — | The item's text. Usually a string, but any node is accepted — e.g. a filtered `Select` bolds the matched substring. Omit and pass `children` for richer content. |
|
|
487
|
+
| `onMouseDown?` | (event) => void | — | Raw `mousedown` on the row. Mainly to `preventDefault()` so the row doesn't take focus on a mouse press — e.g. a combobox option keeping focus in its input field while the click still selects. |
|
|
488
|
+
| `onSelect?` | (event, detail) => void | — | Activation handler — fires when *this* item is chosen (click / Enter / Space), unless it's `disabled`. It does **not** fire for a submenu parent (clicking that opens the flyout, which isn't a selection) nor for a selection bubbling up from a nested submenu. On a link item it fires alongside the navigation. Receives the event plus a `{ value, label }` detail. |
|
|
489
|
+
| `ping?` | string | — | Space-separated URLs the browser pings on navigation. |
|
|
490
|
+
| `rel?` | string | — | Anchor rel. |
|
|
491
|
+
| `role?` | string | — | ARIA role override. Defaults to the role implied by `selectionIndicator` (`menuitem` / `menuitemcheckbox` / `menuitemradio`); set it to reparent the row under a different container role — e.g. `option` inside a `listbox`. |
|
|
492
|
+
| `selected?` | boolean | — | Mark the item as selected. On a plain row (no `selectionIndicator`) this is a persistent background tint, the same resting fill a pressed row shows — also the way to flag the current page on a link item. On a checkable row (`selectionIndicator` set) it instead drives the leading `checkbox` / `radio` indicator and the row's `aria-checked`. |
|
|
493
|
+
| `selectionIndicator?` | 'checkbox' \| 'radio' \| 'check' | — | Turn the row into a checkable item, driven by `selected` (the row stays the control and carries `aria-checked`): - `'checkbox'` → `role="menuitemcheckbox"`, a leading passive `<a-checkbox>` (before `icon`); the tint is dropped (the box carries state). - `'radio'` → `role="menuitemradio"`, a leading passive `<a-radio>`; tint dropped. - `'check'` → `role="menuitemradio"`, a trailing check glyph on the selected row *and* the background tint (the canonical single-select look). Omit for a plain row (the default). |
|
|
494
|
+
| `submenu?` | boolean | — | Marks this item as a submenu parent: adds the trailing chevron and `aria-haspopup="menu"`. Nest the flyout as a `<Menu>` child. |
|
|
495
|
+
| `target?` | string | — | Anchor target, e.g. `'_blank'`. |
|
|
496
|
+
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Semantic tone — colors the label, icon, and hover/selected tint (and the `checkbox`/`radio` indicator, which adopts it). A named tone, or any literal CSS color (`'#ff1493'`, `'rebeccapurple'`) for a one-off custom tone whose hue + chroma are kept while the lightness is pinned to match the brand text. `critical` is the destructive action; `neutral` (the default) is the standard gray. |
|
|
497
|
+
| `toneScope?` | ToneScope | 'all' | Apply `tone` to every row state, or only while the row is selected. In `selected` scope, an unselected row and its checkbox/radio indicator stay neutral. |
|
|
498
|
+
| `value?` | string \| number | — | An opaque value identifying this item, handed back in `onSelect`'s detail so a shared handler can tell which row was chosen without a per-item closure. |
|
|
499
|
+
|
|
500
|
+
## Web Component
|
|
501
|
+
|
|
509
502
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
510
503
|
|
|
511
504
|
Put a focusable trigger immediately before `<a-menu>` and omit `state` for an
|
|
@@ -522,6 +515,8 @@ values.
|
|
|
522
515
|
</a-menu>
|
|
523
516
|
```
|
|
524
517
|
|
|
518
|
+
## Styling
|
|
519
|
+
|
|
525
520
|
The popover surface lives in shadow DOM and is exposed as a **part** — style its
|
|
526
521
|
chrome (background, frost, border, radius, shadow, padding, min-width) with
|
|
527
522
|
`::part(menu)`. Menu items are light DOM, so style them (and their
|