Hadrone
A responsive, draggable/resizable grid system for Rust, inspired by react-grid-layout. The spatial engine is deterministic headless Rust (hadrone-core); UI integrations cover Dioxus 0.7, Leptos, Yew, and vanilla JS via WebAssembly.
Key features
- Shared engine: Compaction, collision handling, pointer/session math, and optional validation live in
hadrone-core(no DOM types in core). - Framework crates:
hadrone-dioxus,hadrone-leptos,hadrone-yewwith aligned drag/resize behavior; Dioxus also exposes structuredLayoutEventlifecycle hooks (on_layout_event,emit_interaction_updates). - Compaction:
CompactionType::Gravity(vertical “rising tide”) andFreePlacement. - Collisions: Pluggable
CollisionStrategy(PushDowndefault,Noneto skip displacement until compaction). - Layout model:
LayoutItemsupports min/max size, optional aspect ratio (width/height),is_static, and separateis_draggable/is_resizable(RGL-style). - Import/export:
validate_layout,repair_layout, and responsivescale_layout_cols/select_breakpointfor breakpoint changes. - Extras:
hadrone-extrasprovides storage adapters and responsive breakpoint helpers (e.g. web + Dioxus).
Architecture
| Crate | Role |
|---|---|
hadrone-core |
Grid math, LayoutEngine, InteractionSession, validation, responsive helpers, LayoutEvent types |
hadrone-dioxus |
GridLayout / GridItem for Dioxus 0.7 |
hadrone-leptos |
GridLayout for Leptos |
hadrone-yew |
GridLayout for Yew |
hadrone-wasm |
JS bindings (GridEngineWasm) for vanilla front ends |
hadrone-extras |
Persistence (LayoutStorage), BreakpointConfig, debounced save |
packages/ui |
Shared dashboard CSS and UI helpers used by web/desktop |
Getting started
Dioxus (dashboards and packages/web)
Leptos
Yew
Vanilla JS (WASM)
Build bindings into examples/vanilla-js/pkg/, then serve only examples/vanilla-js (see examples/vanilla-js/README.md):
&&
Open http://localhost:8083.
Minimal usage (Dioxus)
GridLayout requires margin, compaction, and render_item (other props have defaults such as container_padding, collision_strategy).
use *;
use ;
use GridLayout;
Minimal usage (Leptos)
use CompactionType;
use GridLayout;
use *;
Interaction model
During drag/resize, the core InteractionSession tracks sub-pixel movement and snaps grid updates from deltas, so the live element can stay smooth while the committed layout stays grid-aligned. container_padding on the session matches CSS padding on the grid container when you need pixel-aligned overlays.
License
MIT / Apache-2.0