Skip to Content
Neshel-UI
Animations (experimental)Reference

@neshel-ui/animations/gestures

Every export of @neshel-ui/animations/gestures, generated from its declarations.

Experimental and not on npm

@neshel-ui/animations is a private package (0.0.0). It cannot be installed, and its API may change before a first publication. These pages document what exists in the repository.

Signatures, members and defaults, generated from the built declarations. For explanations and examples read the guide.

  • ElasticScroll component

    A package-rendered scroll container whose content stretches visually at its edges (decorative).

    (props: ElasticScrollProps): Element
  • Gesture component

    `<Gesture>`: physics & gesture effects on a `<div>` or, with `asChild`, your own element.

    <Options, Resolved>(props: GestureProps<Options, Resolved>): Element
  • PinchZoom component

    Pinch-zoom media with zoom buttons and keys (WCAG 2.5.1); one-finger page scrolling kept at scale 1.

    (props: PinchZoomProps): Element
  • PullToRefresh component

    An optional pull-to-refresh indicator on a package-rendered scroll container, plus an explicit refresh button. Never blocks scrolling or the browser's own behaviour (research R3).

    (props: PullToRefreshProps): Element
  • Reorder component

    Drag-to-reorder list. The order is yours: `onReorder(from, to)` asks you to move an item; React re-renders and the items settle from where they are shown (no DOM reordering by the package, no lost state).

    (props: ReorderProps): Element
  • ReorderHandle component

    The drag handle and keyboard control of an item (a real button; touch drags start here).

    (props: ReorderHandleProps): Element
  • ReorderItem component
    (props: ReorderItemProps): Element
  • SwipeDismiss component

    Swipe to dismiss with a built-in, accessible dismiss button (WCAG 2.5.7).

    (props: SwipeDismissProps): Element
  • createGesture function
    (element: HTMLElement, initial: GestureOptions): GestureHandle
  • createGestureControls function

    Create a controls object (one per controlled element; stable for its lifetime).

    (): GestureControls
  • createVelocityTracker function

    Release-velocity estimate from the samples of the last `windowMs` (default 100): slope between the oldest sample in the window and the newest, minimum span 8 ms (research R4). Ring buffer, no allocation per add.

    (windowMs?: number | undefined): VelocityTracker
  • getGestureDebugInfo function
    (): GestureDebugInfo
  • nearestSnap function

    The point of `points` nearest to `value` (`value` itself when the list is empty).

    (value: number, points: readonly number[]): number
  • projectDecay function

    Rest position of an exponential decay started from `value` with release `velocity` (px/s): `value + power · velocity · τ` (research R5). Lets snap points be chosen before animating.

    (value: number, velocity: number, options?: DecayOptions | undefined): number
  • reorderMove function

    Move `item` of a list with an attached `reorder` effect by `step` positions (move up/down buttons): asks the consumer through `onReorder`, announces the result and settles the items. No-op without the effect.

    (list: Element, item: HTMLElement, step: number): void
  • rubberband function

    Rubber band: displacement `overshoot` beyond a bound, over `dimension` px, maps to `(1 − 1 / (|x|·c/d + 1)) · d` with the sign of `overshoot` (research R6). Continuous at 0, monotonic, asymptotic to `dimension`.

    (overshoot: number, dimension: number, constant?: number | undefined): number
  • stepDecay function

    Advance a decay by `dt` seconds with the exact exponential solution (frame-rate independent). The state's velocity is the CURRENT velocity (start it at `power · releaseVelocity`). Returns `true` at rest, where the value lands on its exact projected end.

    (state: DecayState, options: DecayOptions, dt: number): boolean
  • useGestureControls function

    A stable controls object for buttons and commands (the non-gesture alternatives).

    (): GestureControls
  • useReorderItem function

    Move-up / move-down helpers for custom controls inside a `<ReorderItem>` (WCAG 2.5.7).

    (): { moveUp: () => void; moveDown: () => void; index: number | undefined; count: number; isFirst: boolean; isLast: boolean; }
  • useSpringFollow function

    G05 as a hook: a motion value that chases `source` with a spring (no React render per change). Reduced motion jumps.

    (source: MotionValue, spring?: SpringOptions | "gentle" | "snappy" | "bouncy" | undefined, reducedMotion?: ReducedMotion | undefined): MotionValue
  • drag const
    Readonly<EffectDefinition<DragOptions, ResolvedDrag>>
  • dragSnap const
    Readonly<EffectDefinition<DragSnapOptions, ResolvedDrag>>
  • elasticEdge const
    Readonly<EffectDefinition<ElasticEdgeOptions, ResolvedElastic>>
  • fling const
    Readonly<EffectDefinition<FlingOptions, ResolvedDrag>>
  • gestureEffects const

    Every physics & gesture definition in catalogue order (G01–G11), for explicit registries.

    readonly AnyEffectDefinition[]
  • pinchZoom const
    Readonly<EffectDefinition<PinchZoomOptions, ResolvedPinch>>
  • pullToRefresh const
    Readonly<EffectDefinition<PullToRefreshOptions, ResolvedPull>>
  • reorder const
    Readonly<EffectDefinition<ReorderOptions, ResolvedReorder>>
  • rotateGesture const
    Readonly<EffectDefinition<RotateGestureOptions, ResolvedRotate>>
  • springFollow const
    Readonly<EffectDefinition<SpringFollowOptions, ResolvedFollow>>
  • squashStretch const
    Readonly<EffectDefinition<SquashStretchOptions, ResolvedSquash>>
  • swipeDismiss const
    Readonly<EffectDefinition<SwipeDismissOptions, ResolvedSwipe>>
  • DecayOptions interface

    DecayOptions

    Physics primitives (Phase 012; contracts/gesture-engine.md §5, research R4–R6). Pure functions and a small velocity tracker: no scheduler, no DOM. Springs are NOT here — gestures use the 009 integrator (stepSpring) through the 010 spring rig, so there is still one spring integrator.

    DecayOptions
    PropTypeDefaultDescription
    powernumber—Fraction of the release velocity carried into the motion (0–1, default 0.8).
    restSpeednumber5Speed below which the motion rests, px/s (default 5).
    timeConstantnumber—Time constant τ in ms (50–2000, default 325).
  • DecayState interface

    DecayState

    DecayState
    PropTypeDefaultDescription
    value(required)number——
    velocity(required)number——
  • DragOptions interface

    DragOptions

    G01 — Drag with inertia.

    DragOptions
    PropTypeDefaultDescription
    axisGestureAxis"both"Movement axis (default "both").
    constraintsConstraints—Limits of the movement: "parent", an element, or px from the rest position.
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    decayDecayOptions—Decay of the inertia (power 0–1, timeConstant 50–2000 ms).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    elasticnumber—Rubber band beyond the constraints while dragging (0 hard … 1, default 0.35).
    inertiabooleantrueKeep moving after release with exponential decay (default true).
    keyboardStepnumber—px per arrow key (1–200, default 10; Shift × 5). Requires a focusable element.
    onEnd(position: Point) => void—Called when the element comes to rest after a drag, a key or a command.
    onStart() => void——
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    springSpringOptions | SpringPreset"snappy"Spring used for bounces and keyboard moves (default "snappy"-like 300/30).
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
  • DragSnapOptions interface

    DragSnapOptions

    G02 — Drag constraints + snap points.

    DragSnapOptions
    PropTypeDefaultDescription
    axisGestureAxis"both"Movement axis (default "both").
    constraintsConstraints—Limits of the movement: "parent", an element, or px from the rest position.
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    decayDecayOptions—Decay of the inertia (power 0–1, timeConstant 50–2000 ms).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    elasticnumber—Rubber band beyond the constraints while dragging (0 hard … 1, default 0.35).
    keyboardStepnumber—px per arrow key (1–200, default 10; Shift × 5). Requires a focusable element.
    onEnd(position: Point) => void—Called when the element comes to rest after a drag, a key or a command.
    onSnap(point: Point, index: number) => void—Called at rest with the snap point and its index (-1 for grid points).
    onStart() => void——
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    snapreadonly Partial<Point>[] | { grid: Partial<Point>; }—Snap points (px from the rest position) or a grid (default: the rest position only).
    springSpringOptions | SpringPreset"snappy"Spring used for bounces and keyboard moves (default "snappy"-like 300/30).
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
  • ElasticEdgeOptions interface

    ElasticEdgeOptions

    G06 — Elastic edge (visual overscroll, decorative).

    ElasticEdgeOptions
    PropTypeDefaultDescription
    axis"x" | "y""y"Scroll axis of the container (default "y").
    disabledboolean——
    maxnumber—Maximum visual stretch in px (8–200, default 64).
    reducedMotionReducedMotion"user"Decorative: reduced motion turns it off (default "user").
  • ElasticScrollProps interface

    ElasticScrollProps

    ElasticScrollProps
    PropTypeDefaultDescription
    axis"x" | "y""y"Scroll axis of the container (default "y").
    childrenReactNode——
    disabledboolean——
    labelstring"Scrollable content"Accessible name of the scrollable region (default "Scrollable content").
    maxnumber—Maximum visual stretch in px (8–200, default 64).
    reducedMotionReducedMotion"user"Decorative: reduced motion turns it off (default "user").
    refRef<HTMLElement>——

    Also accepts the props of: React DOM attributes.

  • FlingOptions interface

    FlingOptions

    G07 — Throw / fling with decay.

    FlingOptions
    PropTypeDefaultDescription
    axisGestureAxis"both"Movement axis (default "both").
    bouncenumber—Energy kept when bouncing off a constraint (0–1, default 0.5).
    constraintsConstraints—Limits of the movement: "parent", an element, or px from the rest position.
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    decayDecayOptions—Decay of the inertia (power 0–1, timeConstant 50–2000 ms).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    elasticnumber—Rubber band beyond the constraints while dragging (0 hard … 1, default 0.35).
    keyboardStepnumber—px per arrow key (1–200, default 10; Shift × 5). Requires a focusable element.
    onRest(position: Point) => void—Called when the thrown element comes to rest.
    onStart() => void——
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    springSpringOptions | SpringPreset"snappy"Spring used for bounces and keyboard moves (default "snappy"-like 300/30).
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
  • GestureCommonOptions interface

    GestureCommonOptions

    Options shared by every gesture effect.

    GestureCommonOptions
    PropTypeDefaultDescription
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
  • GestureControls interface

    GestureControls

    GestureControls
    PropTypeDefaultDescription
    dismiss(required)() => void——
    moveBy(required)(dx: number, dy: number) => void——
    moveTo(required)(x: number, y: number) => void——
    refresh(required)() => void——
    reset(required)() => void——
    rotateBy(required)(degrees: number) => void——
    snapTo(required)(index: number) => void——
    zoomBy(required)(factor: number) => void——
    zoomTo(required)(scale: number) => void——
  • GestureDebugInfo interface

    GestureDebugInfo

    GestureDebugInfo
    PropTypeDefaultDescription
    claims(required)number—Pointers currently claimed by an active exclusive gesture.
    sessions(required)number—Pointer sessions alive (one per element with an attached gesture).
  • GestureHandle interface

    GestureHandle

    GestureHandle
    PropTypeDefaultDescription
    cancel(required)() => void—Abort the current gesture (onCancel when active); its pointers are ignored until released.
    destroy(required)() => void——
    phase(required)GesturePhase——
    session(required)PointerSession——
    setOptions(required)(options: GestureOptions) => void—Replace options (live); touchAction changes apply at once.
  • GestureOptions interface

    GestureOptions

    GestureOptions
    PropTypeDefaultDescription
    accept(event: PointerEvent | undefined, pointer: SessionPointer) => boolean—Call before activation to veto it (e.g. a handle-only reorder).
    axisGestureAxis"both"Required direction before activation (default "both"): a vertical swipe never starts an x drag.
    exclusivebooleantrueExclusive gestures never share a pointer with another exclusive gesture (default true).
    onCancel(state: GestureState) => void——
    onEnd(state: GestureState) => void——
    onMove(state: GestureState) => void——
    onPress(state: GestureState) => void——
    onStart(state: GestureState) => void——
    onTap(state: GestureState) => void—Released while still pending (no movement beyond the threshold).
    pointerTypesreadonly string[]——
    pointers1 | 2—1 = drag-like (default); 2 = transform gesture (also follows its 1-pointer phase).
    thresholdnumber—px before activation (default 3; 0 = on press). Two pointers activate a transform gesture at once.
    touchActionreadonly TouchToken[]—Touch gestures left to the browser on this element (touch-action contribution).
  • GestureState interface

    GestureState

    GestureState
    PropTypeDefaultDescription
    acceleration(required)Vec—px/s² (diagnostic).
    delta(required)Vec—Movement since the previous callback.
    event(required)PointerEvent | undefined——
    offset(required)Vec—Movement since the gesture started, including scroll compensation (px, client axes).
    origin(required)Vec—Centroid of the active pointers (client coordinates).
    pointerType(required)string——
    pointers(required)number——
    rotation(required)number—Two pointers: angle change in degrees since start (accumulated); 0 otherwise.
    scale(required)number—Two pointers: distance ratio since start (accumulated across re-bases); 1 otherwise.
    velocity(required)Vec—px/s (research R4).
  • PinchZoomOptions interface

    PinchZoomOptions

    G08 — Pinch-zoom media.

    PinchZoomOptions
    PropTypeDefaultDescription
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    doubleTapScalenumber—Scale of a double tap / double click (1–10, default 2; 1 disables).
    maxScalenumber—Maximum scale (1–10, default 4).
    minScalenumber—Minimum scale (0.5–1, default 1).
    onZoomChange(scale: number) => void—Called with the scale after a gesture, a key or a command.
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    springSpringOptions | SpringPreset——
    stepnumber—Factor of the zoom keys and buttons (1.1–4, default 1.5).
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
    wheelboolean—Ctrl/⌘ + wheel and trackpad pinch zoom over the frame (opt-in; prevents the page zoom there).
  • PinchZoomProps interface

    PinchZoomProps

    PinchZoomProps
    PropTypeDefaultDescription
    children(required)ReactElement—Exactly one media element (img, video, canvas, picture, …).
    controlLabels{ zoomIn?: string; zoomOut?: string; reset?: string; }—Button labels (defaults "Zoom in", "Zoom out", "Reset zoom").
    controlsGestureControls——
    disabledboolean—Turn the gesture off (disabled elements never react either).
    doubleTapScalenumber—Scale of a double tap / double click (1–10, default 2; 1 disables).
    labelstring"Zoomable media"Accessible name of the zoomable region (default "Zoomable media").
    maxScalenumber—Maximum scale (1–10, default 4).
    minScalenumber—Minimum scale (0.5–1, default 1).
    onZoomChange(scale: number) => void—Called with the scale after a gesture, a key or a command.
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    refRef<HTMLDivElement>——
    springSpringOptions | SpringPreset——
    stepnumber—Factor of the zoom keys and buttons (1.1–4, default 1.5).
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
    wheelboolean—Ctrl/⌘ + wheel and trackpad pinch zoom over the frame (opt-in; prevents the page zoom there).
    zoomControlsbooleantrueRender the zoom buttons (default true).

    Also accepts the props of: React DOM attributes.

  • Point interface

    Point

    Point
    PropTypeDefaultDescription
    x(required)number——
    y(required)number——
  • PullToRefreshOptions interface

    PullToRefreshOptions

    G04 — Pull-to-refresh indicator.

    PullToRefreshOptions
    PropTypeDefaultDescription
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    onRefresh() => unknown—The refresh action (provided by the consumer); a returned promise keeps the busy state until it settles.
    onStatus(status: "refreshing" | "done") => void—Called with "refreshing" and "done" (announcements; <PullToRefresh> announces them).
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    thresholdnumber—Pull distance (px) that triggers a refresh on release (24–240, default 72).
  • PullToRefreshProps interface

    PullToRefreshProps

    PullToRefreshProps
    PropTypeDefaultDescription
    childrenReactNode——
    controlsGestureControls——
    disabledboolean—Turn the gesture off (disabled elements never react either).
    onRefresh() => unknown—The refresh action (provided by the consumer); a returned promise keeps the busy state until it settles.
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    refRef<HTMLDivElement>——
    refreshButtonbooleantrueRender the built-in refresh button (default true).
    refreshLabelstring"Refresh"Label of the built-in refresh button (default "Refresh").
    scrollerLabelstring"Scrollable content"Accessible name of the scrollable region (default "Scrollable content").
    statusLabels{ refreshing?: string; done?: string; }—Announcements (default "Refreshing…" / "Content updated").
    thresholdnumber—Pull distance (px) that triggers a refresh on release (24–240, default 72).

    Also accepts the props of: React DOM attributes.

  • ReorderAnnouncements interface

    ReorderAnnouncements

    ReorderAnnouncements
    PropTypeDefaultDescription
    cancel(required)(label: string, position: number, count: number) => string——
    drop(required)(label: string, position: number, count: number) => string——
    grab(required)(label: string, position: number, count: number) => string——
    move(required)(label: string, position: number, count: number) => string——
  • ReorderHandleProps interface

    ReorderHandleProps

    ReorderHandleProps
    PropTypeDefaultDescription
    aria-labelstring"Reorder <label>"Accessible name (default "Reorder <label>").
    childrenReactNode——
    refRef<HTMLButtonElement>——

    Also accepts the props of: React DOM attributes.

  • ReorderItemProps interface

    ReorderItemProps

    ReorderItemProps
    PropTypeDefaultDescription
    as"li" | "div""li"Item element (default "li").
    childrenReactNode——
    indexnumber—Position of the item in your order (enables useReorderItem().isFirst/isLast).
    labelstring—Name used in announcements (default: the item's text).
    refRef<HTMLElement>——

    Also accepts the props of: React DOM attributes.

  • ReorderOptions interface

    ReorderOptions

    ReorderOptions
    PropTypeDefaultDescription
    announce(message: string) => void—Announce a message (default: a shared polite live region; <Reorder> passes its own).
    announcementsPartial<ReorderAnnouncements>—Override the English announcements.
    axis"x" | "y""y"List direction (default "y").
    disabledboolean——
    onReorder(from: number, to: number) => void—Move the item at from to to in the consumer's order (required for the list to change).
    pointerTypesreadonly PointerKind[]—Pointer kinds that may drag (default mouse, pen and touch; touch always needs a handle).
    reducedMotionReducedMotion"user"Reduced motion: shifts and settling jump (default "user").
    springSpringOptions | SpringPreset—Spring of shifts and settling (default 420/36).
  • ReorderProps interface

    ReorderProps

    ReorderProps
    PropTypeDefaultDescription
    announcementsPartial<ReorderAnnouncements>—Override the English announcements.
    as"ul" | "ol" | "div""ul"List element (default "ul").
    axis"x" | "y""y"List direction (default "y").
    childrenReactNode——
    disabledboolean——
    instructionsstring—Keyboard instructions read with each handle (default English).
    onReorder(from: number, to: number) => void—Move the item at from to to in the consumer's order (required for the list to change).
    pointerTypesreadonly PointerKind[]—Pointer kinds that may drag (default mouse, pen and touch; touch always needs a handle).
    reducedMotionReducedMotion"user"Reduced motion: shifts and settling jump (default "user").
    refRef<HTMLElement>——
    springSpringOptions | SpringPreset—Spring of shifts and settling (default 420/36).

    Also accepts the props of: React DOM attributes.

  • RotateGestureOptions interface

    RotateGestureOptions

    G09 — Rotate gesture.

    RotateGestureOptions
    PropTypeDefaultDescription
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    keyStepnumberrotateByDegrees per [ / ] key and default rotateBy button step (1–90, default 15).
    onRotateEnd(degrees: number) => void—Called with the rotation (degrees) after a gesture, a key or a command.
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    springSpringOptions | SpringPreset——
    stepnumber—Snap the rotation to multiples of step degrees on release (0 = free, default 0).
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
  • SpringFollowOptions interface

    SpringFollowOptions

    G05 — Spring follow (value chasing).

    SpringFollowOptions
    PropTypeDefaultDescription
    reducedMotionReducedMotion"user"Reduced motion jumps to the value (default "user").
    rotateMotionValue—Rotation to chase (degrees).
    scaleMotionValue—Scale factor to chase.
    springSpringOptions | SpringPreset"gentle"Spring (default "gentle"-like 120/18).
    xMotionValue—Horizontal translation to chase (px).
    yMotionValue—Vertical translation to chase (px).
  • SquashStretchOptions interface

    SquashStretchOptions

    G11 — Velocity squash & stretch (decorative).

    SquashStretchOptions
    PropTypeDefaultDescription
    intensitynumber—Strength (0–1, default 0.25); the deformation never exceeds 25 %.
    reducedMotionReducedMotion"user"Decorative: reduced motion turns it off (default "user").
    springSpringOptions | SpringPreset—Spring of the deformation (default 400/24).
  • SwipeDismissOptions interface

    SwipeDismissOptions

    SwipeDismissOptions
    PropTypeDefaultDescription
    controlsGestureControls—Non-gesture alternatives (createGestureControls() / useGestureControls()).
    directionSwipeDirection"x"Allowed direction(s) (default "x": left or right).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    distancenumber—Fraction of the element's size that dismisses on release (0.1–1, default 0.5).
    keyboardbooleantrueDelete / Backspace dismiss when the element is focused (default true).
    onDismiss(direction: "left" | "right" | "up" | "down") => void—Called once when the element has left; the consumer removes it.
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
    velocitynumber—Release speed that dismisses, px/s (100–5000, default 800).
  • SwipeDismissProps interface

    SwipeDismissProps

    SwipeDismissProps
    PropTypeDefaultDescription
    childrenReactNode——
    controlsGestureControls——
    directionSwipeDirection"x"Allowed direction(s) (default "x": left or right).
    disabledboolean—Turn the gesture off (disabled elements never react either).
    dismissButtonbooleantrueRender the built-in dismiss button (default true). Provide your own accessible control when false.
    dismissLabelstring"Dismiss"Accessible name of the built-in dismiss button (default "Dismiss").
    distancenumber—Fraction of the element's size that dismisses on release (0.1–1, default 0.5).
    keyboardbooleantrueDelete / Backspace dismiss when the element is focused (default true).
    onDismiss(direction: "left" | "right" | "up" | "down") => void—Called once when the element has left; the consumer removes it.
    pointerTypesreadonly PointerKind[]—Pointer kinds that may start the gesture (default mouse, pen and touch).
    reducedMotionReducedMotion"user"Reduced-motion policy (default "user"): automatic motion jumps to its end; direct manipulation stays.
    refRef<HTMLDivElement>——
    thresholdnumber—px of movement before the gesture starts (0–40, default 3).
    velocitynumber—Release speed that dismisses, px/s (100–5000, default 800).

    Also accepts the props of: React DOM attributes.

  • VelocityTracker interface

    VelocityTracker

    VelocityTracker
    PropTypeDefaultDescription
    acceleration(required)() => { x: number; y: number; }—Change of velocity between the last two estimates, px/s² (diagnostic).
    add(required)(time: number, x: number, y: number) => void—Add a sample (time in ms).
    reset(required)() => void——
    velocity(required)(time?: number) => { x: number; y: number; }—Velocity in px/s at time (ms); 0 when the last sample is older than 40 ms (the pointer stopped).
  • Constraints type
    "parent" | Element | { left?: number; right?: number; top?: number; bottom?: number; }
  • GestureAxis type
    "x" | "y" | "both"
  • GesturePhase type
    "idle" | "pending" | "active"
  • GestureProps type

    GestureProps

    GestureProps
    PropTypeDefaultDescription
    asChildboolean—Apply the effects to the single child element instead of rendering a <div>.
    childrenReactNode——
    conflictsConflictPolicy—Conflict reporting for exclusive channels (default: warn in development).
    optionsundefined | NoInfer<Partial<Options>>——
    preset(required)readonly PresetInput<any, any>[] | PresetInput<Options, Resolved>——
    refRef<HTMLDivElement>——

    Also accepts the props of: React DOM attributes.

  • PointerKind type
    "mouse" | "pen" | "touch"
  • SwipeDirection type

    G03 — Swipe to dismiss.

    "x" | "left" | "right" | "y" | "up" | "down"
Edit on GitHub