use fission::prelude::*;
fission_component! {
pub DraggableCard<()> {
props {
card_id: String,
title: String,
open_card: ActionEnvelope,
}
}
view(card, _state, _cx) =>
Draggable(
id: WidgetId::explicit(&format!("board.card.{}", card.card_id)),
semantics_identifier: Some(format!("board.card.{}", card.card_id)),
payload: card.card_id.as_bytes().to_vec(),
child: Button(
child: Text(card.title.clone()),
on_press: card.open_card.clone(),
),
preview: Tag(label: card.title.clone()),
)
}
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | Option<WidgetId> | Stable identity for the drag source. | Use explicit IDs for reordered, filtered, or generated rows. |
semantics_identifier | Option<String> | Stable semantic/test identifier. | Lets tests and accessibility tooling identify the drag source. |
payload | Vec<u8> | Bytes attached to the drag. | Required. The reducer on the drop target decodes them from ctx.input.as_internal_drop(). |
child | Widget | Visible content that the user drags. | Required. |
preview | Option<Widget> | Optional drag avatar rendered near the pointer. | Defaults to None; provide id or semantics_identifier so the runtime can match the source during rebuilds. |
preview_options | DragPreviewOptions | Pointer offset and optional preview snapping. | Defaults to a small pointer offset and no snapping. |
on_drag_start | Option<ActionEnvelope> | Action fired when dragging begins. | Defaults to None. Useful for visual state such as highlighting the source item. |
on_drag_end | Option<ActionEnvelope> | Action fired when dragging ends. | Defaults to None, regardless of whether a target accepted the drop. |