Skip to main content

<SwipeRow /> API

Row that is generally used in a <SwipeListView/>. If you are rendering a <SwipeRow/> explicitly you must pass the <SwipeRow/> exactly two children. The first will be rendered behind the second. e.g.

<SwipeRow>
<View style={hiddenRowStyle} />
<View style={visibleRowStyle} />
</SwipeRow>

Props

PropNotesType(func) SignatureDefault
closeOnRowPressShould the row be closed when it is tappedbooltrue
directionalDistanceChangeThresholdChange the sensitivity of the rownumber2
frictionFriction for the open / close animation. Controls "bounciness"/overshoot. Same scale as v3 — mapped to the Reanimated spring through React Native's Origami conversion, so the feel is unchanged.number7
tensionTension for the open / close animation. Controls speed. Same scale as v3 (see friction).number40
restSpeedThresholdRest speed threshold for the open / close spring.number0.001
restDisplacementThresholdRest displacement threshold for the open / close spring.number0.001
leftOpenValueTranslateX value for opening the row to the left (positive number)number0
rightOpenValueTranslateX value for opening the row to the right (negative number)number0
leftActivationValueTranslateX value for firing onLeftActionStatusChange (positive number)number
rightActivationValueTranslateX value for firing onRightActionStatusChange (negative number)number
initialLeftActionStateInitial value for left action state (default is false)bool
initialRightActionStateInitial value for right action state (default is false)bool
leftActionValueTranslateX value for left action to which the row will be shifted after gesture releasenumber
rightActionValueTranslateX value for right action to which the row will be shifted after gesture releasenumber
stopLeftSwipeTranslateX value for stop the row to the left (positive number). This number is the stop value corresponding to the leftOpenValue (while the row is swiping in the right direction)number
stopRightSwipeTranslateX value for stop the row to the right (negative number). This number is the stop value corresponding to the rightOpenValue (while the row is swiping in the left direction)number
onRowPressCalled when row is pressed.func{ } : void
onRowOpenCalled when row is animating open. Used by the SwipeListView to keep references to open rows.func{ toValue: number } : void
onRowDidOpenCalled when row has animated openfunc{ toValue: number } : void
onRowCloseCalled when row is animating closedfunc{ } : void
onRowDidCloseCalled when a swipe row has animated closedfunc{ } : void
onLeftActionStatusChangeCalled once when swipe value crosses the leftActivationValuefunc{ data: { isActivated: boolean, value: number, key: string } } : void
onRightActionStatusChangeCalled once when swipe value crosses the rightActivationValuefunc{ data: { isActivated: boolean, value: number, key: string } } : void
onLeftActionCalled when row shifted to leftActivationValuefunc{ } : void
onRightActionCalled when row shifted to rightActivationValuefunc{ } : void
swipeToOpenPercentWhat % of the left/right openValue does the user need to swipe past to trigger the row opening.number50
swipeToClosePercentWhat % of the left/right openValue does the user need to swipe past to trigger the row closing.number50
setScrollEnabledUsed by the SwipeListView to close rows on scroll events. You shouldn't need to use this prop explicitly.func
disableLeftSwipeDisable ability to swipe the row leftboolfalse
disableRightSwipeDisable ability to swipe the row rightboolfalse
recalculateHiddenLayoutEnable hidden row onLayout calculations to run alwaysboolfalse
styleStyles for the parent wrapper View of the SwipeRowobject
previewShould the row do a slide out preview to show that it is swipeableboolfalse
previewDurationDuration of the slide out preview animationnumber300
previewRepeatShould the animation repeatboolfalse
previewRepeatDelayDelay between each preview repeat in millisecondsnumber1000
previewOpenValueTranslateX value for the slide out preview animationnumber0.5 * props.rightOpenValue
onSwipeValueChangeCallback invoked any time the translateX value of the row changes. Crosses to the JS thread every frame — prefer swipeAnimatedValue (see below).func{ swipeData: { key: string, value: number, direction: 'left' | 'right', isOpen: bool } } : void
swipeGestureBeganCalled when the row is animating swipefunc{ } : void
swipeGestureEndedCalled when user has ended their swipe gesture. v4: event is now an RNGH GestureStateChangeEvent<PanGestureHandlerEventPayload>; the v3 gestureState field is removed (velocity/translation live on event, with velocityX in px/s).func{ rowKey: string; data: { translateX: number; direction: 'left' | 'right'; event: GestureStateChangeEvent } } : void
swipeToOpenVelocityContributionDescribes how much the ending velocity of the gesture affects whether the swipe will result in the item being closed or open. A velocity factor of 0 (the default) means that the velocity will have no bearing on whether the swipe settles on a closed or open position and it'll just take into consideration the swipeToOpenPercent. Ideal values for this prop tend to be between 5 and 15.number0
shouldItemUpdateCallback to determine whether component should updatefunc{ currentItem: any, newItem: any }
forceCloseToLeftThresholdTranslateX amount(not value!) threshold that triggers force-closing the row to the Left End (positive number)number
forceCloseToRightThresholdTranslateX amount(not value!) threshold that triggers force-closing the row to the Right End (positive number)number
onForceCloseToLeftCallback invoked when row is force closing to the Left Endfunc
onForceCloseToRightCallback invoked when row is force closing to the Right Endfunc
onForceCloseToLeftEndCallback invoked when row has finished force closing to the Left Endfunc
onForceCloseToRightEndCallback invoked when row has finished force closing to the Right Endfunc
swipeKeyOptional key to identify a standalone row, used in the onSwipeValueChange callbackstring
onPreviewEndCallback that runs after row swipe preview is finishedfunc{ } : void
accessibleWhether the row is an accessibility element exposing swipe actions to screen readers. Set false to opt out of the built-in accessibility actions.booltrue
accessibilityActionsOverride the default accessibility actions (swipeleft when rightOpenValue is set, swiperight when leftOpenValue is set).array
onAccessibilityActionOverride the default handler that opens/closes the row in response to an accessibility action.func

swipeAnimatedValue (v4)

Each row exposes its translateX as a Reanimated SharedValue<number>. It is the recommended replacement for onSwipeValueChange — read it inside useAnimatedStyle and your UI updates on the UI thread with no per-frame JS call.

It is available two ways:

  • Injected into both children. Type your child props with SwipeRowChildInjectedProps and read props.swipeAnimatedValue?.value inside a worklet.
  • On the row ref / rowMap entry as swipeAnimatedValue.

See the migration guide for a before/after example.

Removed props

Removed propNotes
useNativeDriverEverything runs on the UI thread under Reanimated. Tolerated with a one-time dev warning, then ignored.

Imperative handle

A ref to a SwipeRow (and each rowMap entry in SwipeListView) is a typed handle, not a class instance:

MemberNotes
closeRow()Animate the row closed.
closeRowWithoutAnimation()Snap the row closed with no animation.
manuallySwipeRow(toValue, onAnimationEnd?)Animate the row to a translateX value.
isOpenWhether the row is currently open.
swipeAnimatedValueThe row's translateX SharedValue (see above).