Fusuma

Components / Layout

grid

cols columns of equal width, each row as tall as its tallest cell (give it .width(Length::Fill(1)) or a fixed width; the gap is between cells and between rows): a launcher, a settings grid, a keypad.

Try it

This is the Foundations page of the gallery, running in your browser: grid is on it, and it is the real widget. Press Run, then use it.

Live: Foundations, where grid is usedOpen full size

Also on this pagesectionwrapcardradioparagraph

cols columns of equal width, each row as tall as its tallest cell (give it .width(Length::Fill(1)) or a fixed width; the gap is between cells and between rows): a launcher, a settings grid, a keypad. A cell with no width of its own fills its column; one with a width keeps it, at the start of the column unless .justify_self(..) (or the grid's .justify_items(..)) says otherwise.

Signature

pub const fn grid<C>(cols: u8, children: C) -> Row<C>

Methods

  • .elevation(level: fusuma_ui::Elevation) -> Self — How far this lifts off the page (see elevated).
  • .padding(px: u32) -> Self — Room around the children, in pixels.
  • .gap(px: u32) -> Self — Room between the children, in pixels.
  • .width(length: Length) -> Self — The width.
  • .height(length: Length) -> Self — The height.
  • .align(align: CrossAlign) -> Self — How the children line up across the axis.
  • .min_size(w: u16, h: u16) -> Self — The least width and height (0 for none).
  • .max_size(w: u16, h: u16) -> Self — The most width and height (0 for none).
  • .margin(px: u8) -> Self — Room around this container, outside its box.
  • .justify(justify: fusuma_ui::Justify) -> Self — How the children spread along the axis when there is room left over.
  • .padding_sides(left: u8, top: u8, right: u8, bottom: u8) -> Self — Padding on each side instead of the same on all: left, top, right and bottom.
  • .margin_auto(left: bool, top: bool, right: bool, bottom: bool) -> Self — auto margins on the sides that are true (left, top, right, bottom): along the flow they take the room left over, across it they centre the child or put it at the far edge.
  • .rows(rows: Track) -> Self — Rows of a grid that are all rows tall: Track::fixed(px), or Track::fill(1) to share the height of the grid equally.
  • .min_percent(w: u8, h: u8) -> Self — A least width and height that are a percent of the room inside the parent (0 leaves a side as it is): CSS min-width: 30%.
  • .max_percent(w: u8, h: u8) -> Self — A most width and height that are a percent of the room inside the parent (0 leaves a side as it is): CSS max-width: 80%.
  • .min_content() -> Self — This child does not shrink below what its content asks for along the flow of its container (CSS min-width: auto).
  • .align_content(how: fusuma_ui::Justify) -> Self — Where the lines of a wrapping flow sit when it is taller than they are (CSS align-content).
  • .snap() -> Self — A scroll area that comes to rest with the top of a child at its top (CSS scroll-snap-type: y mandatory).
  • .dense() -> Self — A grid whose children each take the first place from the top left where they fit (CSS grid-auto-flow: row dense): a small one fills a hole an earlier row left.
  • .sticky_bottom() -> Self — Stays at the bottom of the scroll area it is in (CSS position: sticky; bottom: 0).
  • .sticky() -> Self — Stays at the top of the scroll area it is in (CSS position: sticky; top: 0).
  • .reverse() -> Self — The children run from the end (CSS row-reverse / column-reverse).
  • .width_min_content() -> Self — A paragraph or flow with no width of its own is as narrow as it can be (CSS width: min-content): a paragraph is as wide as its longest word.
  • .width_max_content() -> Self — A paragraph or flow with no width of its own is as wide as it can be (CSS width: max-content): not wrapped.
  • .width_fit_content(limit: u16) -> Self — CSS width: fit-content(limit): wrapped at limit pixels or the room it is given, whichever is less.
  • .safe() -> Self — Center and End across the flow never go past the start edge when the children do not fit (CSS safe center).
  • .first_row(first_row: Track) -> Self — A first row of its own in a grid (a header): Track::fixed(px).
  • .row_gap(gap: u32) -> Self — A gap between the lines of a wrap or the rows of a grid that differs from the one between the children in a line.
  • .basis(basis: u16) -> Self — The size this container starts from, along its parent's axis, before it takes its share of the room left (when it fills).
  • .row_span(rspan: u8) -> Self — How many rows of a grid this container covers.
  • .span(span: u8) -> Self — How many columns of a grid this container covers.
  • .pin(corner: fusuma_ui::Pin, x: i16, y: i16) -> Self — Takes this container out of its parent's flow and pins it x across and y down from corner of the parent.
  • .shrink(shrink: u8) -> Self — How much this container gives up when its parent's children do not fit (0: nothing).
  • .aspect(w: u16, h: u16) -> Self — A width-to-height ratio: the side without a length of its own follows the other.
  • .align_self(align: fusuma_ui::SelfAlign) -> Self — Where this container sits across its parent's axis, if not where the parent puts its children.
  • .justify_self(align: fusuma_ui::SelfAlign) -> Self — Where this container sits across its grid cell, if not where the grid puts its children (CSS justify-self).
  • .justify_items(align: fusuma_ui::SelfAlign) -> Self — Where the children of this grid sit in their cells (CSS justify-items).
  • .background(surface: Surface) -> Self — A background.
  • .round(round: fusuma_ui::Round) -> Self — How round the corners of the background are.

Example

use fusuma::{Length, grid, text};
let view = grid(2, (text("a"), text("b"), text("c"), text("d"))).width(Length::Fixed(200)).gap(8);
let built = fusuma::doc::built::<(), _>(&view);
assert_eq!(built.texts(), ["a", "b", "c", "d"]);

All components · Source