suiss/uim · Pattern

Context Actions

Long press an element to open a bottom alert sheet with actions for it.

Context Actions is an open-source mobile pattern from suiss/uim: components composed into a flow for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Context Actions on iOS in light mode

ContextActions turns any content into a long-press target. Holding ContextActionsTrigger for 500 ms opens an AlertSheet with the actions grouped in one block and a separate Cancel button below.

Use it for secondary actions on photos, messages or list rows that should not take up space on screen.

Installation

$ pnpm dlx @esuiss/uim@latest add context-actions

The CLI also adds what it builds on: Alert Sheet.

Manual

  1. Add the pieces it builds on: Alert Sheet.

  2. Copy the source into components/patterns/context-actions.tsx:

uniwind/components/patterns/context-actions.tsx
import * as React from "react"
import { Pressable } from "react-native"
import {
  AlertSheet,
  AlertSheetAction,
  AlertSheetCancel,
  AlertSheetContent,
  AlertSheetGroup,
  AlertSheetHeader,
  AlertSheetTitle,
} from "@/components/ui/alert-sheet"

const LONG_PRESS_DELAY = 500

type ContextActionsContextProps = {
  setOpen: (open: boolean) => void
  1. Update the import paths to match your project.

Usage

import { ContextActions, ContextActionsTrigger, ContextActionsContent, ContextActionsLabel, ContextActionsItem, ContextActionsSeparator } from "@/components/patterns/context-actions"
<ContextActions>
  <ContextActionsTrigger
    accessibilityLabel="Photo"
    className="h-40 items-center justify-center gap-2 rounded-2xl bg-surface-secondary active:opacity-80"
  >
    <Icon as={ImageIcon} className="size-8 text-label-secondary" />
    <Text className="text-sm text-label-secondary">Long press</Text>
  </ContextActionsTrigger>
  <ContextActionsContent>
    <ContextActionsLabel>Photo</ContextActionsLabel>
    <ContextActionsItem>Copy</ContextActionsItem>
    <ContextActionsItem>Share</ContextActionsItem>
    <ContextActionsItem variant="destructive">Delete</ContextActionsItem>
  </ContextActionsContent>
</ContextActions>

Wrap the target in ContextActionsTrigger and list ContextActionsItems in ContextActionsContent. Add a ContextActionsLabel first to show a title.

The open state is managed internally; use onOpenChange to react to it. ContextActionsTrigger accepts every Pressable prop, so onPress still works for a normal tap, and your own onLongPress runs before the sheet opens. Change the hold time with delayLongPress.

Examples

Inline

A small message bubble as the trigger, with a custom cancelLabel.

iOS
Context Actions (inline) on iOS in light mode

API Reference

ContextActions

The root that owns the open state.

PropType
About
Called when the sheet opens or closes.
Type
(open: boolean) => void
Default
—
About
When false, the sheet ignores outside presses. Defaults to true.
Type
boolean
Default
true
Type
React.ReactNode
Default
—

ContextActionsTrigger

A Pressable that opens the sheet on long press.

ExtendsReact.ComponentProps<typeof Pressable>

ContextActionsContent

The sheet with the grouped items and a Cancel button.

ExtendsReact.ComponentProps<typeof AlertSheetContent>
PropType
About
Text of the Cancel button. Defaults to Cancel.
Type
string
Default
"Cancel"

ContextActionsLabel

A title shown at the top of the group.

ExtendsReact.ComponentProps<typeof AlertSheetTitle>

ContextActionsItem

An actionable entry, rendered as an AlertSheetAction.

ExtendsReact.ComponentProps<typeof AlertSheetAction>

ContextActionsSeparator

Kept for API parity; renders nothing.

PropType
Type
string
Default
—

Accessibility

  • The trigger has the hint "Long press for actions".
  • It adds longpress and showActions ("Show actions") accessibility actions, so screen reader users can open the sheet without holding.
  • Your own accessibilityActions and onAccessibilityAction are kept.

Notes

  • Item text uses text-link, or text-danger for the destructive variant.
  • On iOS the sheet renders in a full-window overlay so it appears above native screens.