Skip to main content

Style

Struct Style 

Source
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: Display

What layout strategy should be used?

§item_is_table: bool

Whether 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: bool

Is 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: bool

Is 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: BoxSizing

Should size styles apply to the content box or the border box of the node

§direction: Direction

Sets the direction of text, table and grid columns, and horizontal overflow.

§overflow: Point<Overflow>

How children overflowing their container should affect layout

§scrollbar_width: f32

How much space (in points) should be reserved for the scrollbars of Overflow::Scroll and Overflow::Auto nodes.

§contain: Contain

The layout-affecting parts of the CSS contain property

§float: Float
Available on crate feature float_layout only.

Should the box be floated

§clear: Clear
Available on crate feature float_layout only.

Should the box clear floats

§position: Position

What 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: AlignItems
Available on crate features flexbox 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: AlignItems
Available on crate features block_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: AlignContent
Available on crate features block_layout or flexbox or grid only.

How should content contained within this item be aligned in the cross/block axis

§justify_content: JustifyContent
Available on crate features flexbox or grid only.

How should content contained within this item be aligned in the main/inline axis

§gap: Size<LengthPercentage>
Available on crate features flexbox or grid only.

How large should the gaps between items in a grid or flex container be?

§text_align: TextAlign
Available on crate feature block_layout only.

How items elements should aligned in the inline axis

§flex_direction: FlexDirection
Available on crate feature flexbox only.

Which direction does the main axis flow in?

§flex_wrap: FlexWrap
Available on crate feature flexbox only.

Should elements wrap, or stay in a single line?

§flex_line_count: u16
Available on crate feature flexbox_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: Dimension
Available on crate feature flexbox only.

Sets the initial main axis size of the item

§flex_grow: f32
Available on crate feature flexbox 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: f32
Available on crate feature flexbox 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>>
Available on crate feature grid only.

Defines the track sizing functions (heights) of the grid rows

§grid_template_columns: Vec<GridTemplateComponent<S>>
Available on crate feature grid only.

Defines the track sizing functions (widths) of the grid columns

§grid_auto_rows: Vec<TrackSizingFunction>
Available on crate feature grid only.

Defines the size of implicitly created rows

§grid_auto_columns: Vec<TrackSizingFunction>
Available on crate feature grid only.

Defined the size of implicitly created columns

§grid_auto_flow: GridAutoFlow
Available on crate feature grid only.

Controls how items get placed into the grid for auto-placed items

§grid_template_areas: Option<GridTemplateAreas<S>>
Available on crate feature grid only.

Defines the rectangular grid areas

§grid_template_column_names: Vec<Vec<S>>
Available on crate feature grid only.

The named lines between the columns

§grid_template_row_names: Vec<Vec<S>>
Available on crate feature grid only.

The named lines between the rows

§grid_row: Line<GridPlacement<S>>
Available on crate feature grid only.

Defines which row in the grid the item should start and end at

§grid_column: Line<GridPlacement<S>>
Available on crate feature grid only.

Defines which column in the grid the item should start and end at

Implementations§

Source§

impl<S: CheapCloneStr> Style<S>

Source

pub const DEFAULT: Style<S>

The Default layout, in a form that can be used in const functions

Trait Implementations§

Source§

impl<S: CheapCloneStr> BlockContainerStyle for Style<S>

Available on crate feature block_layout only.
Source§

fn text_align(&self) -> TextAlign

Defines which row in the grid the item should start and end at
Source§

fn align_content(&self) -> AlignContent

How children of this block container are aligned in the block (cross) axis
Source§

fn justify_items(&self) -> AlignItems

The default inline-axis alignment of this block container’s children (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.
Source§

fn is_table(&self) -> bool

Whether the item is a table. Table children are handled specially in block layout.
Source§

fn align_self(&self) -> Option<AlignSelf>

How an out-of-flow (absolutely positioned) child is aligned in the block axis of its static-position rectangle (align-self). None corresponds to normal/auto.
Source§

fn justify_self(&self) -> Option<AlignSelf>

How an out-of-flow (absolutely positioned) child is aligned in the inline axis of its static-position rectangle (justify-self). None corresponds to normal/auto.
Source§

fn align_content(&self) -> AlignContent

The 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§

fn float(&self) -> Float

Available on crate feature float_layout only.
Whether the item is a floated
Source§

fn clear(&self) -> Clear

Available on crate feature float_layout only.
Whether the item is a floated
Source§

impl<S: Clone + CheapCloneStr> Clone for Style<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: CheapCloneStr> CoreStyle for Style<S>

Source§

type CustomIdent = S

The type of custom identifiers used to identify named grid lines and areas
Source§

fn box_generation_mode(&self) -> BoxGenerationMode

Which box generation mode should be used
Source§

fn is_block(&self) -> bool

Is block layout? Read more
Source§

fn is_compressible_replaced(&self) -> bool

Is it a compressible replaced element: a replaced element (image, video, canvas, …) or a form control with an intrinsic size (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/#compressible
Source§

fn is_replaced(&self) -> bool

Is it a replaced element (image, video, canvas, …)? Unlike other compressible replaced elements (form controls), an auto-sized replaced element is not stretched between its insets under normal alignment. https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements
Source§

fn box_sizing(&self) -> BoxSizing

Which box do size styles apply to
Source§

fn direction(&self) -> Direction

The direction of text, table and grid columns, and horizontal overflow.
Source§

fn overflow(&self) -> Point<Overflow>

How children overflowing their container should affect layout
Source§

fn scrollbar_width(&self) -> f32

How much space (in points) should be reserved for the scrollbars of Overflow::Scroll and Overflow::Auto nodes.
Source§

fn position(&self) -> Position

What should the position value of this struct use as a base offset?
Source§

fn inset(&self) -> Rect<LengthPercentageAuto>

How should the position of this element be tweaked relative to the layout defined?
Source§

fn size(&self) -> Size<Dimension>

Sets the initial size of the item
Source§

fn min_size(&self) -> Size<LengthPercentageAuto>

Controls the minimum size of the item
Source§

fn max_size(&self) -> Size<LengthPercentageAuto>

Controls the maximum size of the item
Source§

fn aspect_ratio(&self) -> Option<f32>

Sets the preferred aspect ratio for the item The ratio is calculated as width divided by height.
Source§

fn margin(&self) -> Rect<LengthPercentageAuto>

How large should the margin be on each side?
Source§

fn padding(&self) -> Rect<LengthPercentage>

How large should the padding be on each side?
Source§

fn border(&self) -> Rect<LengthPercentage>

How large should the border be on each side?
Source§

fn contain(&self) -> Contain

The layout-affecting parts of the CSS contain property that apply to this node
Source§

fn is_containing_block(&self) -> ContainingBlockClaims

Which out-of-flow (absolute/fixed) descendants this node establishes the containing block for. Read more
Source§

impl<S: Debug + CheapCloneStr> Debug for Style<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: CheapCloneStr> Default for Style<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, S> Deserialize<'de> for Style<S>
where Style<S>: Default, S: Deserialize<'de> + CheapCloneStr,

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S: CheapCloneStr> FlexboxContainerStyle for Style<S>

Available on crate feature flexbox only.
Source§

fn flex_direction(&self) -> FlexDirection

Which direction does the main axis flow in?
Source§

fn flex_wrap(&self) -> FlexWrap

Should elements wrap, or stay in a single line?
Source§

fn flex_line_count(&self) -> u16

Available on crate feature flexbox_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.
Source§

fn gap(&self) -> Size<LengthPercentage>

How large should the gaps between items in a grid or flex container be?
Source§

fn align_content(&self) -> AlignContent

How should content contained within this item be aligned in the cross/block axis
Source§

fn align_items(&self) -> AlignItems

How this node’s children aligned in the cross/block axis?
Source§

fn justify_content(&self) -> JustifyContent

How this node’s children should be aligned in the inline axis
Source§

impl<S: CheapCloneStr> FlexboxItemStyle for Style<S>

Available on crate feature flexbox only.
Source§

fn flex_basis(&self) -> Dimension

Sets the initial main axis size of the item
Source§

fn flex_grow(&self) -> f32

The relative rate at which this item grows when it is expanding to fill space
Source§

fn flex_shrink(&self) -> f32

The relative rate at which this item shrinks when it is contracting to fit into space
Source§

fn align_self(&self) -> Option<AlignSelf>

How this node should be aligned in the cross/block axis Falls back to the parents AlignItems if not set
Source§

impl<S: CheapCloneStr> GridContainerStyle for Style<S>

Available on crate feature grid only.
Source§

type Repetition<'a> = &'a GridTemplateRepetition<S> where Self: 'a

The type for a repeat() within a grid_template_rows or grid_template_columns
Source§

type TemplateTrackList<'a> = Map<Iter<'a, GridTemplateComponent<S>>, fn(&'a GridTemplateComponent<S>) -> GenericGridTemplateComponent<S, &'a GridTemplateRepetition<S>>> where Self: 'a

The type returned by grid_template_rows and grid_template_columns
Source§

type AutoTrackList<'a> = Copied<Iter<'a, MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>> where Self: 'a

The type returned by grid_auto_rows and grid_auto_columns
Source§

type TemplateLineNames<'a> = Map<Iter<'a, Vec<S>>, fn(&Vec<S>) -> Iter<'_, S>> where Self: 'a

The type returned by grid_template_row_names and grid_template_column_names
Source§

type GridTemplateAreas<'a> = Cloned<Iter<'a, GridTemplateArea<S>>> where Self: 'a

The type of custom identifiers used to identify named grid lines and areas
Source§

fn grid_template_rows(&self) -> Option<Self::TemplateTrackList<'_>>

Defines the track sizing functions (heights) of the grid rows
Source§

fn grid_template_columns(&self) -> Option<Self::TemplateTrackList<'_>>

Defines the track sizing functions (widths) of the grid columns
Source§

fn grid_auto_rows(&self) -> Self::AutoTrackList<'_>

Defines the size of implicitly created rows
Source§

fn grid_auto_columns(&self) -> Self::AutoTrackList<'_>

Defined the size of implicitly created columns
Source§

fn grid_auto_flow(&self) -> GridAutoFlow

Controls how items get placed into the grid for auto-placed items
Source§

fn gap(&self) -> Size<LengthPercentage>

How large should the gaps between items in a grid or flex container be?
Source§

fn align_content(&self) -> AlignContent

How should content contained within this item be aligned in the cross/block axis
Source§

fn justify_content(&self) -> JustifyContent

How should contained within this item be aligned in the main/inline axis
Source§

fn align_items(&self) -> AlignItems

How this node’s children aligned in the cross/block axis?
Source§

fn justify_items(&self) -> AlignItems

How this node’s children should be aligned in the inline axis
Source§

fn grid_template_areas(&self) -> Option<Self::GridTemplateAreas<'_>>

Named grid areas
Source§

fn grid_template_area_row_count(&self) -> u16

The number of rows in the 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

The number of columns in the 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<'_>>

Defines the line names for row lines
Source§

fn grid_template_row_names(&self) -> Option<Self::TemplateLineNames<'_>>

Defines the size of implicitly created rows
Source§

fn grid_template_tracks( &self, axis: AbsoluteAxis, ) -> Option<Self::TemplateTrackList<'_>>

Get a grid item’s row or column placement depending on the axis passed
Source§

fn grid_align_content(&self, axis: AbstractAxis) -> AlignContent

Get a grid container’s align-content or justify-content alignment depending on the axis passed (with normal resolved to stretch)
Source§

impl<S: CheapCloneStr> GridItemStyle for Style<S>

Available on crate feature grid only.
Source§

fn grid_row(&self) -> Line<GridPlacement<S>>

Defines which row in the grid the item should start and end at
Source§

fn grid_column(&self) -> Line<GridPlacement<S>>

Defines which column in the grid the item should start and end at
Source§

fn align_self(&self) -> Option<AlignSelf>

How this node should be aligned in the cross/block axis Falls back to the parents AlignItems if not set
Source§

fn justify_self(&self) -> Option<AlignSelf>

How this node should be aligned in the inline axis Falls back to the parents super::JustifyItems if not set
Source§

fn grid_placement( &self, axis: AbsoluteAxis, ) -> Line<GridPlacement<Self::CustomIdent>>

Get a grid item’s row or column placement depending on the axis passed
Source§

impl<S: CheapCloneStr> OofItemStyle for Style<S>

Source§

fn align_self(&self) -> Option<AlignSelf>

How the box is aligned in the block axis of its inset-modified containing block (align-self). None corresponds to normal/auto.
Source§

fn justify_self(&self) -> Option<AlignSelf>

How the box is aligned in the inline axis of its inset-modified containing block (justify-self). None corresponds to normal/auto.
Source§

fn is_table(&self) -> bool

Whether the box is a table wrapper box. A normal self-alignment does not stretch tables to fill their inset-modified containing block.
Source§

fn grid_row(&self) -> Line<GridPlacement<S>>

Available on crate feature grid only.
Defines which row in the grid the box should start and end at, when the box’s containing block is a grid container
Source§

fn grid_column(&self) -> Line<GridPlacement<S>>

Available on crate feature grid only.
Defines which column in the grid the box should start and end at, when the box’s containing block is a grid container
Source§

impl<S: PartialEq + CheapCloneStr> PartialEq for Style<S>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S> Serialize for Style<S>

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<S: PartialEq + CheapCloneStr> StructuralPartialEq for Style<S>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.