Skip to main content

Style

Struct Style 

Source
pub struct Style { /* private fields */ }
Expand description

Complete compiled style value combining layout, paint, and typography with zero heap allocations.

Implementations§

Source§

impl Style

Fluent zero-allocation builder methods for Style.

Source

pub fn apply<T>(self, prop: T) -> Self
where T: StyleApply,

Applies any strongly-typed StyleApply value (e.g. AlignItems::Center, Overflow::Hidden, Shadow) to this style.

§Arguments
  • Self - Source style.
  • T - Typed property implementing StyleApply.
§Returns
  • Self - Updated style.
Source

pub fn direction(self, direction: FlexDirection) -> Self

Sets the flex container axis direction (FlexDirection::Row or FlexDirection::Column).

§Arguments
  • Self - Source style.
  • FlexDirection - Target flex axis direction.
§Returns
  • Self - Updated style.
Source

pub fn display(self, display: Display) -> Self

Sets the box display mode.

§Arguments
  • Self - Source style.
  • Display - Target display mode.
§Returns
  • Self - Updated style.
Source

pub fn position(self, position: Position) -> Self

Sets the positioning mode.

§Arguments
  • Self - Source style.
  • Position - Target position mode.
§Returns
  • Self - Updated style.
Source

pub fn row(self) -> Self

Configures a horizontal flex row.

§Arguments
  • Self - Source style.
§Returns
  • Self - Updated style.
Source

pub fn column(self) -> Self

Configures a vertical flex column.

§Arguments
  • Self - Source style.
§Returns
  • Self - Updated style.
Source

pub fn grid(self, columns: u16) -> Self

Configures a grid layout with columns equal-width columns.

§Arguments
  • Self - Source style.
  • u16 - Number of grid columns (clamped to at least 1).
§Returns
  • Self - Updated style.
Source

pub fn wrap(self, wrap: FlexWrap) -> Self

Sets flex wrapping behavior.

§Arguments
  • Self - Source style.
  • FlexWrap - Wrap mode.
§Returns
  • Self - Updated style.
Source

pub fn justify(self, justify: JustifyContent) -> Self

Sets main-axis justification.

§Arguments
  • Self - Source style.
  • JustifyContent - Justification mode.
§Returns
  • Self - Updated style.
Source

pub fn align(self, align: AlignItems) -> Self

Sets cross-axis alignment.

§Arguments
  • Self - Source style.
  • AlignItems - Cross-axis alignment.
§Returns
  • Self - Updated style.
Source

pub fn flex_grow(self, grow: f32) -> Self

Sets flex grow factor.

§Arguments
  • Self - Source style.
  • f32 - Flex grow factor.
§Returns
  • Self - Updated style.
Source

pub fn flex_shrink(self, shrink: f32) -> Self

Sets flex shrink factor.

§Arguments
  • Self - Source style.
  • f32 - Flex shrink factor.
§Returns
  • Self - Updated style.
Source

pub fn width(self, width: Length) -> Self

Sets width length.

§Arguments
  • Self - Source style.
  • Length - Target width.
§Returns
  • Self - Updated style.
Source

pub fn height(self, height: Length) -> Self

Sets height length.

§Arguments
  • Self - Source style.
  • Length - Target height.
§Returns
  • Self - Updated style.
Source

pub fn min_width(self, min_width: Length) -> Self

Sets minimum width constraint.

§Arguments
  • Self - Source style.
  • Length - Minimum width.
§Returns
  • Self - Updated style.
Source

pub fn min_height(self, min_height: Length) -> Self

Sets minimum height constraint.

§Arguments
  • Self - Source style.
  • Length - Minimum height.
§Returns
  • Self - Updated style.
Source

pub fn max_width(self, max_width: Length) -> Self

Sets maximum width constraint.

§Arguments
  • Self - Source style.
  • Length - Maximum width.
§Returns
  • Self - Updated style.
Source

pub fn max_height(self, max_height: Length) -> Self

Sets maximum height constraint.

§Arguments
  • Self - Source style.
  • Length - Maximum height.
§Returns
  • Self - Updated style.
Source

pub fn aspect_ratio(self, ratio: f32) -> Self

Sets an explicit width-to-height aspect ratio constraint.

§Arguments
  • Self - Source style.
  • f32 - Positive aspect ratio (width / height).
§Returns
  • Self - Updated style.
Source

pub fn gap(self, gap: f32) -> Self

Sets uniform gap along both row and column axes.

§Arguments
  • Self - Source style.
  • f32 - Gap in logical pixels.
§Returns
  • Self - Updated style.
Source

pub fn padding(self, padding: Edges) -> Self

Sets inner padding edges.

§Arguments
  • Self - Source style.
  • Edges - Inner padding insets.
§Returns
  • Self - Updated style.
Source

pub fn margin(self, margin: Edges) -> Self

Sets outer margin edges.

§Arguments
  • Self - Source style.
  • Edges - Outer margin insets.
§Returns
  • Self - Updated style.
Source

pub fn overflow(self, overflow: Overflow) -> Self

Sets overflow behavior.

§Arguments
  • Self - Source style.
  • Overflow - Target overflow behavior.
§Returns
  • Self - Updated style.
Source

pub fn z_index(self, z_index: i32) -> Self

Sets stacking z-index.

§Arguments
  • Self - Source style.
  • i32 - Stacking layer index.
§Returns
  • Self - Updated style.
Source

pub fn inset( self, top: Option<f32>, right: Option<f32>, bottom: Option<f32>, left: Option<f32>, ) -> Self

Sets absolute or fixed inset coordinates.

§Arguments
  • Self - Source style.
  • Option<f32> - Top offset.
  • Option<f32> - Right offset.
  • Option<f32> - Bottom offset.
  • Option<f32> - Left offset.
§Returns
  • Self - Updated style.
Source

pub fn background(self, color: Color) -> Self

Sets solid background fill color.

§Arguments
  • Self - Source style.
  • Color - Background color.
§Returns
  • Self - Updated style.
Source

pub fn gradient(self, gradient: LinearGradient) -> Self

Sets linear gradient fill.

§Arguments
  • Self - Source style.
  • LinearGradient - Linear gradient specification.
§Returns
  • Self - Updated style.
Source

pub fn border(self, width: f32, color: Color) -> Self

Sets border stroke width and color.

§Arguments
  • Self - Source style.
  • f32 - Border width in logical pixels.
  • Color - Border color.
§Returns
  • Self - Updated style.
Source

pub fn radius(self, radius: f32) -> Self

Sets uniform corner radius.

§Arguments
  • Self - Source style.
  • f32 - Corner radius in logical pixels.
§Returns
  • Self - Updated style.
Source

pub fn shadow(self, shadow: Shadow) -> Self

Sets drop shadow.

§Arguments
  • Self - Source style.
  • Shadow - Shadow definition.
§Returns
  • Self - Updated style.
Source

pub fn focus_ring(self, ring: Border) -> Self

Sets focus ring stroke.

§Arguments
  • Self - Source style.
  • Border - Focus ring width and color.
§Returns
  • Self - Updated style.
Source

pub fn opacity(self, opacity: f32) -> Self

Sets opacity in [0.0, 1.0].

§Arguments
  • Self - Source style.
  • f32 - Opacity factor.
§Returns
  • Self - Updated style.
Source

pub fn cursor(self, cursor: CursorIcon) -> Self

Sets cursor icon hint.

§Arguments
  • Self - Source style.
  • CursorIcon - Target cursor icon.
§Returns
  • Self - Updated style.
Source

pub fn pointer_events(self, pointer_events: PointerEvents) -> Self

Sets pointer hit-test participation behavior.

§Arguments
  • Self - Source style.
  • PointerEvents - Target pointer-events mode.
§Returns
  • Self - Updated style.
Source

pub fn color(self, color: Color) -> Self

Sets foreground text color.

§Arguments
  • Self - Source style.
  • Color - Text color.
§Returns
  • Self - Updated style.
Source

pub fn font_size(self, size: f32) -> Self

Sets font size in logical pixels.

§Arguments
  • Self - Source style.
  • f32 - Font size in pixels.
§Returns
  • Self - Updated style.
Source

pub fn font_weight(self, weight: FontWeight) -> Self

Sets font weight.

§Arguments
  • Self - Source style.
  • FontWeight - Target font weight.
§Returns
  • Self - Updated style.
Source

pub fn font_family(self, family: FontFamily) -> Self

Sets font family.

§Arguments
  • Self - Source style.
  • FontFamily - Semantic font family.
§Returns
  • Self - Updated style.
Source

pub fn text_align(self, align: TextAlign) -> Self

Sets horizontal text alignment.

§Arguments
  • Self - Source style.
  • TextAlign - Text alignment.
§Returns
  • Self - Updated style.
Source

pub fn text_overflow(self, overflow: TextOverflow) -> Self

Sets text overflow behavior.

§Arguments
  • Self - Source style.
  • TextOverflow - Overflow strategy.
§Returns
  • Self - Updated style.
Source

pub fn stop_scroll_propagation(self, stop: bool) -> Self

Configures whether scroll deltas stop at this node (true) or chain/penetrate to parent scrollables (false).

§Arguments
  • Self - Source style.
  • bool - true blocks scroll penetration to ancestors; false permits scroll chaining.
§Returns
  • Self - Updated style.
Source

pub fn stop_event_propagation(self, stop: bool) -> Self

Configures whether click/pointer events stop bubbling at this node (true) or bubble to ancestors (false).

§Arguments
  • Self - Source style.
  • bool - true blocks event bubbling; false permits bubbling.
§Returns
  • Self - Updated style.
Source§

impl Style

Source

pub fn get_layout(&self) -> LayoutStyle

Source

pub fn get_mut_layout(&mut self) -> &mut LayoutStyle

Source

pub fn set_layout(&mut self, val: LayoutStyle) -> &mut Self

Source

pub fn get_paint(&self) -> PaintStyle

Source

pub fn get_mut_paint(&mut self) -> &mut PaintStyle

Source

pub fn set_paint(&mut self, val: PaintStyle) -> &mut Self

Source

pub fn get_text(&self) -> TextStyle

Source

pub fn get_mut_text(&mut self) -> &mut TextStyle

Source

pub fn set_text(&mut self, val: TextStyle) -> &mut Self

Source§

impl Style

Source

pub fn new(layout: LayoutStyle, paint: PaintStyle, text: TextStyle) -> Self

Trait Implementations§

Source§

impl Clone for Style

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

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() -> Self

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

impl PartialEq for Style

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

Source§

impl StyleApply for Style

StyleApply implementation for Style allowing base-style merging inside style! { base_style; ... }.

Source§

fn apply_to(self, _style: Style) -> Style

Replaces style with self as a base preset inside style!.

§Arguments
  • Self - Base style preset.
  • Style - Previous accumulator.
§Returns
  • Style - Base style value.

Auto Trait Implementations§

§

impl Forget for Style

§

impl Freeze for Style

§

impl Move 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> 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.