Skip to main content

Style

Struct Style 

Source
pub struct Style {
Show 56 fields pub width: Option<Dimension>, pub height: Option<Dimension>, pub min_width: Option<Dimension>, pub min_height: Option<Dimension>, pub max_width: Option<Dimension>, pub max_height: Option<Dimension>, pub padding: Option<Edges>, pub margin: Option<MarginEdges>, pub display: Option<Display>, pub flex_direction: Option<FlexDirection>, pub justify_content: Option<JustifyContent>, pub align_items: Option<AlignItems>, pub align_self: Option<AlignItems>, pub flex_wrap: Option<FlexWrap>, pub align_content: Option<AlignContent>, pub flex_grow: Option<f64>, pub flex_shrink: Option<f64>, pub flex_basis: Option<Dimension>, pub gap: Option<f64>, pub row_gap: Option<f64>, pub column_gap: Option<f64>, pub grid_template_columns: Option<Vec<GridTrackSize>>, pub grid_template_rows: Option<Vec<GridTrackSize>>, pub grid_auto_rows: Option<GridTrackSize>, pub grid_auto_columns: Option<GridTrackSize>, pub grid_placement: Option<GridPlacement>, pub font_family: Option<String>, pub font_size: Option<f64>, pub font_weight: Option<u32>, pub font_style: Option<FontStyle>, pub line_height: Option<f64>, pub text_align: Option<TextAlign>, pub letter_spacing: Option<f64>, pub text_decoration: Option<TextDecoration>, pub text_transform: Option<TextTransform>, pub hyphens: Option<Hyphens>, pub lang: Option<String>, pub direction: Option<Direction>, pub text_overflow: Option<TextOverflow>, pub line_breaking: Option<LineBreaking>, pub overflow: Option<Overflow>, pub color: Option<Color>, pub background_color: Option<Color>, pub opacity: Option<f64>, pub border_width: Option<EdgeValues<f64>>, pub border_color: Option<EdgeValues<Color>>, pub border_radius: Option<CornerValues>, pub position: Option<Position>, pub top: Option<f64>, pub right: Option<f64>, pub bottom: Option<f64>, pub left: Option<f64>, pub wrap: Option<bool>, pub break_before: Option<bool>, pub min_widow_lines: Option<u32>, pub min_orphan_lines: Option<u32>,
}
Expand description

The complete set of style properties for a node.

Fields§

§width: Option<Dimension>

Explicit width in points.

§height: Option<Dimension>

Explicit height in points.

§min_width: Option<Dimension>

Minimum width.

§min_height: Option<Dimension>

Minimum height.

§max_width: Option<Dimension>

Maximum width.

§max_height: Option<Dimension>

Maximum height.

§padding: Option<Edges>

Padding inside the border.

§margin: Option<MarginEdges>

Margin outside the border. Supports auto values for centering.

§display: Option<Display>

Display mode: flex (default) or grid.

§flex_direction: Option<FlexDirection>

Direction of the main axis.

§justify_content: Option<JustifyContent>

How to distribute space along the main axis.

§align_items: Option<AlignItems>

How to align items along the cross axis.

§align_self: Option<AlignItems>

Override align-items for this specific child.

§flex_wrap: Option<FlexWrap>

Whether flex items wrap to new lines.

§align_content: Option<AlignContent>

How to distribute space between flex lines on the cross axis.

§flex_grow: Option<f64>

Flex grow factor.

§flex_shrink: Option<f64>

Flex shrink factor.

§flex_basis: Option<Dimension>

Flex basis (initial main size).

§gap: Option<f64>

Gap between flex items.

§row_gap: Option<f64>

Row gap (overrides gap for rows).

§column_gap: Option<f64>

Column gap (overrides gap for columns).

§grid_template_columns: Option<Vec<GridTrackSize>>

Column track definitions (e.g., [Pt(100), Fr(1), Fr(2)]).

§grid_template_rows: Option<Vec<GridTrackSize>>

Row track definitions.

§grid_auto_rows: Option<GridTrackSize>

Auto-generated row size.

§grid_auto_columns: Option<GridTrackSize>

Auto-generated column size.

§grid_placement: Option<GridPlacement>

Grid placement for this child item.

§font_family: Option<String>

Font family name.

§font_size: Option<f64>

Font size in points.

§font_weight: Option<u32>

Font weight (100-900).

§font_style: Option<FontStyle>

Font style.

§line_height: Option<f64>

Line height as a multiplier of font size.

§text_align: Option<TextAlign>

Text alignment within the text block.

§letter_spacing: Option<f64>

Letter spacing in points.

§text_decoration: Option<TextDecoration>

Text decoration.

§text_transform: Option<TextTransform>

Text transform.

§hyphens: Option<Hyphens>

Hyphenation mode (CSS hyphens property).

§lang: Option<String>

BCP 47 language tag for hyphenation and line breaking.

§direction: Option<Direction>

Text direction (ltr, rtl, or auto).

§text_overflow: Option<TextOverflow>

Text overflow behavior (wrap, ellipsis, clip).

§line_breaking: Option<LineBreaking>

Line breaking algorithm: optimal (Knuth-Plass, default) or greedy.

§overflow: Option<Overflow>

Overflow behavior for container elements.

§color: Option<Color>

Text color.

§background_color: Option<Color>

Background color.

§opacity: Option<f64>

Opacity (0.0 - 1.0).

§border_width: Option<EdgeValues<f64>>

Border width for all sides.

§border_color: Option<EdgeValues<Color>>

Border color for all sides.

§border_radius: Option<CornerValues>

Border radius (uniform or per-corner).

§position: Option<Position>

Positioning mode (relative or absolute).

§top: Option<f64>

Top offset (for absolute positioning).

§right: Option<f64>

Right offset (for absolute positioning).

§bottom: Option<f64>

Bottom offset (for absolute positioning).

§left: Option<f64>

Left offset (for absolute positioning).

§wrap: Option<bool>

Whether this node can be broken across pages. true = breakable (default for View, Text, Table). false = keep on one page; if it doesn’t fit, move to next page.

§break_before: Option<bool>

Force a page break before this node.

§min_widow_lines: Option<u32>

Minimum number of lines to keep at the bottom of a page before breaking (widow control). Default: 2.

§min_orphan_lines: Option<u32>

Minimum number of lines to keep at the top of a new page after breaking (orphan control). Default: 2.

Implementations§

Source§

impl Style

Source

pub fn resolve( &self, parent: Option<&ResolvedStyle>, available_width: f64, ) -> ResolvedStyle

Resolve this style against a parent’s resolved style and available dimensions.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

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

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

impl Default for Style

Source§

fn default() -> Style

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

impl<'de> Deserialize<'de> for Style

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 Serialize for Style

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

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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