Box selection as a shape: a ball born under the pointer stretches into a pill, becomes a tile and snaps tight around the items it caught, with a count.
DragDrag
Library / Campaign drafts
Campaign drafts
8 files
Drag on empty space to select (long press on touch). Shift + arrows from the keyboard.
hero-draft.png
PNG · 2.4 MB
banner-wide.png
PNG · 1.8 MB
icon-set.svg
SVG · 96 KB
pattern-01.png
PNG · 3.1 MB
promo-loop.mp4
MP4 · 8.2 MB
cover-alt.jpg
JPG · 1.2 MB
pattern-02.png
PNG · 2.9 MB
badge-round.svg
SVG · 40 KB
0
snap-lasso · , lively
snap-lasso-demo.tsx
When to use
Use for boards of items people select many at a time: drag on empty space and the tile snaps around what was caught with a count. Click, arrows and touch long press also work; hint (on by default) shows the gesture once.
When not to use
Not for a single choice: use a radio group or a select. For table rows with bulk actions use Selection Bar.
Use Snap Lasso for boards of things people select many at a time: a media library, a file manager, dashboard widgets in edit mode, a queue of tickets. Press on empty space and a ball appears under the pointer; drag and it becomes a tile that follows the marquee, lifting the items it touches; let go and the tile snaps tight around the group with a count on its corner, so the person sees what was taken and how many. Click, the arrows and Shift + arrows do the same without a pointer. For a single choice use a radio group or a select; for a long text list prefer checkboxes in a table.
SnapLasso is the board (a multi-select listbox) and draws the lasso; SnapLassoItem is one option (asChild merges it onto your card). Lay the items out however you like and leave some empty space around them (the board's padding and the gaps) to start a drag from. The lasso is drawn under the items (they sit at z-index: 1), so give them an opaque background: the tile and its counter show in the gaps and never cross item text. When a lasso catches items on both sides of one it skipped (a disabled item), each group gets its own outline. In additive the counter shows the whole selection. value, defaultValue and onValueChange hold the selected values; messages sets what the live region says.
Presets: marquee (default, the lasso replaces the selection and the outline holds 600 ms), additive (each sweep adds to the selection) and pinned (the outline stays around the group until the selection changes). mode and holdOutline override the preset. seed and frame take a Shape (ball and tile by default). hint shows the gesture once, the first time the board scrolls into view, without selecting anything.
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful). It changes motion intensity only, never the drawing.
The board is a listbox with aria-multiselectable, named by label; items are options with aria-selected and a roving tab stop (one item in the tab order).
The SVG overlay and the counter ball are aria-hidden. A polite live region outside the listbox says "4 selected" or "Selection cleared" after every change.
Every gesture has a keyboard and a click path: a click toggles one item, Shift + arrows select a range.
The selection ring is 3 px of primary 5 px outside the item; the focus ring is the standard 3 px ring right on the item, so both show together, 2 px apart. The counter digit is primary-foreground on primary.
disabled on the board removes the items from the tab order and stops the lasso; disabled on an item skips it.
No seed, stretch, squeeze or counter kick, and no hint: the tile fades in on the marquee, the outline appears on the group and fades, and Escape fades it out. Items do not lift; their ring still shows.
One SVG overlay and one requestAnimationFrame loop that runs only while the lasso moves, settles or fades, and stops at rest.
Item rectangles are read once at press, not per frame; hit testing is plain box overlap.
The selection lift and rings are CSS on the items; the overlay is pointer-events: none.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-slot, motion.
Dependencies
@radix-ui/react-slot · peer
motion · peer
Triggers
drag, pointer movement, press, entering the viewport
Reduced motion
No seed, stretch, squeeze or kick and no hint: the tile fades in on the marquee, the outline appears on the group and fades, and items do not lift (their ring still shows).
Keyboard
Arrow keys
Move focus to the nearest item in that direction
Space / Enter
Toggle the focused item
Shift + Arrow keys
Grow a keyboard lasso from the anchor item; releasing Shift snaps it on the group and selects it
Ctrl/Cmd + A
Select every item
Escape
Pull back a running lasso, or clear the selection
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)