Swipeable
tetra-ui/swipeableFreeComponent
Swipe leading and trailing actions onto row content.
Live preview
live · rendered by the registry
Rendered by tetra-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://tetra-ui.com/r/swipeable.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import {3 Children,4 cloneElement,5 createContext,6 isValidElement,7 useCallback,8 useContext,9 useEffect,10 useMemo,11 useRef,12} from "react";13import { Text, useWindowDimensions, View } from "react-native";14import { Pressable as GestureHandlerPressable } from "react-native-gesture-handler";15import ReanimatedSwipeable, {16 type SwipeableProps as ReanimatedSwipeableProps,17 type SwipeableMethods,18 SwipeDirection,19} from "react-native-gesture-handler/ReanimatedSwipeable";20import Animated, {21 type SharedValue,22 useAnimatedReaction,23 useAnimatedStyle,24 useSharedValue,25 withTiming,26} from "react-native-reanimated";27import { withUniwind } from "uniwind";28import { cn } from "@/lib/utils";2930export type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";3132const Pressable = withUniwind(GestureHandlerPressable);3334// Types35type SwipeableSlot = "content" | "action-group";3637type SwipeableSlotComponent = {38 slot?: SwipeableSlot;39};4041export type SwipeableEdge = "leading" | "trailing";4243export type SwipeableListProps = {44 children: React.ReactNode;45 /** When true, opening one row closes every other registered row. */46 exclusive?: boolean;47};4849export type SwipeableContentProps = {50 children: React.ReactNode;51 className?: string;52 /** Prefer this over a nested RN Pressable — RNGH press cancels on swipe. */53 onPress?: React.ComponentProps<typeof Pressable>["onPress"];54 disabled?: boolean;55};5657export type SwipeableActionGroupProps = {58 edge: SwipeableEdge;59 allowsFullSwipe?: boolean;60 children?: React.ReactNode;61 className?: string;62};6364type SwipeableActionVariant = VariantProps<65 typeof swipeableActionVariants66>["variant"];6768export type SwipeableActionProps = Omit<69 React.ComponentProps<typeof Pressable>,70 "children"71> &72 VariantProps<typeof swipeableActionVariants> & {73 children?: React.ReactNode;74 };7576type SwipeableActionContextValue = {77 foregroundOpacity: SharedValue<number>;78 variant: SwipeableActionVariant;79};8081type SwipeableExclusiveMember = {82 close: () => void;83};8485type SwipeableListContextValue = {86 join: (member: SwipeableExclusiveMember) => () => void;87 opened: (member: SwipeableExclusiveMember) => void;88 closeAll: () => void;89};9091type ClassNameElement = React.ReactElement<{ className?: string }>;9293type ParsedSwipeableSlots = {94 content?: React.ReactNode;95 contentClassName?: string;96 contentDisabled?: boolean;97// … truncated
What it pulls in
npm packages
Files it writes
More from tetra-ui
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | tetra-ui | Components | Free | 1 dep | |
| Action Inputaction-input | tetra-ui | Components | Free | no deps | |
| Alertalert | tetra-ui | Components | Free | no deps | |
| Avataravatar | tetra-ui | Components | Free | no deps | |
| Badgebadge | tetra-ui | Components | Free | no deps | |
| Bottom Sheetbottom-sheet | tetra-ui | Components | Free | 4 deps · 7 files | |
| Buttonbutton | tetra-ui | Components | Free | no deps | |
| Cardcard | tetra-ui | Components | Free | no deps |
