Sortable API
import { Sortable } from '@editora/ui-react';
Props
| Prop | Type | Description |
|---|---|---|
allowFilteredDrag | boolean | |
allowNesting | boolean | |
canDrop | (info: SortableDropInfo) => boolean | Decides whether items may go somewhere; return false to refuse. Asked on every pointer move, so keep it quick. |
disabled | boolean | |
dragHandleMode | SortableDragHandleMode | |
dragHandleSelector | string | |
dragPreviewSize | SortableDragPreviewSize | |
dropIndicatorVisibility | SortableDropIndicatorVisibility | |
dropzoneStyle | SortableDropzoneStyle | |
filterQuery | string | |
group | string | Sortables with the same group can exchange items: drop a card on another one and both report it (change's external). Ids must be unique across the group. |
handleRadius | SortableRadius | |
hideToolbar | boolean | |
itemRadius | SortableRadius | |
items (required) | SortableItem[] | |
itemSpacing | SortableSpace | |
labels | SortableLabels | |
listGap | SortableSpace | |
listMaxHeight | number | string | The tallest the cards of a list can be before the list scrolls on its own: a number of px or a CSS length such as "20rem". A list's own maxHeight overrides it. |
lists (required) | SortableList[] | |
nestTrigger | SortableNestTrigger | |
onBeforeChange | (detail: SortableBeforeChangeDetail, event: Event) => boolean | void | Called just before a move is applied, with the result it would have. Return false (or call event.preventDefault()) to cancel it: nothing changes and onChange does not fire. |
onChange | (detail: SortableChangeDetail) => void | |
onItemsChange | (items: SortableItem[]) => void | |
onPersistRequest | (detail: SortableChangeDetail) => void | |
onSelectionChange | (detail: SortableSelectionChangeDetail) => void | |
pageStyles | boolean | renderItem / renderListHeader content is drawn inside the sortable's shadow root, where your CSS classes do not reach. pageStyles lets the page's stylesheets style it (they never override the sortable's own look). |
persistKey | string | |
renderEmptyState | (list: SortableList, context: SortableRenderEmptyStateContext) => React.ReactNode | |
renderItem | (item: SortableItem, context: SortableRenderItemContext) => React.ReactNode | |
renderListHeader | (list: SortableList, context: SortableRenderListHeaderContext) => React.ReactNode | |
selection | string[] | |
showSelectionBadge | boolean | |
sort | SortableSortMode | |
touchHoldDelay | number | Milliseconds a finger must rest on a card before it lifts (touch, dragging by the card). 0 lifts at once. Default 350. |
Also accepts the standard HTML and React props of the element it renders (className, style, id, aria-*, data-*, event handlers).
Element: <ui-sortable>
Sortable renders the ui-sortable custom element from @editora/ui-core, which can also be used without React.
Attributes: allow-filtered-drag, allow-nesting, custom-item-rendering, disabled, drag-handle-mode, drag-handle-selector, drag-preview-size, drop-indicator-visibility, dropzone-style, filter-query, group, hide-toolbar, items, labels, list-max-height, lists, nest-trigger, page-styles, persist-key, selection, show-selection-badge, sort, touch-hold-delay
Events: before-change, change, persist-request, selection-change