For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/ui/components/sortable.md.
lynx-ui logo
lynx-ui
  • English
  • Sortable

    A headless Sortable list component for ReactLynx. It provides list reordering primitives via main-thread animations.
    Info

    You can check the source code to understand how it works, and you're welcome to submit PRs to enhance its capabilities.

    Basic Usage

    Examples

    Drag Without a boundary

    If no boundaryId is provided, the SortableItem can be dragged freely without restrictions.

    Disable all dragging and sorting behavior

    Structure

    By default, the whole SortableItem responds to dragging.

    <SortableRoot>
      {(item) => (
        <SortableItem sortingKey={item.getSortingKey()} />
      )}
    </SortableRoot>

    Use SortableItemArea when only a specific area should respond to dragging.

    <SortableRoot>
      {(item) => (
        <SortableItem as="DraggableRoot" sortingKey={item.getSortingKey()}>
          <SortableItemArea />
        </SortableItem>
      )}
    </SortableRoot>

    Component API

    SortableRoot

    asiOSAndroidHarmony
    Type'ScrollView'
    Specifies which container element SortableRoot should render and own as the scrollable boundary. - 'ScrollView': render an internal vertical scroll-view. - Omit (default): render a plain view without scrolling capability.
    boundaryIdiOSAndroidHarmony
    Typestring
    The unique key of the item that acts as the boundary. If the item is dragged out of the boundary, the sorting will be canceled.
    childreniOSAndroidHarmony
    Type(item: {dataItem: T, getSortingKey: () => string}) => ReactNode
    Children, which is a function that receives an item and returns a ReactNode.
    dataiOSAndroidHarmony
    TypeSortableData<T>[]
    The data for the sortable list.
    debugLogiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Display debug logs. Open it when you find a bug.
    enableSortingiOSAndroidHarmony
    Typeboolean·Defaulttrue
    Whether to enable sorting.
    onSortEndiOSAndroidHarmony
    Type(sortedData: SortableData<T>[]) => void
    Callback function that is triggered when sorting ends. The parameter is the sorted data.
    onSortStartiOSAndroidHarmony
    Type() => void
    Callback function that is triggered when sorting starts.
    scrollableBoundaryIdiOSAndroidHarmony
    Typestring
    The unique id of a scrollable boundary container. When the dragged item reaches the edge of this container, Sortable will call scrollBy on it so the list can continue moving with the drag direction.
    scrollableClassNameiOSAndroidHarmony
    Typestring
    Class name applied to the owned scroll-view when as is 'ScrollView'.
    scrollableContentClassNameiOSAndroidHarmony
    Typestring
    Class name applied to the owned content boundary view when as is 'ScrollView'.
    scrollableEnableScrolliOSAndroidHarmony
    Typeboolean·Defaulttrue
    Whether the owned scroll-view can be scrolled by user gestures.
    scrollableStickyLowerOffsetiOSAndroidHarmony
    Typenumber·Default0
    Distance between the dragged item and the lower edge of the owned or configured scrollable boundary while auto-scrolling downward.
    scrollableStickyUpperOffsetiOSAndroidHarmony
    Typenumber·Default0
    Distance between the dragged item and the upper edge of the owned or configured scrollable boundary while auto-scrolling upward.

    SortableItem

    The item inside Sortable.

    asiOSAndroidHarmony
    TypeDraggable | DraggableRoot·Default'Draggable'
    Specifies the underlying component to be used.
    childreniOSAndroidHarmony
    TypeReactNode
    Children.
    classNameiOSAndroidHarmony
    Typestring
    className
    disablediOSAndroidHarmony
    Typeboolean·Defaultfalse
    Whether this item is locked from sorting. A disabled item: - Cannot be dragged itself. Touch / long-press gestures are not bound on it, so interacting with it never starts a sort operation. - Cannot be displaced by other items being dragged. It always stays at its current position. - Always keeps its absolute position in the final sorted order. Other items can still freely cross over it; only the relative order of non-disabled items can change. Note that this only affects the disabled item itself. Other (non-disabled) items keep their full interactivity.
    sortingKeyiOSAndroidHarmony
    Typestring
    The unique key for sorting.

    Supporting Types

    SortableData

    The data structure for each item in the Sortable component.

    dataItemiOSAndroidHarmony
    TypeT
    The original data item.
    getSortingKeyiOSAndroidHarmony
    Type() => string
    A function that returns the unique key for sorting.
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.