Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 71 ยท Components and Interaction

Pressable, Buttons and Touch Feedback

Learn Pressable, Button and touch feedback in React Native: pressed states, long press, hitSlop, Android ripple and minimum touch targets, with live stand-ins.

On a phone, a tap is the main way people talk to your app. A tap needs three things: an area that reacts, visible feedback that tells the person "I heard you", and a target big enough for a fingertip. React Native gives you Pressable for all three, plus a plain Button for quick prototypes.

If you know web React, think of Pressable as the replacement for a clickable div or button. There is no hover, no mouse and no onClick. There are only touches, and a touch has a life cycle: finger down, finger up (a press), or finger held (a long press).

What runs on this site. Touches come from a real phone screen, so the real Pressable code below is read-only. The runnable examples are stand-ins: they use mouse events to imitate onPressIn, onPressOut and onLongPress, and some arithmetic to check touch-target sizes. The timing and press-retention rules are those of the real component, but the events are not.

Pressable

Pressable wraps any content and reports the touch life cycle. It is the recommended building block for anything tappable.

JSX
import { Pressable, Text } from 'react-native';

export function LikeButton({ onLike }) {
  return (
    <Pressable
      onPress={onLike}
      onLongPress={() => console.log('show reactions')}
      style={({ pressed }) => [
        { padding: 12, borderRadius: 8, backgroundColor: '#2563eb' },
        pressed && { opacity: 0.7 },
      ]}
    >
      <Text style={{ color: 'white' }}>Like</Text>
    </Pressable>
  );
}

The key callbacks are:

  • onPressIn: the finger touched the element.
  • onPressOut: the finger lifted or moved away, whether or not it counted as a press.
  • onPress: a complete tap (down and up on the element).
  • onLongPress: the finger stayed down for delayLongPress milliseconds (500 by default). After a long press fires, onPress does not.

Pressed styles

The two most useful features are function props. Both style and children can be a function that receives { pressed }. This is how you change the look while the finger is down, without keeping any state yourself.

JSX
<Pressable style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}>
  {({ pressed }) => <Text>{pressed ? 'Pressing...' : 'Press me'}</Text>}
</Pressable>

Feedback matters more than it looks. A button that does not react feels broken, and the person taps again, which can submit twice. A common feedback is a small opacity or color change. On Android you can use the platform's native ripple:

JSX
<Pressable android_ripple={{ color: '#ffffff55', borderless: false }}>
  <Text>Ripple on Android</Text>
</Pressable>

android_ripple does nothing on iOS, so combine it with the pressed style if you want both platforms to show feedback.

A touch has a life cycle

onPressIn The finger lands.
onLongPress Held for 500 ms by default.
onPressOut The finger lifts or leaves.
onPress A completed tap.
1 / 2
Press life cycle simulator (stand-in)

hitSlop and touch targets

A fingertip is much bigger than a mouse pointer. Platform guidelines set a minimum size for anything tappable: about 44 by 44 points on iOS and 48 by 48 dp on Android. A small icon, such as a close "x" of 20 points, is too small to hit reliably.

You do not have to draw a bigger icon. hitSlop extends the touchable area beyond the visible bounds:

JSX
<Pressable
  onPress={close}
  hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
  accessibilityRole="button"
  accessibilityLabel="Close"
>
  <CloseIcon size={20} />
</Pressable>

Here a 20-point icon gets a 44-point target. hitSlop also accepts a single number for all sides. Be careful in dense layouts: the extended areas of neighboring controls can overlap, and the one later in the tree wins. When controls sit close together, prefer real padding.

Related is pressRetentionOffset: once a touch starts on a pressable, the finger can drift a short distance outside it before the press is cancelled. This is why a tap that wanders slightly still counts.

Is this touch target big enough?

The Button component

Button is the built-in quick option. It takes only a few props and renders in each platform's own style: a plain blue text button on iOS, a filled rectangle on Android.

JSX
import { Button } from 'react-native';

<Button title="Save" onPress={save} color="#2563eb" disabled={!canSave} />

You cannot style it beyond color, so there is no padding, border radius or icon. That is fine for prototypes and settings screens. For anything branded, build your own button on Pressable, and put it in a shared component so you write it once.

Touchable components, the older way

You will meet TouchableOpacity, TouchableHighlight and TouchableWithoutFeedback in older code. They still work, and each bakes in a feedback style: TouchableOpacity dims the child (activeOpacity, default 0.2), TouchableHighlight shows an underlay color. New code should use Pressable, which is more flexible and is where the React Native team puts new features. When a library asks for gesture-heavy touchables, react-native-gesture-handler provides its own, covered in Reanimated and Gesture Handler.

Accessible buttons

A touchable that is not marked up is invisible to screen readers. Give tappable elements an accessibilityRole="button" and a short accessibilityLabel when the content is not text (for instance an icon). The disabled prop already tells assistive technology that the control is off. The full story is in Accessibility in React Native.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How do you change a Pressable's style only while the finger is down?

    style (and children) can be functions that receive { pressed }. There is no hover or CSS pseudo-class in React Native, and onClick does not exist.
  2. 2. A close icon is 20 points wide and you want a 44-point touch target. What is the best fix?

    hitSlop extends the touchable area beyond the visible bounds. 20 + 12 + 12 = 44, so the icon looks the same but is much easier to hit.
  3. 3. After onLongPress fires, what happens when the user lifts their finger?

    A long press consumes the touch. onPressOut still fires when the finger lifts, but the quick-tap onPress does not.
  4. 4. Why build your own button on Pressable instead of using Button for a branded app?

    Button renders platform-native styling and only exposes props such as title and color. Pressable lets you control padding, shape, icons and pressed feedback.

Summary

  • Pressable reports the touch life cycle: onPressIn, onPressOut, onPress and onLongPress (500 ms by default).
  • style and children can be functions of { pressed }, which makes pressed feedback easy; android_ripple adds the native Android wave.
  • Aim for touch targets of about 44 points (iOS) and 48 dp (Android); hitSlop enlarges the touchable area without changing how the control looks.
  • Button is quick but barely stylable; build branded buttons on Pressable; older Touchable* components still work but are legacy.
  • Mark tappable elements with an accessibility role and label.
  • On this site the real code is read-only and the TryIts simulate touches with mouse events.

Next, show pictures and icons in Images, Icons and Media.