Skip to main content

TreeNodeTarget

Function TreeNodeTarget 

Source
pub fn TreeNodeTarget<T: Clone + PartialEq + 'static>(
    _: TreeNodeTargetProps<T>,
) -> Element
Expand description

A single tree row that acts as a drop target with intent detection.

The payload type T travels through the shared DndContext<T> (use the core Draggable on your rows to start drags). While a pointer drag (mouse, touch, pen) hovers, the wrapper carries data-intent="before" | "after" | "into" for styling insertion indicators. The attribute is absent when not hovered, so both value selectors (Tailwind data-[intent=into]:bg-blue-50) and presence selectors (data-intent:outline) work.

Every target also registers itself in the shared zone registry, which is what makes it reachable by pointer hit-testing and keyboard navigation. Keyboard drops land with Into intent (the row’s center band). At the registry level a target accepts a payload if your accepts passes for any intent; the exact intent is re-checked at drop time.

§Props

For details, see the props struct definition.

  • node : NodeId

    The node this row represents.

  • row_height : f64

    Height of the row in pixels, used for the before/into/after bands. Keep this close to the actual rendered row height: keyboard drops resolve their intent from the measured row center against this value, so a large mismatch (e.g. wrapped/custom content taller than the default) can bias a keyboard drop toward After/Before instead of Into.

  • accepts : Option<Callback<(T,DropIntent),bool>>

    Reject drops (typically: cycle prevention). Receives (payload, intent).

  • on_drop : EventHandler<TreeDropEvent<T>>
  • label : Option<String>

    Announced to screen readers during keyboard navigation.

  • attributes : Vec<Attribute>
  • children : Element