pub struct Style {Show 24 fields
pub width: Dimension,
pub height: Dimension,
pub min_width: Dimension,
pub min_height: Dimension,
pub max_width: Dimension,
pub max_height: Dimension,
pub flex_grow: f32,
pub flex_shrink: f32,
pub flex_basis: Dimension,
pub flex_direction: FlexDirection,
pub justify: Justify,
pub align: Align,
pub align_content: AlignContent,
pub align_self: Option<Align>,
pub padding: Insets,
pub margin: Insets,
pub aspect_ratio: Option<f32>,
pub gap: f32,
pub row_gap: Option<f32>,
pub column_gap: Option<f32>,
pub flex_wrap: bool,
pub grid_columns: Option<usize>,
pub grid_row_height: Option<f32>,
pub overlap: bool,
}Expand description
A layout node’s style.
Fields§
§width: DimensionWidth.
height: DimensionHeight.
min_width: DimensionMinimum width: a floor the layout never goes below. Useful for a box that
grows with its content and never squashes (Auto = no floor).
min_height: DimensionMinimum height: a floor the layout never goes below — for instance a row
that grows with tall content and never shrinks (Auto = no floor).
max_width: DimensionMaximum width: a ceiling the layout never goes above, whatever the content
or the space on offer asks for (Auto = no ceiling).
max_height: DimensionMaximum height: the same ceiling on the vertical axis (Auto = none).
flex_grow: f32The main-axis grow factor (flexbox): the share of spare room this item takes.
flex_shrink: f32The main-axis shrink factor: the share of a deficit this item absorbs when
the children do not fit. 1.0 — the flexbox default — means everything squashes
together, in proportion to its basis; 0.0 means not me, and is what fixed
chrome wants: an icon button at the end of a row keeps its 40 px however long the
label beside it is. See Style::flex_basis for the other half.
flex_basis: DimensionThe main-axis basis: the size an item starts from, before growing or
shrinking. Auto — the default — means use the content, so a long label starts
long and drags the whole row with it. Length(0.0) means start from nothing and
take what is left, which is the shape of the reference’s expanding child.
flex_direction: FlexDirectionThe main-axis direction, for a container.
justify: JustifyDistribution along the main axis.
align: AlignAlignment on the cross axis, for a container: what it does to its children.
align_content: AlignContentHow a wrapping container’s lines are distributed on the cross axis.
Silent unless the container wraps and has cross-axis room to spare, since one line has nowhere to go.
align_self: Option<Align>This item’s own cross-axis alignment, overriding whatever its parent asked
for. None — the default — means “do as the others do”.
One box out of step with its row is a common enough shape that the alternative is a wrapper widget per exception, and flexbox already has the field.
padding: InsetsPadding, per side, in logical pixels.
margin: InsetsMargin, per side, in logical pixels: space reserved around the box, outside its decoration, which pushes siblings away.
aspect_ratio: Option<f32>When Some(r), the box keeps an aspect ratio of r (width / height):
the free dimension is derived from the constrained one. None means no
ratio constraint.
gap: f32Spacing between children, in logical pixels.
row_gap: Option<f32>Spacing between rows, when it differs from gap. None means gap.
A grid’s two spacings are separate in the reference — one along the axis it scrolls, one across it — and a tile grid usually wants them different.
column_gap: Option<f32>Spacing between columns, when it differs from gap. None means gap.
flex_wrap: boolWhen true, children wrap onto the next line (flex-wrap) once they
overflow the main axis — automatic responsive reflow.
grid_columns: Option<usize>When Some(n), the container is a grid of n equal columns, with
children placed automatically, row by row. None means flex.
grid_row_height: Option<f32>When Some(h), every grid row is exactly h logical pixels tall instead of
following its content — the reference’s per-tile main-axis extent. Ignored
outside a grid.
overlap: boolWhen true, the children overlap: all of them share one cell, which is as big
as the largest, and each is placed in it by Style::align on both axes.
It is how a box sizes itself to the biggest of several things drawn on top of one another — a picture on its way out under the one coming in — which a flex line cannot say (it adds its children up) and a stack here does not (its layers are laid out apart from it, so an unsized stack is nothing). Handed a box by its parent, the cell fills it, as the reference’s stack fills a tight constraint.
Implementations§
Source§impl Style
impl Style
Sourcepub fn layout_hash<H: Hasher>(&self, hasher: &mut H)
pub fn layout_hash<H: Hasher>(&self, hasher: &mut H)
Mixes into hasher every field that affects layout geometry. Two styles
with the same fingerprint produce the same arrangement — which is what makes
a relayout cache possible, skipping taffy when nothing relevant has changed.
The f32s are hashed by bit pattern, so equality is exact; colour and text do
not enter into it, since they only affect painting.