XiodUI
HomeDocs
OverviewComponentsStyling & CustomizationChangelog

Components

  • Accordion
  • Agent Steps
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Autocomplete
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • Button Split
  • Calendar
  • Card
  • Carousel
  • Checkbox
  • Circular Progress
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy To Clipboard
  • Corner Badge
  • Dashboard Grid
  • Date Picker
  • Dialog
  • Dot Matrix
  • Draggable
    Updated
  • Drawer
  • Empty
  • Field
  • Fieldset
  • File Upload
    Updated
  • Form
  • Frame
  • Gauge
  • Grid
  • Group
  • Input
  • Input Group
  • Input OTP
  • Input Payment
  • Input Phone
    Updated
  • Input Sensitive
  • Kbd
  • Kinetic Click
  • Label
  • List Box
    Updated
  • Loader
  • Marker
  • Menu
  • Menubar
  • Message
  • Meter
  • Morphic Toast
  • Navigation Menu
  • Number Field
  • Option Picker
  • Orb
  • Pagination
  • Popover
  • Preview Card
    Updated
  • Progress
  • Radio
  • Resizable
  • Ruler Picker
  • Scroll Area
  • Scroll Bar
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Sortable
  • Switch
  • Table
  • Tabs
  • Text
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Toolbar
  • Tooltip
  • Waveform
  • Wheel Picker

Loading...

Preview Skeleton

Installation Skeleton

Usage Skeleton

API Reference Skeleton

Sponsors

Support the development of XiodUI and help us build the best component library on Earth.

+++
Sponsor on GitHub

Sortable

Previous: SliderNext: Switch

A list or grid the user can reorder by dragging or with the keyboard.

Preview

Loading Preview...

Installation

bun add xiod-ui

Usage

Imports

1import {2  Sortable,3  SortableColumn,4  SortableColumnHeader,5  SortableColumnTitle,6  SortableItem,7  SortableItemHandle,8  SortableItemRemove9} from "xiod-ui/sortable";

Anatomy

1<Sortable>2  <SortableItem>3    <SortableItemHandle />4    <SortableItemRemove />5  </SortableItem>6</Sortable>

API Reference

Detailed documentation of properties and options.

Sortable

Accepts render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
itemsReq
string[]
–

The ids of the items, in their current order. Each SortableItem finds its place by its id.

onReorder
SliderSwitch
Req
(newItems: string[]) => void
–

Called with the ids in their new order whenever an item moves: on drop with a pointer, or on each arrow key while moving one with the keyboard. Escape during a keyboard move calls it again with the original order.

disabled
boolean
false

Whether items can't be moved. They are still shown and focusable.

getItemLabel
((id: string) => string)
–

Returns the text that names an item, for screen readers, announcements, the remove button and the drag preview. Defaults to the item's textValue, then its id.

handleIcon
ReactNode
–

Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

labels
Partial<SortableLabels>
–

Replaces the built-in text for this instance. See LabelsProvider to change it everywhere.

onRemove
((id: string) => void)
–

Called with an item's id when its SortableItemRemove button is pressed.

onSortEnd
((event: SortableEndEvent) => void)
–

Called when a lifted item is dropped or the drag is cancelled.

onSortStart
((id: string) => void)
–

Called with an item's id when it is lifted, by pointer or keyboard.

orientation
"grid"|"horizontal"|"vertical"
"vertical"

How the items are laid out, which also sets the arrow keys: grid moves an item a row with Up and Down.

renderOverlay
((id: string) => ReactNode)
–

What follows the pointer while an item is dragged. Defaults to a chip with a grip and the item's label.

variant
"default"|"ghost"|"bordered"
default

The visual style of the component.

SortableColumn

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
idReq
string
–

The column's id. It also names the column for screen readers unless you pass aria-label.

SortableColumnHeader

Accepts render, plus every native <div> attribute.

SortableColumnTitle

Accepts render, plus every native <span> attribute.

SortableItem

Accepts render, plus every native <div> attribute.

PropTypeDefaultDescription
idReq
string
–

The item's id, as listed in the Sortable's items.

disabled
boolean
false

Whether this item can't be moved. Others can still move past it.

textValue
string
–

The text that names the item, for screen readers, announcements, the remove button and the drag preview. Defaults to the id. The Sortable's getItemLabel takes precedence.

variant
"default"|"flat"|"accent"
default

The visual style of the component.

SortableItemHandle

Accepts render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
icon
ReactNode
–

Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.

SortableItemRemove

Accepts render, plus every native attribute of the element it renders.

PropTypeDefaultDescription
idReq
string
–

The id of the item to remove, passed to the Sortable's onRemove.

icon
ReactNode
–

Replaces this icon. Accepts any node; null renders no icon. Takes precedence over IconProvider.