pub struct Style<S: CheapCloneStr = String> {Show 45 fields
pub dummy: PhantomData<S>,
pub display: Display,
pub item_is_table: bool,
pub item_is_replaced: bool,
pub item_is_compressible_replaced: bool,
pub box_sizing: BoxSizing,
pub direction: Direction,
pub overflow: Point<Overflow>,
pub scrollbar_width: f32,
pub contain: Contain,
pub float: Float,
pub clear: Clear,
pub position: Position,
pub inset: Rect<LengthPercentageAuto>,
pub size: Size<Dimension>,
pub min_size: Size<LengthPercentageAuto>,
pub max_size: Size<LengthPercentageAuto>,
pub aspect_ratio: Option<f32>,
pub margin: Rect<LengthPercentageAuto>,
pub padding: Rect<LengthPercentage>,
pub border: Rect<LengthPercentage>,
pub align_items: AlignItems,
pub align_self: Option<AlignSelf>,
pub justify_items: AlignItems,
pub justify_self: Option<AlignSelf>,
pub align_content: AlignContent,
pub justify_content: JustifyContent,
pub gap: Size<LengthPercentage>,
pub text_align: TextAlign,
pub flex_direction: FlexDirection,
pub flex_wrap: FlexWrap,
pub flex_line_count: u16,
pub flex_basis: Dimension,
pub flex_grow: f32,
pub flex_shrink: f32,
pub grid_template_rows: Vec<GridTemplateComponent<S>>,
pub grid_template_columns: Vec<GridTemplateComponent<S>>,
pub grid_auto_rows: Vec<TrackSizingFunction>,
pub grid_auto_columns: Vec<TrackSizingFunction>,
pub grid_auto_flow: GridAutoFlow,
pub grid_template_areas: Option<GridTemplateAreas<S>>,
pub grid_template_column_names: Vec<Vec<S>>,
pub grid_template_row_names: Vec<Vec<S>>,
pub grid_row: Line<GridPlacement<S>>,
pub grid_column: Line<GridPlacement<S>>,
}Expand description
A typed representation of the CSS style information for a single node.
The most important idea in flexbox is the notion of a “main” and “cross” axis, which are always perpendicular to each other.
The orientation of these axes are controlled via the FlexDirection field of this struct.
This struct follows the CSS equivalent directly; information about the behavior on the web should transfer directly.
Detailed information about the exact behavior of each of these fields can be found on MDN by searching for the field name. The distinction between margin, padding and border is explained well in this introduction to the box model.
If the behavior does not match the flexbox layout algorithm on the web, please file a bug!
Fields§
§dummy: PhantomData<S>This is a dummy field which is necessary to make Takia compile with the grid feature disabled
It should always be set to core::marker::PhantomData.
display: DisplayWhat layout strategy should be used?
item_is_table: boolWhether a child is display:table or not. This affects children of block layouts.
This should really be part of Display, but it is currently seperate because table layout isn’t implemented
item_is_replaced: boolIs it a replaced element like an image or video? Implies is_compressible_replaced.
https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements
item_is_compressible_replaced: boolIs it a compressible replaced element that is not a replaced element (a form control with an intrinsic size)? https://drafts.csswg.org/css-sizing-3/#compressible
box_sizing: BoxSizingShould size styles apply to the content box or the border box of the node
direction: DirectionSets the direction of text, table and grid columns, and horizontal overflow.
overflow: Point<Overflow>How children overflowing their container should affect layout
scrollbar_width: f32How much space (in points) should be reserved for the scrollbars of Overflow::Scroll and Overflow::Auto nodes.
contain: ContainThe layout-affecting parts of the CSS contain property
float: Floatfloat_layout only.Should the box be floated
clear: Clearfloat_layout only.Should the box clear floats
position: PositionWhat should the position value of this struct use as a base offset?
inset: Rect<LengthPercentageAuto>How should the position of this element be tweaked relative to the layout defined?
size: Size<Dimension>Sets the initial size of the item
min_size: Size<LengthPercentageAuto>Controls the minimum size of the item
max_size: Size<LengthPercentageAuto>Controls the maximum size of the item
aspect_ratio: Option<f32>Sets the preferred aspect ratio for the item
The ratio is calculated as width divided by height.
margin: Rect<LengthPercentageAuto>How large should the margin be on each side?
padding: Rect<LengthPercentage>How large should the padding be on each side?
border: Rect<LengthPercentage>How large should the border be on each side?
align_items: AlignItemsflexbox or grid only.How this node’s children aligned in the cross/block axis?
align_self: Option<AlignSelf>How this node should be aligned in the cross/block axis
Falls back to the parents AlignItems if not set
justify_items: AlignItemsblock_layout or grid only.How this node’s children should be aligned in the inline axis
justify_self: Option<AlignSelf>How this node should be aligned in the inline axis
Falls back to the parents JustifyItems if not set
align_content: AlignContentblock_layout or flexbox or grid only.How should content contained within this item be aligned in the cross/block axis
justify_content: JustifyContentflexbox or grid only.How should content contained within this item be aligned in the main/inline axis
gap: Size<LengthPercentage>flexbox or grid only.How large should the gaps between items in a grid or flex container be?
text_align: TextAlignblock_layout only.How items elements should aligned in the inline axis
flex_direction: FlexDirectionflexbox only.Which direction does the main axis flow in?
flex_wrap: FlexWrapflexbox only.Should elements wrap, or stay in a single line?
flex_line_count: u16flexbox_balance only.The minimum number of flex lines requested for a multi-line container. When items are
balanced (FlexWrap::Balance or FlexWrap::BalanceReverse) they are balanced into
at least this many lines. For any multi-line container, definite cross-axis available
space for measuring items is divided between this many lines.
1 is the default value, and this value must be at least 1.
flex_basis: Dimensionflexbox only.Sets the initial main axis size of the item
flex_grow: f32flexbox only.The relative rate at which this item grows when it is expanding to fill space
0.0 is the default value, and this value must be positive.
flex_shrink: f32flexbox only.The relative rate at which this item shrinks when it is contracting to fit into space
1.0 is the default value, and this value must be positive.
grid_template_rows: Vec<GridTemplateComponent<S>>grid only.Defines the track sizing functions (heights) of the grid rows
grid_template_columns: Vec<GridTemplateComponent<S>>grid only.Defines the track sizing functions (widths) of the grid columns
grid_auto_rows: Vec<TrackSizingFunction>grid only.Defines the size of implicitly created rows
grid_auto_columns: Vec<TrackSizingFunction>grid only.Defined the size of implicitly created columns
grid_auto_flow: GridAutoFlowgrid only.Controls how items get placed into the grid for auto-placed items
grid_template_areas: Option<GridTemplateAreas<S>>grid only.Defines the rectangular grid areas
grid_template_column_names: Vec<Vec<S>>grid only.The named lines between the columns
grid_template_row_names: Vec<Vec<S>>grid only.The named lines between the rows
grid_row: Line<GridPlacement<S>>grid only.Defines which row in the grid the item should start and end at
grid_column: Line<GridPlacement<S>>grid only.Defines which column in the grid the item should start and end at
Implementations§
Trait Implementations§
Source§impl<S: CheapCloneStr> BlockContainerStyle for Style<S>
Available on crate feature block_layout only.
impl<S: CheapCloneStr> BlockContainerStyle for Style<S>
block_layout only.Source§fn text_align(&self) -> TextAlign
fn text_align(&self) -> TextAlign
Source§fn align_content(&self) -> AlignContent
fn align_content(&self) -> AlignContent
Source§fn justify_items(&self) -> AlignItems
fn justify_items(&self) -> AlignItems
justify-items).
Out-of-flow children with justify-self: auto are aligned within their static-position
rectangle according to this value.Source§impl<S: CheapCloneStr> BlockItemStyle for Style<S>
Available on crate feature block_layout only.
impl<S: CheapCloneStr> BlockItemStyle for Style<S>
block_layout only.Source§fn is_table(&self) -> bool
fn is_table(&self) -> bool
Source§fn align_self(&self) -> Option<AlignSelf>
fn align_self(&self) -> Option<AlignSelf>
align-self). None corresponds to normal/auto.Source§fn justify_self(&self) -> Option<AlignSelf>
fn justify_self(&self) -> Option<AlignSelf>
justify-self). None corresponds to normal/auto.Source§fn align_content(&self) -> AlignContent
fn align_content(&self) -> AlignContent
align-content of the item (if it is itself a block container). A non-normal
value makes the item establish an independent formatting context, so that it is laid
out next to (rather than underneath) floats and does not collapse margins with its
parent (https://www.w3.org/TR/css-align-3/#distribution-block).Source§impl<S: CheapCloneStr> CoreStyle for Style<S>
impl<S: CheapCloneStr> CoreStyle for Style<S>
Source§type CustomIdent = S
type CustomIdent = S
Source§fn box_generation_mode(&self) -> BoxGenerationMode
fn box_generation_mode(&self) -> BoxGenerationMode
Source§fn is_compressible_replaced(&self) -> bool
fn is_compressible_replaced(&self) -> bool
input, select, textarea, meter, …)?
Such boxes resolve an auto width to their intrinsic size rather than being stretched by
block layout, and have a zero min-content contribution in grid layout.
https://drafts.csswg.org/css-sizing-3/#compressibleSource§fn is_replaced(&self) -> bool
fn is_replaced(&self) -> bool
auto-sized replaced element is not stretched between its
insets under normal alignment.
https://html.spec.whatwg.org/multipage/rendering.html#replaced-elementsSource§fn box_sizing(&self) -> BoxSizing
fn box_sizing(&self) -> BoxSizing
Source§fn direction(&self) -> Direction
fn direction(&self) -> Direction
Source§fn overflow(&self) -> Point<Overflow>
fn overflow(&self) -> Point<Overflow>
Source§fn scrollbar_width(&self) -> f32
fn scrollbar_width(&self) -> f32
Overflow::Scroll and Overflow::Auto nodes.Source§fn position(&self) -> Position
fn position(&self) -> Position
position value of this struct use as a base offset?Source§fn inset(&self) -> Rect<LengthPercentageAuto>
fn inset(&self) -> Rect<LengthPercentageAuto>
Source§fn min_size(&self) -> Size<LengthPercentageAuto>
fn min_size(&self) -> Size<LengthPercentageAuto>
Source§fn max_size(&self) -> Size<LengthPercentageAuto>
fn max_size(&self) -> Size<LengthPercentageAuto>
Source§fn aspect_ratio(&self) -> Option<f32>
fn aspect_ratio(&self) -> Option<f32>
Source§fn margin(&self) -> Rect<LengthPercentageAuto>
fn margin(&self) -> Rect<LengthPercentageAuto>
Source§fn padding(&self) -> Rect<LengthPercentage>
fn padding(&self) -> Rect<LengthPercentage>
Source§fn border(&self) -> Rect<LengthPercentage>
fn border(&self) -> Rect<LengthPercentage>
Source§fn contain(&self) -> Contain
fn contain(&self) -> Contain
contain property that apply to this nodeSource§fn is_containing_block(&self) -> ContainingBlockClaims
fn is_containing_block(&self) -> ContainingBlockClaims
absolute/fixed) descendants this node establishes the containing block for. Read moreSource§impl<S: CheapCloneStr> Default for Style<S>
impl<S: CheapCloneStr> Default for Style<S>
Source§impl<'de, S> Deserialize<'de> for Style<S>
Available on crate feature serde only.
impl<'de, S> Deserialize<'de> for Style<S>
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<S: CheapCloneStr> FlexboxContainerStyle for Style<S>
Available on crate feature flexbox only.
impl<S: CheapCloneStr> FlexboxContainerStyle for Style<S>
flexbox only.Source§fn flex_direction(&self) -> FlexDirection
fn flex_direction(&self) -> FlexDirection
Source§fn flex_line_count(&self) -> u16
fn flex_line_count(&self) -> u16
flexbox_balance only.FlexWrap::Balance or FlexWrap::BalanceReverse) they are balanced into
at least this many lines. For any multi-line container, definite cross-axis available
space for measuring items is divided between this many lines.Source§fn gap(&self) -> Size<LengthPercentage>
fn gap(&self) -> Size<LengthPercentage>
Source§fn align_content(&self) -> AlignContent
fn align_content(&self) -> AlignContent
Source§fn align_items(&self) -> AlignItems
fn align_items(&self) -> AlignItems
Source§fn justify_content(&self) -> JustifyContent
fn justify_content(&self) -> JustifyContent
Source§impl<S: CheapCloneStr> FlexboxItemStyle for Style<S>
Available on crate feature flexbox only.
impl<S: CheapCloneStr> FlexboxItemStyle for Style<S>
flexbox only.Source§fn flex_basis(&self) -> Dimension
fn flex_basis(&self) -> Dimension
Source§fn flex_grow(&self) -> f32
fn flex_grow(&self) -> f32
Source§fn flex_shrink(&self) -> f32
fn flex_shrink(&self) -> f32
Source§fn align_self(&self) -> Option<AlignSelf>
fn align_self(&self) -> Option<AlignSelf>
AlignItems if not setSource§impl<S: CheapCloneStr> GridContainerStyle for Style<S>
Available on crate feature grid only.
impl<S: CheapCloneStr> GridContainerStyle for Style<S>
grid only.Source§type Repetition<'a> = &'a GridTemplateRepetition<S>
where
Self: 'a
type Repetition<'a> = &'a GridTemplateRepetition<S> where Self: 'a
repeat() within a grid_template_rows or grid_template_columnsSource§type TemplateTrackList<'a> = Map<Iter<'a, GridTemplateComponent<S>>, fn(&'a GridTemplateComponent<S>) -> GenericGridTemplateComponent<S, &'a GridTemplateRepetition<S>>>
where
Self: 'a
type TemplateTrackList<'a> = Map<Iter<'a, GridTemplateComponent<S>>, fn(&'a GridTemplateComponent<S>) -> GenericGridTemplateComponent<S, &'a GridTemplateRepetition<S>>> where Self: 'a
Source§type AutoTrackList<'a> = Copied<Iter<'a, MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>
where
Self: 'a
type AutoTrackList<'a> = Copied<Iter<'a, MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>> where Self: 'a
Source§type TemplateLineNames<'a> = Map<Iter<'a, Vec<S>>, fn(&Vec<S>) -> Iter<'_, S>>
where
Self: 'a
type TemplateLineNames<'a> = Map<Iter<'a, Vec<S>>, fn(&Vec<S>) -> Iter<'_, S>> where Self: 'a
Source§type GridTemplateAreas<'a> = Cloned<Iter<'a, GridTemplateArea<S>>>
where
Self: 'a
type GridTemplateAreas<'a> = Cloned<Iter<'a, GridTemplateArea<S>>> where Self: 'a
Source§fn grid_template_rows(&self) -> Option<Self::TemplateTrackList<'_>>
fn grid_template_rows(&self) -> Option<Self::TemplateTrackList<'_>>
Source§fn grid_template_columns(&self) -> Option<Self::TemplateTrackList<'_>>
fn grid_template_columns(&self) -> Option<Self::TemplateTrackList<'_>>
Source§fn grid_auto_rows(&self) -> Self::AutoTrackList<'_>
fn grid_auto_rows(&self) -> Self::AutoTrackList<'_>
Source§fn grid_auto_columns(&self) -> Self::AutoTrackList<'_>
fn grid_auto_columns(&self) -> Self::AutoTrackList<'_>
Source§fn grid_auto_flow(&self) -> GridAutoFlow
fn grid_auto_flow(&self) -> GridAutoFlow
Source§fn gap(&self) -> Size<LengthPercentage>
fn gap(&self) -> Size<LengthPercentage>
Source§fn align_content(&self) -> AlignContent
fn align_content(&self) -> AlignContent
Source§fn justify_content(&self) -> JustifyContent
fn justify_content(&self) -> JustifyContent
Source§fn align_items(&self) -> AlignItems
fn align_items(&self) -> AlignItems
Source§fn justify_items(&self) -> AlignItems
fn justify_items(&self) -> AlignItems
Source§fn grid_template_areas(&self) -> Option<Self::GridTemplateAreas<'_>>
fn grid_template_areas(&self) -> Option<Self::GridTemplateAreas<'_>>
Source§fn grid_template_area_row_count(&self) -> u16
fn grid_template_area_row_count(&self) -> u16
grid-template-areas template (0 if there is no template).
May be greater than the extent of the named areas due to unnamed (.) cells.Source§fn grid_template_area_column_count(&self) -> u16
fn grid_template_area_column_count(&self) -> u16
grid-template-areas template (0 if there is no template).
May be greater than the extent of the named areas due to unnamed (.) cells.Source§fn grid_template_column_names(&self) -> Option<Self::TemplateLineNames<'_>>
fn grid_template_column_names(&self) -> Option<Self::TemplateLineNames<'_>>
Source§fn grid_template_row_names(&self) -> Option<Self::TemplateLineNames<'_>>
fn grid_template_row_names(&self) -> Option<Self::TemplateLineNames<'_>>
Source§fn grid_template_tracks(
&self,
axis: AbsoluteAxis,
) -> Option<Self::TemplateTrackList<'_>>
fn grid_template_tracks( &self, axis: AbsoluteAxis, ) -> Option<Self::TemplateTrackList<'_>>
Source§fn grid_align_content(&self, axis: AbstractAxis) -> AlignContent
fn grid_align_content(&self, axis: AbstractAxis) -> AlignContent
normal resolved to stretch)Source§impl<S: CheapCloneStr> GridItemStyle for Style<S>
Available on crate feature grid only.
impl<S: CheapCloneStr> GridItemStyle for Style<S>
grid only.Source§fn grid_row(&self) -> Line<GridPlacement<S>>
fn grid_row(&self) -> Line<GridPlacement<S>>
Source§fn grid_column(&self) -> Line<GridPlacement<S>>
fn grid_column(&self) -> Line<GridPlacement<S>>
Source§fn align_self(&self) -> Option<AlignSelf>
fn align_self(&self) -> Option<AlignSelf>
AlignItems if not setSource§fn justify_self(&self) -> Option<AlignSelf>
fn justify_self(&self) -> Option<AlignSelf>
super::JustifyItems if not setSource§fn grid_placement(
&self,
axis: AbsoluteAxis,
) -> Line<GridPlacement<Self::CustomIdent>>
fn grid_placement( &self, axis: AbsoluteAxis, ) -> Line<GridPlacement<Self::CustomIdent>>
Source§impl<S: CheapCloneStr> OofItemStyle for Style<S>
impl<S: CheapCloneStr> OofItemStyle for Style<S>
Source§fn align_self(&self) -> Option<AlignSelf>
fn align_self(&self) -> Option<AlignSelf>
align-self). None corresponds to normal/auto.Source§fn justify_self(&self) -> Option<AlignSelf>
fn justify_self(&self) -> Option<AlignSelf>
justify-self). None corresponds to normal/auto.Source§fn is_table(&self) -> bool
fn is_table(&self) -> bool
normal self-alignment does not stretch
tables to fill their inset-modified containing block.Source§fn grid_row(&self) -> Line<GridPlacement<S>>
fn grid_row(&self) -> Line<GridPlacement<S>>
grid only.Source§fn grid_column(&self) -> Line<GridPlacement<S>>
fn grid_column(&self) -> Line<GridPlacement<S>>
grid only.Source§impl<S> Serialize for Style<S>where
S: Serialize + CheapCloneStr,
Available on crate feature serde only.
impl<S> Serialize for Style<S>where
S: Serialize + CheapCloneStr,
serde only.