Drag Card
A floating card that can be dragged and closed. Used for movable panels.
Preview
Rendered in WASM — scroll may behave differently from the rest of the pageUsage
rust
use ui_theme::components::drag_card::{drag_card, DragCardState};
let mut state = DragCardState {
pos: egui::pos2(100.0, 100.0),
size: egui::vec2(250.0, 200.0),
};
let response = drag_card(ui, &theme, egui::Id::new("my_card"), &mut state, "Panel", |ui| {
ui.label("Drag me around!");
});
if response.closed {
// Handle close
} Props
| Prop | Type | Default | Description |
|---|---|---|---|
ui | &mut Ui | required | The egui UI context |
theme | &Theme | required | Theme instance |
id | Id | required | Unique widget ID |
state | &mut DragCardState | required | Position and size state |
title | &str | required | Card title |
add_contents | impl FnOnce(&mut Ui) | required | Card body content |
Response
| Field | Type | Description |
|---|---|---|
closed | bool | Close button was clicked |
dragging | bool | Card is being dragged |