Sortable

Sortable list for lit-material: reorder items by pointer, touch or keyboard, within a list or between lists, with screen reader announcements.

  • 3.4 KB gzipped
  • @lit-material/sortable 0.2.2
  • Renders on the server

Example

Install

npm install @lit-material/sortable @lit-material/tokens
import "@lit-material/sortable";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-sortable>

Lets people reorder a list: by dragging a handle with a mouse, pen or finger, or from the keyboard — focus a handle, Space (or Enter) picks the item up, ↑/↓ move it, Space drops it and Escape puts it back. Each step is announced to screen readers.

Properties

PropertyAttributeTypeDefaultDescription
groupgroupstring""Lists with the same group accept each other's items. Empty: this list only.
labellabelstring""Names the list in announcements, e.g. "Requests".
disableddisabledbooleanfalse
layoutlayoutSortLayout"list"list: one item per row. grid: items in rows (a card grid, wrapping chips, one horizontal row).
announcementproperty onlystring""The last announcement, also read by tests.
itemsproperty onlyHTMLElement[]noneThe items, in order.

Events

EventDescription
sortWhen an item is dropped somewhere new; detail is SortDetail.

Slots

SlotDescription
defaultThe items.

CSS custom properties

PropertyDescription
--lit-material-sortable-indicator-colorThe drop line (default --md-sys-color-primary).

Source on GitHub npm