FragiolaDnD
Documentation
Concepts

State attributes and inline style

Every state a wrapper has is a data-dnd attribute on your element, present or absent, and the only inline style it writes is structural.

A wrapper exposes its state on the element it wraps, as data-dnd-* attributes and ARIA. A boolean attribute is present (empty) or absent, never "false". The names are namespaced, so wrapping another primitive never collides with its own attributes (Dockable's data-dragging, Grid Layout's data-dragging).

Parts and ids

Every element a wrapper touches carries data-dnd-part: draggable, handle, droppable, overlay, sortable, sortable-group or swappable. A draggable, a droppable, a sortable and a swappable item also carry data-dnd-id, the id they were given (as a string); a SortableGroup carries its group there. Stacked wrappers list their parts (data-dnd-part="draggable droppable"; select with [data-dnd-part~="droppable"]). Tests and tooling select by them, never by class names.

States

attributeonwhen
data-dnd-draggingdraggable, sortable, swappable, its handleit is the source of the drag in progress
data-dnd-disableddraggable, sortable, swappable, its handle, droppable, sortable groupdisabled is set
data-dnd-handlehandlealways: it is a drag handle
data-dnd-activedroppablea drag runs that this droppable would accept (its scope, its accepts)
data-dnd-overdroppablean accepted source hovers it, and no drop middleware vetoes it
data-dnd-refuseddroppablea source hovers it that its accepts, or a drop middleware, refuses
data-dnd-sortingsortable, sortable groupits group takes part in a sort in progress: the source's group, or one that accepts it
data-dnd-swap-targetswappableit is the item the drag would swap with now; written by the core, never rendered
aria-disabled="true"draggable, sortable, swappable, its handle, droppable, sortable groupdisabled is set
aria-describedbydraggable, sortable, swappable, handleonly when the app passes describedBy

A droppable is never both over and refused. A refused hover never reports onDrop. data-dnd-sorting is rendered by React at a sort's start and end only; data-dnd-swap-target is written by the core with the target's shift, so a swap preview commits nothing.

The same state in functions

className and style take a value or a function of the state, and so does render:

column.tsx
<Droppable id="done" className={(state) => (state.refused ? "column column-refused" : "column")}>
    <section aria-label="Done" />
</Droppable>
partstate
Draggable, DragHandle{ dragging, disabled }
Droppable{ over, active, refused, disabled }
Sortable{ dragging, sorting, disabled }
SortableGroup{ sorting, disabled }
Swappable{ dragging, disabled }
DragOverlay{ operation }: the drag it shows

Inline style is structural only

The packages ship no CSS. The only inline style they write:

styleonwhy
translatethe dragged element, during a dragit follows the pointer; the CSS translate property, never transform, so it composes with a host that owns transform
translatea sort's shifted items, a swap's targetthe preview: each moved from its box at rest, never a DOM move
touch-action: nonea drag handlea touch on the handle drags, never scrolls
position: fixed, left, top, width, height, box-sizing, pointer-events: noneDragOverlay's boxit sits where the dragged box is, inert to the pointer

translate is written once per animation frame at most, and cleared after your onDrop and onDragEnd run, back to the inline value the element had. A draggable with translate={false} is never moved. Everything else, the look of a dragged item, the placeholder, the cursor, the z-index and the transitions, is yours.

Styling showcase
Gallery