@omer-x/tailwind-ui-kit 1.0.0-alpha.44 → 1.0.0-alpha.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +52 -1707
  2. package/dist/components/form/BaseAutocomplete.d.ts +1 -1
  3. package/dist/components/form/BaseSlider.d.ts +136 -0
  4. package/dist/components/form/BaseSlider.js +66 -0
  5. package/dist/components/form/BaseSliderControl.d.ts +12 -0
  6. package/dist/components/form/BaseSliderControl.js +14 -0
  7. package/dist/components/form/BaseSliderIndicator.d.ts +12 -0
  8. package/dist/components/form/BaseSliderIndicator.js +14 -0
  9. package/dist/components/form/BaseSliderLabel.d.ts +9 -0
  10. package/dist/components/form/BaseSliderLabel.js +7 -0
  11. package/dist/components/form/BaseSliderThumb.d.ts +30 -0
  12. package/dist/components/form/BaseSliderThumb.js +15 -0
  13. package/dist/components/form/BaseSliderTrack.d.ts +12 -0
  14. package/dist/components/form/BaseSliderTrack.js +12 -0
  15. package/dist/components/form/BaseSliderValue.d.ts +14 -0
  16. package/dist/components/form/BaseSliderValue.js +10 -0
  17. package/dist/components/form/index.d.ts +3 -1
  18. package/dist/components/form/index.js +2 -1
  19. package/dist/components/form/sliderStyles.d.ts +5 -0
  20. package/dist/components/form/sliderStyles.js +32 -0
  21. package/dist/components/menu/BaseMenu.d.ts +1 -1
  22. package/dist/components/menu/BaseMenubar.d.ts +1 -1
  23. package/dist/components/navigation/BaseTabs.d.ts +44 -0
  24. package/dist/components/navigation/BaseTabs.js +24 -0
  25. package/dist/components/navigation/BaseTabsIndicator.d.ts +30 -0
  26. package/dist/components/navigation/BaseTabsIndicator.js +16 -0
  27. package/dist/components/navigation/BaseTabsList.d.ts +19 -0
  28. package/dist/components/navigation/BaseTabsList.js +14 -0
  29. package/dist/components/navigation/BaseTabsPanel.d.ts +19 -0
  30. package/dist/components/navigation/BaseTabsPanel.js +11 -0
  31. package/dist/components/navigation/BaseTabsTab.d.ts +20 -0
  32. package/dist/components/navigation/BaseTabsTab.js +11 -0
  33. package/dist/components/navigation/index.d.ts +6 -0
  34. package/dist/components/navigation/index.js +1 -0
  35. package/dist/components/navigation/tabsTypes.d.ts +8 -0
  36. package/dist/components/navigation/tabsTypes.js +1 -0
  37. package/docs/button/BaseButton.md +32 -0
  38. package/docs/button/BaseToggle.md +29 -0
  39. package/docs/button/BaseToggleGroup.md +28 -0
  40. package/docs/dialog/BaseAlertDialog.md +36 -0
  41. package/docs/dialog/BaseDialog.md +61 -0
  42. package/docs/dialog/createAlertDialogHandle.md +21 -0
  43. package/docs/dialog/createDialogHandle.md +31 -0
  44. package/docs/disclosure/BaseAccordion.md +67 -0
  45. package/docs/disclosure/BaseCollapsible.md +56 -0
  46. package/docs/display/BaseAvatar.md +48 -0
  47. package/docs/display/BaseMeter.md +62 -0
  48. package/docs/elements/README.md +9 -0
  49. package/docs/feedback/BaseToast.md +91 -0
  50. package/docs/feedback/createToastManager.md +19 -0
  51. package/docs/feedback/useToast.md +37 -0
  52. package/docs/form/BaseAutocomplete.md +110 -0
  53. package/docs/form/BaseCheckbox.md +33 -0
  54. package/docs/form/BaseCheckboxGroup.md +28 -0
  55. package/docs/form/BaseFieldset.md +24 -0
  56. package/docs/form/BaseForm.md +89 -0
  57. package/docs/form/BaseFormField.md +47 -0
  58. package/docs/form/BaseInput.md +13 -0
  59. package/docs/form/BaseRadio.md +28 -0
  60. package/docs/form/BaseRadioGroup.md +35 -0
  61. package/docs/form/BaseSelect.md +109 -0
  62. package/docs/form/BaseSlider.md +93 -0
  63. package/docs/form/BaseSwitch.md +27 -0
  64. package/docs/form/useFormMessages.md +29 -0
  65. package/docs/hooks/useRipples.md +26 -0
  66. package/docs/layout/BaseSeparator.md +24 -0
  67. package/docs/layout/Container.md +5 -0
  68. package/docs/menu/BaseContextMenu.md +96 -0
  69. package/docs/menu/BaseMenu.md +84 -0
  70. package/docs/menu/BaseMenubar.md +45 -0
  71. package/docs/menu/createMenuHandle.md +31 -0
  72. package/docs/navigation/BaseTabs.md +69 -0
  73. package/docs/overlay/BaseTooltip.md +74 -0
  74. package/docs/overlay/createTooltipHandle.md +29 -0
  75. package/docs/page/Pagination.md +37 -0
  76. package/docs/page/usePagination.md +17 -0
  77. package/docs/providers/ToastProvider.md +11 -0
  78. package/docs/providers/TooltipProvider.md +17 -0
  79. package/docs/table/TableCell.md +16 -0
  80. package/docs/table/Tdx.md +5 -0
  81. package/docs/utils/RenderProp.md +5 -0
  82. package/docs/utils/cn.md +9 -0
  83. package/docs/utils/mergeProps.md +9 -0
  84. package/docs/utils/useRender.md +26 -0
  85. package/package.json +6 -1
@@ -0,0 +1,109 @@
1
+ # `BaseSelect`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/form`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Select`](https://base-ui.com/react/components/select): choose a predefined value from a dropdown. Like a native `<select>`, the popup opens over the trigger with the selected item on top of the value. A simple one:
6
+
7
+ ```tsx
8
+ import { BaseSelect } from "@omer-x/tailwind-ui-kit/form";
9
+
10
+ const fruits = { apple: "Apple", banana: "Banana", cherry: "Cherry" };
11
+
12
+ <BaseSelect items={fruits}>
13
+ <BaseSelect.Label>Fruit</BaseSelect.Label>
14
+ <BaseSelect.Trigger className="border border-neutral-300">
15
+ <BaseSelect.Value placeholder="Pick a fruit" className="data-placeholder:text-neutral-500" />
16
+ <BaseSelect.Icon><ChevronIcon /></BaseSelect.Icon>
17
+ </BaseSelect.Trigger>
18
+ <BaseSelect.Popup className="rounded-md bg-white py-1 shadow-lg">
19
+ <BaseSelect.List>
20
+ {Object.entries(fruits).map(([value, label]) => (
21
+ <BaseSelect.Item key={value} value={value} className="px-2 py-1.5 data-highlighted:bg-blue-600">
22
+ <BaseSelect.ItemIndicator><CheckIcon /></BaseSelect.ItemIndicator>
23
+ <BaseSelect.ItemText>{label}</BaseSelect.ItemText>
24
+ </BaseSelect.Item>
25
+ ))}
26
+ </BaseSelect.List>
27
+ </BaseSelect.Popup>
28
+ </BaseSelect>
29
+ ```
30
+
31
+ The parts are reached with dot notation, which only works in client components. Build selects in a `"use client"` file, e.g. your app's themed wrapper.
32
+
33
+ | Part | Renders | Description |
34
+ |------|---------|-------------|
35
+ | `BaseSelect` | a hidden `<input>` | Groups the parts and holds the value. The hidden input carries the value for the form |
36
+ | `.Label` | `<div>` | Names the trigger. Not needed inside `BaseFormField`, whose `label` names it |
37
+ | `.Trigger` | `<button>` | Shows the value and opens the popup (`flex items-center justify-between gap-2`). Takes `size` (`"lg" \| "md" \| "sm" \| "xs"`, default `"md"`), the same sizes as `BaseInput`. `data-popup-open`, `data-placeholder` |
38
+ | `.Value` | `<span>` | The selected item's label (`min-w-0 flex-1 truncate`). `placeholder` shows while nothing is selected (`data-placeholder`). Children can be a function of the value |
39
+ | `.Icon` | `<span>` | A decorative icon (e.g. a chevron), hidden from assistive technology. Bring your own icon as children |
40
+ | `.Popup` | `<div>` | The floating container, portaled and positioned. At least as wide as the trigger, with scale and fade transitions (none while it's over the trigger) |
41
+ | `.List` | `<div>` | The scrollable list, never taller than the space left in the viewport |
42
+ | `.Item` | `<div>` | An option (`flex items-center gap-2`). `value` is what it selects (`null` clears the selection), `label` its typeahead text. `data-selected`, `data-highlighted`, `data-disabled` |
43
+ | `.ItemText` | `<div>` | The item's text. Over the trigger, it's lined up with the value |
44
+ | `.ItemIndicator` | `<span>` | Marks the selected item. Only rendered while selected (`keepMounted` keeps it, e.g. to keep texts lined up). Bring your own icon, and give it `aria-hidden` so it stays out of the item's accessible name |
45
+ | `.Group` | `<div>` | A group of items |
46
+ | `.GroupLabel` | `<div>` | Names a group |
47
+ | `.Separator` | `<div>` | A line between items or groups, with `data-orientation`. It has `role="presentation"`: a listbox can't hold separators |
48
+ | `.ScrollUpArrow`, `.ScrollDownArrow` | `<div>` | Put them in `.Popup`, next to `.List`. They scroll the list while hovered, and are only rendered while it can scroll their way (`keepMounted` keeps them). Pinned to the popup's top / bottom edge. No content by default: bring your own icon |
49
+
50
+ Every part takes `className` and a `render` prop. Render functions get the part's state (`SelectTriggerState`, `SelectItemState`, `SelectPopupState`, …), which is also set as data attributes: `data-open`, `data-popup-side`, `data-placeholder`, `data-selected`, `data-highlighted`, `data-side`, `data-align`, `data-starting-style`, … The trigger and `.Label` also carry the field's state (`data-invalid`, `data-dirty`, `data-touched`, `data-filled`, `data-focused`).
51
+
52
+ `BaseSelect` props:
53
+
54
+ | Prop | Type | Description |
55
+ |------|------|-------------|
56
+ | `value` / `defaultValue` | `Value \| null` (an array with `multiple`) | The selected value, controlled / uncontrolled |
57
+ | `onValueChange` | `(value, event) => void` | Called with the new value and the DOM event (none when changed from code) |
58
+ | `multiple` | `boolean` | Lets the user select several items. The popup stays open while choosing |
59
+ | `items` | `Record<string, ReactNode> \| { value, label }[] \| { items }[]` | The items' labels, so `.Value` shows the selected label (not the raw value) before the popup has ever opened |
60
+ | `itemToStringLabel` | `(value) => string` | Text shown for an object value. `{ value, label }` objects use `label` without it |
61
+ | `itemToStringValue` | `(value) => string` | Text submitted for an object value. `{ value, label }` objects use `value` without it |
62
+ | `isItemEqualToValue` | `(itemValue, value) => boolean` | Matches object values, e.g. by id. Defaults to `Object.is` |
63
+ | `open` / `defaultOpen` | `boolean` | The popup's state |
64
+ | `onOpenChange` | `(open, event) => void` | Called with the new state and the DOM event |
65
+ | `onOpenChangeComplete` | `(open) => void` | Called after the transition ends |
66
+ | `modal` | `boolean` | Default `true`. Locks page scroll and outside pointer input while open |
67
+ | `highlightItemOnHover` | `boolean` | Default `true`. `false` lets `:hover` and `data-highlighted` differ |
68
+ | `name`, `form`, `autoComplete`, `id`, `required`, `disabled`, `readOnly` | | Form props. Inside `BaseFormField`, the field's `name` is used |
69
+ | `inputRef` | `Ref<HTMLInputElement>` | The hidden input |
70
+ | `actionsRef` | `RefObject<SelectActions>` | `actionsRef.current?.close()` |
71
+
72
+ `BaseSelect.Popup` props, besides `<div>` props:
73
+
74
+ | Prop | Description |
75
+ |------|-------------|
76
+ | `alignItemWithTrigger` | Default `true`: the popup opens over the trigger (`data-side="none"`), and `side`, `align` and their offsets don't apply. Touch input and too little space fall back to a regular placement. `false` always places it beside the trigger |
77
+ | `side`, `align` | Placement against the trigger. Default `"bottom"`, `"center"` |
78
+ | `sideOffset`, `alignOffset` | Offsets in pixels, or a function of the placement and sizes |
79
+ | `anchor`, `positionMethod`, `collisionBoundary`, `collisionPadding`, `collisionAvoidance`, `sticky`, `disableAnchorTracking` | Positioning control |
80
+ | `renderPositioner` | Replaces the element that positions the popup, e.g. `<div className="z-50" />` |
81
+ | `container` | Portal target (default `<body>`) |
82
+ | `backdrop`, `renderBackdrop` | Renders a `fixed inset-0` backdrop (off by default) |
83
+ | `arrow`, `renderArrow`, `arrowPadding` | An arrow pointing at the trigger. Rendered when `arrow` (its content, e.g. an `<svg>`) or `renderArrow` is given. Only shows while the popup is beside the trigger |
84
+ | `finalFocus` | The element focused when the popup closes. Defaults to the trigger |
85
+
86
+ **Several values.** With `multiple`, the value is an array. Render it in `.Value` with a function:
87
+
88
+ ```tsx
89
+ <BaseSelect multiple items={fruits}>
90
+ <BaseSelect.Trigger>
91
+ <BaseSelect.Value placeholder="Pick fruits">
92
+ {(values: string[]) => values.map(value => fruits[value]).join(", ")}
93
+ </BaseSelect.Value>
94
+ </BaseSelect.Trigger>
95
+ …
96
+ </BaseSelect>
97
+ ```
98
+
99
+ **In a form.** Put it in `BaseFormField`'s `children`. The field gives it its `name`, label, validation, server errors and `data-invalid`, and `onlyDirty` sees its value (`defaultValues` holds the item values, an array with `multiple`). `BaseForm` never resets the form after a submit (#4), so the select keeps its value. Only `required` is checked in the browser; other schema rules are checked by the server:
100
+
101
+ ```tsx
102
+ <BaseFormField name="fruit" label="Fruit" schema={Schema.shape.fruit}>
103
+ {constraints => (
104
+ <BaseSelect items={fruits} required={constraints.required}>
105
+ …
106
+ </BaseSelect>
107
+ )}
108
+ </BaseFormField>
109
+ ```
@@ -0,0 +1,93 @@
1
+ # `BaseSlider`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/form`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Slider`](https://base-ui.com/react/components/slider): pick a number, or a range of numbers, within known bounds by dragging a thumb, pressing the track or using the keyboard (arrows by `step`, Page Up / Page Down by `largeStep`, Home / End to the bounds). It renders a `<div>` with the label and the value on top and the control below (`flex flex-wrap`). An array value makes a range slider with one thumb per value.
6
+
7
+ ```tsx
8
+ import { BaseSlider } from "@omer-x/tailwind-ui-kit/form";
9
+
10
+ <BaseSlider
11
+ label="Volume"
12
+ defaultValue={40}
13
+ showValue
14
+ trackClassName="bg-neutral-200"
15
+ indicatorClassName="bg-blue-600"
16
+ thumbClassName="border-2 border-blue-600 bg-white outline-blue-500"
17
+ />
18
+ ```
19
+
20
+ | Prop | Type | Default | Description |
21
+ |------|------|---------|-------------|
22
+ | `value` / `defaultValue` | `number \| number[]` | | The value, controlled / uncontrolled. An array makes a range |
23
+ | `onValueChange` | `(value, event) => void` | | Called on every move with the new value and the DOM event |
24
+ | `onValueCommitted` | `(value, event) => void` | | Called with the final value when a drag ends or a key press is done |
25
+ | `min` / `max` | `number` | `0` / `100` | The bounds |
26
+ | `step` | `number` | `1` | Values snap to multiples of it, counted from `min` |
27
+ | `largeStep` | `number` | `10` | The step of Page Up / Page Down and Shift + arrows |
28
+ | `minStepsBetweenValues` | `number` | `0` | The minimum gap between the thumbs of a range, in steps |
29
+ | `thumbCollisionBehavior` | `"push" \| "swap" \| "none"` | `"push"` | What thumbs of a range do when they meet while dragging |
30
+ | `thumbAlignment` | `"center" \| "edge" \| "edge-client-only"` | `"center"` | Where the thumbs sit at the bounds: centered on the control's edge, or inside it |
31
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | A vertical slider stacks the parts in a column. Give it a height |
32
+ | `disabled` | `boolean` | | |
33
+ | `name`, `form` | `string` | | Form props. Each thumb submits its value under `name`, so a range sends one value per thumb. Inside `BaseFormField`, the field's `name` is used |
34
+ | `format` | `Intl.NumberFormatOptions` | | How values are formatted for the value text and screen readers |
35
+ | `locale` | `Intl.LocalesArgument` | runtime locale | The locale used to format values |
36
+ | `label` | `ReactNode` | | The visible name. It labels every thumb. Not needed inside `BaseFormField`, whose `label` names it |
37
+ | `labelClassName` | `string` | | Classes for the label `<div>` (default `grow` while horizontal) |
38
+ | `renderLabel` | `RenderProp<"div", SliderState>` | | Render another element for the label |
39
+ | `showValue` | `boolean \| (formattedValues, values) => ReactNode` | `false` | Shows the value as text next to the label (a range shows `20 – 80`). A function shows something else, e.g. `` (f) => f.join(" to ") `` |
40
+ | `valueClassName` | `string` | | Classes for the value `<output>` (default `ms-auto tabular-nums` while horizontal) |
41
+ | `renderValue` | `RenderProp<"output", SliderState>` | | Render another element for the value |
42
+ | `size` | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | The track's thickness (`2` / `1.5` / `1` / `0.5`) and the thumbs' size (`size-5` / `4` / `3.5` / `3`) |
43
+ | `controlClassName` | `string` | | Classes for the control `<div>`, the area that reacts to the pointer (default `flex touch-none items-center select-none`, full width with `py-2` while horizontal) |
44
+ | `renderControl` | `RenderProp<"div", SliderState>` | | Render another element for the control |
45
+ | `trackClassName` | `string` | | Classes for the track `<div>` (default `rounded-full`, full length) |
46
+ | `renderTrack` | `RenderProp<"div", SliderState>` | | Render another element for the track |
47
+ | `indicatorClassName` | `string` | | Classes for the indicator `<div>`, the filled part (default `rounded-full`). Its position and length are set inline |
48
+ | `renderIndicator` | `RenderProp<"div", SliderState>` | | Render another element for the indicator |
49
+ | `thumbClassName` | `string` | | Classes for every thumb `<div>` (default `rounded-full`, a focus outline through `has-focus-visible:outline-2 outline-offset-2`: set its color) |
50
+ | `renderThumb` | `RenderProp<"div", SliderState>` | | Render another element for the thumbs. Keep `props.children`: it holds the thumb's `<input type="range">` |
51
+ | `getAriaLabel` | `(index) => string` | | The thumbs' accessible names. Use it without a `label`, or to name the thumbs of a range |
52
+ | `getAriaValueText` | `(formattedValue, value, index) => string` | | What screen readers announce for a thumb's value |
53
+ | `children` | `ReactNode` | | Lays out the parts yourself (see below). The built-in label, value and control aren't rendered then |
54
+ | `className` | `string` | | Classes for the root `<div>` |
55
+ | `render` | `RenderProp<"div", SliderState>` | | Render another element for the root |
56
+ | …rest | | | `<div>` props |
57
+
58
+ To place the parts yourself, pass them as children. Dot notation only works in client components.
59
+
60
+ ```tsx
61
+ <BaseSlider defaultValue={[20, 80]} className="flex-col items-stretch">
62
+ <BaseSlider.Label>Price</BaseSlider.Label>
63
+ <BaseSlider.Control>
64
+ <BaseSlider.Track className="bg-neutral-200">
65
+ <BaseSlider.Indicator className="bg-blue-600" />
66
+ <BaseSlider.Thumb index={0} className="bg-blue-600" getAriaLabel={() => "Minimum price"} />
67
+ <BaseSlider.Thumb index={1} className="bg-blue-600" getAriaLabel={() => "Maximum price"} />
68
+ </BaseSlider.Track>
69
+ </BaseSlider.Control>
70
+ <BaseSlider.Value>{formatted => formatted.join(" to ")}</BaseSlider.Value>
71
+ </BaseSlider>
72
+ ```
73
+
74
+ | Part | Renders | Props |
75
+ |------|---------|-------|
76
+ | `BaseSlider.Label` | `<div>` | `className`, `render` |
77
+ | `BaseSlider.Value` | `<output>` | `className`, `render`, `children?: (formattedValues, values) => ReactNode` |
78
+ | `BaseSlider.Control` | `<div>` | `className`, `render` |
79
+ | `BaseSlider.Track` | `<div>` | `size`, `className`, `render` |
80
+ | `BaseSlider.Indicator` | `<div>` | `className`, `render` |
81
+ | `BaseSlider.Thumb` | `<div>` with a hidden `<input type="range">` | `index` (needed to server-render a range), `size`, `disabled`, `getAriaLabel`, `getAriaValueText`, `inputRef`, `onFocus` / `onBlur` / `onKeyDown` (on the input), `className`, `render` |
82
+
83
+ Render functions get `SliderState`: `{ values, min, max, step, orientation, disabled, dragging, activeThumbIndex, touched, dirty, valid, focused }`. Every part sets `data-orientation`, `data-disabled` and `data-dragging`; inside `BaseFormField` also `data-valid` / `data-invalid`, `data-touched`, `data-dirty` and `data-focused`. Thumbs set `data-index`.
84
+
85
+ **In a form.** Put it in `BaseFormField`'s `children`. The field gives it its `name`, label, server errors and `data-invalid`, and `onlyDirty` sees its value (`defaultValues` holds a number, or an array for a range). Read the bounds from the schema:
86
+
87
+ ```tsx
88
+ <BaseFormField name="rating" label="Rating" schema={z.coerce.number().int().min(0).max(10)}>
89
+ {constraints => (
90
+ <BaseSlider defaultValue={5} min={Number(constraints.min)} max={Number(constraints.max)} showValue />
91
+ )}
92
+ </BaseFormField>
93
+ ```
@@ -0,0 +1,27 @@
1
+ # `BaseSwitch`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/form`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Switch`](https://base-ui.com/react/components/switch) with its label. It submits `"true"` / `"false"` by default, so its value always appears in form data.
6
+
7
+ | Prop | Type | Default | Description |
8
+ |------|------|---------|-------------|
9
+ | `label` | `ReactNode` | | Text next to the switch (required) |
10
+ | `labelClassName` | `string` | | Classes for the `<label>` around the switch and its text (default `flex items-center gap-2 text-sm font-normal`) |
11
+ | `renderThumb` | `RenderProp<"span", SwitchState>` | | Style the thumb |
12
+ | `value` | `string` | `"true"` | Submitted when checked |
13
+ | `uncheckedValue` | `string` | `"false"` | Submitted when unchecked |
14
+ | `onCheckedChange` | `(checked: boolean, event: Event) => void` | | Called with the new state and the DOM event that changed it |
15
+ | `render` | `RenderProp<"span", SwitchState>` | | Render another element for the track |
16
+ | …rest | | | `name`, `checked`, `defaultChecked`, `disabled`, `readOnly`, `required`, `form`, `inputRef`, `nativeButton`, and `<span>` props |
17
+
18
+ Render functions get `SwitchState`: `{ checked, disabled, readOnly, required }`.
19
+
20
+ ```tsx
21
+ <BaseSwitch
22
+ name="active"
23
+ label="Active"
24
+ className="rounded-full bg-neutral-300 data-checked:bg-blue-600"
25
+ renderThumb={<span className="rounded-full bg-white" />}
26
+ />
27
+ ```
@@ -0,0 +1,29 @@
1
+ # `useFormMessages`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/form`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ Returns the form-level messages of the latest result of the surrounding `BaseForm`, already passed through `formatMessage`. Call it anywhere inside the form.
6
+
7
+ ```ts
8
+ const { messages, submissionId } = useFormMessages();
9
+ // messages: { key: string, type: "error" | "warning", text: string }[]
10
+ // submissionId: changes once per completed submission
11
+ ```
12
+
13
+ ```tsx
14
+ // Inline alerts, placed anywhere in the form
15
+ const FormAlerts = () => {
16
+ const { messages } = useFormMessages();
17
+ return messages.map(m => <Alert key={m.key} type={m.type}>{m.text}</Alert>);
18
+ };
19
+
20
+ // Toasts: fire once per submission, not on every re-render
21
+ const FormToasts = () => {
22
+ const { messages, submissionId } = useFormMessages();
23
+ const { add } = useToast();
24
+ useEffect(() => {
25
+ messages.forEach(m => add({ type: m.type, description: m.text }));
26
+ }, [submissionId]);
27
+ return null;
28
+ };
29
+ ```
@@ -0,0 +1,26 @@
1
+ # `useRipples`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/hooks`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ The ripple effect of `BaseButton` and `BaseToggle`, for your own clickable elements. Returns `[handleClick, ripples]`: call `handleClick` from `onClick` and render `ripples` inside the element.
6
+
7
+ - The element needs `relative` (the ripples are positioned absolutely and clipped to its rounded corners).
8
+ - Ripples use `bg-current`, so they follow the text color. They start from the center on keyboard clicks and are hidden when the user prefers reduced motion.
9
+
10
+ ```tsx
11
+ import { useRipples } from "@omer-x/tailwind-ui-kit/hooks";
12
+
13
+ const Chip = ({ children, onClick, ...props }: ComponentProps<"button">) => {
14
+ const [handleRipple, ripples] = useRipples();
15
+ return (
16
+ <button
17
+ {...props}
18
+ className="relative rounded-full px-3 py-1"
19
+ onClick={event => { handleRipple(event); onClick?.(event); }}
20
+ >
21
+ {children}
22
+ {ripples}
23
+ </button>
24
+ );
25
+ };
26
+ ```
@@ -0,0 +1,24 @@
1
+ # `BaseSeparator`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/layout`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Separator`](https://base-ui.com/react/components/separator): a `1px` line between blocks that screen readers announce. Renders a `<div>` with `role="separator"`, `aria-orientation` and `data-orientation`. It has no color: give it one with `className`.
6
+
7
+ ```tsx
8
+ import { BaseSeparator } from "@omer-x/tailwind-ui-kit/layout";
9
+
10
+ <BaseSeparator className="bg-neutral-300" />
11
+
12
+ <nav className="flex items-center gap-3">
13
+ <a href="/">Home</a>
14
+ <BaseSeparator orientation="vertical" className="h-4 bg-neutral-300" />
15
+ <a href="/pricing">Pricing</a>
16
+ </nav>
17
+ ```
18
+
19
+ | Prop | Type | Default | Description |
20
+ |------|------|---------|-------------|
21
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Horizontal: `h-px w-full`. Vertical: `w-px self-stretch` (the height of its flex row; set a height with `className` otherwise) |
22
+ | `render` | `RenderProp<"div", SeparatorState>` | | The state is `{ orientation }`. E.g. `render={<hr />}` (add `border-0`: Tailwind's preflight gives `<hr>` a top border) |
23
+
24
+ Style each orientation with `data-[orientation=vertical]:…`.
@@ -0,0 +1,5 @@
1
+ # `Container`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/layout`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ Tailwind's `container`, centered with horizontal padding (`container mx-auto px-3`). Accepts all `<div>` props.
@@ -0,0 +1,96 @@
1
+ # `BaseContextMenu`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/menu`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Context Menu`](https://base-ui.com/react/components/context-menu): a menu that opens at the pointer on right click or long press. `Popup` brings its portal and positioner, so a simple context menu needs no more than this:
6
+
7
+ ```tsx
8
+ import { BaseContextMenu } from "@omer-x/tailwind-ui-kit/menu";
9
+
10
+ <BaseContextMenu>
11
+ <BaseContextMenu.Trigger className="h-40 rounded border border-dashed">Right click here</BaseContextMenu.Trigger>
12
+ <BaseContextMenu.Popup className="rounded-md border bg-white shadow-lg">
13
+ <BaseContextMenu.Item className="data-highlighted:bg-neutral-100" onClick={reload}>Reload</BaseContextMenu.Item>
14
+ <BaseContextMenu.Separator className="bg-neutral-200" />
15
+ <BaseContextMenu.LinkItem className="data-highlighted:bg-neutral-100" href="/help">Help</BaseContextMenu.LinkItem>
16
+ </BaseContextMenu.Popup>
17
+ </BaseContextMenu>
18
+ ```
19
+
20
+ Like `BaseDialog`, the parts use dot notation, so build menus in a `"use client"` file. Every part except the root and `Trigger` is shared with `BaseMenu`, so one set of popup and item styles themes both.
21
+
22
+ | Part | Renders | Description |
23
+ |------|---------|-------------|
24
+ | `BaseContextMenu` | nothing | Groups the parts and holds the open state |
25
+ | `BaseContextMenu.Trigger` | `<div>` | The area that opens the menu on right click or long press. `data-popup-open` while the menu is open |
26
+ | `BaseContextMenu.Popup` | `<div>` | The menu, portaled and placed at the pointer (or next to its submenu trigger), with scale and fade transitions. Scrolls when taller than the viewport. Optional backdrop |
27
+ | `BaseContextMenu.Arrow` | `<div>` | An arrow pointing at the anchor, inside `Popup`. Draw it yourself |
28
+ | `BaseContextMenu.Item` | `<div>` | An action. Closes the menu when clicked (`closeOnClick`, default `true`) |
29
+ | `BaseContextMenu.LinkItem` | `<a>` | A link. Use `render` for your router's link. Doesn't close the menu (`closeOnClick`, default `false`) |
30
+ | `BaseContextMenu.Separator` | `<div>` | A `1px` line between items (`my-1 h-px`). Give it a color with `className` |
31
+ | `BaseContextMenu.Group` | `<div>` | Groups related items, labelled by the `GroupLabel` inside it |
32
+ | `BaseContextMenu.GroupLabel` | `<div>` | The group's name (`text-xs font-medium`) |
33
+ | `BaseContextMenu.RadioGroup` | `<div>` | Holds `RadioItem`s: `value` / `defaultValue`, `onValueChange(value, event)`, `disabled` |
34
+ | `BaseContextMenu.RadioItem` | `<div>` | An option of a `RadioGroup` (`value`) |
35
+ | `BaseContextMenu.CheckboxItem` | `<div>` | A toggle: `checked` / `defaultChecked`, `onCheckedChange(checked, event)` |
36
+ | `BaseContextMenu.Submenu` | nothing | Holds a `SubmenuTrigger` and a nested `Popup`. Takes `open` / `defaultOpen`, `onOpenChange`, `onOpenChangeComplete`, `disabled`, `loopFocus`, `highlightItemOnHover` and `closeParentOnEsc` |
37
+ | `BaseContextMenu.SubmenuTrigger` | `<div>` | The item that opens its submenu, on click or hover (`openOnHover`, `delay`, `closeDelay`). `icon` is shown at the end (e.g. a chevron), with `iconClassName` for its `<span>` |
38
+
39
+ Every part that renders an element takes `className` and `render`.
40
+
41
+ Items (`Item`, `LinkItem`, `SubmenuTrigger`, `CheckboxItem`, `RadioItem`) share one layout: `flex items-center gap-2 px-3 py-1.5 text-sm`, no outline, faded and inert while disabled. They take `label` (the text for keyboard text navigation), and the `<div>` ones take `disabled` and `nativeButton` (set it to `true` when `render` renders a `<button>`). Style the highlighted item with `data-highlighted:`.
42
+
43
+ `CheckboxItem` and `RadioItem` put their indicator in a first `1rem` column, so labels line up whether it shows or not. Indicator props:
44
+
45
+ | Prop | Type | Description |
46
+ |------|------|-------------|
47
+ | `indicator` | `ReactNode` | Shown when checked, e.g. a check mark or a dot. Nothing by default |
48
+ | `renderIndicator` | `RenderProp<"span", State>` | Style or replace the indicator's `<span>` |
49
+ | `keepIndicatorMounted` | `boolean` | Keeps the indicator in the DOM when unchecked, e.g. to animate it out |
50
+ | `closeOnClick` | `boolean` | Closes the menu when clicked. Default `false` |
51
+
52
+ `BaseContextMenu` props:
53
+
54
+ | Prop | Type | Default | Description |
55
+ |------|------|---------|-------------|
56
+ | `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
57
+ | `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
58
+ | `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
59
+ | `disabled` | `boolean` | `false` | Doesn't open, so the browser's own context menu shows |
60
+ | `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last item to the first |
61
+ | `highlightItemOnHover` | `boolean` | `true` | Highlights items under the pointer. Turn it off to style `:hover` apart from `data-highlighted` |
62
+ | `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Which arrow keys move between items |
63
+
64
+ `BaseContextMenu.Popup` props:
65
+
66
+ | Prop | Type | Default | Description |
67
+ |------|------|---------|-------------|
68
+ | `side` / `align` | `MenuSide` / `MenuAlign` | at the pointer | Where the popup sits against its anchor (`"top"`, `"bottom"`, `"left"`, `"right"`, `"inline-start"`, `"inline-end"` / `"start"`, `"center"`, `"end"`). Submenus default to `"inline-end"` / `"start"` |
69
+ | `sideOffset` / `alignOffset` | `number \| MenuOffsetFunction` | | Offsets from the anchor, in pixels, or a function of the placement and sizes |
70
+ | `collisionPadding` | `number \| { top, right, bottom, left }` | `5` | Space kept from the viewport edges |
71
+ | `collisionBoundary` / `collisionAvoidance` | | `"clipping-ancestors"` | The area the popup stays inside, and how it avoids its edges (flip or shift) |
72
+ | `anchor` | `Element \| RefObject \| () => Element \| null` | the trigger | The element the popup is placed against |
73
+ | `disableAnchorTracking` | `boolean` | `false` | Stops following the anchor when it moves |
74
+ | `arrowPadding` | `number` | `5` | Minimum distance between an `Arrow` and the popup's corners |
75
+ | `sticky` | `boolean` | `false` | Stays in view while the anchor scrolls away |
76
+ | `positionMethod` | `"absolute" \| "fixed"` | `"absolute"` | Use `"fixed"` when the anchor is inside a fixed container |
77
+ | `positionerClassName` / `renderPositioner` | `string` / `RenderProp<"div", MenuPositionerState>` | | Style or replace the positioner, the `<div>` around the popup that places it (`z-50`) |
78
+ | `finalFocus` | `MenuFocusTarget` | `true` | The element focused on close: `true` (default), `false` (don't move focus), a ref, or a function of the interaction type |
79
+ | `container` | `HTMLElement \| ShadowRoot \| RefObject \| null` | `<body>` | Where the popup is portaled to |
80
+ | `keepMounted` | `boolean` | `false` | Keeps the popup in the DOM while closed |
81
+ | `backdrop` | `boolean` | `false` | Renders a transparent full-screen backdrop (`fixed inset-0`) behind the popup |
82
+ | `renderBackdrop` | `RenderProp<"div", MenuBackdropState>` | | Style or replace the backdrop. A `className` on the element wins over the kit's conflicting classes |
83
+ | `render` | `RenderProp<"div", MenuPopupState>` | | The state is `{ open, side, align, nested }` |
84
+
85
+ Data attributes: the popup has `data-open` / `data-closed`, `data-side`, `data-align`, `data-nested` (in a submenu) and `data-starting-style` / `data-ending-style` during transitions. Items have `data-highlighted` and `data-disabled`; checkbox and radio items and their indicators also have `data-checked` / `data-unchecked`.
86
+
87
+ **Submenus:** put a `Submenu` among the items, with a `SubmenuTrigger` and another `Popup` inside:
88
+
89
+ ```tsx
90
+ <BaseContextMenu.Submenu>
91
+ <BaseContextMenu.SubmenuTrigger icon={<ChevronRight />}>Share</BaseContextMenu.SubmenuTrigger>
92
+ <BaseContextMenu.Popup className="rounded-md border bg-white shadow-lg">
93
+ <BaseContextMenu.Item>Email</BaseContextMenu.Item>
94
+ </BaseContextMenu.Popup>
95
+ </BaseContextMenu.Submenu>
96
+ ```
@@ -0,0 +1,84 @@
1
+ # `BaseMenu`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/menu`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Menu`](https://base-ui.com/react/components/menu): a list of actions opened from a button, with keyboard navigation, submenus, checkbox and radio items, and optional filtering. It uses the same `Popup`, `Arrow`, items, groups and submenus as `BaseContextMenu` (see above), so one set of styles themes both. A simple menu needs no more than this:
6
+
7
+ ```tsx
8
+ import { BaseMenu } from "@omer-x/tailwind-ui-kit/menu";
9
+
10
+ <BaseMenu>
11
+ <BaseMenu.Trigger render={<Button />}>Actions</BaseMenu.Trigger>
12
+ <BaseMenu.Popup sideOffset={4} className="rounded-md border bg-white shadow-lg">
13
+ <BaseMenu.Item className="data-highlighted:bg-neutral-100" onClick={edit}>Edit</BaseMenu.Item>
14
+ <BaseMenu.Separator className="bg-neutral-200" />
15
+ <BaseMenu.Item className="data-highlighted:bg-neutral-100" onClick={remove}>Delete</BaseMenu.Item>
16
+ </BaseMenu.Popup>
17
+ </BaseMenu>
18
+ ```
19
+
20
+ Parts besides the shared ones (`Popup`, `Arrow`, `Item`, `LinkItem`, `Separator`, `Group`, `GroupLabel`, `RadioGroup`, `RadioItem`, `CheckboxItem`, `Submenu`, `SubmenuTrigger`):
21
+
22
+ | Part | Renders | Description |
23
+ |------|---------|-------------|
24
+ | `BaseMenu` | nothing | Groups the parts and holds the open state |
25
+ | `BaseMenu.Trigger` | `<button>` | Opens the menu. `data-popup-open` while its menu is open. Takes `handle`, `payload`, `openOnHover` (also open on hover), `delay` / `closeDelay` (hover delays in ms, default `100` / `0`) and `nativeButton` |
26
+ | `BaseMenu.Input` | `<input>` | The search box of a `filterable` menu (`role="searchbox"`) |
27
+ | `BaseMenu.Clear` | `<button>` | Clears the search box. Only rendered while there's a query. A pointer shortcut: out of the tab order and `aria-hidden` |
28
+ | `BaseMenu.Empty` | `<div>` | Shown only when no item matches (`role="status"`). Not rendered otherwise |
29
+ | `BaseMenu.List` | `<div>` | Holds the items when the popup has other content too (the search box). Scrolls when the popup runs out of space (`min-h-0 flex-1 overflow-y-auto`) |
30
+ | `BaseMenu.Viewport` | `<div>` | Animates the content when one menu is opened by several triggers and its content depends on the trigger. `data-activation-direction`, `data-transitioning` |
31
+
32
+ The popup is placed below the trigger and centered by default (`side="bottom"`, `align="center"`).
33
+
34
+ `BaseMenu` props:
35
+
36
+ | Prop | Type | Default | Description |
37
+ |------|------|---------|-------------|
38
+ | `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
39
+ | `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
40
+ | `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
41
+ | `modal` | `boolean` | `true` | Locks page scroll and blocks outside pointer input while open. Menus opened by hover never are |
42
+ | `disabled` | `boolean` | `false` | |
43
+ | `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last item to the first |
44
+ | `highlightItemOnHover` | `boolean` | `true` | Turn it off to style `:hover` apart from `data-highlighted` |
45
+ | `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Which arrow keys move between items |
46
+ | `onItemHighlighted` | `(item, { reason, label }) => void` | | The highlighted element (or `undefined`). `reason` is `"keyboard"`, `"pointer"` or `"none"` |
47
+ | `actionsRef` | `RefObject<MenuActions>` | | `actionsRef.current?.close()` |
48
+ | `handle` | `MenuHandle<Payload>` | | Connects triggers outside the menu and opens it from code (see below) |
49
+ | `triggerId` / `defaultTriggerId` | `string \| null` | | The trigger a controlled / initially open menu belongs to |
50
+ | `children` | `ReactNode \| ({ payload }) => ReactNode` | | The parts, or a function that gets the payload of the trigger that opened the menu |
51
+ | `filterable` | `boolean` | `false` | Adds filtering (see below) |
52
+
53
+ `Submenu` also takes `orientation`, `onItemHighlighted`, `actionsRef` and the filtering props.
54
+
55
+ **Router links.** `LinkItem` renders an `<a>`. Pass your router's link as `render`, and it gets the item's props and behavior:
56
+
57
+ ```tsx
58
+ import Link from "next/link";
59
+
60
+ <BaseMenu.LinkItem render={<Link href="/settings" />}>Settings</BaseMenu.LinkItem>
61
+ ```
62
+
63
+ **Filtering.** `filterable` (on `BaseMenu` or a `Submenu`) lets the user filter the items by typing in an `Input`. Put the items in a `List`; items that don't match are removed. The popup becomes a `role="dialog"` holding the search box and the `role="menu"` list. Make the popup a flex column (`flex flex-col`) so only the list scrolls:
64
+
65
+ ```tsx
66
+ <BaseMenu filterable>
67
+ <BaseMenu.Trigger render={<Button />}>Labels</BaseMenu.Trigger>
68
+ <BaseMenu.Popup className="flex flex-col">
69
+ <BaseMenu.Input aria-label="Search labels" placeholder="Search labels" />
70
+ <BaseMenu.Empty className="py-1.5">No labels found</BaseMenu.Empty>
71
+ <BaseMenu.List>
72
+ {labels.map(label => <BaseMenu.CheckboxItem key={label}>{label}</BaseMenu.CheckboxItem>)}
73
+ </BaseMenu.List>
74
+ </BaseMenu.Popup>
75
+ </BaseMenu>
76
+ ```
77
+
78
+ | Prop | Type | Description |
79
+ |------|------|-------------|
80
+ | `filter` | `(text, query) => boolean \| null` | Decides what matches, from the item's `label` (or text) and the trimmed query. Defaults to "contains", ignoring case, accents and punctuation. `null` shows every item (filter them yourself) |
81
+ | `autoHighlight` | `boolean \| "always"` | Highlights the first match while there's a query (`"always"`: also without one) |
82
+ | `locale` | `Intl.LocalesArgument` | Locale of the default filter |
83
+ | `query` / `defaultQuery` | `string` | The query, controlled / uncontrolled. It's cleared when the menu closes |
84
+ | `onQueryChange` | `(query, event) => void` | Called with the new query and the DOM event |
@@ -0,0 +1,45 @@
1
+ # `BaseMenubar`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/menu`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ A Base UI [`Menubar`](https://base-ui.com/react/components/menubar): an application menu bar holding several `BaseMenu`s. Once one menu is open, hovering another trigger switches to its menu, and the arrow keys move between the triggers. `BaseMenu` is attached as `BaseMenubar.Menu`, so one import is enough:
6
+
7
+ ```tsx
8
+ import { BaseMenubar } from "@omer-x/tailwind-ui-kit/menu";
9
+
10
+ <BaseMenubar className="gap-1 rounded-md border p-1">
11
+ <BaseMenubar.Menu>
12
+ <BaseMenubar.Menu.Trigger className="rounded px-3 py-1 data-popup-open:bg-neutral-200">File</BaseMenubar.Menu.Trigger>
13
+ <BaseMenubar.Menu.Popup sideOffset={6} className="rounded-md border bg-white shadow-lg">
14
+ <BaseMenubar.Menu.Item className="data-highlighted:bg-neutral-100" onClick={save}>Save</BaseMenubar.Menu.Item>
15
+ </BaseMenubar.Menu.Popup>
16
+ </BaseMenubar.Menu>
17
+ <BaseMenubar.Menu>
18
+ <BaseMenubar.Menu.Trigger className="rounded px-3 py-1 data-popup-open:bg-neutral-200">Edit</BaseMenubar.Menu.Trigger>
19
+ <BaseMenubar.Menu.Popup sideOffset={6} className="rounded-md border bg-white shadow-lg">
20
+ <BaseMenubar.Menu.Item className="data-highlighted:bg-neutral-100" onClick={undo}>Undo</BaseMenubar.Menu.Item>
21
+ </BaseMenubar.Menu.Popup>
22
+ </BaseMenubar.Menu>
23
+ </BaseMenubar>
24
+ ```
25
+
26
+ `<BaseMenu>` inside a `<BaseMenubar>` works the same. Every menu part (`Popup`, items, submenus, …) behaves as described for `BaseMenu`, with these differences:
27
+
28
+ - Triggers are items of the menubar (`role="menuitem"`), with one tab stop for the whole bar.
29
+ - Popups open below a horizontal menubar's triggers and start-aligned (`side="bottom"`, `align="start"`), or beside a vertical one's.
30
+ - The menubar's `modal` and `disabled` apply to every menu in it. `BaseMenu`'s own `modal` is ignored there.
31
+
32
+ | Part | Renders | Description |
33
+ |------|---------|-------------|
34
+ | `BaseMenubar` | `<div>` | The bar (`role="menubar"`, `flex`, `flex-col` when vertical). `data-orientation`, `data-modal`, `data-has-submenu-open` (one of its menus is open) |
35
+ | `BaseMenubar.Menu` | nothing | `BaseMenu`, with all its parts (`BaseMenubar.Menu.Trigger`, `BaseMenubar.Menu.Popup`, …) |
36
+
37
+ `BaseMenubar` props:
38
+
39
+ | Prop | Type | Default | Description |
40
+ |------|------|---------|-------------|
41
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The direction of the bar, and the arrow keys that move between its triggers |
42
+ | `modal` | `boolean` | `true` | Locks page scroll and blocks outside pointer input while a menu is open |
43
+ | `disabled` | `boolean` | `false` | Disables every menu (`data-disabled` on the triggers) |
44
+ | `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last trigger to the first |
45
+ | `render` | `RenderProp<"div", MenubarState>` | | The state is `{ orientation, modal, hasSubmenuOpen }` |
@@ -0,0 +1,31 @@
1
+ # `createMenuHandle`
2
+
3
+ Import from `@omer-x/tailwind-ui-kit/menu`. See the [README](../../README.md) for setup, theming and the other components.
4
+
5
+ Opens one menu from triggers anywhere on the page, or from code. Each trigger can pass a `payload`, which the menu's function children receive:
6
+
7
+ ```tsx
8
+ import { BaseMenu, createMenuHandle } from "@omer-x/tailwind-ui-kit/menu";
9
+
10
+ const rowMenu = createMenuHandle<{ id: string, name: string }>();
11
+
12
+ // triggers anywhere on the page
13
+ <BaseMenu.Trigger id={`row-${row.id}`} handle={rowMenu} payload={row} render={<Button />}>Options</BaseMenu.Trigger>
14
+
15
+ // one menu on the page
16
+ <BaseMenu handle={rowMenu}>
17
+ {({ payload }) => payload && (
18
+ <BaseMenu.Popup>
19
+ <BaseMenu.Item onClick={() => rename(payload.id)}>Rename {payload.name}</BaseMenu.Item>
20
+ </BaseMenu.Popup>
21
+ )}
22
+ </BaseMenu>
23
+
24
+ // from code
25
+ rowMenu.open(`row-${id}`);
26
+ ```
27
+
28
+ A `MenuHandle<Payload>` has `open(triggerId)`, `close()` and `isOpen`. Unlike the dialog handles, it has no `openWithPayload`: a menu is placed against its trigger, so `open` needs the `id` of a trigger with the same handle (it throws when there's none).
29
+
30
+ - Calls are **ignored while the menu isn't mounted**. Keep the `BaseMenu` with the handle rendered.
31
+ - Call them **from event handlers or effects, never during render**.