datui
Color scheme

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" with menuitem / 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.

PropTypeDefaultDescription
anchorRefRefObject<HTMLElement | null>—The element the menu is anchored to on regular width (usually the button that opened it).
cancelLabelstringCancelLabel of the cancel row in sheet mode.
childrenReactNode—`ActionSheetItem` elements.
classNamestring—
defaultOpenbooleantrue
descriptionReactNode—
mode"menu" | "sheet"—Force a layout. Default: `sheet` on compact width, `menu` on regular width.
offsetnumber4Menu 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)—
openboolean—Controlled visibility. Mount the sheet to show it, or drive it with `open`.
placementPlacementbottom-endMenu placement relative to the anchor.
restoreFocusRestoreFocusthe anchorWhere focus goes on close.
titleReactNode—

ActionSheetItem

One action row of an `ActionSheet`.

PropTypeDefaultDescription
afterReactNode—Content at the end.
autoCloseDisabledbooleanfalseKeep the sheet open after activation.
beforeReactNode—Icon before the label.
checkedbooleanfalseChecked state of a selectable item.
classNamestring—
disabledboolean—
hrefstring—
metaReactNode—Muted text at the end, before `after`.
mode"default" | "destructive"default
multilinebooleanfalseLet 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.
selectablebooleanfalseBehave as one option of a single-choice group (`menuitemradio` in menu mode).
subtitleReactNode—Second line under the label.
targetstring—