Components / Layout & organisation

Floating panel

Markdown crates/ui/src/floating.rs docs.rs

Floating panel

Ask your agent

Install the bezel skill once

npx skills add crabtalk/bezel --skill bezel

Then ask

Show a small FPS meter floating over the page that I can drag anywhere.
use ui::floating::{self, Floating};

// self.meter: Floating, built with Floating::new(Painter::of(cx))
div().relative().size_full()
    .child(page)
    .child(floating::panel("meter", &self.meter, home, meter))
  • Mount it in a relative() container; it lays a layer over that container's whole box.
  • Pass home every render. The panel sits there until first dragged.
  • Nothing is clamped or persisted. Read at() and hand it back with move_to to keep a position across launches.
  • held() and dragging() tell a press from a move, for a grab cursor or a lift.