I want to implement floating labels, for this I have a Text
Component Above a TextInput
. I want to ignore all the touch events on the Text
so that the TextInput
under it gets all the events. Is there a way I can do this ? In CSS we used to have pointer-events: none
, I am not sure how to do this in React Native.

- 29,373
- 11
- 46
- 65

- 2,787
- 3
- 13
- 6
-
It would be helpful to show us what you have so far. – Rian Schmits May 04 '15 at 22:39
-
I am trying to build something like http://codepen.io/soulrider911/pen/ugnyl – Mayank Patel May 05 '15 at 15:03
-
1If anyone is looking for the solution in **normal React** (*not React Native*), you can simply set the css to `pointer-events: none` for the element that you want the clicks to pass through. – protoEvangelion Jun 06 '17 at 06:36
-
If you are using @react-navigation/drawer and getting this error, The below link might help you. https://stackoverflow.com/a/76329208/20972519 – Nidhul May 25 '23 at 07:17
7 Answers
In react-native, pointerEvents is a prop, not a style.
<View pointerEvents="none" />

- 29,373
- 11
- 46
- 65

- 35,242
- 14
- 75
- 119
-
2
-
18In some cases, you may want the subviews to still be the target of touches so pointerEvents={'box-none'} would be the appropriate solution: https://facebook.github.io/react-native/docs/view.html#pointerevents – RaphArbuz Mar 05 '18 at 18:20
-
1Also since OP asked about `Text` specifically, it's important to note that the `Text` component does not have a `pointerEvents` prop at all. SO, you will need to wrap the Text in a View and set the view's `pointerEvents` prop to be none. – ICW Apr 04 '22 at 19:50
Add pointerEvents: 'none'
to the Text
component. This allows touch events to go to the ancestors of the component, but not the component itself or its children.
React Native also supports 'box-none'
, which allows touch events to go to the ancestors and children of the component, and excludes only the component itself.

- 19,942
- 5
- 64
- 106
-
15For some reason I couldn't get it to work on a `Text` component, but wrapping the `Text` in a `View` and putting the `pointerEvents="none"` prop there solved it. – Cryszon Feb 05 '16 at 13:43
I had the same problem as Cryszon. On Android is seems like pointerEvents="none" doesn't work for Text components.
Wrapping the Text in a View and putting the pointerEvents="none" prop there solved it.

- 4,958
- 1
- 24
- 15
pointerEvents
work only on View
not on Text
or TouchableOpacity
.

- 15,447
- 5
- 79
- 98

- 772
- 1
- 16
- 38
If you have an issue where even 'box-none'
doesn't allow touch events to go to the children, you could do something like this
let setPointerEvents = 'none';
...
<View pointerEvents={setPointerEvents}>
...
<TouchableOpacity onPress= {()=>this.set(false)}/>
</View>
<TouchableOpacity onPress= {()=>this.set(true)}/>
...
set(bool){
switch(bool){
case true:
setPointerEvents= 'auto'
break;
case false:
setPointerEvents= 'none'
break;
}
}
Kind of a hack, but it works.

- 304
- 1
- 13
When you want to override a react <TextInput>
object with a custom modal for input for example, you can do this:
<TouchableOpacity
onPress={() => this.openSourceOptions()}
>
<TextInput
label={"InputBox"}
editable={false}
pointerEvents="none"
value={somevalue}
mode="outlined"
/>
</TouchableOpacity>

- 13
- 3
PointerEvents didn't work on my View for some reason. I wrapped the View with a Pressable without giving onPress function. This worked for me.

- 141
- 1
- 15