React Native · Components
Swipeable
A container that reveals actions when the row is swiped sideways (like iOS Mail, Android Gmail).
5 exports
Import
Swipeable
componentA container that reveals actions when the row is swiped sideways (like iOS Mail, Android Gmail). In lists, swipe left to delete/archive, right to pin/mark read.
- Horizontal pulls belong to the row, vertical ones to the list: the list does not scroll while the row is pulled and the row does not open while the list scrolls (
@yasinsensoy/native/gesture, decided on the native side). A pull towards a direction without actions goes to the outer gesture (e.g. navigation's "back" swipe). - Only one row stays open at a time; it closes when the list scrolls or the open row's content is tapped.
fullSwipe: pulling all the way and releasing runs the outermost action.- Screen readers: actions are offered as the row's accessibility actions (swipe up/down in VoiceOver, the actions menu in TalkBack).
- Edges swap in right-to-left languages.
Examples
SwipeSide
typeRow edge: start is the left one (the right one in right-to-left languages), end the opposite.
SwipeAction
interfaceAction revealed when the row is swiped sideways.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | Unique key (also the name of the screen reader action). | |
label | string | Button text; screen readers read it too. | |
icon? | IconProp | Icon above the text (e.g. "trash", "pin", "inbox"). | |
tone? | Tone | "neutral" | Color. |
onPress | () => void | The action was chosen (button pressed or triggered by a full swipe). | |
keepOpen? | boolean | false | The row stays open on press (e.g. a button that opens a "More" menu). |
SwipeableHandle
interfaceMethods of a Swipeable instance.
| Name | Type | Description |
|---|---|---|
open | (side: SwipeSide): void | Opens the actions of one edge. |
close | (): void | Closes the row. |
SwipeableProps
interfaceSwipeable props.
| Name | Type | Default | Description |
|---|---|---|---|
ref? | Ref<SwipeableHandle> | Methods: open, close. | |
children | ReactNode | Row content. | |
startActions? | readonly SwipeAction[] | Actions on the start edge (when the finger pulls right; left in right-to-left languages). The first item is the outermost; a full swipe triggers it. | |
endActions? | readonly SwipeAction[] | Actions on the end edge (when the finger pulls left). The first item is the outermost. | |
fullSwipe? | boolean | SwipeSide | false | Full swipe: pulling most of the row width and releasing runs the outermost action without pressing the button (e.g. "Delete", "Archive"). true for both edges. |
actionWidth? | number | 76 | Width of one button (dp). |
disabled? | boolean | Cannot be swiped while disabled. | |
closeOnScroll? | boolean | true | The open row closes when the list starts scrolling (it always closes when another drag starts). |
onOpenChange? | (side: SwipeSide | null) => void | The open edge changed (null: closed). | |
style? | StyleProp<ViewStyle> | Outer container style (e.g. margin, corner radius). | |
contentStyle? | StyleProp<ViewStyle> | Style of the sliding content. The content background defaults to the theme background color: actions only show when pulled. |