Pressable is a Core Component wrapper that can detect various stages of press interactions on any of its defined children.
On an element wrapped by
onPressInis called when a press is activated.
onPressOutis called when the press gesture is deactivated.
onPressIn, one of two things will happen:
- The person will remove their finger, triggering
- If the person leaves their finger longer than 500 milliseconds before removing it,
onLongPressis triggered. (
onPressOutwill still fire when they remove their finger.)
Fingers are not the most precise instruments, and it is common for users to accidentally activate the wrong element or miss the activation area. To help,
Pressable has an optional
HitRect you can use to define how far a touch can register away from the wrapped element. Presses can start anywhere within a
PressRect allows presses to move beyond the element and its
HitRect while maintaining activation and being eligible for a "press"—think of sliding your finger slowly away from a button you're pressing down on.
The touch area never extends past the parent view bounds and the Z-index of sibling views always takes precedence if a touch hits two overlapping views.
Pressableuses React Native's
PressabilityAPI. For more information around the state machine flow of Pressability and how it works, check out the implementation for Pressability.
If true, doesn't play Android system sound on press.
Enables the Android ripple effect and configures its properties.
Either children or a function that receives a boolean reflecting whether the component is currently pressed.
Duration (in milliseconds) to wait after press down before calling
Duration (in milliseconds) from
onLongPress is called.
Whether the press behavior is disabled.
Sets additional distance outside of element in which a press can be detected.
|Rect or number||No|
Called if the time after
onPressIn lasts longer than 500 milliseconds. This time period can be customized with
Called immediately when a touch is engaged, before
Called when a touch is released.
Additional distance outside of this view in which a touch is considered a press before
onPressOut is triggered.
|Rect or number||No|
Either view styles or a function that receives a boolean reflecting whether the component is currently pressed and returns view styles.
Used only for documentation or testing (e.g. snapshot testing).
Ripple effect configuration for the
|color||color||No||Defines the color of the ripple effect.|
|borderless||boolean||No||Defines if ripple effect should not include border.|
|radius||number||No||Defines the radius of the ripple effect.|