pub struct BuiltinStyle<'a> { /* private fields */ }Implementations§
Source§impl BuiltinStyle<'_>
impl BuiltinStyle<'_>
Sourcepub fn display(&self) -> Display
pub fn display(&self) -> Display
Controls the display type of the view.
This determines how the view participates in layout.
Sourcepub fn position(&self) -> Position
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.
Sourcepub fn is_fixed(&self) -> bool
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
insetproperties 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.
Sourcepub fn width(&self) -> PxPctAuto
pub fn width(&self) -> PxPctAuto
Sets the width of the view.
Can be specified in pixels, percentages, or auto.
Sourcepub fn height(&self) -> PxPctAuto
pub fn height(&self) -> PxPctAuto
Sets the height of the view.
Can be specified in pixels, percentages, or auto.
Sourcepub fn min_width(&self) -> PxPctAuto
pub fn min_width(&self) -> PxPctAuto
Sets the minimum width of the view.
The view will not shrink below this width.
Sourcepub fn min_height(&self) -> PxPctAuto
pub fn min_height(&self) -> PxPctAuto
Sets the minimum height of the view.
The view will not shrink below this height.
Sourcepub fn max_width(&self) -> PxPctAuto
pub fn max_width(&self) -> PxPctAuto
Sets the maximum width of the view.
The view will not grow beyond this width.
Sourcepub fn max_height(&self) -> PxPctAuto
pub fn max_height(&self) -> PxPctAuto
Sets the maximum height of the view.
The view will not grow beyond this height.
Sourcepub fn flex_direction(&self) -> FlexDirection
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.
Sourcepub fn flex_wrap(&self) -> FlexWrap
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.
Sourcepub fn flex_grow(&self) -> f32
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.
Sourcepub fn flex_shrink(&self) -> f32
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.
Sourcepub fn flex_basis(&self) -> PxPctAuto
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.
Sourcepub fn justify_content(&self) -> Option<JustifyContent>
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.
Sourcepub fn justify_items(&self) -> Option<JustifyItems>
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.
Sourcepub fn box_sizing(&self) -> Option<BoxSizing>
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.
Sourcepub fn justify_self(&self) -> Option<AlignItems>
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.
Sourcepub fn align_items(&self) -> Option<AlignItems>
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.
Sourcepub fn align_content(&self) -> Option<AlignContent>
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.
Sourcepub fn grid_template_rows(&self) -> Vec<GridTemplateComponent<String>>
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.
Sourcepub fn grid_template_columns(&self) -> Vec<GridTemplateComponent<String>>
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.
Sourcepub fn grid_auto_rows(
&self,
) -> Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>
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.
Sourcepub fn grid_auto_columns(
&self,
) -> Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>
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.
Sourcepub fn grid_auto_flow(&self) -> GridAutoFlow
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.
Sourcepub fn grid_row(&self) -> Line<GridPlacement>
pub fn grid_row(&self) -> Line<GridPlacement>
Specifies a grid item’s location within the grid row.
Determines which grid rows the item spans.
Sourcepub fn grid_column(&self) -> Line<GridPlacement>
pub fn grid_column(&self) -> Line<GridPlacement>
Specifies a grid item’s location within the grid column.
Determines which grid columns the item spans.
Sourcepub fn align_self(&self) -> Option<AlignItems>
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.
Sourcepub fn outline_color(&self) -> Brush
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.
Sourcepub fn outline(&self) -> Stroke
pub fn outline(&self) -> Stroke
Sets the outline stroke properties.
Defines the width, style, and other properties of the outline.
Sourcepub fn outline_progress(&self) -> Pct
pub fn outline_progress(&self) -> Pct
Controls the progress/completion of the outline animation.
Useful for creating animated outline effects.
Sourcepub fn border_progress(&self) -> Pct
pub fn border_progress(&self) -> Pct
Controls the progress/completion of the border animation.
Useful for creating animated border effects.
Sourcepub fn border_left(&self) -> Stroke
pub fn border_left(&self) -> Stroke
Sets the left border.
Sourcepub fn border_top(&self) -> Stroke
pub fn border_top(&self) -> Stroke
Sets the top border.
Sourcepub fn border_right(&self) -> Stroke
pub fn border_right(&self) -> Stroke
Sets the right border.
Sourcepub fn border_bottom(&self) -> Stroke
pub fn border_bottom(&self) -> Stroke
Sets the bottom border.
Sourcepub fn border_left_color(&self) -> Option<Brush>
pub fn border_left_color(&self) -> Option<Brush>
Sets the left border color.
Sourcepub fn border_top_color(&self) -> Option<Brush>
pub fn border_top_color(&self) -> Option<Brush>
Sets the top border color.
Sourcepub fn border_right_color(&self) -> Option<Brush>
pub fn border_right_color(&self) -> Option<Brush>
Sets the right border color.
Sourcepub fn border_bottom_color(&self) -> Option<Brush>
pub fn border_bottom_color(&self) -> Option<Brush>
Sets the bottom border color.
Sourcepub fn border_top_left_radius(&self) -> PxPct
pub fn border_top_left_radius(&self) -> PxPct
Sets the top-left border radius.
Sourcepub fn border_top_right_radius(&self) -> PxPct
pub fn border_top_right_radius(&self) -> PxPct
Sets the top-right border radius.
Sourcepub fn border_bottom_left_radius(&self) -> PxPct
pub fn border_bottom_left_radius(&self) -> PxPct
Sets the bottom-left border radius.
Sourcepub fn border_bottom_right_radius(&self) -> PxPct
pub fn border_bottom_right_radius(&self) -> PxPct
Sets the bottom-right border radius.
Sourcepub fn padding_left(&self) -> PxPct
pub fn padding_left(&self) -> PxPct
Sets the left padding.
Sourcepub fn padding_top(&self) -> PxPct
pub fn padding_top(&self) -> PxPct
Sets the top padding.
Sourcepub fn padding_right(&self) -> PxPct
pub fn padding_right(&self) -> PxPct
Sets the right padding.
Sourcepub fn padding_bottom(&self) -> PxPct
pub fn padding_bottom(&self) -> PxPct
Sets the bottom padding.
Sourcepub fn margin_left(&self) -> PxPctAuto
pub fn margin_left(&self) -> PxPctAuto
Sets the left margin.
Sourcepub fn margin_top(&self) -> PxPctAuto
pub fn margin_top(&self) -> PxPctAuto
Sets the top margin.
Sourcepub fn margin_right(&self) -> PxPctAuto
pub fn margin_right(&self) -> PxPctAuto
Sets the right margin.
Sourcepub fn margin_bottom(&self) -> PxPctAuto
pub fn margin_bottom(&self) -> PxPctAuto
Sets the bottom margin.
Sourcepub fn inset_left(&self) -> PxPctAuto
pub fn inset_left(&self) -> PxPctAuto
Sets the left offset for positioned views.
Sourcepub fn inset_right(&self) -> PxPctAuto
pub fn inset_right(&self) -> PxPctAuto
Sets the right offset for positioned views.
Sourcepub fn inset_bottom(&self) -> PxPctAuto
pub fn inset_bottom(&self) -> PxPctAuto
Sets the bottom offset for positioned views.
Sourcepub fn pointer_events(&self) -> Option<PointerEvents>
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.
Sourcepub fn z_index(&self) -> Option<i32>
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.
Sourcepub fn cursor(&self) -> Option<CursorStyle>
pub fn cursor(&self) -> Option<CursorStyle>
Sets the cursor style when hovering over the view.
Changes the appearance of the mouse cursor.
Sourcepub fn color(&self) -> Option<Color>
pub fn color(&self) -> Option<Color>
Sets the text color.
This property is inherited by child views.
Sourcepub fn background(&self) -> Option<Brush>
pub fn background(&self) -> Option<Brush>
Sets the background color or image.
Can be a solid color, gradient, or image.
Sourcepub fn foreground(&self) -> Option<Brush>
pub fn foreground(&self) -> Option<Brush>
Sets the foreground color or pattern.
Used for drawing content like icons or shapes.
Sourcepub fn box_shadow(&self) -> SmallVec<[BoxShadow; 3]>
pub fn box_shadow(&self) -> SmallVec<[BoxShadow; 3]>
Adds one or more drop shadows to the view.
Can create depth and visual separation effects.
Sourcepub fn font_size(&self) -> Option<f32>
pub fn font_size(&self) -> Option<f32>
Sets the font size for text content.
This property is inherited by child views.
Sourcepub fn font_family(&self) -> Option<String>
pub fn font_family(&self) -> Option<String>
Sets the font family for text content.
This property is inherited by child views.
Sourcepub fn font_weight(&self) -> Option<FontWeightProp>
pub fn font_weight(&self) -> Option<FontWeightProp>
Sets the font weight (boldness) for text content.
This property is inherited by child views.
Sourcepub fn font_style(&self) -> Option<FontStyle>
pub fn font_style(&self) -> Option<FontStyle>
Sets the font style (italic, normal) for text content.
This property is inherited by child views.
Sourcepub fn cursor_color(&self) -> Brush
pub fn cursor_color(&self) -> Brush
Sets the color of the text cursor.
Visible when text input views have focus.
Sourcepub fn selection_corer_radius(&self) -> f64
pub fn selection_corer_radius(&self) -> f64
Sets the corner radius of text selections.
Controls how rounded the corners of selected text appear.
Sourcepub fn selectable(&self) -> bool
pub fn selectable(&self) -> bool
Controls whether the view’s text can be selected.
This property is inherited by child views.
Sourcepub fn text_overflow(&self) -> TextOverflow
pub fn text_overflow(&self) -> TextOverflow
Controls how overflowed text content is handled.
Determines whether text wraps or gets clipped.
Sourcepub fn text_align(&self) -> Option<Alignment>
pub fn text_align(&self) -> Option<Alignment>
Sets text alignment within the view.
Controls horizontal alignment of text content.
Sourcepub fn line_height(&self) -> Option<LineHeightValue>
pub fn line_height(&self) -> Option<LineHeightValue>
Sets the line height for text content.
This property is inherited by child views.
Sourcepub fn aspect_ratio(&self) -> Option<f32>
pub fn aspect_ratio(&self) -> Option<f32>
Sets the preferred aspect ratio for the view.
Maintains width-to-height proportions during layout.
Sourcepub fn object_fit(&self) -> ObjectFit
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.
Sourcepub fn col_gap(&self) -> PxPct
pub fn col_gap(&self) -> PxPct
Sets the gap between columns in grid or flex layouts.
Creates space between items in the horizontal direction.
Sourcepub fn row_gap(&self) -> PxPct
pub fn row_gap(&self) -> PxPct
Sets the gap between rows in grid or flex layouts.
Creates space between items in the vertical direction.
Sourcepub fn scrollbar_width(&self) -> Px
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, reservesscrollbar_widthfrom the right side of the container - When
overflow_x: Scroll, reservesscrollbar_widthfrom 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, orClip
Example:
// Reserve 10px for scrollbar
.scrollbar_width(10.0)
// Thinner scrollbar for compact UI
.scrollbar_width(6.0)Default: 8px
Sourcepub fn overflow_x(&self) -> Overflow
pub fn overflow_x(&self) -> Overflow
How children overflowing their container in X axis should affect layout
Sourcepub fn overflow_y(&self) -> Overflow
pub fn overflow_y(&self) -> Overflow
How children overflowing their container in Y axis should affect layout
Sourcepub fn scale_x(&self) -> Pct
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).
Sourcepub fn scale_y(&self) -> Pct
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).
Sourcepub fn translate_x(&self) -> PxPct
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.
Sourcepub fn translate_y(&self) -> PxPct
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.
Sourcepub fn rotate(&self) -> Angle
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).
Sourcepub fn rotate_about(&self) -> AnchorAbout
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).
Sourcepub fn scale_about(&self) -> AnchorAbout
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).
Sourcepub fn transform(&self) -> Affine
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:
- Individual
translate_xandtranslate_yproperties - Individual
rotateproperty - Individual
scale_xandscale_yproperties - This
transformproperty (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 lastSourcepub fn opacity(&self) -> f32
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.
Sourcepub fn set_selected(&self) -> bool
pub fn set_selected(&self) -> bool
Sets the selected state of the view.
This property is inherited by child views.
Sourcepub fn set_disabled(&self) -> bool
pub fn set_disabled(&self) -> bool
Controls the disabled state of the view.
This property is inherited by child views.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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