dioxus-mosaic
A React-Mosaic-style tiling window manager library for Dioxus applications.
Demo

Features
- ⚡ HashMap-based architecture - O(1) operations for smooth 60 FPS performance
- 📐 Binary splits - Simple, proven pattern (like VSCode, Sublime)
- 🎯 Resizable dividers - Drag to resize panes smoothly
- ✂️ Dynamic splitting - Split any tile horizontally or vertically
- 🎮 Panel controls - Close tiles, collapse/expand
- 💾 LocalStorage persistence - Layout survives page reloads
- 🏗️ Clean builder API - Easy-to-use tree-like configuration
- 🎨 Drag-and-drop - Reorder tiles by dragging
Quick Start
Add to your Cargo.toml:
[]
= "0.1.0"
Basic Example
use *;
use ;
Run the example:
Architecture
Why HashMap?
Performance matters: When you drag a divider, hundreds of events per second need O(1) lookups.
| Operation | Tree (React-Mosaic) | HashMap (dioxus-mosaic) |
|---|---|---|
| Find tile | O(n) | O(1) |
| Update split % | O(n) | O(1) |
| Split tile | O(n) | O(1) |
Result: 100x faster for runtime operations while maintaining a clean tree-like API for developers.
Binary Splits
We use binary splits (2 children per split) like VSCode, Sublime Text, and Emacs:
- ✅ Simpler resize UX (one divider affects exactly 2 panes)
- ✅ More flexible (nested splits can create any layout)
- ✅ Easier to implement and reason about
Want 3+ panes side-by-side? Just nest splits:
horizontal
.left
.right
.split
.build
Result: [A | B | C] ✓
Advanced Usage
Complex Layouts
let layout = horizontal
.left
.right
.split
.build;
Programmatic Control
// Access layout state
let mut layout = use_signal;
// Split a tile programmatically
let layout_clone = layout.clone;
let split_editor = move |_| ;
// Close a tile
let close_panel = move |_| ;
Persistence
Layout automatically persists to LocalStorage. Want custom storage?
// Save layout
let json = to_string?;
// Store in your backend, file, etc.
// Restore layout
let tree: MosaicNode = from_str?;
layout.set;
Examples
basic.rs- Simple 3-panel layout (sidebar, editor, terminal)advanced.rs- Complex multi-panel layout with all features
Run examples:
# Simple example
# Advanced example
Features Roadmap
v0.1.0 (Current) ✅
- HashMap-based layout with O(1) operations
- Binary splits (horizontal/vertical)
- Resizable dividers
- Dynamic splitting and closing
- LocalStorage persistence
- Drag-and-drop tile reordering
- Clean builder API
v0.2.0 (Planned)
- Undo/Redo with keyboard shortcuts
- Themes and custom styling
- Layout templates
- Comprehensive documentation
Future
- Floating panels (detach from grid)
- Tab groups (multiple tiles in one pane)
- Custom tile widgets (progress bars, badges)
Performance
Optimized for real-time interaction:
- < 16ms frame time (60 FPS) even during drag operations
- O(1) HashMap lookups for all runtime operations
- Zero-cost abstractions with Rust
API Documentation
Full API documentation available at docs.rs/dioxus-mosaic.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT - See LICENSE for details.
Real-World Usage
Using dioxus-mosaic in your project? Open a PR to add it here!
Acknowledgments
Inspired by:
- react-mosaic-component - The original React implementation
- VSCode's split view system
- Sublime Text's pane management
Built with ❤️ using Dioxus