Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is HitRect used with Pressable in React Native?

We're planning on switching from TouchableOpacity to Pressable.

We want to use Pressable's optional HitRec to ensure our hit targets are appropriately sized (we'll calculate the dimensions) for accessibility purposes.

The Pressable documentation has no information about using HitRect. I've found references to HitRect elsewhere, but they also have no useful information.

Can anyone describe how one should implement HitRect with Pressable?

like image 258
David Nedrow Avatar asked Oct 15 '25 08:10

David Nedrow


1 Answers

You can set HitRect with hitSlop as the example given below

<Pressable
       onPress={() => navigation.toggleDrawer()}
       hitSlop = {50} // to increase the clickable area
       >
                    Menu
</Pressable>
like image 107
Raj Prajapati Avatar answered Oct 19 '25 06:10

Raj Prajapati