Give the cards a size and a card for each index, and read each choice in onSwipe.
stay-picker.tsx
SwipeDeck
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | |
| count | number | — | How many cards the deck has. The deck renders only the cards near the top. |
| index | number | — | The index of the top card (controlled). count means the deck is empty. |
| default | number | — | The index of the top card at first (uncontrolled). Default 0. |
| on | — | A swipe or an undo moved the top card. A controlled parent must take the new index. | |
| on | — | A card left on a side: from a drag, a flick, a button, an arrow key, or the app (actor.send). | |
| on | — | Undo brought a card back: the index it has again, and the side it had left on. | |
| directions | readonly SwipeDeckDirection[] | — | The sides a card can leave on. Default left and right; add up or down. |
| threshold | number | — | The share of the width (the height for up and down) a release must pass. Default 0.35. |
| visible | number | — | How many cards show in the pile, the top one included. Default 3. |
| disabled | boolean | — | No drag, no keys, no buttons. |
| driver | — | 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>| Prop | Type | Default | Description |
|---|---|---|---|
| children | — | 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>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
SwipeDeckStamp
<div>SwipeDeckButton
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| direction | "down""left""right""up" | — | The side the top card leaves on. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether 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>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether 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>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
| Arrow Left / Arrow Right | Swipe the focused top card to that side. |
|---|---|
| Arrow Up / Arrow Down | Swipe the top card up or down, when directions has that side. |
| Backspace | Undo: bring the last card back. It works on the top card and on the empty deck. |
| Tab | Move from the top card to the buttons. The cards behind it are inert. |
Built with
Installs with Swipe Deck
- Components
- Button











