Sortable
Сортировка перетаскиванием. Бесплатно, MIT · Данные и показатели › Списки и деревья
Установка
npx valyro-cli@latest add sortable
npx shadcn@latest add https://valyro.xyz/r/sortable.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { Sortable } from 'valyro-ui';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
items | readonly T[] | Controlled items, in order. | |
defaultItems | readonly T[] | Initial items when uncontrolled. | |
onReorder | (items: T[], move: SortableMove<T>) => void | Called after a drop that changed the order (pointer or keyboard). | |
getKey | (item: T) => SortableKey | Stable key of an item. Defaults to item.id, or the item itself for strings and numbers. | |
children * | (item: T, state: SortableItemState) => ReactNode | Renders one item; also renders the copy that follows the pointer (state.isOverlay). | |
layout | 'vertical' | 'horizontal' | 'grid' | 'vertical' | grid matches drop positions in both directions and moves rows with ArrowUp / ArrowDown. |
handle | boolean | false | Only a SortableHandle inside the item starts a drag; the rest of the item stays interactive. |
disabled | boolean | false | Turn off reordering: no item can be picked up by pointer or keyboard, and handles are disabled. |
isItemDisabled | (item: T) => boolean | Items that can't be picked up (others can still move past them). | |
getItemLabel | (item: T) => string | Item name for announcements and handle labels. Defaults to "item 3". | |
labels | Partial<SortableLabels> | Overrides for the built-in English text; keys left out keep their defaults. |
Похожие компоненты
- List Block — Блок списка с картинками или иконками, описанием и значением
- Description List — Список «ключ — значение»: столбиком, строками или сеткой с иконками
- Tree View — Древовидные структуры
- Accordion — Раскрывающиеся секции
- JSON Viewer — Просмотр JSON
- Timeline — Хронология событий
- Data Table — Таблицы с поиском и сортировкой
- Data Grid — Таблица на 100 000 строк: группировка, фильтры, редактирование
- Virtual List — Виртуальный список на 100 000 строк
- Bulk Action Bar — Панель действий над выбранными строками с горячими клавишами
- Card — Универсальные карточки
- Item Card — Карточка-строка: иконка, заголовок, описание и элемент управления справа
Назад: Accordion · Далее: JSON Viewer · Весь раздел «Данные и показатели»