Chapter 2 · Practice 2 of 5
Use Pressable for touch targets and give it visible feedback
Why it matters
Pressable is the flexible, current primitive for touch handling. It exposes the pressed state, so you can style feedback yourself, and it supports hitSlop to make small icons easier to hit without changing the layout.
Every pressable element should:
- show a clear pressed state,
- have an accessible label and role (see the accessibility chapter),
- avoid doing heavy work synchronously in
onPress.
Do
- Style the pressed state with the
pressedvalue Pressable passes in - Use
hitSlopon small icon buttons
Avoid
- A
Viewwith anonTouchEndhandler standing in for a button
Example
<Pressable
onPress={onSave}
hitSlop={8}
accessibilityRole="button"
accessibilityLabel="Save note"
style={({ pressed }) => [styles.button, pressed && styles.buttonPressed]}
>
<Text style={styles.buttonText}>Save</Text>
</Pressable>