Overlays
ActionSheet
A list of actions: a menu anchored to its toggle on regular width, a bottom sheet with a Cancel row on compact width.
import { ActionSheet, ActionSheetItem } from "datui";Examples
Basic
Pass the toggle as anchorRef; the layout follows the viewport.
Sheet
mode="sheet" forces the bottom sheet.
Accessibility
- Menu layout:
role="menu"withmenuitem/menuitemradio(aria-checked) items; Arrow keys, Home/End and first-letter typeahead move focus; disabled items are skipped. - Sheet layout: a modal dialog with a list of buttons and a Cancel button.
- Escape and outside clicks close it; activating an item closes it and then runs its
onClick. - Focus moves to the first item on open and returns to the anchor on close.
API
ActionSheet
A list of actions: a bottom sheet on compact width, a menu anchored to `anchorRef` on regular width.
| Prop | Type | Default | Description |
|---|---|---|---|
| anchorRef | RefObject<HTMLElement | null> | — | The element the menu is anchored to on regular width (usually the button that opened it). |
| cancelLabel | string | Cancel | Label of the cancel row in sheet mode. |
| children | ReactNode | — | `ActionSheetItem` elements. |
| className | string | — | |
| defaultOpen | boolean | true | |
| description | ReactNode | — | |
| mode | "menu" | "sheet" | — | Force a layout. Default: `sheet` on compact width, `menu` on regular width. |
| offset | number | 4 | Menu distance from the anchor in px. |
| onClose | ((reason: ActionSheetCloseReason) => void) | — | |
| onClosed | (() => void) | — | Called after the sheet has closed and unmounted (after deferred item `onClick`s). |
| onOpenChange | ((open: boolean) => void) | — | |
| open | boolean | — | Controlled visibility. Mount the sheet to show it, or drive it with `open`. |
| placement | Placement | bottom-end | Menu placement relative to the anchor. |
| restoreFocus | RestoreFocus | the anchor | Where focus goes on close. |
| title | ReactNode | — |
ActionSheetItem
One action row of an `ActionSheet`.
| Prop | Type | Default | Description |
|---|---|---|---|
| after | ReactNode | — | Content at the end. |
| autoCloseDisabled | boolean | false | Keep the sheet open after activation. |
| before | ReactNode | — | Icon before the label. |
| checked | boolean | false | Checked state of a selectable item. |
| className | string | — | |
| disabled | boolean | — | |
| href | string | — | |
| meta | ReactNode | — | Muted text at the end, before `after`. |
| mode | "default" | "destructive" | default | |
| multiline | boolean | false | Let the label wrap instead of truncating. |
| onClick | ((event: MouseEvent<HTMLElement, MouseEvent>) => void) | — | Runs after the sheet has closed. |
| onImmediateClick | ((event: MouseEvent<HTMLElement, MouseEvent>) => void) | — | Runs right away, before the sheet starts closing. |
| selectable | boolean | false | Behave as one option of a single-choice group (`menuitemradio` in menu mode). |
| subtitle | ReactNode | — | Second line under the label. |
| target | string | — |