TouchableHighlight is a wrapper component that responds to touches by decreasing the opacity of the wrapped view and showing an underlay color, providing visual feedback that the element is being pressed.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/react-native/llms.txt
Use this file to discover all available pages before exploring further.
Usage
Props
Determines what the opacity of the wrapped view should be when touch is active.
The color of the underlay that shows through when the touch is active. This creates the “highlight” effect.
Called when the touch is released, but not if cancelled (e.g., by a scroll).
Called when a touch is engaged, before
onPress.Called when the touch is released or cancelled.
Called when the user holds down the press for more than
delayLongPress milliseconds.Called immediately after the underlay is shown.
Called immediately after the underlay is hidden.
If true, disables all interactions for this component.
Delay in milliseconds from the start of the touch before
onPressIn is called.Delay in milliseconds from the release of the touch before
onPressOut is called.Delay in milliseconds from
onPressIn before onLongPress is called.Defines how far the touch can start away from the button. Extends the touchable area without changing visual layout.
Defines how far the touch can move off the button before deactivating it.
Style applied to the wrapper View.
How It Works
When pressed, TouchableHighlight:- Wraps your child in a View
- Reduces the child’s opacity to
activeOpacity - Shows the
underlayColorthrough the transparent child - Restores opacity when released
Make sure your child component has an explicit
backgroundColor set, otherwise the underlay effect may not be visible.Common Patterns
Button Component
List Item
With Image
Tracking Press State
Comparison with Other Touchables
- TouchableHighlight: Shows underlay color when pressed. Best for opaque backgrounds.
- TouchableOpacity: Fades opacity when pressed. Simpler and more commonly used.
- TouchableWithoutFeedback: No visual feedback. Should be avoided unless necessary.
- Pressable: Modern replacement with more flexibility and better performance.
For new projects, consider using Pressable instead, which offers more customization and better performance.