Skip to content

Handles

Rows dragged only by their grip, while the rest of each row stays clickable

A handle is the part of an item that starts the drag: the six dots of a row, the title bar of a window or of a node. The rest of the item keeps working as usual: buttons, inputs, links and text selection.

def row(self, field):
return pz.row([
pz.drag_handle(pz.icon("grip-vertical")), # drag from here
ui.input(field["label"], lambda v: self.rename(field, v)),
ui.button("Delete", lambda: self.remove(field)),
], spacing=8)
pz.sortable(items=self.fields, item=self.row, id="form", handle=True, on_reorder=self.reorder)
  • handle=True on a pz.draggable or a pz.sortable makes it start only from a pz.drag_handle inside each item.
  • pz.drag_handle(content, cursor="grab") shows the cursor when hovered ("grab", "move", "pointer"…).

Without handles, presses on buttons and inputs inside an item are theirs and don’t start a drag. from_children=True changes that.

The draggable options limit how an item moves:

pz.draggable(thumb, "thumb", axis="x", bounds="parent") # a slider's thumb
pz.draggable(clip, clip.id, axis="x", grid=24) # a timeline clip, in steps
pz.sortable(..., direction="horizontal", lock_axis=True) # tabs: sideways only, inside the bar
pz.sortable(..., delay=250) # long press: the list can still scroll by touch