Skip to main content

BuiltinStyle

Struct BuiltinStyle 

Source
pub struct BuiltinStyle<'a> { /* private fields */ }

Implementations§

Source§

impl BuiltinStyle<'_>

Source

pub fn display(&self) -> Display

Controls the display type of the view.

This determines how the view participates in layout.

Source

pub fn position(&self) -> Position

Sets the positioning scheme for the view.

This affects how the view is positioned relative to its normal position in the document flow.

Source

pub fn is_fixed(&self) -> bool

Enables fixed positioning relative to the viewport.

When true, the view is positioned relative to the window viewport rather than its parent. This is similar to CSS position: fixed. The view will:

  • Use inset properties relative to the viewport
  • Have percentage sizes relative to the viewport
  • Be painted above all other content (like overlays)

Note: This works in conjunction with position: absolute internally.

Source

pub fn width(&self) -> PxPctAuto

Sets the width of the view.

Can be specified in pixels, percentages, or auto.

Source

pub fn height(&self) -> PxPctAuto

Sets the height of the view.

Can be specified in pixels, percentages, or auto.

Source

pub fn min_width(&self) -> PxPctAuto

Sets the minimum width of the view.

The view will not shrink below this width.

Source

pub fn min_height(&self) -> PxPctAuto

Sets the minimum height of the view.

The view will not shrink below this height.

Source

pub fn max_width(&self) -> PxPctAuto

Sets the maximum width of the view.

The view will not grow beyond this width.

Source

pub fn max_height(&self) -> PxPctAuto

Sets the maximum height of the view.

The view will not grow beyond this height.

Source

pub fn flex_direction(&self) -> FlexDirection

Sets the direction of the main axis for flex items.

Determines whether flex items are laid out in rows or columns.

Source

pub fn flex_wrap(&self) -> FlexWrap

Controls whether flex items wrap to new lines.

When enabled, items that don’t fit will wrap to the next line.

Source

pub fn flex_grow(&self) -> f32

Sets the flex grow factor for the flex item.

Determines how much the item should grow relative to other items.

Source

pub fn flex_shrink(&self) -> f32

Sets the flex shrink factor for the flex item.

Determines how much the item should shrink relative to other items.

Source

pub fn flex_basis(&self) -> PxPctAuto

Sets the initial main size of a flex item.

This is the size of the item before free space is distributed.

Source

pub fn justify_content(&self) -> Option<JustifyContent>

Controls alignment of flex items along the main axis.

Determines how extra space is distributed between and around items.

Source

pub fn justify_items(&self) -> Option<JustifyItems>

Controls default alignment of grid items along the inline axis.

Sets the default justify-self value for all items in the container.

Source

pub fn box_sizing(&self) -> Option<BoxSizing>

Controls how the total width and height are calculated.

Determines whether borders and padding are included in the view’s size.

Source

pub fn justify_self(&self) -> Option<AlignItems>

Controls individual alignment along the inline axis.

Overrides the container’s justify-items value for this specific item.

Source

pub fn align_items(&self) -> Option<AlignItems>

Controls alignment of flex items along the cross axis.

Determines how items are aligned when they don’t fill the container’s cross axis.

Source

pub fn align_content(&self) -> Option<AlignContent>

Controls alignment of wrapped flex lines.

Only has an effect when flex-wrap is enabled and there are multiple lines.

Source

pub fn grid_template_rows(&self) -> Vec<GridTemplateComponent<String>>

Defines the line names and track sizing functions of the grid rows.

Specifies the size and names of the rows in a grid layout.

Source

pub fn grid_template_columns(&self) -> Vec<GridTemplateComponent<String>>

Defines the line names and track sizing functions of the grid columns.

Specifies the size and names of the columns in a grid layout.

Source

pub fn grid_auto_rows( &self, ) -> Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>

Specifies the size of implicitly-created grid rows.

Sets the default size for rows that are created automatically.

Source

pub fn grid_auto_columns( &self, ) -> Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>

Specifies the size of implicitly-created grid columns.

Sets the default size for columns that are created automatically.

Source

pub fn grid_auto_flow(&self) -> GridAutoFlow

Controls how auto-placed items get flowed into the grid.

Determines the direction that grid items are placed when not explicitly positioned.

Source

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

Specifies a grid item’s location within the grid row.

Determines which grid rows the item spans.

Source

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

Specifies a grid item’s location within the grid column.

Determines which grid columns the item spans.

Source

pub fn align_self(&self) -> Option<AlignItems>

Controls individual alignment along the cross axis.

Overrides the container’s align-items value for this specific item.

Source

pub fn outline_color(&self) -> Brush

Sets the color of the view’s outline.

The outline is drawn outside the border and doesn’t affect layout.

Source

pub fn outline(&self) -> Stroke

Sets the outline stroke properties.

Defines the width, style, and other properties of the outline.

Source

pub fn outline_progress(&self) -> Pct

Controls the progress/completion of the outline animation.

Useful for creating animated outline effects.

Source

pub fn border_progress(&self) -> Pct

Controls the progress/completion of the border animation.

Useful for creating animated border effects.

Source

pub fn border_left(&self) -> Stroke

Sets the left border.

Source

pub fn border_top(&self) -> Stroke

Sets the top border.

Source

pub fn border_right(&self) -> Stroke

Sets the right border.

Source

pub fn border_bottom(&self) -> Stroke

Sets the bottom border.

Source

pub fn border_left_color(&self) -> Option<Brush>

Sets the left border color.

Source

pub fn border_top_color(&self) -> Option<Brush>

Sets the top border color.

Source

pub fn border_right_color(&self) -> Option<Brush>

Sets the right border color.

Source

pub fn border_bottom_color(&self) -> Option<Brush>

Sets the bottom border color.

Source

pub fn border_top_left_radius(&self) -> PxPct

Sets the top-left border radius.

Source

pub fn border_top_right_radius(&self) -> PxPct

Sets the top-right border radius.

Source

pub fn border_bottom_left_radius(&self) -> PxPct

Sets the bottom-left border radius.

Source

pub fn border_bottom_right_radius(&self) -> PxPct

Sets the bottom-right border radius.

Source

pub fn padding_left(&self) -> PxPct

Sets the left padding.

Source

pub fn padding_top(&self) -> PxPct

Sets the top padding.

Source

pub fn padding_right(&self) -> PxPct

Sets the right padding.

Source

pub fn padding_bottom(&self) -> PxPct

Sets the bottom padding.

Source

pub fn margin_left(&self) -> PxPctAuto

Sets the left margin.

Source

pub fn margin_top(&self) -> PxPctAuto

Sets the top margin.

Source

pub fn margin_right(&self) -> PxPctAuto

Sets the right margin.

Source

pub fn margin_bottom(&self) -> PxPctAuto

Sets the bottom margin.

Source

pub fn inset_left(&self) -> PxPctAuto

Sets the left offset for positioned views.

Source

pub fn inset_top(&self) -> PxPctAuto

Sets the top offset for positioned views.

Source

pub fn inset_right(&self) -> PxPctAuto

Sets the right offset for positioned views.

Source

pub fn inset_bottom(&self) -> PxPctAuto

Sets the bottom offset for positioned views.

Source

pub fn pointer_events(&self) -> Option<PointerEvents>

Controls whether the view can be the target of mouse events.

When disabled, mouse events pass through to views behind.

Source

pub fn z_index(&self) -> Option<i32>

Controls the stack order of positioned views.

This is not a global z-index and will only be used as an override to the sorted order of sibling elements. If you want a view positioned above others, use an overlay.

Higher values appear in front of lower values.

Source

pub fn cursor(&self) -> Option<CursorStyle>

Sets the cursor style when hovering over the view.

Changes the appearance of the mouse cursor.

Source

pub fn color(&self) -> Option<Color>

Sets the text color.

This property is inherited by child views.

Source

pub fn background(&self) -> Option<Brush>

Sets the background color or image.

Can be a solid color, gradient, or image.

Source

pub fn foreground(&self) -> Option<Brush>

Sets the foreground color or pattern.

Used for drawing content like icons or shapes.

Source

pub fn box_shadow(&self) -> SmallVec<[BoxShadow; 3]>

Adds one or more drop shadows to the view.

Can create depth and visual separation effects.

Source

pub fn font_size(&self) -> Option<f32>

Sets the font size for text content.

This property is inherited by child views.

Source

pub fn font_family(&self) -> Option<String>

Sets the font family for text content.

This property is inherited by child views.

Source

pub fn font_weight(&self) -> Option<FontWeightProp>

Sets the font weight (boldness) for text content.

This property is inherited by child views.

Source

pub fn font_style(&self) -> Option<FontStyle>

Sets the font style (italic, normal) for text content.

This property is inherited by child views.

Source

pub fn cursor_color(&self) -> Brush

Sets the color of the text cursor.

Visible when text input views have focus.

Source

pub fn selection_corer_radius(&self) -> f64

Sets the corner radius of text selections.

Controls how rounded the corners of selected text appear.

Source

pub fn selectable(&self) -> bool

Controls whether the view’s text can be selected.

This property is inherited by child views.

Source

pub fn text_overflow(&self) -> TextOverflow

Controls how overflowed text content is handled.

Determines whether text wraps or gets clipped.

Source

pub fn text_align(&self) -> Option<Alignment>

Sets text alignment within the view.

Controls horizontal alignment of text content.

Source

pub fn line_height(&self) -> Option<LineHeightValue>

Sets the line height for text content.

This property is inherited by child views.

Source

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

Sets the preferred aspect ratio for the view.

Maintains width-to-height proportions during layout.

Source

pub fn object_fit(&self) -> ObjectFit

Controls how replaced content (like images) should be resized to fit its container.

This property specifies how an image or other replaced element should be resized to fit within its container while potentially preserving its aspect ratio. Corresponds to the CSS object-fit property.

Source

pub fn col_gap(&self) -> PxPct

Sets the gap between columns in grid or flex layouts.

Creates space between items in the horizontal direction.

Source

pub fn row_gap(&self) -> PxPct

Sets the gap between rows in grid or flex layouts.

Creates space between items in the vertical direction.

Source

pub fn scrollbar_width(&self) -> Px

Width of the scrollbar track in pixels.

This property reserves space for scrollbars when overflow_x or overflow_y is set to Scroll. The reserved space reduces the available content area but ensures content doesn’t flow under the scrollbar.

Layout behavior:

  • When overflow_y: Scroll, reserves scrollbar_width from the right side of the container
  • When overflow_x: Scroll, reserves scrollbar_width from the bottom of the container
  • Space is reserved inside the container’s bounds, reducing the content rect size
  • No space is reserved for overflow: Hidden, Visible, or Clip

Example:

// Reserve 10px for scrollbar
.scrollbar_width(10.0)

// Thinner scrollbar for compact UI
.scrollbar_width(6.0)

Default: 8px

Source

pub fn overflow_x(&self) -> Overflow

How children overflowing their container in X axis should affect layout

Source

pub fn overflow_y(&self) -> Overflow

How children overflowing their container in Y axis should affect layout

Source

pub fn scale_x(&self) -> Pct

Sets the horizontal scale transform.

Values less than 100% shrink the view, greater than 100% enlarge it. Scale is applied last in the transform sequence, after translation and rotation. The scaling occurs around the anchor point specified by scale_about. Transform order: translate → rotate → scale (matches CSS individual transform properties).

Source

pub fn scale_y(&self) -> Pct

Sets the vertical scale transform.

Values less than 100% shrink the view, greater than 100% enlarge it. Scale is applied last in the transform sequence, after translation and rotation. The scaling occurs around the anchor point specified by scale_about. Transform order: translate → rotate → scale (matches CSS individual transform properties).

Source

pub fn translate_x(&self) -> PxPct

Sets the horizontal translation transform.

Moves the view left (negative) or right (positive). Translation is applied first in the transform sequence, in the element’s local coordinate space. This matches CSS individual transform properties behavior. Transform order: translate → rotate → scale.

Source

pub fn translate_y(&self) -> PxPct

Sets the vertical translation transform.

Moves the view up (negative) or down (positive). Translation is applied first in the transform sequence, in the element’s local coordinate space. This matches CSS individual transform properties behavior. Transform order: translate → rotate → scale.

Source

pub fn rotate(&self) -> Angle

Sets the rotation transform angle.

Positive values rotate clockwise, negative values rotate counter-clockwise. Use .deg() or .rad() methods to specify the angle unit. Rotation is applied after translation but before scaling, around the anchor point specified by rotate_about. Transform order: translate → rotate → scale (matches CSS individual transform properties).

Source

pub fn rotate_about(&self) -> AnchorAbout

Sets the anchor point for rotation transformations.

Determines the point around which the view rotates. Use predefined constants like AnchorAbout::CENTER or create custom anchor points with pixel or percentage values. The anchor point is specified in the element’s local coordinate space (before any transforms).

Source

pub fn scale_about(&self) -> AnchorAbout

Sets the anchor point for scaling transformations.

Determines the point around which the view scales. Use predefined constants like AnchorAbout::CENTER or create custom anchor points with pixel or percentage values. The anchor point is specified in the element’s local coordinate space (before any transforms). Transform order: translate → rotate → scale (matches CSS individual transform properties).

Source

pub fn transform(&self) -> Affine

Sets a custom affine transformation matrix.

This property allows you to specify an arbitrary 2D affine transformation that will be applied in addition to the individual transform properties (translate_x, translate_y, scale_x, scale_y, rotate).

Transform application order:

  1. Individual translate_x and translate_y properties
  2. Individual rotate property
  3. Individual scale_x and scale_y properties
  4. This transform property (applied last)

This matches CSS behavior where individual transform properties are applied before the transform property. The transform matrix is applied in the final coordinate space after all individual transforms.

Example:

let _style = Style::new()
    .translate_x(10.0) // Applied first
    .scale(1.5) // Applied second
    .transform(Affine::rotate(0.5)); // Applied last
Source

pub fn opacity(&self) -> f32

Sets the opacity of the view.

Values range from 0.0 (fully transparent) to 1.0 (fully opaque). This affects the entire view including its children.

Source

pub fn set_selected(&self) -> bool

Sets the selected state of the view.

This property is inherited by child views.

Source

pub fn set_disabled(&self) -> bool

Controls the disabled state of the view.

This property is inherited by child views.

Source

pub fn set_focus(&self) -> Focus

Controls whether the view can receive focus during navigation such as tab or arrow navigation.

Auto Trait Implementations§

§

impl<'a> Freeze for BuiltinStyle<'a>

§

impl<'a> !RefUnwindSafe for BuiltinStyle<'a>

§

impl<'a> !Send for BuiltinStyle<'a>

§

impl<'a> !Sync for BuiltinStyle<'a>

§

impl<'a> Unpin for BuiltinStyle<'a>

§

impl<'a> UnsafeUnpin for BuiltinStyle<'a>

§

impl<'a> !UnwindSafe for BuiltinStyle<'a>

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more