Calm motion: animations on this site only fade, with no movement
Sortable
Drag-to-reorder list or grid, keyboard grab and move
A list or grid whose order the user sets by hand: a playlist, a dashboard layout, a set of cards. Each row has a grip. Drag the grip, or focus it and use the keyboard. For a list that also needs ↑ ↓ buttons, use OrderList. To move items between two lists, use PickList.
Basic
- 第1話 プロローグ
- 第2話 運命の出会い
- 第3話 フラグの立たない
- 第4話 冴えない彼女
Grid
- Mon
- Tue
- Wed
- Thu
- Fri
- Sat
Between lists
- Write the intro
- Record the demo
- Proofread
- Pick a title
- Pointer drag works with mouse, touch and pen (the grip sets
touch-action: none, so the page still scrolls when you swipe elsewhere). A line marks where the item will land. The order changes on release. - Keyboard: focus a grip. Space or Enter grabs the item, ← ↑ and → ↓ move it (mirrored under RTL), Space drops it, and Esc puts everything back. Each step is announced.
- Holding a grip near the top or bottom of the window scrolls the page, so a long list can be dragged across.
:columns="3"lays the items out as a grid. The drop marker turns vertical.group="name"on two or more lists lets them trade items. Drag a grip over another list (an empty one shows a dashed outline). Or hold an item and press Alt+← / Alt+→ to send it to the neighboring list, where it stays held. Esc puts every list in the group back. Each list keeps its ownv-model. The sending list emitstransferwith(item, from, to).- Pass
rowKeywhen items have an id, so rows keep their state as they move. - The
moveevent gives(from, to).useSortableis exported for building your own sortable surface.
Usage
ts
import { BlessSortable } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
rowKey | ((item: T, index: number) => string | number) | — | |
label | string | "Sortable" | |
columns | number | 1 | lay the items out in this many equal columns (a grid); 1 is a list |
group | string | — | lists that share a group name take each other's items: drag across, or hold an item and press Alt with ← / → to send it to the neighbouring list. Bind each list's own `v-model`. |
labels | Partial<{ grip: (index: number) => string; grabbed: (index: number, total: number) => string; moved: (position: number, total: number) => string; sent: (list: string, position: number, total: number) => string; dropped: (position: number, total: number) => string; cancelled: string; hint: string; groupHint: string; roleDescription: string; }> | — | screen-reader wording; each message that carries numbers is a function of them |
modelValue | T[] | [] |
Events
| Name | Payload | Description |
|---|---|---|
move | [from: number, to: number] | |
transfer | [item: T, from: number, to: number] | |
update:modelValue | [value: T[]] |
Slots
| Name | Scope | Description |
|---|---|---|
default | { item: T; index: number; } |