Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

drag-surface

Accessible drag-and-drop reorder surface with keyboard support, live region announcements, and cross-surface transfer.

Overview

The <drag-surface> component wraps the native HTML Drag and Drop API, adding keyboard accessibility, live region announcements for screen readers, and clean custom events. It supports both single-surface reorder and cross-surface transfer between surfaces that share a group attribute.

Children just need draggable="true" — the component handles all event wiring, state attributes for CSS, and ARIA management.

The surface is only as big as its content (with a small minimum block size). In a kanban column, give it flex: 1 in your own CSS (for example .board > section > drag-surface { flex: 1; }) so the whole column is a drop target, not just the space the cards occupy.

Attributes

On <drag-surface>

AttributeTypeDefaultDescription
group string — Transfer group. Items can move between surfaces that share the same group value.
orientation string "vertical" Set to "horizontal" to use Left/Right arrows and the inline axis for drop position. Both follow the computed direction, so they flip in RTL.
disabled boolean — Disables dragging out of, dropping into, keyboard reorder and move controls on this surface. Reflected as aria-disabled="true"; grouped surfaces skip it as a transfer target.
data-move-controls boolean — Renders per-item Move buttons: a single-pointer alternative to dragging. See Move controls.
data-label-instructions string "Press Space or Enter to grab, then use the arrow keys to move" Text of the aria-description set on each item, which tells screen reader users how to move it.

On Children

AttributeTypeDescription
draggable="true" boolean Native HTML — marks the element as draggable. Required.
data-id string Stable identifier for the item (survives reorder).
data-sort-order number Numeric position within the surface. Managed automatically on reorder.
data-drag-handle boolean If present on a descendant, only that element initiates the drag. If the handle is a focusable <button>, keyboard reorder works from it too and it gets aria-pressed while grabbed.

CSS State Attributes

The component manages visual state entirely through data attributes, keeping all styling in CSS.

AttributeSet OnWhen
data-dragging The dragged child During a mouse drag operation
data-drag-over The surface A dragged item is hovering over a valid drop target
data-drop-target="before|after" A child item Shows where the dragged item will be inserted
data-reorder-mode The surface During keyboard reorder (item is grabbed)
data-grabbed A child item Item is grabbed for keyboard reorder (its aria-description changes to “Grabbed” unless it has its own description)
aria-disabled="true" The surface Mirrors the disabled attribute
data-just-dropped A child item Briefly set after a drop (mouse or keyboard) to trigger a flash animation. Removed automatically after the animation ends.

Kanban Board

Link multiple surfaces with group to enable cross-surface transfer. Items can be dragged between any surfaces that share the same group value.

Move Controls

Dragging needs a press-and-move gesture, which WCAG 2.5.7 (Dragging Movements) says must have a single-pointer alternative. Add data-move-controls and each item gets small Move buttons: up/down (left/right for horizontal surfaces, flipped in RTL) and, for grouped surfaces, a button for each neighbouring surface. Every button’s accessible name includes the item label, for example “Move Export to CSV down” or “Move Export to CSV to This sprint”.

The buttons use the same move logic as dragging, so they fire the same drag-surface:reorder and drag-surface:transfer events. Focus stays on the button you pressed. At either end of the list the button is marked aria-disabled rather than disabled, so it keeps focus.

Name each surface with aria-label or aria-labelledby: the transfer buttons and announcements use that name. The buttons are added inside each item, in a [data-drag-surface-controls] wrapper you can style.

Drag Handles

Add data-drag-handle to a descendant element to constrain where the drag can be initiated. Only clicks on the handle start a drag — clicking other parts of the item does not.

Horizontal Layout

Set orientation="horizontal" to switch keyboard navigation to Left/Right arrows and use the inline axis for drop calculations. Both follow the computed direction: in a right-to-left context, ArrowLeft moves an item towards the end of the list, and the drop indicator is drawn on the inline-start or inline-end edge.

Events

EventDetailDescription
drag-surface:reorder {item, itemId, oldIndex, newIndex, order} Items within this surface were reordered (mouse, keyboard or move controls).
drag-surface:transfer {item, itemId, fromSurface, toSurface, newIndex, fromOrder, toOrder} An item moved between surfaces sharing a group. Fired on the receiving surface.
drag-surface:reorder-start — A drag or keyboard grab began.
drag-surface:reorder-end — A drag or keyboard grab ended (dropped, cancelled, or the drag was abandoned). For a pointer drag it fires on the source surface.

Keyboard Navigation

Keys are handled only when focus is on the item itself (or on its data-drag-handle button). Buttons, links and inputs inside an item keep their normal keyboard behaviour.

KeyAction
Space / Enter Grab the focused item (toggle). Press again to drop at current position.
ArrowUp / ArrowDown Move the grabbed item up/down (vertical orientation).
ArrowLeft / ArrowRight Move the grabbed item towards the start/end of the list (horizontal orientation; follows the reading direction), or transfer it to the grouped surface on that side (vertical orientation). Without a grab, arrows move focus between items.
Escape Cancel the reorder and return the item to its original position. Does not undo cross-surface transfers. Moving focus out of the grabbed item also cancels.

Keyboard Transfer

When surfaces share a group, grabbed items can move between them using the perpendicular arrow keys:

  • Vertical surfaces (default): ArrowLeft / ArrowRight transfer to the adjacent surface
  • Horizontal surfaces: ArrowUp / ArrowDown transfer to the adjacent surface

The arrow points at the surface on that side of the screen: for vertical surfaces ArrowRight moves to the surface physically to the right (in RTL as well), and horizontal surfaces use top-to-bottom order. Disabled surfaces are skipped. The item stays grabbed in the new surface. The transfer is committed immediately: Escape afterwards returns the item to where it landed in the new surface, not to the original surface.

After transfer, the item receives focus in the new surface and a data-just-dropped flash animation plays. The drag-surface:transfer event fires on the receiving surface.

Disabled State

Add disabled to the surface to turn it off: its items can’t be dragged, grabbed or moved, it rejects drops from other surfaces in its group, and move controls are marked aria-disabled. The surface gets aria-disabled="true" and drag handles lose the grab cursor.

Accessibility

ARIA Roles

The surface sets role="list" on itself and gives each draggable child role="listitem" and tabindex="0", including items added later. Each item also gets an aria-description that says how to move it (“Press Space or Enter to grab, then use the arrow keys to move”); set data-label-instructions on the surface to change or translate the text. An item that has its own aria-description or aria-describedby keeps it. Grab state is not exposed through the deprecated aria-grabbed. While an item is grabbed its description changes to “Grabbed”, a button handle gets aria-pressed="true", and every change is announced.

Every item is its own tab stop. That is deliberate: each item is a control you pick up and move, the same as a list of buttons, and separate tab stops let Tab reach the links, buttons and move controls inside each item. The arrow keys also move focus between items.

Live Region

A visually hidden role="status" region announces position changes during keyboard reorder (e.g., “Position 2 of 5”), grab/drop actions and move-control moves. It is inserted as the surface’s next sibling, not inside the list, so the list only contains list items.

Keyboard and Pointer Alternatives

Keyboard reorder covers keyboard and screen reader users: grab with Space/Enter, move with the arrow keys, drop with Space/Enter, cancel with Escape. It does not satisfy WCAG 2.5.7 Dragging Movements, which asks for a single-pointer alternative for people who can tap or click but can’t hold and drag. Add data-move-controls (or your own buttons that call into your data model) wherever reordering matters.

Reduced Motion

When prefers-reduced-motion: reduce is active, the stylesheet turns off the drop flash animation and the surface’s background transition.

Progressive Enhancement

LayerWhat WorksWhat’s Missing
HTML only Content is readable as a static list No interactivity
HTML + draggable Browser provides native drag ghost No drop handling, no keyboard support
HTML + <drag-surface> JS Full reorder, transfer, keyboard, optional move controls, live announcements No persistence (resets on reload)
HTML + JS + consumer code Consumer listens to events, persists order Full experience

Related

↑