Pressable
Shared press feedback with role-based scaling, interruption, haptics and reduced-motion support.
npx @swipeui/cli add pressableVariant
Preset
Material
Scheme
Feel
When to use it
- Making any custom shape tappable, such as an image tile, a list cell or a custom chip, with SwipeUI's press feel.
- Building your own buttons or controls that should match every other SwipeUI component.
- Replacing React Native's Pressable when you want press scaling, haptics and Reduce Motion handled for you.
- Prototyping interactions that respond to the app-wide motion feel.
When not to use it
- Standard buttons with text. Button already has variants, sizes and loading.
- Icon-only actions. Icon button adds the required label and sizing.
- Toggles and selections. Use Switch, Checkbox or Segmented control so the role is right.
- Swipes or drags. Use Gesture Handler gestures; Pressable is only for taps.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add pressable- Adds
components/swipeui/ui/pressable.tsxand 4 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, expo-haptics, clsx, tailwind-merge. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Pressable } from '@/components/swipeui/ui/pressable';
<Pressable accessibilityLabel="Open" onPress={open}>
<Text>Open</Text>
</Pressable>;API reference
| Prop | Type | Default | Description |
|---|---|---|---|
layout? | | — | Optional layout transition for composed controls; derive its values from useMotion. |
motion? | | | The app's press character, or a local override. |
haptics? | | | Impact feedback on activation. Disable when a parent already provides feedback. |
className? | | | Classes merged after the base target and radius roles. |
style? | | | Native style escape hatch; caller transforms take precedence. |
Composition and behavior
- Wraps React Native's Pressable with a press scale, haptics and disabled styling.
- motion sets the feel or overrides the spring and scale.
- haptics turns the impact on or off; the preset's haptic style is used.
- layout accepts a Reanimated layout transition for composed controls.
- Rounded with the control radius token and dims to 50% when disabled.
Behavior and gestures
- When a finger lands, the target shrinks slightly; when it lifts, it springs back, even if the animation hadn't finished.
- Sliding your finger off cancels the press and springs back without firing.
- A completed tap plays one light haptic tap; pass haptics={false} when a parent already gives feedback.
- Disabled targets dim to half opacity and ignore touches.
- Your onPressIn, onPressOut and onPress handlers still run.
Accessibility
- Defaults to the button role and reports its disabled state; set accessibilityRole for links or other roles.
- Every target is at least 44 by 44 points.
- Give it an accessibilityLabel whenever the content isn't text.
- Reduce Motion removes the scale but keeps haptics and taps.
Motion
- Uses the
pressmotion role, so it follows your app's feel. Passmotionto tune this one instance. - Scale depends on the feel: 0.98 smooth, 0.97 snappy, 0.96 springy and 0.94 bouncy, on the press spring.
- The none feel and system Reduce Motion keep it at full size.
- Pass motion to override the feel or the exact scale for one instance.
Performance
- The scale is a Reanimated shared value on the UI thread; pressing never re-renders children.
- Haptics are fire-and-forget and never throw on devices without a haptic engine.
Notes for AI
- Use it as the base for every custom tappable surface.
- Turn off haptics on inner pressables when the parent plays its own.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.