Skip to content
Sign upGet access
MicrointeractionsChip reorderMenu

Chip reorder

Context chips you put in order by hand, with neighbours making room on springs.

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

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/chip-reorder.json

Usage

tsx
import { ChipReorder } from "@/components/ui/chatcn/chip-reorder"

<ChipReorder chips={context} onReorder={(ids) => setContext(ids.map(byId))} />

Props

PropTypeNotes
chips{ id, label, kind?: "file" | "link" | "image" | "note" }[]
onReorder(ids: string[]) => voidOnce a chip is dropped somewhere new
labelstringThe list's name. Default "Context"

Keyboard

KeyAction
Space / EnterPick up or drop the focused chip
Arrow keysMove the picked up chip
EscapePut 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.