@antadesign/anta 0.3.25 → 0.3.27
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 +4 -0
- package/dist/anta_helpers.js +17 -3
- package/dist/box-types.d.ts +161 -0
- package/dist/box-types.js +0 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +25 -25
- package/dist/capture-types.d.ts +156 -0
- package/dist/capture-types.js +0 -0
- package/dist/components/Box.d.ts +52 -0
- package/dist/components/Box.js +55 -0
- package/dist/components/Capture.d.ts +39 -0
- package/dist/components/Capture.js +36 -0
- 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-banner.js +4 -4
- package/dist/elements/a-box.css +1 -0
- package/dist/elements/a-box.d.ts +41 -0
- package/dist/elements/a-box.js +584 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-calendar.js +2 -2
- 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 +2 -2
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.js +3 -3
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.js +6 -6
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.js +3 -3
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.js +2 -2
- package/dist/elements/a-radio-group.js +3 -3
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.js +6 -6
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-switch.js +2 -2
- package/dist/elements/a-tabpanel.js +2 -2
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.js +6 -6
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.js +2 -2
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +4 -3
- package/dist/elements/a-tooltip.js +9 -5
- package/dist/elements/capture-input.d.ts +5 -0
- package/dist/elements/capture-input.js +609 -0
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +6 -0
- package/dist/general_types.d.ts +70 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/jsx-runtime.d.ts +3 -1
- package/docs/accessibility.md +24 -0
- package/docs/changelog.md +45 -3
- package/docs/colors.md +141 -0
- package/docs/comparison.md +463 -28
- package/docs/components/avatar.md +364 -0
- package/docs/components/banner.md +13 -27
- package/docs/components/box.md +354 -0
- package/docs/components/breadcrumbs.md +7 -6
- 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 +16 -39
- 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 +73 -77
- package/docs/components/progress.md +10 -14
- package/docs/components/radio.md +17 -36
- package/docs/components/select-faceted.md +7 -25
- package/docs/components/select.md +24 -97
- package/docs/components/slider.md +16 -21
- package/docs/components/steps.md +38 -8
- package/docs/components/switch.md +11 -14
- package/docs/components/tabs.md +52 -40
- package/docs/components/tag.md +11 -22
- 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 +6 -3
- package/docs/install-config.md +24 -0
- package/docs/normalization.md +45 -0
- package/docs/packages/stickers.md +56 -0
- package/docs/theming.md +270 -0
- package/package.json +3 -1
package/docs/components/menu.md
CHANGED
|
@@ -366,6 +366,8 @@ chevron stay centered on the row, so it composes with a trailing counter.
|
|
|
366
366
|
</Menu>
|
|
367
367
|
```
|
|
368
368
|
|
|
369
|
+
## MenuItemCopy
|
|
370
|
+
|
|
369
371
|
`MenuItemCopy` is a row that copies to the clipboard when chosen: `copy` for a
|
|
370
372
|
string, `copyNode` for a DOM region, or `copyUrl` for the current URL. It composes
|
|
371
373
|
a `<MenuItem>` with a slotted `<a-copy>` element that performs the write, and
|
|
@@ -390,89 +392,32 @@ navigating links.
|
|
|
390
392
|
|
|
391
393
|
| Prop | Type | Default | Description |
|
|
392
394
|
|------|------|---------|-------------|
|
|
393
|
-
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most
|
|
394
|
-
notably the nested `<Menu>` for a submenu parent. |
|
|
395
|
+
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most notably the nested `<Menu>` for a submenu parent. |
|
|
395
396
|
| `copiedLabel?` | string | Copied | Text in the successful no-icon confirmation. |
|
|
396
397
|
| `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. |
|
|
398
|
+
| `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
399
|
| `copyUrl?` | true | — | Copy the current page URL (`location.href`). |
|
|
402
400
|
| `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. |
|
|
401
|
+
| `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. |
|
|
402
|
+
| `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
403
|
| `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. |
|
|
404
|
+
| `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. |
|
|
405
|
+
| `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). |
|
|
406
|
+
| `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. |
|
|
407
|
+
| `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. |
|
|
408
|
+
| `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. |
|
|
409
|
+
| `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
410
|
| `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. |
|
|
411
|
+
| `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. |
|
|
412
|
+
| `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. |
|
|
413
|
+
| `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. |
|
|
414
|
+
| `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`. |
|
|
415
|
+
| `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`. |
|
|
416
|
+
| `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). |
|
|
417
|
+
| `submenu?` | boolean | — | Marks this item as a submenu parent: adds the trailing chevron and `aria-haspopup="menu"`. Nest the flyout as a `<Menu>` child. |
|
|
418
|
+
| `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. |
|
|
419
|
+
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Like `tone`, but applied only while the row is `selected` — an unselected row stays neutral. The whole selected row (label, icon, tint, and the `checkbox` / `radio` indicator) takes the tone. Same value set as `tone`; on a selected row `toneSelected` wins over `tone` when both are set. |
|
|
420
|
+
| `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
421
|
|
|
477
422
|
## Keyboard
|
|
478
423
|
|
|
@@ -506,6 +451,55 @@ call `event.preventDefault()` to keep the menu as-is (e.g. block a dismiss).
|
|
|
506
451
|
Controlled, the menu never self-moves — apply `detail.next` to `open` to accept,
|
|
507
452
|
or do nothing to reject. (Submenus are always uncontrolled, regardless of `open`.)
|
|
508
453
|
|
|
454
|
+
## Menu props
|
|
455
|
+
|
|
456
|
+
| Prop | Type | Default | Description |
|
|
457
|
+
|------|------|---------|-------------|
|
|
458
|
+
| `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. |
|
|
459
|
+
| `children?` | ReactNode | — | The menu's contents: `MenuItem`, `MenuSeparator`, `MenuGroup`, or any custom element. |
|
|
460
|
+
| `context?` | boolean | — | Open on right-click (the `contextmenu` event) of the trigger region instead of a left click, positioned at the pointer. |
|
|
461
|
+
| `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. |
|
|
462
|
+
| `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. |
|
|
463
|
+
| `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. |
|
|
464
|
+
| `offset?` | number | 4 | Gap in pixels between the trigger and the menu. |
|
|
465
|
+
| `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. |
|
|
466
|
+
| `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). |
|
|
467
|
+
| `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. |
|
|
468
|
+
| `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. |
|
|
469
|
+
| `role?` | string | menu | ARIA role of the menu surface. |
|
|
470
|
+
| `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. |
|
|
471
|
+
| `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. |
|
|
472
|
+
|
|
473
|
+
## MenuItem props
|
|
474
|
+
|
|
475
|
+
| Prop | Type | Default | Description |
|
|
476
|
+
|------|------|---------|-------------|
|
|
477
|
+
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most notably the nested `<Menu>` for a submenu parent. |
|
|
478
|
+
| `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. |
|
|
479
|
+
| `download?` | string \| boolean | — | Download the resource instead of navigating: `true` / `''` uses the resource's default filename, a string overrides it. |
|
|
480
|
+
| `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. |
|
|
481
|
+
| `href?` | string | — | Renders the item as `<a role="menuitem" data-anta-menu-item href>`. |
|
|
482
|
+
| `icon?` | IconShape | — | Leading icon shape. |
|
|
483
|
+
| `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). |
|
|
484
|
+
| `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. |
|
|
485
|
+
| `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. |
|
|
486
|
+
| `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. |
|
|
487
|
+
| `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. |
|
|
488
|
+
| `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. |
|
|
489
|
+
| `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. |
|
|
490
|
+
| `ping?` | string | — | Space-separated URLs the browser pings on navigation. |
|
|
491
|
+
| `rel?` | string | — | Anchor rel. |
|
|
492
|
+
| `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`. |
|
|
493
|
+
| `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`. |
|
|
494
|
+
| `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). |
|
|
495
|
+
| `submenu?` | boolean | — | Marks this item as a submenu parent: adds the trailing chevron and `aria-haspopup="menu"`. Nest the flyout as a `<Menu>` child. |
|
|
496
|
+
| `target?` | string | — | Anchor target, e.g. `'_blank'`. |
|
|
497
|
+
| `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. |
|
|
498
|
+
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Like `tone`, but applied only while the row is `selected` — an unselected row stays neutral. The whole selected row (label, icon, tint, and the `checkbox` / `radio` indicator) takes the tone. Same value set as `tone`; on a selected row `toneSelected` wins over `tone` when both are set. |
|
|
499
|
+
| `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. |
|
|
500
|
+
|
|
501
|
+
## Web Component
|
|
502
|
+
|
|
509
503
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
510
504
|
|
|
511
505
|
Put a focusable trigger immediately before `<a-menu>` and omit `state` for an
|
|
@@ -522,6 +516,8 @@ values.
|
|
|
522
516
|
</a-menu>
|
|
523
517
|
```
|
|
524
518
|
|
|
519
|
+
## Styling
|
|
520
|
+
|
|
525
521
|
The popover surface lives in shadow DOM and is exposed as a **part** — style its
|
|
526
522
|
chrome (background, frost, border, radius, shadow, padding, min-width) with
|
|
527
523
|
`::part(menu)`. Menu items are light DOM, so style them (and their
|
|
@@ -92,25 +92,19 @@ works for one at the bottom.
|
|
|
92
92
|
`round` makes the track fully round. Pass a number or CSS length for a custom
|
|
93
93
|
radius.
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
## Component props
|
|
96
96
|
|
|
97
97
|
| Prop | Type | Default | Description |
|
|
98
98
|
|------|------|---------|-------------|
|
|
99
|
-
| `hint?` | string | — | Right-aligned hint text (e.g. "3 of 7"). Like `label`, it's not rendered
|
|
100
|
-
|
|
101
|
-
| `label?` | string | — | Text label displayed after the percentage, or on its own for
|
|
102
|
-
indeterminate progress. When you provide custom `children` (which replace
|
|
103
|
-
the default label row), `label` is no longer rendered — but it still
|
|
104
|
-
supplies the progressbar's accessible name. |
|
|
99
|
+
| `hint?` | string | — | Right-aligned hint text (e.g. "3 of 7"). Like `label`, it's not rendered when custom `children` are provided but still feeds the accessible name. |
|
|
100
|
+
| `label?` | string | — | Text label displayed after the percentage, or on its own for indeterminate progress. When you provide custom `children` (which replace the default label row), `label` is no longer rendered — but it still supplies the progressbar's accessible name. |
|
|
105
101
|
| `max?` | number | 100 | Upper bound of the range. |
|
|
106
|
-
| `round?` | boolean \| number \| string | — | Fully-round track (`border-radius: 999px`); the fill is clipped to it. Pass a
|
|
107
|
-
`number` (px) or a CSS length string for a custom radius. |
|
|
102
|
+
| `round?` | boolean \| number \| string | — | Fully-round track (`border-radius: 999px`); the fill is clipped to it. Pass a `number` (px) or a CSS length string for a custom radius. |
|
|
108
103
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Size variant. Scales the track and the default label row together. |
|
|
109
|
-
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Color variant, or any literal CSS color for a one-off custom tone (the
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
indeterminate progress. Negative values are clamped to 0. |
|
|
104
|
+
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Color variant, or any literal CSS color for a one-off custom tone (the surface / indicator / text are derived from it in oklch). Named tones track light/dark automatically. |
|
|
105
|
+
| `value?` | number \| false | — | Current progress value. Omit this prop, or pass `false`, to show indeterminate progress. Negative values are clamped to 0. |
|
|
106
|
+
|
|
107
|
+
## Web Component
|
|
114
108
|
|
|
115
109
|
```html
|
|
116
110
|
<a-progress style="width: 100%" value="42" max="100" tone="info" role="progressbar"
|
|
@@ -158,6 +152,8 @@ is absent, while using Anta's track, fill, tone, and size treatments. Native
|
|
|
158
152
|
progress does not render Anta's label or hint structure; give it an accessible
|
|
159
153
|
name instead.
|
|
160
154
|
|
|
155
|
+
## Styling
|
|
156
|
+
|
|
161
157
|
```css
|
|
162
158
|
/* a fancy bar: rounded track (all sides), a multi-stop gradient fill with a glow,
|
|
163
159
|
and a crisp hard right edge (the default soft right-edge fade is cleared). */
|
package/docs/components/radio.md
CHANGED
|
@@ -250,50 +250,29 @@ element — `Input`, and the composed `Select` — skip it and expose only
|
|
|
250
250
|
<RadioGroup onValueChange={(_e, { value }) => save(value)} options={…} />
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
+
## RadioGroup props
|
|
254
|
+
|
|
253
255
|
| Prop | Type | Default | Description |
|
|
254
256
|
|------|------|---------|-------------|
|
|
255
|
-
| `options` | RadioOption[] | — | The options. The wrapper renders one `<a-radio>` per entry and computes its
|
|
256
|
-
`selected` / roving `tabindex` / `role` declaratively. |
|
|
257
|
+
| `options` | RadioOption[] | — | The options. The wrapper renders one `<a-radio>` per entry and computes its `selected` / roving `tabindex` / `role` declaratively. |
|
|
257
258
|
| `defaultValue?` | string | — | Initial selected value for uncontrolled use. |
|
|
258
259
|
| `disabled?` | boolean | — | Disable the whole group. |
|
|
259
|
-
| `hint?` | string | — | Plain-text description for the group, rendered directly under `label` (above
|
|
260
|
-
the options) — typically instructional copy. Per-option helper text goes on
|
|
261
|
-
the option's own `hint` instead. |
|
|
260
|
+
| `hint?` | string | — | Plain-text description for the group, rendered directly under `label` (above the options) — typically instructional copy. Per-option helper text goes on the option's own `hint` instead. |
|
|
262
261
|
| `label?` | string | — | Plain-text label for the whole group, rendered above the options. |
|
|
263
|
-
| `name?` | string | — | Form field name — the group submits one `name=value` (it's the
|
|
264
|
-
form-associated element). |
|
|
262
|
+
| `name?` | string | — | Form field name — the group submits one `name=value` (it's the form-associated element). |
|
|
265
263
|
| `onBlur?` | (event) => void | — | Fired when focus leaves the group entirely — wired to `focusout`. |
|
|
266
|
-
| `onChange?` | (event) => void | — | Fired *after* the selection changes — a native `change` event (the post-apply
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
| `
|
|
270
|
-
focus lands on an individual option, not the group element itself. |
|
|
271
|
-
| `onStateChange?` | (event, detail) => void | — | Fired whenever selection changes — event-first. `detail` is
|
|
272
|
-
`{ next, prev, reason }`: `next`/`prev` are values (`null` = nothing selected);
|
|
273
|
-
`reason` is `'user'` \| `'reset'` \| `'restore'`. A `'user'` pick fires *before*
|
|
274
|
-
applying and is **cancelable** — `event.preventDefault()` vetoes it
|
|
275
|
-
(uncontrolled), or in controlled mode answer by updating `value` (reject by
|
|
276
|
-
doing nothing). `'reset'` (form reset) and `'restore'` (bfcache / autofill) are
|
|
277
|
-
not cancelable — filter on `reason` if you only track user picks. |
|
|
278
|
-
| `onValueChange?` | (event, attrs) => void | — | Like `onChange`, but with a `{ value, name }` snapshot as the second argument,
|
|
279
|
-
matching `Input`. |
|
|
264
|
+
| `onChange?` | (event) => void | — | Fired *after* the selection changes — a native `change` event (the post-apply counterpart to `onStateChange`). Not cancelable; for a controlled group it fires once you've updated `value`. |
|
|
265
|
+
| `onFocus?` | (event) => void | — | Fired when focus enters the group (any option) — wired to `focusin`, since focus lands on an individual option, not the group element itself. |
|
|
266
|
+
| `onStateChange?` | (event, detail) => void | — | Fired whenever selection changes — event-first. `detail` is `{ next, prev, reason }`: `next`/`prev` are values (`null` = nothing selected); `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` (reject by doing nothing). `'reset'` (form reset) and `'restore'` (bfcache / autofill) are not cancelable — filter on `reason` if you only track user picks. |
|
|
267
|
+
| `onValueChange?` | (event, attrs) => void | — | Like `onChange`, but with a `{ value, name }` snapshot as the second argument, matching `Input`. |
|
|
280
268
|
| `orientation?` | 'vertical' \| 'horizontal' | 'vertical' | Layout + arrow-key axis. |
|
|
281
269
|
| `size?` | 'small' \| 'medium' \| 'large' | 'medium' | Size applied to every option (an option's own `size` wins). |
|
|
282
|
-
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | 'neutral' | Validation/feedback tone for the group `hint` — recolors it (same tone set
|
|
283
|
-
|
|
284
|
-
the neutral
|
|
285
|
-
| `
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
instead to tone only the selected option and leave the rest neutral. The option
|
|
289
|
-
text stays neutral — recolor it in plain CSS via the `--text-N-{tone}` tokens. |
|
|
290
|
-
| `toneSelected?` | 'brand' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Like `tone`, but colored onto the **selected option only** — every unselected
|
|
291
|
-
ring stays neutral grey. Applied to every option (an option's own `toneSelected`
|
|
292
|
-
wins). Prefer this over `tone` when a resting tinted border would read as a
|
|
293
|
-
validation state. |
|
|
294
|
-
| `value?` | string | — | Controlled selected value. The group follows this prop and reports a
|
|
295
|
-
requested change through `onStateChange`. Leave it undefined for
|
|
296
|
-
uncontrolled use. |
|
|
270
|
+
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | 'neutral' | Validation/feedback tone for the group `hint` — recolors it (same tone set as `Input`'s `status`). Use `critical` for an error message, etc.; omit for the neutral default. |
|
|
271
|
+
| `tone?` | 'brand' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Mark tone applied to every option (an option's own `tone` wins), or any literal CSS color for a one-off custom tone. Colors the selected-ring fill + dot *and* the unselected ring border. Named tones track light/dark mode. Use `toneSelected` instead to tone only the selected option and leave the rest neutral. The option text stays neutral — recolor it in plain CSS via the `--text-N-{tone}` tokens. |
|
|
272
|
+
| `toneSelected?` | 'brand' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Like `tone`, but colored onto the **selected option only** — every unselected ring stays neutral grey. Applied to every option (an option's own `toneSelected` wins). Prefer this over `tone` when a resting tinted border would read as a validation state. |
|
|
273
|
+
| `value?` | string | — | Controlled selected value. The group follows this prop and reports a requested change through `onStateChange`. Leave it undefined for uncontrolled use. |
|
|
274
|
+
|
|
275
|
+
## Web Component
|
|
297
276
|
|
|
298
277
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
299
278
|
|
|
@@ -326,6 +305,8 @@ treatments.
|
|
|
326
305
|
</div>
|
|
327
306
|
```
|
|
328
307
|
|
|
308
|
+
## Styling
|
|
309
|
+
|
|
329
310
|
Reach for the props first: **`tone`** colors the mark in every state,
|
|
330
311
|
**`toneSelected`** only the selected option (any CSS color for a custom tone, set on
|
|
331
312
|
the group or a single option — derives the full curve in oklch), **`size`** the
|
|
@@ -358,7 +358,7 @@ const recency: SelectFacetCustom<Recency> = {
|
|
|
358
358
|
// concrete date (or take the day as-is) and filter your rows with it
|
|
359
359
|
```
|
|
360
360
|
|
|
361
|
-
|
|
361
|
+
## Component props
|
|
362
362
|
|
|
363
363
|
| Prop | Type | Default | Description |
|
|
364
364
|
|------|------|---------|-------------|
|
|
@@ -370,33 +370,15 @@ const recency: SelectFacetCustom<Recency> = {
|
|
|
370
370
|
| `icon?` | IconShape | filter | Default trigger's leading icon. |
|
|
371
371
|
| `label?` | string | Filter | Default trigger's button label. |
|
|
372
372
|
| `offset?` | number | 4 | Gap in pixels between the trigger and the filter menu. |
|
|
373
|
-
| `onValueChange?` | (value, attrs) => void | — | Fires after any facet changes. `value` is the whole new record (a facet key →
|
|
374
|
-
|
|
375
|
-
`{ facet, kind, value }` for a single facet edit, or `{ all: true }` for the
|
|
376
|
-
"Clear all" row — narrow on `'all' in attrs` before reading `facet`. |
|
|
377
|
-
| `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 root filter menu relative to its trigger. The
|
|
378
|
-
menu auto-flips vertically and clamps horizontally when needed. |
|
|
373
|
+
| `onValueChange?` | (value, attrs) => void | — | Fires after any facet changes. `value` is the whole new record (a facet key → that facet's value; a cleared facet is absent). `attrs` says what changed: `{ facet, kind, value }` for a single facet edit, or `{ all: true }` for the "Clear all" row — narrow on `'all' in attrs` before reading `facet`. |
|
|
374
|
+
| `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 root filter menu relative to its trigger. The menu auto-flips vertically and clamps horizontally when needed. |
|
|
379
375
|
| `priority?` | 'primary' \| 'secondary' | secondary | Default trigger's button priority. |
|
|
380
|
-
| `renderTrigger?` | (state) => ReactNode | — | Replaces the default `Button` with a trigger returned from this function.
|
|
381
|
-
|
|
382
|
-
the menu is positioned relative to that element and opens when it is clicked.
|
|
383
|
-
Add `aria-haspopup="menu"` and `aria-expanded={state.open}` to the returned
|
|
384
|
-
element, on a role that supports them (an Anta `Button` already carries
|
|
385
|
-
`role="button"`; otherwise add `role="combobox"`). `className`, `style`, and
|
|
386
|
-
other trigger props apply only to the default Button, so add styling and
|
|
387
|
-
attributes to the returned element. |
|
|
388
|
-
| `searchable?` | boolean | — | Adds a search field at the top of the root menu. It searches the options of
|
|
389
|
-
every `single` and `multiple` facet in one list. For example, "alice" can
|
|
390
|
-
appear under application-defined Assignee and Owner facets. `text` and
|
|
391
|
-
`custom` facets remain available when the search is empty. Each facet uses
|
|
392
|
-
its `filter` function when supplied, or the built-in substring match. |
|
|
376
|
+
| `renderTrigger?` | (state) => ReactNode | — | Replaces the default `Button` with a trigger returned from this function. Receives a `SelectFacetedTriggerState`. Return exactly one focusable element: the menu is positioned relative to that element and opens when it is clicked. Add `aria-haspopup="menu"` and `aria-expanded={state.open}` to the returned element, on a role that supports them (an Anta `Button` already carries `role="button"`; otherwise add `role="combobox"`). `className`, `style`, and other trigger props apply only to the default Button, so add styling and attributes to the returned element. |
|
|
377
|
+
| `searchable?` | boolean | — | Adds a search field at the top of the root menu. It searches the options of every `single` and `multiple` facet in one list. For example, "alice" can appear under application-defined Assignee and Owner facets. `text` and `custom` facets remain available when the search is empty. Each facet uses its `filter` function when supplied, or the built-in substring match. |
|
|
393
378
|
| `searchPlaceholder?` | string | Filter… | Placeholder for the global search field. |
|
|
394
379
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Default trigger's button size. |
|
|
395
|
-
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | — | Tone applied to a selected option row in the facet flyouts (label, selected
|
|
396
|
-
|
|
397
|
-
color, matching `Select`'s `toneSelected`. Defaults to a neutral selection. |
|
|
398
|
-
| `value?` | SelectFacetedValue | — | Controlled value record, keyed by facet. When provided, update it through
|
|
399
|
-
`onValueChange`. Leave it undefined for uncontrolled use. |
|
|
380
|
+
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | — | Tone applied to a selected option row in the facet flyouts (label, selected tint, and the check / checkbox indicator). A named tone or a custom CSS color, matching `Select`'s `toneSelected`. Defaults to a neutral selection. |
|
|
381
|
+
| `value?` | SelectFacetedValue | — | Controlled value record, keyed by facet. When provided, update it through `onValueChange`. Leave it undefined for uncontrolled use. |
|
|
400
382
|
|
|
401
383
|
### The `SelectFacet` type
|
|
402
384
|
|
|
@@ -623,117 +623,40 @@ sections is one pick (dev builds warn).
|
|
|
623
623
|
groups (their label becomes the heading) and drops empty ones, so results read as one
|
|
624
624
|
scannable list instead of hiding matches behind flyouts.
|
|
625
625
|
|
|
626
|
-
|
|
626
|
+
## Component props
|
|
627
627
|
|
|
628
628
|
| Prop | Type | Default | Description |
|
|
629
629
|
|------|------|---------|-------------|
|
|
630
|
-
| `options` | SelectItem[] | — | The options to choose from — bare strings, `SelectOption` objects, `SelectGroup`s
|
|
631
|
-
(
|
|
632
|
-
submenus nest and mix with plain options. Selection stays global (one `value`,
|
|
633
|
-
leaf options only); a filter query flattens the tree into grouped results.
|
|
634
|
-
|
|
635
|
-
`Select` infers its value type `V` from these options: `{ value: 365 }` makes
|
|
636
|
-
`onValueChange` report `number`. A mix of value types widens `V` to the union.
|
|
637
|
-
|
|
638
|
-
Each leaf `value` is the option's identity and must be **unique across the whole
|
|
639
|
-
tree** (selection is value-keyed, so a value repeated in two sections is one logical
|
|
640
|
-
pick: both rows toggle together, the trigger resolves to the last). Values that
|
|
641
|
-
stringify alike (`365` and `"365"`) also collide as row keys; dev builds
|
|
642
|
-
`console.warn` on either. |
|
|
643
|
-
| `clearable?` | boolean | — | Add a "Clear" row pinned in the menu **footer** that empties the selection
|
|
644
|
-
(single → none, multiple → `[]`). Shown only while something is selected, so
|
|
645
|
-
it never scrolls away in a long or filtered list. |
|
|
630
|
+
| `options` | SelectItem[] | — | The options to choose from — bare strings, `SelectOption` objects, `SelectGroup`s (inline titled sections), or `SelectSubmenu`s (flyout branches). Groups and submenus nest and mix with plain options. Selection stays global (one `value`, leaf options only); a filter query flattens the tree into grouped results. `Select` infers its value type `V` from these options: `{ value: 365 }` makes `onValueChange` report `number`. A mix of value types widens `V` to the union. Each leaf `value` is the option's identity and must be **unique across the whole tree** (selection is value-keyed, so a value repeated in two sections is one logical pick: both rows toggle together, the trigger resolves to the last). Values that stringify alike (`365` and `"365"`) also collide as row keys; dev builds `console.warn` on either. |
|
|
631
|
+
| `clearable?` | boolean | — | Add a "Clear" row pinned in the menu **footer** that empties the selection (single → none, multiple → `[]`). Shown only while something is selected, so it never scrolls away in a long or filtered list. |
|
|
646
632
|
| `clearLabel?` | string | Clear | Label for the `clearable` footer row. |
|
|
647
633
|
| `defaultValue?` | V \| V[] | — | Initial selected option value for uncontrolled use. |
|
|
648
634
|
| `disabled?` | boolean | — | Disable the whole select. |
|
|
649
|
-
| `filter?` | boolean \| (option, query) => boolean | — | Add a search field at the top of the menu that filters the options as you
|
|
650
|
-
type. `true` uses the built-in matcher — a case-insensitive substring of the
|
|
651
|
-
option's **value / label / hint**. Pass a **function** `(option, query) =>
|
|
652
|
-
boolean` for custom matching (called per option; return `true` to keep it). |
|
|
635
|
+
| `filter?` | boolean \| (option, query) => boolean | — | Add a search field at the top of the menu that filters the options as you type. `true` uses the built-in matcher — a case-insensitive substring of the option's **value / label / hint**. Pass a **function** `(option, query) => boolean` for custom matching (called per option; return `true` to keep it). |
|
|
653
636
|
| `hint?` | string | — | Helper text under the field (Input's `hint`). |
|
|
654
|
-
| `icon?` | IconShape | — | Leading icon shown at the left of the field (the default trigger's `Input`
|
|
655
|
-
`
|
|
656
|
-
`state.icon` instead — the consumer places it. |
|
|
657
|
-
| `indicator?` | 'none' \| 'check' \| 'radio' | none | The per-row mark for **single**-select: `'none'` (a tint-only highlight),
|
|
658
|
-
`'check'` (a trailing checkmark on the selected row, keeping the tint — the
|
|
659
|
-
canonical Select look), or `'radio'` (a leading radio on every row).
|
|
660
|
-
Multi-select always uses checkboxes. |
|
|
637
|
+
| `icon?` | IconShape | — | Leading icon shown at the left of the field (the default trigger's `Input` `leading` slot). With a custom `renderTrigger`, it's passed through as `state.icon` instead — the consumer places it. |
|
|
638
|
+
| `indicator?` | 'none' \| 'check' \| 'radio' | none | The per-row mark for **single**-select: `'none'` (a tint-only highlight), `'check'` (a trailing checkmark on the selected row, keeping the tint — the canonical Select look), or `'radio'` (a leading radio on every row). Multi-select always uses checkboxes. |
|
|
661
639
|
| `label?` | string | — | Field label, above the trigger (Input's `label`). |
|
|
662
|
-
| `leading?` | ReactNode | — | Content for the default trigger's `leading` slot, such as a key prefix
|
|
663
|
-
before the value. It replaces the icon derived from `icon`. Include an
|
|
664
|
-
`<Icon>` in this content when both are needed. Ignored by `renderTrigger`. |
|
|
640
|
+
| `leading?` | ReactNode | — | Content for the default trigger's `leading` slot, such as a key prefix before the value. It replaces the icon derived from `icon`. Include an `<Icon>` in this content when both are needed. Ignored by `renderTrigger`. |
|
|
665
641
|
| `offset?` | number | 4 | Gap in pixels between the trigger and the options menu. |
|
|
666
|
-
| `onValueChange?` | (value, attrs) => void | — | Fires after the selection changes, with the new value and a
|
|
667
|
-
`{ value, option }` snapshot. Select has no discrete element state, so
|
|
668
|
-
there is no cancelable `onStateChange` (see the Input event-model note). |
|
|
642
|
+
| `onValueChange?` | (value, attrs) => void | — | Fires after the selection changes, with the new value and a `{ value, option }` snapshot. Select has no discrete element state, so there is no cancelable `onStateChange` (see the Input event-model note). |
|
|
669
643
|
| `placeholder?` | string | — | Text shown when nothing is selected. |
|
|
670
|
-
| `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 options menu relative to the trigger. The menu
|
|
671
|
-
|
|
672
|
-
| `
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
list renders nothing. Whatever you return goes where the option rows would —
|
|
677
|
-
a plain node is inert; return a `MenuItem` (e.g. a "Create" row) to make it
|
|
678
|
-
focusable and selectable. |
|
|
679
|
-
| `renderIndicator?` | (state) => ReactNode | — | Replace each row's selection **mark** with your own node, drawn at the
|
|
680
|
-
leading edge. The row stays the control (`role` + `aria-checked` from
|
|
681
|
-
`indicator` / `selection`); only the drawn mark changes, so pair it with an
|
|
682
|
-
`indicator` (`'check'` / `'radio'`) or `selection="multiple"` for the
|
|
683
|
-
semantics. Composes with `renderOption`. |
|
|
684
|
-
| `renderOption?` | (option, state) => ReactNode | — | Replaces the built-in `label`, `hint`, and `icon` layout for each option row.
|
|
685
|
-
Select still supplies the row container, click handling, ARIA attributes, and
|
|
686
|
-
selection indicator. Read extra option fields through `SelectOption`'s index
|
|
687
|
-
signature. `state` contains `value`, `selected`, and `disabled`. Filtering
|
|
688
|
-
still matches the option's `value`, `label`, and `hint`, but Select cannot
|
|
689
|
-
highlight matches within the returned content. |
|
|
690
|
-
| `renderSummary?` | (selected) => string \| undefined | — | `multiple` only: build the trigger's selection summary text yourself,
|
|
691
|
-
replacing the built-in "`All` / one label / `N selected`" logic. Receives
|
|
692
|
-
the resolved selected options (`selected.length` is the count) and runs only
|
|
693
|
-
while something is selected — an empty selection still shows the
|
|
694
|
-
`placeholder`. Return a **string**: it flows into the default trigger's
|
|
695
|
-
read-only field, so a long summary ellipsizes at the field's width just
|
|
696
|
-
like a long value (`Engineering, Design, … `). Return `undefined` to fall
|
|
697
|
-
back to the default for that case (e.g. customize only the count, keeping
|
|
698
|
-
the single-label case built-in). For rich content (chips, multiple nodes)
|
|
699
|
-
use `renderTrigger`, which replaces the whole field. |
|
|
700
|
-
| `renderTrigger?` | (state) => ReactNode | — | Replaces the default field with a trigger returned from this function.
|
|
701
|
-
Receives `open`, `value`, `selected`, `disabled`, and `icon`. Return exactly
|
|
702
|
-
one focusable element, such as an Anta `Button`. The menu is positioned
|
|
703
|
-
relative to that element and opens when it is clicked. Do not return a
|
|
704
|
-
fragment, multiple siblings, or a non-focusable wrapper. Add
|
|
705
|
-
`aria-haspopup="menu"` and `aria-expanded={state.open}` to the element, on a
|
|
706
|
-
role that supports them (an Anta `Button` already carries `role="button"`;
|
|
707
|
-
otherwise add `role="combobox"`).
|
|
708
|
-
Field props (`label`, `hint`, `size`, `status`, `placeholder`, and `round`) and
|
|
709
|
-
`className` / `style` apply only to the default field. Add styling and
|
|
710
|
-
attributes to the returned element instead. |
|
|
644
|
+
| `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 options menu relative to the trigger. The menu auto-flips vertically and clamps horizontally when needed. |
|
|
645
|
+
| `renderEmpty?` | (state) => ReactNode | — | Render content in the menu body when the (filtered) option list is empty — a "no results" message, a loading indicator (gated on your own external loading state), or a "create from the query" row. Receives an `EmptyState` (`query`, trimmed). There is no built-in empty message: when omitted, an empty list renders nothing. Whatever you return goes where the option rows would — a plain node is inert; return a `MenuItem` (e.g. a "Create" row) to make it focusable and selectable. |
|
|
646
|
+
| `renderIndicator?` | (state) => ReactNode | — | Replace each row's selection **mark** with your own node, drawn at the leading edge. The row stays the control (`role` + `aria-checked` from `indicator` / `selection`); only the drawn mark changes, so pair it with an `indicator` (`'check'` / `'radio'`) or `selection="multiple"` for the semantics. Composes with `renderOption`. |
|
|
647
|
+
| `renderOption?` | (option, state) => ReactNode | — | Replaces the built-in `label`, `hint`, and `icon` layout for each option row. Select still supplies the row container, click handling, ARIA attributes, and selection indicator. Read extra option fields through `SelectOption`'s index signature. `state` contains `value`, `selected`, and `disabled`. Filtering still matches the option's `value`, `label`, and `hint`, but Select cannot highlight matches within the returned content. |
|
|
648
|
+
| `renderSummary?` | (selected) => string \| undefined | — | `multiple` only: build the trigger's selection summary text yourself, replacing the built-in "`All` / one label / `N selected`" logic. Receives the resolved selected options (`selected.length` is the count) and runs only while something is selected — an empty selection still shows the `placeholder`. Return a **string**: it flows into the default trigger's read-only field, so a long summary ellipsizes at the field's width just like a long value (`Engineering, Design, … `). Return `undefined` to fall back to the default for that case (e.g. customize only the count, keeping the single-label case built-in). For rich content (chips, multiple nodes) use `renderTrigger`, which replaces the whole field. |
|
|
649
|
+
| `renderTrigger?` | (state) => ReactNode | — | Replaces the default field with a trigger returned from this function. Receives `open`, `value`, `selected`, `disabled`, and `icon`. Return exactly one focusable element, such as an Anta `Button`. The menu is positioned relative to that element and opens when it is clicked. Do not return a fragment, multiple siblings, or a non-focusable wrapper. Add `aria-haspopup="menu"` and `aria-expanded={state.open}` to the element, on a role that supports them (an Anta `Button` already carries `role="button"`; otherwise add `role="combobox"`). Field props (`label`, `hint`, `size`, `status`, `placeholder`, and `round`) and `className` / `style` apply only to the default field. Add styling and attributes to the returned element instead. |
|
|
711
650
|
| `round?` | boolean \| number \| string | — | Round the field corners — `true` for fully round, or a number / CSS length. |
|
|
712
|
-
| `selectAll?` | boolean | true | `multiple` only: shows a "Select all" row that toggles every enabled option,
|
|
713
|
-
or only the visible options when a filter query is active. Its checkbox is
|
|
714
|
-
mixed when some options are selected. It is on by default. Set it to `false`
|
|
715
|
-
to remove the row and the Alt/Option-click shortcut that selects only one row. |
|
|
651
|
+
| `selectAll?` | boolean | true | `multiple` only: shows a "Select all" row that toggles every enabled option, or only the visible options when a filter query is active. Its checkbox is mixed when some options are selected. It is on by default. Set it to `false` to remove the row and the Alt/Option-click shortcut that selects only one row. |
|
|
716
652
|
| `selectAllLabel?` | string | Select all | Label for the `selectAll` row. |
|
|
717
|
-
| `selection?` | 'single' \| 'multiple' | single | Selection mode. `'single'` (the default) keeps `value` a single value and
|
|
718
|
-
closes the menu on pick. Switch to `'multiple'` for checkboxes + an
|
|
719
|
-
array value. |
|
|
653
|
+
| `selection?` | 'single' \| 'multiple' | single | Selection mode. `'single'` (the default) keeps `value` a single value and closes the menu on pick. Switch to `'multiple'` for checkboxes + an array value. |
|
|
720
654
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Field size. |
|
|
721
655
|
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | neutral | Validation/feedback tone for the field (Input's `status`). |
|
|
722
|
-
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph shown before the `hint` when `status` is set (Input's `statusIcon`).
|
|
723
|
-
|
|
724
|
-
| `
|
|
725
|
-
|
|
726
|
-
the chosen option. A named tone or a custom CSS color. Most visible with the
|
|
727
|
-
tint-based marks (`indicator` `'none'` / `'check'`); with `'radio'` /
|
|
728
|
-
`'checkbox'` it tones the label + indicator (those modes have no row tint). |
|
|
729
|
-
| `value?` | V \| V[] | — | Controlled value: the selected option's `value`. Update it through
|
|
730
|
-
`onValueChange`. Leave it undefined for uncontrolled use. |
|
|
731
|
-
| `verbose?` | boolean | — | `multiple` only: spell the picks out in the count summary — `3 selected:
|
|
732
|
-
A, B, C` (labels comma-joined) in place of the bare `3 selected`. Applies
|
|
733
|
-
to the multi-count case only: `All` stays `All`, a single pick stays its
|
|
734
|
-
own label, and an empty selection stays the `placeholder`. The list flows
|
|
735
|
-
into the read-only field, so it ellipsizes at the field's width when long
|
|
736
|
-
(`3 selected: Engineering, Des… `). `renderSummary` overrides this. |
|
|
656
|
+
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph shown before the `hint` when `status` is set (Input's `statusIcon`). Each status has a default; pass a shape to override, or `false` to drop it. |
|
|
657
|
+
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | — | Tone applied to the **selected** row(s) — the whole row takes this tone (label, icon, indicator, and the background tint), like passing `tone` to just the chosen option. A named tone or a custom CSS color. Most visible with the tint-based marks (`indicator` `'none'` / `'check'`); with `'radio'` / `'checkbox'` it tones the label + indicator (those modes have no row tint). |
|
|
658
|
+
| `value?` | V \| V[] | — | Controlled value: the selected option's `value`. Update it through `onValueChange`. Leave it undefined for uncontrolled use. |
|
|
659
|
+
| `verbose?` | boolean | — | `multiple` only: spell the picks out in the count summary — `3 selected: A, B, C` (labels comma-joined) in place of the bare `3 selected`. Applies to the multi-count case only: `All` stays `All`, a single pick stays its own label, and an empty selection stays the `placeholder`. The list flows into the read-only field, so it ellipsizes at the field's width when long (`3 selected: Engineering, Des… `). `renderSummary` overrides this. |
|
|
737
660
|
|
|
738
661
|
### The `SelectItem` type
|
|
739
662
|
|
|
@@ -829,6 +752,8 @@ inline `SelectGroup`, and a flyout `SelectSubmenu` (whose items are themselves
|
|
|
829
752
|
/>
|
|
830
753
|
```
|
|
831
754
|
|
|
755
|
+
## Web Component
|
|
756
|
+
|
|
832
757
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
833
758
|
|
|
834
759
|
`Select` has no host element. Compose a read-only `<a-input>` trigger with an
|
|
@@ -896,6 +821,8 @@ corners.
|
|
|
896
821
|
</select>
|
|
897
822
|
```
|
|
898
823
|
|
|
824
|
+
## Styling
|
|
825
|
+
|
|
899
826
|
Select is an [Input](./input.md) plus a [Menu](./menu.md), so it
|
|
900
827
|
inherits both surfaces' hooks. Reach for props first, then plain CSS or `::part` for
|
|
901
828
|
the rest. Don't override an element's internal `--*` output tokens.
|