shadcn.io is not affiliated with official shadcn/ui
Swipe Deck Features Block for React
A features section as a triage deck of feature requests: drag the top card past a threshold to keep it or skip it, or use the Keep and Skip buttons and the arrow keys, with a tally and a Start over button.
Installation
Overview
A features section for React with Base UI, built as a deck you triage. Seven feature requests from a feedback tool sit in a pile of three; the top card follows your pointer as you drag it, tilts with the drag, and shows a Keep or Skip stamp that fades in with distance. Drag past a threshold and the card flies off; let go sooner and it springs back. The Keep and Skip buttons and the arrow keys do the same, so nothing needs a pointer. A tally under the deck reads "4 kept, 3 skipped" with how many are left, "Start over" deals the deck again, and a floor hairline separates the deck from its controls. It's built from Button, Shine Button, Badge, Kbd and the Guides line kit, with your theme's tokens for every colour.
FAQ
How do I change the requests?
Edit REQUESTS at the top of the file: each has an id, an area, the team that asked first, a title, a sentence, votes, teams and an effort size. The pile shows three at a time and the tally is counted from the decisions, so the number of requests can be anything.
How does the drag work?
The pointer handlers write one CSS variable on the top card, the distance in pixels, and the card's position, tilt and stamps all follow from it in CSS: no animation loop runs. On release, a distance past 96 pixels keeps or skips the card and a shorter one clears the variable, so the card springs back with a transition. Vertical swipes still scroll the page on a touch screen.
How does it work from the keyboard?
Focus the deck (it is a named list and a tab stop) and press the arrow keys: toward the end of the line keeps the card and toward the start skips it, which flips in a right-to-left page. The Keep and Skip buttons work with Enter and Space. After each decision a polite status line says what happened and how many are left, and when the last card goes, focus moves to "Start over".
What happens with reduced motion?
The card leaves at once without the flight, the tilt is off, and the pile does not animate. The drag itself still moves the card with your pointer, because that is direct manipulation and not a decoration.
Related
- Pro
Layered Deck Shuffle Features
Carousels and mediaA stack of six flashcards with one large front card and three peek cards above it at shrinking scale; Next card sends the front card to the back and clicking a peek brings it forward, beside three features.
- Pro
Card Carousel Features
Carousels and mediaA multi-up carousel of seven capability cards for a product-tour builder, each led by a greyscale drawing, with the next card cut off at the rail and previous and next buttons in the heading row.
- Pro
Scroll Snap Reel Features
Carousels and mediaA features section as a full-height vertical snap reel: five slides that lock into place as you scroll, each with a drawing, a title, a sentence and three stats, a rail of dot buttons and a counter beside a sticky header.
- 0102Pro
Photo Booth Strip Features
Documents and objectsA vertical strip of four frames showing one card as empty, loading, error and success, with a numbered spine, held timecodes, a sticky header and a split divider.
- Pro
Carousel Slider Features
Carousels and mediaA one-slide-at-a-time carousel of the five steps of making a deck, each a checklist beside a greyscale drawing, with a segmented progress bar of labelled segments as the navigation.
- Pro
3D Ring Carousel Features
Carousels and mediaSix capability cards on a true 3D ring in a framed stage, turned a card at a time by the previous and next buttons or the arrow keys, with the far cards dimming behind the front one.