use fission::prelude::*;
const PRODUCT_CARD_MIN_WIDTH: f32 = 220.0;
let (_ctx, view) = fission::build::current::<CatalogState>();
let spacing = &view.env().theme.tokens.spacing;
let widget: Widget = Grid {
columns: vec![GridTrack::auto_fit(GridTrack::minmax(
GridTrack::Points(PRODUCT_CARD_MIN_WIDTH),
GridTrack::Fr(1.0),
))],
rows: vec![GridTrack::Auto],
column_gap: Some(spacing.l),
row_gap: Some(spacing.l),
children: cards
.iter()
.map(|card| GridItem::new(ProductCard { card }).into())
.collect(),
..Default::default()
}
.into();
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | Option<WidgetId> | Stable widget identity. | Defaults to None. |
children | Vec<Widget> | Grid children, usually GridItem nodes. | Defaults to an empty list. |
columns | Vec<GridTrack> | Column track definitions. | Defaults to an empty list, so define these explicitly in real layouts. |
rows | Vec<GridTrack> | Row track definitions. | Defaults to an empty list. |
column_gap | Option<f32> | Horizontal gap between columns. | Defaults to None. |
row_gap | Option<f32> | Vertical gap between rows. | Defaults to None. |
padding | [f32; 4] | Inner padding in [left, right, top, bottom] order. | Defaults to [0.0; 4]. |
Track type | Meaning | When to use it |
|---|---|---|
GridTrack::Points(x) | Fixed track size in layout points. | Use for known fixed rails such as headers or side gutters. |
GridTrack::Percent(x) | Track as a percentage. | Use when the design is explicitly percentage-based. |
GridTrack::Fr(x) | Fractional remaining space. | Use for most flexible dashboard-style layouts. |
GridTrack::Auto | Size from content and constraints. | Good for content-driven tracks. |
GridTrack::MinContent / MaxContent | Content-based intrinsic sizing. | Use only when you intentionally want intrinsic track behavior. |
GridTrack::minmax(min, max) | Track constrained between two track definitions. | Use for responsive cards that should never shrink below a readable size. |
GridTrack::repeat(count, tracks) | Fixed repeated track list. | Use for regular grids with a known number of columns or rows. |
GridTrack::auto_fit(track) | Repeat a track up to the available space and collapse empty tracks. | Use for responsive product or card grids. |
GridTrack::auto_fill(track) | Repeat a track up to the available space and keep empty tracks. | Use when empty slots should still reserve grid space. |