Skip to content

Swipe Deck

Pro

A pile of cards: swipe the top card to a side to choose, as in a dating app. Buttons, arrow keys, and undo do the same without a drag.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 10, 2026 · Pro license

Playground

Loading the preview

Props

Needs your Pro API key in GELATIN_UI_PRO_TOKEN. Set it up

Pro itemAPI key required

Swipe Deck needs a Pro API key

Try the live preview for free. With Pro, the add command above puts the source in your project.

Files it adds
25
More Pro items, one API key
+327
Your coding agent runs it
1 cmd

$79$129once, for life

Already have Pro? Sign in to set up your API key.

Give the cards a size and a card for each index, and read each choice in onSwipe.

stay-picker.tsx

SwipeDeck

<div>
PropTypeDefaultDescription
childrenReactNode—
countRequirednumber—How many cards the deck has. The deck renders only the cards near the top.
indexnumber—The index of the top card (controlled). count means the deck is empty.
defaultIndexnumber—The index of the top card at first (uncontrolled). Default 0.
onIndexChange—A swipe or an undo moved the top card. A controlled parent must take the new index.
onSwipe—A card left on a side: from a drag, a flick, a button, an arrow key, or the app (actor.send).
onUndo—Undo brought a card back: the index it has again, and the side it had left on.
directionsreadonly SwipeDeckDirection[]—The sides a card can leave on. Default left and right; add up or down.
thresholdnumber—The share of the width (the height for up and down) a release must pass. Default 0.35.
visiblenumber—How many cards show in the pile, the top one included. Default 3.
disabledboolean—No drag, no keys, no buttons.
driverRef—Drives a drag of the top card from code (DragDriver, no item): a staged scene or a test grabs the card, carries it, and lets go, and the deck's own release rules fly it out or bring it back, with the tilt, the stamps, and the pile as for a finger.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

SwipeDeckCards

<ul>
PropTypeDefaultDescription
childrenRequired—One card for an index: usually a SwipeDeckCard. Called only for the cards near the top.
...props<ul> attributes—Every other attribute goes to the <ul>, with a ref.

SwipeDeckCard

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

SwipeDeckStamp

<div>
PropTypeDefaultDescription
children—
directionRequired"down""left""right""up"—The side whose drag shows this stamp.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

SwipeDeckButton

<button>
PropTypeDefaultDescription
classNamestring—
directionRequired"down""left""right""up"—The side the top card leaves on.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

SwipeDeckUndo

<button>
PropTypeDefaultDescription
classNamestring—
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

SwipeDeckEmpty

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • Set count, and give SwipeDeckCards the deck size (h-96 w-72) and a function that returns a SwipeDeckCard for an index.
  • Read each choice in onSwipe (index, direction), and remove it again in onUndo.
  • Add a SwipeDeckButton for each side and a SwipeDeckUndo, so a choice works without a drag.
  • Add up or down to directions for a third answer, such as a strong yes.
  • Put a SwipeDeckEmpty next to the cards for the end of the deck, with your own text and action.
  • To browse slides with no choice to make, use Carousel.
  • For one action that must be confirmed with a drag, use Swipe to Confirm.
Arrow Left / Arrow RightSwipe the focused top card to that side.
Arrow Up / Arrow DownSwipe the top card up or down, when directions has that side.
BackspaceUndo: bring the last card back. It works on the top card and on the empty deck.
TabMove from the top card to the buttons. The cards behind it are inert.

Only the top card is in the tab order. The cards behind it are inert, and each card has its place (aria-posinset, aria-setsize).

The top card names its keys in aria-keyshortcuts. The stamps are aria-hidden.

The buttons keep their focus when the deck is empty, so a keyboard user does not lose their place.

Drag
none · the card follows the finger and tilts up to 12° at a full width, in the same frame
Release
sheet · a card let go before the threshold goes back on the sheet clock (300ms)
Fly out
panel · a thrown card keeps the speed of the finger, 200 to 360ms on the panel curve; a button or a key uses the sheet clock
Pile
panel · the cards behind rise one place on the clock of the card that left or came back
Undo
sheet · the last card slides back from its side to the top of the pile

Built with

Installs with Swipe Deck

Components
Button
  1. AddedSwipe Deck, with Button.
Open the release