Drag and Drop
A web component implementation of a HTML Drag and Drop API.
The user may select draggable elements with a mouse, drag those elements to a droppable element, and drop them by releasing the mouse button. A translucent representation of the draggable elements follows the pointer during the drag operation.
Example
Usage examples
Nested drag & drop
This example demonstrates how to nest multiple FluentDragContainer
components to enable drag-and-drop interactions across hierarchical structures such as rows, columns, and elements.
The key to making this multi-level drag-and-drop system work is the use of the StopPropagation
property. By enabling it where appropriate, each nested FluentDragContainer
can handle drag events independently-preventing unintended interference from parent containers.
Each level supports independent drag behavior:
- Rows can be reordered vertically.
- Columns can be moved within the same row or between different rows.
- Elements can be rearranged inside a column or moved across columns.
Documentation
FluentDragContainer<TItem> Class
Parameters
Name | Type | Default | Description |
---|---|---|---|
ChildContent | RenderFragment? | Gets or sets the content to be rendered inside the component. | |
OnDragEnd | Action<FluentDragEventArgs<TItem>>? | This event is fired when the drag operation ends (such as releasing a mouse button or hitting the Esc key). | |
OnDragEnter | Action<FluentDragEventArgs<TItem>>? | This event is fired when a dragged element enters a valid drop target. | |
OnDragLeave | Action<FluentDragEventArgs<TItem>>? | This event is fired when a dragged element leaves a valid drop target. | |
OnDragOver | Action<FluentDragEventArgs<TItem>>? | This event is fired when an element is being dragged over a valid drop target. | |
OnDragStart | Action<FluentDragEventArgs<TItem>>? | This event is fired when the user starts dragging an element. | |
OnDropEnd | Action<FluentDragEventArgs<TItem>>? | This event is fired when an element is dropped on a valid drop target. |
FluentDropZone<TItem> Class
Parameters
Name | Type | Default | Description |
---|---|---|---|
ChildContent | RenderFragment? | Gets or sets the content to be rendered inside the component. | |
Draggable | bool | False | Gets or sets a value indicating whether the element can be dragged. |
Droppable | bool | False | Gets or sets a value indicating whether the element can receive a dragged item. |
Item | TItem? | Gets or sets the item to identify a draggable zone. | |
OnDragEnd | Action<FluentDragEventArgs<TItem>>? | This event is fired when the drag operation ends (such as releasing a mouse button or hitting the Esc key). | |
OnDragEnter | Action<FluentDragEventArgs<TItem>>? | This event is fired when a dragged element enters a valid drop target. | |
OnDragLeave | Action<FluentDragEventArgs<TItem>>? | This event is fired when a dragged element leaves a valid drop target. | |
OnDragOver | Action<FluentDragEventArgs<TItem>>? | This event is fired when an element is being dragged over a valid drop target. | |
OnDragStart | Action<FluentDragEventArgs<TItem>>? | This event is fired when the user starts dragging an element. | |
OnDropEnd | Action<FluentDragEventArgs<TItem>>? | This event is fired when an element is dropped on a valid drop target. | |
StopPropagation | bool | False | Gets or sets a way to prevent further propagation of the current event in the capturing and bubbling phases. |
FluentDragEventArgs<TItem> Class
Properties
Name | Type | Default | Description |
---|---|---|---|
Source | FluentDropZone<TItem> | Gets the zone where the drag started. | |
Target | FluentDropZone<TItem> | Gets the zone where the drag ended. |