Expand description
2D Grid layout system for dashboard-style positioning.
Grid provides constraint-based 2D positioning with support for:
- Row and column constraints
- Cell spanning (colspan, rowspan)
- Named areas for semantic layout references
- Gap configuration
§Example
use ftui_layout::grid::Grid;
use ftui_layout::Constraint;
use ftui_core::geometry::Rect;
// Create a 3x2 grid (3 rows, 2 columns)
let grid = Grid::new()
.rows([
Constraint::Fixed(3), // Header
Constraint::Min(10), // Content
Constraint::Fixed(1), // Footer
])
.columns([
Constraint::Percentage(30.0), // Sidebar
Constraint::Min(20), // Main
])
.row_gap(1)
.col_gap(2);
let area = Rect::new(0, 0, 80, 24);
let layout = grid.split(area);
// Access cell by (row, col)
let header_left = layout.cell(0, 0);
let content_main = layout.cell(1, 1);Structs§
- Grid
- A 2D grid layout container.
- Grid
Area - Definition of a named grid area.
- Grid
Layout - Result of solving a grid layout.