Sortable

Your array, reordered — dragged by mouse, touch or pen, or lifted and moved by the keyboard, each step announced in your words; a list, a row, a grid, or items carried between linked lists.

AdvancedExperimental

Usage

Usage

Space lifts an item, the arrow keys move it, Space drops it, Escape puts it back.

  • Customer support
  • Performance
  • Accessibility
  • New features
  • Documentation

Customer support, Performance, Accessibility, New features, Documentation

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScSortable,  type ScSortableAnnouncement,  ScSortableItem,} from '@semantic-components/ui';
interface Item {  readonly id: string;  readonly label: string;

Anatomy

The list on your element, an item for each of yours (rendered from items(): while one is moved, the moving order), an optional handle. Linked lists sit in a group, which holds them all.

import { ScSortable, ScSortableGroup, ScSortableHandle, ScSortableItem } from '@semantic-components/ui';
<ul scSortable #list="scSortable" [(value)]="items" [announce]="announce" aria-label="Priorities">  @for (item of list.items(); track item.id) {    <li [scSortableItem]="item" aria-describedby="help">      <span scSortableHandle>…</span> {{ item.label }}    </li>  }</ul>
<div scSortableGroup #board="scSortableGroup" [(value)]="board">  <ul [scSortable]="'todo'">@for (task of board.items('todo'); …) { … }</ul></div>

Moving

  • Mouse and pen: a press that moves a few pixels drags; touch: a press held a moment, then moved (a quick swipe scrolls). The item follows the pointer; near the list's edges, it scrolls. A press on the item's buttons, links or fields is theirs; with a handle, only the handle drags.
  • The others make room, gliding to their new places (150ms, as dnd-kit); dropped, the item shows it a moment (Atlassian's flash). Neither under reduced motion. The looks are the style's (sortable).
  • The value is replaced on the drop — a new array, your items untouched. move(item, index) moves one at once: for Move up / Move down buttons, the way that needs neither a drag nor the keys.
  • orientation: vertical, horizontal (a row, as the text reads), or grid (your columns).

Keyboard

  • Space or Enter lifts the focused item; again, drops it. Escape puts it back.
  • Lifted, the arrows move it — ↑ ↓ down a list, ← → along a row (as the text reads), by one and by a row in a grid, across lists in a group; Home / End to the start and the end.

Accessibility

  • Each item is a Tab stop; describe the keys once (aria-describedby). Name each list.
  • announce puts each keyboard step into your words — positions, not indexes ("Dropped Performance at 2 of 5"); the library writes none.
  • Offer move() in buttons too: some can neither drag nor lift.

Examples

Handle

Space lifts an item, the arrow keys move it, Space drops it, Escape puts it back.

Write the outline, Draft the introduction, Collect the figures, Ask for a review

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScCheckbox,  ScField,  ScLabel,  ScSortable,  type ScSortableAnnouncement,  ScSortableHandle,  ScSortableItem,} from '@semantic-components/ui';

Horizontal

Space lifts an item, ← → move it, Space drops it, Escape puts it back.

  • Plan
  • Design
  • Build
  • Test
  • Ship

Plan, Design, Build, Test, Ship

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScSortable,  type ScSortableAnnouncement,  ScSortableItem,} from '@semantic-components/ui';
interface Item {  readonly id: string;  readonly label: string;

Grid

Space lifts an item, ← → ↑ ↓ move it, Space drops it, Escape puts it back.

  • Café
  • Coast
  • Forest
  • Gorge
  • Mountains
  • Shed
  • Summit
  • Waterfall

Café, Coast, Forest, Gorge, Mountains, Shed, Summit, Waterfall

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScSortable,  type ScSortableAnnouncement,  ScSortableItem,} from '@semantic-components/ui';
interface Item {  readonly id: string;  readonly label: string;

Move buttons

Space lifts an item, the arrow keys move it, Space drops it, Escape puts it back.

  1. Opening theme
  2. Night drive
  3. Slow morning
  4. Last call

Opening theme, Night drive, Slow morning, Last call

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScButton,  ScSortable,  type ScSortableAnnouncement,  ScSortableItem,} from '@semantic-components/ui';import { SiArrowDownIcon, SiArrowUpIcon } from '@semantic-icons/lucide-icons';
interface Item {

Linked lists

Space lifts a card, the arrow keys move it, Space drops it, Escape puts it back.

To do 3

  • Write the release notes
  • Plan the next sprint
  • Update the dependencies

In progress 2

  • Design the settings page
  • Fix the login redirect

Done 1

  • Set up the CI
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScFrame,  ScSortable,  ScSortableGroup,  type ScSortableGroupAnnouncement,  type ScSortableGroupValue,  ScSortableItem,} from '@semantic-components/ui';

Disabled

Space lifts an item, the arrow keys move it, Space drops it, Escape puts it back.

  • First
  • Second
  • Third

First, Second, Third

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScField,  ScSortable,  type ScSortableAnnouncement,  ScSortableItem,  ScSwitch,} from '@semantic-components/ui';
interface Item {

RTL

المسافة ترفع عنصرًا، والأسهم ← → تحركه، والمسافة تضعه، وEscape يعيده.

  • التخطيط
  • التصميم
  • البناء
  • الاختبار
  • الإطلاق

التخطيط، التصميم، البناء، الاختبار، الإطلاق

import { Dir } from '@angular/cdk/bidi';import {  Component,  LOCALE_ID,  ViewEncapsulation,  computed,  signal,} from '@angular/core';import {  ScSortable,

API reference

Each part takes class, merged over its own.

PartSelectorDescription
ScSortable[scSortable] A list, a row or a grid. exportAs: items(), move(), active(), dragging(), lifted(), dropped().
ScSortableItem[scSortableItem] An item: dragged, lifted; data-dragging, data-lifted, data-dropped.
ScSortableHandle[scSortableHandle] Optional: only it starts a drag (decorative to screen readers).
ScSortableGroup[scSortableGroup] Linked lists: one value for all; items(key), move(item, key, index).
InputTypeDefaultDescription
valueT[][] Two-way: your items, in order (in a group, the group’s).
scSortablestring'' In a group: this list’s key.
orientation'vertical' | 'horizontal' | 'grid''vertical' How it is laid out, and so which arrows move.
announce(event) => string— Each keyboard step, in your words.
disabledbooleanfalse Shown, not moved; not Tab stops.