Skip to content

Handle

With Handle=".handle" a row can only be dragged by grabbing the handle icon. The rest of the row keeps its normal pointer behaviour: its text can be selected, its inputs focused and typed into, its buttons clicked.

A drag handle

Handle is a CSS selector, matched inside each item. Press anywhere else on a row and nothing is dragged - select its text instead.

☰Item 1
☰Item 2
☰Item 3
☰Item 4
☰Item 5
☰Item 6

Order: Item 1, Item 2, Item 3, Item 4, Item 5, Item 6

Rows with controls

Where a handle earns its place: rows that hold controls. Each step of this checklist is an input you can click into and edit, with a checkbox to tick - and the grip on the left reorders the steps.

☰
☰
☰
☰

Steps: Pack the tent, Check the weather ✓, Fill the water bottles, Charge the torch

Try it

  • Drag a row of the first list by its body: nothing moves, and the text can be selected. Drag it by ☰: it sorts.
  • In the checklist, click into a step and edit it, tick its box, then reorder it by ☰ - the edit and the tick travel with it, because they live in the item.
  • From the keyboard nothing changes: Tab to a row (not to the input inside it) and Space picks it up. Keys pressed inside the input are the input's - Space types a space.
  • On a touch screen a handle still needs the long press; the touch page shows a handle that drags at once.

How it works

  • With a Handle, items render as not draggable. Pressing an element that matches the selector makes its item draggable for the drag that follows; the next press starts from undraggable again.
  • The list's container gets the bit-bortable-has-handle class, which the stylesheet uses to take the grab cursor and the no-select rule off the rest of the item. Give the handle its own grab cursor.
  • A handle belongs to the item it sits in: in nested lists, a handle of an inner list's item never drags the outer item around it.
  • An invalid selector does not break the page: the browser layer warns once in the console, and no item drags.
  • For a handle that a keyboard user reaches as well, make it a <button type="button"> with an accessible name: it picks its item up too.

Parameters on this page

ParameterHereWhat it does
Handle.handleThe CSS selector of the element, inside each item, that starts a drag.
ItemLabels => s.TextHow announcements name a step: by its text, as it is now.
AriaLabelChecklistThe list's accessible name.
An unhandled error has occurred. Reload 🗙