Skip to Content
Notion UI

Sortable

Reorder lists and collections with drag and drop.

Sortable List

boolean

Installation

pnpm add @notion-kit/ui

Anatomy

<Sortable.Root>
  <Sortable.List>
    <Sortable.Item>
      <Sortable.Handle />
    </Sortable.Item>
  </Sortable.List>
  <Sortable.Overlay />
</Sortable.Root>

Examples


Use getSortableItemsAfterDrag in onDragEnd to update ordered state after a successful drop.

Sortable List

boolean
<Sortable.Root onDragEnd={...}>
  <Sortable.List render={<MenuGroup />}>
    {items.map((item, index) => (
      <Sortable.Item
        key={item.id}
        id={item.id}
        index={index}
        render={<MenuItem label={item.label} icon={<Sortable.Handle />} />}
      />
    ))}
  </Sortable.List>
</Sortable.Root>

API Reference

Sortable.Root

Wraps DragDropProvider and provides orientation, disabled state, sensors, and default movement modifiers to sortable children.

Prop

Type

Sortable.List

Renders the sortable item container. Accepts standard <div> props and Base UI render composition props.

Prop

Type

Sortable.Item

Registers one draggable item. Accepts dnd-kit sortable options in addition to render composition props.

Prop

Type

Sortable.Handle

Button used as the drag handle for the nearest Sortable.Item. It must be rendered inside a sortable item.

Sortable.Overlay

Renders dnd-kit's DragOverlay in a portal. Use it when you need a custom drag preview.

Prop

Type

getSortableItemsAfterDrag

Moves an array after a drag end event and returns the original array when the operation was canceled.

const nextItems = getSortableItemsAfterDrag(items, event);

Prop

Type

type SortableItemState

Prop

Type

On this page