Skip to main content

GridItem

GridItem is the placement wrapper for one child inside a Grid.

It tells the grid where that child starts and, optionally, how many tracks it spans. Use it when the layout has named or explicit rows and columns and placement matters.

Use GridItem together with Grid. Do not use it for simple wrapping galleries or equal-width card layouts. Those are often better handled by SimpleGrid or Wrap.

Example

use fission::core::ui::{GridItem, Text};

let card = GridItem::new(Text::new("Revenue").into_node())
.cell(1, 1)
.span(1, 2)
.into_node();

This places the item at row 1, column 1, and spans two columns.

Field table

FieldTypeMeaningNotes / default behavior
idOption<NodeId>Stable node identity.Defaults to None.
childBox<Node>The content placed inside the grid.Required.
row_startGridPlacementStarting row placement.Defaults to GridPlacement::Auto.
row_endGridPlacementEnding row placement or row span.Defaults to GridPlacement::Auto.
col_startGridPlacementStarting column placement.Defaults to GridPlacement::Auto.
col_endGridPlacementEnding column placement or column span.Defaults to GridPlacement::Auto.

Placement behavior

The convenience helpers are the easiest way to use this type.

cell(row, col) sets the starting row and column using 1-indexed grid lines.

span(row_span, col_span) sets the ending placement as a span value.

If you omit placement, the grid can auto-place the item. That is convenient for simple cases, but explicit placement is usually clearer when you chose Grid in the first place.

Specific advice

Reach for GridItem when placement is part of the design, not just part of implementation detail. If you find yourself assigning every item a row and column only to simulate a simple responsive gallery, the layout probably wants SimpleGrid instead.

Grid, SimpleGrid, and Wrap.