Skip to main content

DragOverlay

Function DragOverlay 

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

Renders its children pinned to the pointer while a drag is in flight - a custom “ghost” that follows the cursor.

Extra attributes (class, …) are forwarded to the wrapper div, so the ghost styles directly - e.g. Tailwind class: "rotate-3 scale-105 shadow-xl". A forwarded style is merged after the functional positioning rather than replacing it.

With settle: true, a successful pointer drop doesn’t vanish the ghost: it glides from the release point until its center meets the receiving zone’s center, then unmounts - the drop-settle animation. During the glide the drag context is settling: dragging() is already false (zones have unlit), but payload() stays readable so the ghost keeps its content. The glide honors prefers-reduced-motion via data-dnd-motion (it snaps near-instantly, and cleanup still runs because transitionend still fires). Cancelled drags and keyboard drops never settle.

Note: the ghost follows the shared context’s pointer position, which pointer drags update on every move. Keyboard drags carry no pointer, so during one the ghost sits at the viewport origin - check dnd.mode() and skip rendering it if that matters to you.

§Props

For details, see the props struct definition.

  • phantom : std::marker::PhantomData<T>

    Internal marker; never set this.

  • settle : bool

    Glide the ghost into the receiving zone on drop instead of vanishing. Off by default.

  • duration : f64

    Settle transition duration in milliseconds.

  • easing : String

    CSS easing function for the settle glide.

  • attributes : Vec<Attribute>
  • children : Element