Sortable list
A list put in a new order by dragging an item from anywhere on it, except a control inside it, by touch with a long press, and by keyboard from its handle. Its neighbours glide aside as it passes, each move is announced, and it works as a column or as a wrapping grid.
Examples
Default
Give it the order as value and keep the new one from onValueChange, which runs once an item is dropped in a new place. Drag a row from anywhere, or focus its handle and press Space.
Grid
layout='grid' puts items in rows that wrap, laid out by className; the arrow keys move a picked-up item along a line and between lines.
Doing3
Press Space to pick it up. Then use the arrow keys to move it, Space to drop it, or Escape to put it back.
Controls inside
A press on a button, a link, a checkbox or any other control inside an item does what it says; a press anywhere else drags.
Press Space to pick it up. Then use the arrow keys to move it, Space to drop it, or Escape to put it back.
Items that come and go
Items added or removed take their place in the order, and the others glide to make room or close the gap.
Backlog
12 issuesIn a box that scrolls
Dragged to the edge of a box that scrolls, the box scrolls; picked up by keyboard, the item stays in view as it moves.
Press Space to pick it up. Then use the arrow keys to move it, Space to drop it, or Escape to put it back.
Different widths
Without value, the list keeps its own order. Items of any width wrap and glide across lines.
Disabled
disabled keeps the order as it is: nothing drags, and the handles go.
Installation
npx shadcn@latest add https://kinoui.com/r/sortable-list.json- Files
lib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/announce.tsxlib/controllable.tslib/run-progress.tslib/highlight.tslib/flow.tslib/scroll.tslib/sort.tsxcomponents/kino/sortable-list.tsx- Packages
@base-ui/reactclass-variance-authority- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
SortableList
SortableItem
Data attributes
Accessibility
- The list is a list and each item a list item. Each item’s handle is a button named “Move” and the item’s
label, which describes how to move it. - Space or Enter on the handle picks the item up and drops it; the arrow keys move it, Home and End take it to the ends, Escape puts it back where it was, and Tab drops it where it is. A screen reader’s activate command picks it up and drops it as Space does.
- Focus stays on the handle as its item moves, and the item is scrolled into view.
- A polite status region says each pick-up, move, drop and cancel, with the item’s position (“moved to position 3 of 6”).
- A picked-up item shows it with a raised shadow and its handle pressed (
aria-pressed), and with an outline in forced colours, where shadows go. - A press on a control inside an item, such as a button, a link, a checkbox or a field, goes to the control and never starts a drag.