Chip reorder
Context chips you put in order by hand, with neighbours making room on springs.
On this page
Pick up a chip and it lifts and tilts with your hand while the others slide aside on springs to open its slot; drop it and it settles in with a small overshoot.
Pick up a chip and it lifts off the row, tilting with the speed you move it, while the chips around it slide out of the way on springs to open the slot it would land in. Let go and it settles into the gap with a small overshoot; Escape puts everything back. Each chip says what it is with the colour of its glyph: file, link, image or note.
Installation
Usage
import { ChipReorder } from "@/components/ui/chatcn/chip-reorder"
<ChipReorder chips={context} onReorder={(ids) => setContext(ids.map(byId))} />Props
| Prop | Type | Notes |
|---|---|---|
chips | { id, label, kind?: "file" | "link" | "image" | "note" }[] | |
onReorder | (ids: string[]) => void | Once a chip is dropped somewhere new |
label | string | The list's name. Default "Context" |
Keyboard
| Key | Action |
|---|---|
Space / Enter | Pick up or drop the focused chip |
Arrow keys | Move the picked up chip |
Escape | Put it back |
Accessibility
- Each chip is a sortable item with its position in its name; moves are announced.
Motion
- Neighbours FLIP 300 ms from where they are painted, so a change mid move never jumps. The held chip follows the pointer and settles on a slightly underdamped spring.