<!-- index: /slotted/llms.txt -->
# action-sheet

`data-ui="action-sheet"` · Bottom sheet of short actions for touch.

## Import

```tsx
import { ActionSheet, ActionSheetCancel, ActionSheetContent, ActionSheetDefaultsProvider, ActionSheetGroup, ActionSheetHeader, ActionSheetItem, ActionSheetList, ActionSheetMessage, ActionSheetSeparator, ActionSheetTitle, ActionSheetTrigger } from '@slotted/react';
```

## Minimal example

Example

```tsx
import {
  ActionSheet,
  ActionSheetCancel,
  ActionSheetContent,
  ActionSheetHeader,
  ActionSheetItem,
  ActionSheetList,
  ActionSheetMessage,
  ActionSheetTitle,
  ActionSheetTrigger,
} from '@slotted/react/action-sheet';
import { Button } from '@slotted/react/button';
import { Glyph } from '@slotted/react/icon';

export default function ActionSheetBasic() {
  return (
    <ActionSheet>
      <ActionSheetTrigger
        render={(props) => (
          <Button {...props} variant="outline">
            Order actions
          </Button>
        )}
      />
      <ActionSheetContent>
        <ActionSheetHeader>
          <ActionSheetTitle>Order SO-20418</ActionSheetTitle>
          <ActionSheetMessage>Harbor Freight Supply, 12 lines, $4,820.00.</ActionSheetMessage>
        </ActionSheetHeader>
        <ActionSheetList>
          <ActionSheetItem icon={<Glyph name="copy" />} value="copy">
            Copy order link
          </ActionSheetItem>
          <ActionSheetItem icon={<Glyph name="download" />} value="invoice">
            Download invoice
          </ActionSheetItem>
          <ActionSheetItem icon={<Glyph name="pencil" />} value="edit">
            Edit order
          </ActionSheetItem>
        </ActionSheetList>
        <ActionSheetCancel />
      </ActionSheetContent>
    </ActionSheet>
  );
}
```

## Anatomy

| Part | Element | Required |
| --- | --- | --- |
| `root` | div, inside drawer’s panel | yes |
| `trigger` | button, or the element render returns | no |
| `header` | header | no |
| `title` | h2, or the element render returns | no |
| `message` | p, or the element render returns | no |
| `list` | div with role="menu" | yes |
| `group` | div with role="group" | no |
| `group-label` | div | no |
| `item` | button with role="menuitem", or the element render returns | yes |
| `icon` | span[aria-hidden] | no |
| `label` | span | yes |
| `description` | span | no |
| `separator` | hr with role="separator" | no |
| `footer` | div, rendered by ActionSheetCancel | no |
| `cancel` | button, or the element render returns | no |

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `open` | `boolean` | — | ActionSheet | Present at all means the consumer owns the state, for the life of the component. ActionSheet then asks and waits. |
| `defaultOpen` | `boolean` | — | ActionSheet | The value an uncontrolled sheet starts from, read once. |
| `modal` | `boolean` | true | ActionSheet, ActionSheetDefaultsProvider | Whether the page is inert, the scroll locked, focus contained and the scrim painted. false keeps the page operable and paints no scrim. |
| `mount` | `'active' \| 'lazy' \| 'eager'` | active | ActionSheet, ActionSheetDefaultsProvider | When the layer exists. active drops it once the exit is over, lazy builds it on the first open and keeps it, eager builds it up front and makes it inert. |
| `escape` | `'close' \| 'none'` | close | ActionSheet, ActionSheetDefaultsProvider | Whether Escape asks to close. It reaches the topmost layer only. |
| `outsidePress` | `'close' \| 'none'` | close | ActionSheet, ActionSheetDefaultsProvider | Whether a press outside the panel — on the scrim, or on the page behind a non-modal sheet — asks to close. |
| `back` | `'close' \| 'none'` | close | ActionSheet, ActionSheetDefaultsProvider | The platform’s way back — a phone’s gesture, a browser’s button — closes the sheet instead of leaving the page, while it is modal. |
| `closeOnSelect` | `boolean` | true | ActionSheet, ActionSheetDefaultsProvider | Whether choosing an action closes the sheet with the reason select. |
| `messages` | `Partial<ActionSheetMessages>` | — | ActionSheet | Words laid over the language in force, key by key: the cancel’s words when it is given no children (cancel) |
| `initialFocus` | `RefObject<HTMLElement> \| false` | — | ActionSheet | Where focus goes on opening. Unstated, the first action that can run, or the least destructive one when that action is danger. false moves nothing. |
| `finalFocus` | `RefObject<HTMLElement> \| false` | — | ActionSheet | Where focus goes on closing. Unstated, the element that held it on opening. |
| `value` | `string` | — | ActionSheetItem | What the close request carries as result when this action is chosen. |
| `textValue` | `string` | — | ActionSheetItem | What typeahead matches when the label is not plain text. |
| `icon` | `ReactNode` | — | ActionSheetItem | The action’s visual, drawn in the mark column. |
| `description` | `ReactNode` | — | ActionSheetItem | The second line, which aria-describedby points at. |
| `tone` | `'accent' \| 'secondary' \| 'success' \| 'warning' \| 'danger'` | — | ActionSheetItem | Paints the words, the mark and the highlight. danger is the destructive action. |
| `disabled` | `boolean` | false | ActionSheetItem | The action cannot run. It stays focusable and takes aria-disabled. |
| `loading` | `boolean` | false | ActionSheetItem | The action is running: the ring takes the mark’s box, aria-busy is written, a second press is refused and the sheet stays open. |
| `closeOnSelect` | `boolean` | — | ActionSheetItem | Overrides the sheet’s closeOnSelect for this action. |
| `label` | `ReactNode` | — | ActionSheetGroup | Rendered as the group-label part, and the group’s accessible name. |
| `render` | `(props) => ReactNode` | — | ActionSheetTrigger, ActionSheetContent, ActionSheetTitle, ActionSheetMessage, ActionSheetItem, ActionSheetCancel | Substitutes the element. An item that navigates renders an anchor and keeps its role and keyboard; the trigger becomes the application’s own Button. The list, the groups and the separator are fixed, because their role is what they are. |
| `ref` | `Ref<ActionSheetHandle> on ActionSheet, Ref<HTMLElement> on every part` | — | ActionSheet, every part | On a part it reaches the element. On ActionSheet it is a handle with open(), close() and focus() — the actions a consumer cannot express declaratively. |
| `container` | `Element \| null` | — | ActionSheet | A parent for this layer alone instead of the shared portal root, passed to drawer. |
| `useActionSheet()` | `() => ActionSheetContextValue` | — | inside ActionSheet | What the parts read: the open state, the identifiers, the axes and close(reason, result). It throws outside a sheet. |
| `ActionSheetDefaultsProvider` | `{ modal, mount, escape, outsidePress, back, closeOnSelect }` | — | a subtree | The decisions an application takes once. A sheet that states any of them itself still wins. |

## Events

| Name | Payload | When |
| --- | --- | --- |
| `onOpenChange` | `(open: boolean, request: ActionSheetChangeRequest)` | Before the sheet moves, for every way it can: reason is pointer or keyboard from the trigger, pointer from a drag of the sheet that asks to close, select from an item, dismiss from the cancel, escape, outsidePress, back, or programmatic from the handle. result carries the chosen item’s value when the reason is select, and cancel() refuses the move before anything commits. |
| `onSelect` | `(event: ActionSheetSelectEvent)` | On ActionSheetItem, when an item that can run is activated, before the sheet asks to close. The event carries reason, value and the originating event; preventDefault() keeps the sheet open. |
| `onClick, onKeyDown, onPointerMove, on every part` | `the element’s own events` | Whenever the element fires them. The consumer’s handler runs first, and preventDefault() refuses the action sheet’s own behavior. |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `modal` | `true`, `false` | `true` |
| `mount` | `active`, `lazy`, `eager` | `active` |
| `escape` | `close`, `none` | `close` |
| `outsidePress` | `close`, `none` | `close` |
| `back` | `close`, `none` | `close` |
| `closeOnSelect` | `true`, `false` | `true` |

## Rules

- No WAI-ARIA APG pattern describes an action sheet, so the layer answers Dialog (Modal) — w3.org/WAI/ARIA/apg/patterns/dialog-modal/ — and the list answers Menu — w3.org/WAI/ARIA/apg/patterns/menubar/. The panel is role="dialog", aria-modal while modal, named by the title and described by the message; the list is role="menu", named by the same title, and every action is a native button with role="menuitem".
- The list is one tab stop. ArrowDown and ArrowUp move between actions and wrap, Home and End reach the ends, and a printable character moves to the next action whose label, or textValue, begins with it. Tab moves between the list and the cancel and does not close — the one departure from the menu pattern, because the menu is the content of a dialog and the dialog contains focus. A reader leaves with Escape or the cancel.
- A screen reader hears the title twice on entry, once for the dialog and once for the menu. Without a name the menu would be anonymous to a reader moving by widget, and the repetition is the cheaper cost.
- Focus enters on the first action that can run. When that action is destructive it enters on the cancel, which is the least destructive action the dialog pattern’s first note recommends; with no cancel, on the first action that is not danger. It returns to the element that held it on close, except after a press outside a non-modal sheet, where the reader was going somewhere else.
- A disabled or loading action keeps its place in the ring and takes aria-disabled, as the menu pattern requires; a loading one also carries aria-busy. The cancel is never disabled, because a sheet that cannot be left is a trap. Every action is a control’s height tall, which the theme raises to the 44-pixel comfortable target under a coarse pointer; on a phone the label grows from 14 to 16 pixels with it.
- The layer is drawer’s, so the sheet answers everything a drawer from the bottom answers: a touch on its body drags it and a release toward the edge asks to close with the reason pointer, which cancel() refuses like any other close; with the virtual keyboard open the sheet lands above the keys. Nothing of that needs a key: Escape and the cancel are the keyboard’s way out.
- A mouse or a pen moving over an action focuses it, so one row is lit whichever device drives; a finger does not, because focus moving under a touch that is about to scroll would light rows at random.

## Tokens

`--slotted-action-sheet-footer-surface`, `--slotted-action-sheet-highlight`, `--slotted-action-sheet-highlight-active`, `--slotted-action-sheet-inline-size`, `--slotted-action-sheet-rule-color`, `--slotted-border-subtle`, `--slotted-border-width-thin`, `--slotted-control-border-color`, `--slotted-control-border-width`, `--slotted-control-font-family`, `--slotted-control-gap-lg`, `--slotted-control-height-lg`, `--slotted-control-padding-inline-lg`, `--slotted-control-radius`, `--slotted-control-shadow`, `--slotted-control-surface`, `--slotted-control-transition-duration`, `--slotted-control-transition-easing`, `--slotted-disabled-background`, `--slotted-disabled-foreground`, `--slotted-duration-short`, `--slotted-easing-standard`, `--slotted-focus-ring-color`, `--slotted-focus-ring-offset`, `--slotted-focus-ring-width`, `--slotted-font-family-heading`, `--slotted-font-family-sans`, `--slotted-font-size-lg`, `--slotted-font-size-md`, `--slotted-font-size-sm`, `--slotted-font-weight-semibold`, `--slotted-line-height-md`, `--slotted-line-height-sm`, `--slotted-space-1`, `--slotted-space-2`, `--slotted-space-4`, `--slotted-space-5`, `--slotted-space-6`, `--slotted-surface-sunken`, `--slotted-text`, `--slotted-text-muted`, `--slotted-tone-accent-subtle-active`, `--slotted-tone-accent-surface`, `--slotted-tone-accent-text`, `--slotted-tone-danger-subtle-active`, `--slotted-tone-danger-surface`, `--slotted-tone-danger-text`, `--slotted-tone-secondary-subtle-active`, `--slotted-tone-secondary-subtle-hover`, `--slotted-tone-secondary-surface`, `--slotted-tone-secondary-text`, `--slotted-tone-success-subtle-active`, `--slotted-tone-success-surface`, `--slotted-tone-success-text`, `--slotted-tone-warning-subtle-active`, `--slotted-tone-warning-surface`, `--slotted-tone-warning-text`

## Examples

See [action-sheet.examples.md](./action-sheet.examples.md).
