Usage
Props
number
default:"0.2"
Determines what the opacity of the wrapped view should be when touch is active. A value between 0 and 1.
(event: GestureResponderEvent) => void
Called when the touch is released, but not if cancelled (e.g., by a scroll that steals the responder lock).
(event: GestureResponderEvent) => void
Called when a touch is engaged, immediately when the finger touches down.
(event: GestureResponderEvent) => void
Called when the touch is released or cancelled (finger lifted or moved away).
(event: GestureResponderEvent) => void
Called when the user holds down the press for more than
delayLongPress milliseconds.boolean
default:"false"
If true, disables all interactions for this component.
number
default:"0"
Delay in milliseconds from the start of the touch before
onPressIn is called.number
default:"0"
Delay in milliseconds from the release of the touch before
onPressOut is called.number
default:"500"
Delay in milliseconds from
onPressIn before onLongPress is called.Insets
Extends the touchable area without changing the visual layout. Useful for making small buttons easier to tap.
Insets
Defines how far the touch can move off the button before deactivating it.
ViewStyleProp
Style applied to the Animated.View wrapper.
string
Used to locate this view in end-to-end tests.
How It Works
TouchableOpacity uses anAnimated.View to smoothly animate the opacity:
- On press: Animates to
activeOpacity(default 0.2) with a 150ms duration - On release: Animates back to original opacity with a 250ms duration
- Uses native driver for better performance
Unlike TouchableHighlight, TouchableOpacity doesn’t require your child to have an explicit background color.
Common Patterns
Button Component
Icon Button
Card Component
List Item
With Loading State
Custom Press Feedback
Platform Considerations
Android Ripple Effect
For Android’s native ripple effect, useTouchableNativeFeedback or Pressable with android_ripple:
Comparison with Other Touchables
- TouchableOpacity: Fades opacity (most commonly used)
- TouchableHighlight: Shows underlay color
- TouchableWithoutFeedback: No visual feedback
- Pressable: Modern alternative with more features
For new projects, consider using Pressable which provides more flexibility and follows modern React patterns.