Skip to main content

Pressable -clickable component

Based on React Native Pressable package.

Note: Pressable is a new feature introduced by react-native in version 0.63, which also means that if your project is lower than version 0.63, the Pressable component cannot be used

Effect demonstration

1. Default effect

<Pressable onPress={handlePress} onLongPress={handleLongPress}>
<Box width={90} height={90} backgroundColor="gray300" />
</Pressable>
default effect ios

API

PropertiesRequiredDescriptionTypeDefault Value
onPressfalseClick event(event: GestureResponderEvent) => void
onPressInfalseBefore the click event is executed(event: GestureResponderEvent) => void
onPressOutfalseAfter the click event is executed(event: GestureResponderEvent) => void
onLongPressfalseLong press event(event: GestureResponderEvent) => void
disabledfalseWhether to disableboolean
delayLongPressfalseDelay time from click state to long press statenumber1000
activeOpacityfalseOpacity on clicknumber0.5
pressOffsetfalseThe distance the finger moves out of the component but holds the clicked statenumber20
hitOffsetfalseThe distance from the component to trigger onPressInnumber20
stylefalseCustom styleViewStyle