pub struct Style { /* private fields */ }Implementations§
Source§impl Style
impl Style
Sourcepub fn content_hash(&self) -> u64
pub fn content_hash(&self) -> u64
Compute a content hash of this style for cache keying.
This hash captures the identity of the style’s contents using value-based hashing. Identical style values will produce identical hashes, enabling effective cache sharing.
Sourcepub fn inherited_equal(&self, other: &Style) -> bool
pub fn inherited_equal(&self, other: &Style) -> bool
Check if the inherited properties of this style equal another’s.
This is the key comparison for cache validation (Chromium’s approach). Two styles with different inherited values cannot share a cache entry even if their non-inherited properties are identical.
Source§impl Style
impl Style
pub fn new() -> Self
Sourcepub fn apply_only_inherited(to: &mut Rc<Style>, from: &Style)
pub fn apply_only_inherited(to: &mut Rc<Style>, from: &Style)
Apply only inherited properties from from style to to style.
This is used during style propagation to pass inherited values to children.
Only properties marked as inherited: true in their StylePropInfo are applied.
This is more efficient than apply_mut when we only need to propagate
inherited properties like font-size, color, etc.
Sourcepub fn apply_inherited_and_class_maps(to: &mut Rc<Style>, from: &Style)
pub fn apply_inherited_and_class_maps(to: &mut Rc<Style>, from: &Style)
Apply inherited properties and class nested maps from from style to to style.
This is used during style propagation to pass both inherited values and
class definitions to children. Class nested maps (like .class(ListItemClass, ...))
need to flow to descendants so they can apply the styling when they have matching classes.
Sourcepub fn apply_only_class_maps(to: &mut Rc<Style>, from: &Style)
pub fn apply_only_class_maps(to: &mut Rc<Style>, from: &Style)
Apply only class nested maps from from style to to style.
This is used during style propagation to pass class definitions to children.
Only class nested maps (.class(SomeClass, ...)) are applied, not inherited props.
Sourcepub fn apply_classes_from_context(
self,
classes: &[StyleClassRef],
class_context: &Rc<Style>,
) -> (Style, bool)
pub fn apply_classes_from_context( self, classes: &[StyleClassRef], class_context: &Rc<Style>, ) -> (Style, bool)
Applies class styling from the context (inherited from ancestors) to this style.
The view’s own explicit styles take precedence over context class styles. This is achieved by applying context class styles first, then applying the view’s own styles on top.
Context mappings (from with_context/with_theme) from class styles are
merged with the view’s own context mappings. Class mappings run first (as
defaults), then view’s own mappings run (allowing overrides). This ensures
that theme class styles can use with_context for context-aware styling
(like toggle button height based on font size) while still allowing views
to override via their own with_context closures.
The returned boolean is true if a nested map was applied.
pub fn apply_class<C: StyleClass>(self, _class: C) -> Style
pub fn apply_selectors(self, selectors: &[StyleSelector]) -> Style
Sourcepub fn with_context<P: StyleProp>(
self,
f: impl Fn(Self, &P::Type) -> Self + 'static,
) -> Self
pub fn with_context<P: StyleProp>( self, f: impl Fn(Self, &P::Type) -> Self + 'static, ) -> Self
Apply a context-based style transformation.
This evaluates the closure immediately with the context prop’s default value (for selector and inherited prop discovery), and also stores the closure to be re-evaluated with actual ancestor context values during style resolution.
Signal reactivity works because the outer style closure re-runs when signals change.
Sourcepub fn with_context_opt<P: StyleProp<Type = Option<T>>, T: 'static + Default>(
self,
f: impl Fn(Self, T) -> Self + 'static,
) -> Self
pub fn with_context_opt<P: StyleProp<Type = Option<T>>, T: 'static + Default>( self, f: impl Fn(Self, T) -> Self + 'static, ) -> Self
Apply a context-based style transformation for optional props.
Like with_context, this evaluates immediately with defaults for discovery,
and stores the closure for context-aware re-evaluation.
pub fn builtin(&self) -> BuiltinStyle<'_>
Sourcepub fn apply(self, over: Style) -> Style
pub fn apply(self, over: Style) -> Style
Apply another Style to this style, returning a new Style with the overrides
StyleValue::Val will override the value with the given value
StyleValue::Unset will unset the value, causing it to fall back to the default.
StyleValue::Base will leave the value as-is, whether falling back to the default
or using the value in the Style.
pub fn map(self, over: impl FnOnce(Self) -> Self) -> Self
Sourcepub fn apply_overriding_styles(
self,
overrides: impl Iterator<Item = Style>,
) -> Style
pub fn apply_overriding_styles( self, overrides: impl Iterator<Item = Style>, ) -> Style
Apply multiple Styles to this style, returning a new Style with the overrides.
Later styles take precedence over earlier styles.
Source§impl Style
impl Style
Sourcepub fn display(self, v: impl Into<Display>) -> Self
pub fn display(self, v: impl Into<Display>) -> Self
Controls the display type of the view.
This determines how the view participates in layout.
Sourcepub fn position(self, v: impl Into<Position>) -> Self
pub fn position(self, v: impl Into<Position>) -> Self
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, v: impl Into<bool>) -> Self
pub fn is_fixed(self, v: impl Into<bool>) -> Self
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, v: impl Into<PxPctAuto>) -> Self
pub fn width(self, v: impl Into<PxPctAuto>) -> Self
Sets the width of the view.
Can be specified in pixels, percentages, or auto.
Sourcepub fn height(self, v: impl Into<PxPctAuto>) -> Self
pub fn height(self, v: impl Into<PxPctAuto>) -> Self
Sets the height of the view.
Can be specified in pixels, percentages, or auto.
Sourcepub fn min_width(self, v: impl Into<PxPctAuto>) -> Self
pub fn min_width(self, v: impl Into<PxPctAuto>) -> Self
Sets the minimum width of the view.
The view will not shrink below this width.
Sourcepub fn min_height(self, v: impl Into<PxPctAuto>) -> Self
pub fn min_height(self, v: impl Into<PxPctAuto>) -> Self
Sets the minimum height of the view.
The view will not shrink below this height.
Sourcepub fn max_width(self, v: impl Into<PxPctAuto>) -> Self
pub fn max_width(self, v: impl Into<PxPctAuto>) -> Self
Sets the maximum width of the view.
The view will not grow beyond this width.
Sourcepub fn max_height(self, v: impl Into<PxPctAuto>) -> Self
pub fn max_height(self, v: impl Into<PxPctAuto>) -> Self
Sets the maximum height of the view.
The view will not grow beyond this height.
Sourcepub fn flex_direction(self, v: impl Into<FlexDirection>) -> Self
pub fn flex_direction(self, v: impl Into<FlexDirection>) -> Self
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, v: impl Into<FlexWrap>) -> Self
pub fn flex_wrap(self, v: impl Into<FlexWrap>) -> Self
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, v: impl Into<f32>) -> Self
pub fn flex_grow(self, v: impl Into<f32>) -> Self
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, v: impl Into<f32>) -> Self
pub fn flex_shrink(self, v: impl Into<f32>) -> Self
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, v: impl Into<PxPctAuto>) -> Self
pub fn flex_basis(self, v: impl Into<PxPctAuto>) -> Self
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, v: impl Into<Option<JustifyContent>>) -> Self
pub fn justify_content(self, v: impl Into<Option<JustifyContent>>) -> Self
Controls alignment of flex items along the main axis.
Determines how extra space is distributed between and around items.
Sourcepub fn justify_items(self, v: impl Into<Option<JustifyItems>>) -> Self
pub fn justify_items(self, v: impl Into<Option<JustifyItems>>) -> Self
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, v: impl Into<Option<BoxSizing>>) -> Self
pub fn box_sizing(self, v: impl Into<Option<BoxSizing>>) -> Self
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, v: impl Into<Option<AlignItems>>) -> Self
pub fn justify_self(self, v: impl Into<Option<AlignItems>>) -> Self
Controls individual alignment along the inline axis.
Overrides the container’s justify-items value for this specific item.
Sourcepub fn align_items(self, v: impl Into<Option<AlignItems>>) -> Self
pub fn align_items(self, v: impl Into<Option<AlignItems>>) -> Self
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, v: impl Into<Option<AlignContent>>) -> Self
pub fn align_content(self, v: impl Into<Option<AlignContent>>) -> Self
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,
v: impl Into<Vec<GridTemplateComponent<String>>>,
) -> Self
pub fn grid_template_rows( self, v: impl Into<Vec<GridTemplateComponent<String>>>, ) -> Self
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,
v: impl Into<Vec<GridTemplateComponent<String>>>,
) -> Self
pub fn grid_template_columns( self, v: impl Into<Vec<GridTemplateComponent<String>>>, ) -> Self
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,
v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>,
) -> Self
pub fn grid_auto_rows( self, v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>, ) -> Self
Specifies the size of implicitly-created grid rows.
Sets the default size for rows that are created automatically.
Sourcepub fn grid_auto_columns(
self,
v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>,
) -> Self
pub fn grid_auto_columns( self, v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>, ) -> Self
Specifies the size of implicitly-created grid columns.
Sets the default size for columns that are created automatically.
Sourcepub fn grid_auto_flow(self, v: impl Into<GridAutoFlow>) -> Self
pub fn grid_auto_flow(self, v: impl Into<GridAutoFlow>) -> Self
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, v: impl Into<Line<GridPlacement>>) -> Self
pub fn grid_row(self, v: impl Into<Line<GridPlacement>>) -> Self
Specifies a grid item’s location within the grid row.
Determines which grid rows the item spans.
Sourcepub fn grid_column(self, v: impl Into<Line<GridPlacement>>) -> Self
pub fn grid_column(self, v: impl Into<Line<GridPlacement>>) -> Self
Specifies a grid item’s location within the grid column.
Determines which grid columns the item spans.
Sourcepub fn align_self(self, v: impl Into<Option<AlignItems>>) -> Self
pub fn align_self(self, v: impl Into<Option<AlignItems>>) -> Self
Controls individual alignment along the cross axis.
Overrides the container’s align-items value for this specific item.
Sourcepub fn outline_color(self, v: impl Into<Brush>) -> Self
pub fn outline_color(self, v: impl Into<Brush>) -> Self
Sets the color of the view’s outline.
The outline is drawn outside the border and doesn’t affect layout.
Sourcepub fn outline_progress(self, v: impl Into<Pct>) -> Self
pub fn outline_progress(self, v: impl Into<Pct>) -> Self
Controls the progress/completion of the outline animation.
Useful for creating animated outline effects.
Sourcepub fn border_progress(self, v: impl Into<Pct>) -> Self
pub fn border_progress(self, v: impl Into<Pct>) -> Self
Controls the progress/completion of the border animation.
Useful for creating animated border effects.
Sourcepub fn inset_left(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_left(self, v: impl Into<PxPctAuto>) -> Self
Sets the left offset for positioned views.
Sourcepub fn inset_top(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_top(self, v: impl Into<PxPctAuto>) -> Self
Sets the top offset for positioned views.
Sourcepub fn inset_right(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_right(self, v: impl Into<PxPctAuto>) -> Self
Sets the right offset for positioned views.
Sourcepub fn inset_bottom(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_bottom(self, v: impl Into<PxPctAuto>) -> Self
Sets the bottom offset for positioned views.
Sourcepub fn pointer_events(self, v: impl Into<Option<PointerEvents>>) -> Self
pub fn pointer_events(self, v: impl Into<Option<PointerEvents>>) -> Self
Controls whether the view can be the target of mouse events.
When disabled, mouse events pass through to views behind.
Sourcepub fn selectable(self, v: impl Into<bool>) -> Self
pub fn selectable(self, v: impl Into<bool>) -> Self
Controls whether the view’s text can be selected.
This property is inherited by child views.
Sourcepub fn text_overflow(self, v: impl Into<TextOverflow>) -> Self
pub fn text_overflow(self, v: impl Into<TextOverflow>) -> Self
Controls how overflowed text content is handled.
Determines whether text wraps or gets clipped.
Sourcepub fn text_align(self, v: impl Into<Option<Align>>) -> Self
pub fn text_align(self, v: impl Into<Option<Align>>) -> Self
Sets text alignment within the view.
Controls horizontal alignment of text content.
Sourcepub fn aspect_ratio(self, v: impl Into<Option<f32>>) -> Self
pub fn aspect_ratio(self, v: impl Into<Option<f32>>) -> Self
Sets the preferred aspect ratio for the view.
Maintains width-to-height proportions during layout.
Sourcepub fn scale_x(self, v: impl Into<Pct>) -> Self
pub fn scale_x(self, v: impl Into<Pct>) -> Self
Sets the horizontal scale transform.
Values less than 100% shrink the view, greater than 100% enlarge it.
Sourcepub fn scale_y(self, v: impl Into<Pct>) -> Self
pub fn scale_y(self, v: impl Into<Pct>) -> Self
Sets the vertical scale transform.
Values less than 100% shrink the view, greater than 100% enlarge it.
Sourcepub fn translate_x(self, v: impl Into<PxPct>) -> Self
pub fn translate_x(self, v: impl Into<PxPct>) -> Self
Sets the horizontal translation transform.
Moves the view left (negative) or right (positive).
Sourcepub fn translate_y(self, v: impl Into<PxPct>) -> Self
pub fn translate_y(self, v: impl Into<PxPct>) -> Self
Sets the vertical translation transform.
Moves the view up (negative) or down (positive).
Sourcepub fn rotate(self, v: impl Into<Angle>) -> Self
pub fn rotate(self, v: impl Into<Angle>) -> Self
Sets the rotation transform angle.
Positive values rotate clockwise, negative values rotate counter-clockwise.
Use .deg() or .rad() methods to specify the angle unit.
Sourcepub fn rotate_about(self, v: impl Into<AnchorAbout>) -> Self
pub fn rotate_about(self, v: impl Into<AnchorAbout>) -> Self
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.
Sourcepub fn scale_about(self, v: impl Into<AnchorAbout>) -> Self
pub fn scale_about(self, v: impl Into<AnchorAbout>) -> Self
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.
Sourcepub fn opacity(self, v: impl Into<f32>) -> Self
pub fn opacity(self, v: impl Into<f32>) -> Self
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, v: impl Into<bool>) -> Self
pub fn set_selected(self, v: impl Into<bool>) -> Self
Sets the selected state of the view.
This property is inherited by child views.
Sourcepub fn set_disabled(self, v: impl Into<bool>) -> Self
pub fn set_disabled(self, v: impl Into<bool>) -> Self
Controls the disabled state of the view.
This property is inherited by child views.
Sourcepub fn focusable(self, v: impl Into<bool>) -> Self
pub fn focusable(self, v: impl Into<bool>) -> Self
Controls whether the view can receive focus.
Focus is necessary for keyboard interaction.
Sourcepub fn draggable(self, v: impl Into<bool>) -> Self
pub fn draggable(self, v: impl Into<bool>) -> Self
Controls whether the view can be dragged.
Enables drag-and-drop functionality for the view.
Sourcepub fn unset_display(self) -> Self
pub fn unset_display(self) -> Self
Unsets the display property.
Sourcepub fn unset_position(self) -> Self
pub fn unset_position(self) -> Self
Unsets the position property.
Sourcepub fn unset_is_fixed(self) -> Self
pub fn unset_is_fixed(self) -> Self
Unsets the is_fixed property.
Sourcepub fn unset_width(self) -> Self
pub fn unset_width(self) -> Self
Unsets the width property.
Sourcepub fn unset_height(self) -> Self
pub fn unset_height(self) -> Self
Unsets the height property.
Sourcepub fn unset_min_width(self) -> Self
pub fn unset_min_width(self) -> Self
Unsets the min_width property.
Sourcepub fn unset_min_height(self) -> Self
pub fn unset_min_height(self) -> Self
Unsets the min_height property.
Sourcepub fn unset_max_width(self) -> Self
pub fn unset_max_width(self) -> Self
Unsets the max_width property.
Sourcepub fn unset_max_height(self) -> Self
pub fn unset_max_height(self) -> Self
Unsets the max_height property.
Sourcepub fn unset_flex_direction(self) -> Self
pub fn unset_flex_direction(self) -> Self
Unsets the flex_direction property.
Sourcepub fn unset_flex_wrap(self) -> Self
pub fn unset_flex_wrap(self) -> Self
Unsets the flex_wrap property.
Sourcepub fn unset_flex_grow(self) -> Self
pub fn unset_flex_grow(self) -> Self
Unsets the flex_grow property.
Sourcepub fn unset_flex_shrink(self) -> Self
pub fn unset_flex_shrink(self) -> Self
Unsets the flex_shrink property.
Sourcepub fn unset_flex_basis(self) -> Self
pub fn unset_flex_basis(self) -> Self
Unsets the flex_basis property.
Sourcepub fn unset_justify_content(self) -> Self
pub fn unset_justify_content(self) -> Self
Unsets the justify_content property.
Sourcepub fn unset_justify_items(self) -> Self
pub fn unset_justify_items(self) -> Self
Unsets the justify_items property.
Sourcepub fn unset_box_sizing(self) -> Self
pub fn unset_box_sizing(self) -> Self
Unsets the box_sizing property.
Sourcepub fn unset_justify_self(self) -> Self
pub fn unset_justify_self(self) -> Self
Unsets the justify_self property.
Sourcepub fn unset_align_items(self) -> Self
pub fn unset_align_items(self) -> Self
Unsets the align_items property.
Sourcepub fn unset_align_content(self) -> Self
pub fn unset_align_content(self) -> Self
Unsets the align_content property.
Sourcepub fn unset_grid_template_rows(self) -> Self
pub fn unset_grid_template_rows(self) -> Self
Unsets the grid_template_rows property.
Sourcepub fn unset_grid_template_columns(self) -> Self
pub fn unset_grid_template_columns(self) -> Self
Unsets the grid_template_columns property.
Sourcepub fn unset_grid_auto_rows(self) -> Self
pub fn unset_grid_auto_rows(self) -> Self
Unsets the grid_auto_rows property.
Sourcepub fn unset_grid_auto_columns(self) -> Self
pub fn unset_grid_auto_columns(self) -> Self
Unsets the grid_auto_columns property.
Sourcepub fn unset_grid_auto_flow(self) -> Self
pub fn unset_grid_auto_flow(self) -> Self
Unsets the grid_auto_flow property.
Sourcepub fn unset_grid_row(self) -> Self
pub fn unset_grid_row(self) -> Self
Unsets the grid_row property.
Sourcepub fn unset_grid_column(self) -> Self
pub fn unset_grid_column(self) -> Self
Unsets the grid_column property.
Sourcepub fn unset_align_self(self) -> Self
pub fn unset_align_self(self) -> Self
Unsets the align_self property.
Sourcepub fn unset_outline_color(self) -> Self
pub fn unset_outline_color(self) -> Self
Unsets the outline_color property.
Sourcepub fn unset_outline(self) -> Self
pub fn unset_outline(self) -> Self
Unsets the outline property.
Sourcepub fn unset_outline_progress(self) -> Self
pub fn unset_outline_progress(self) -> Self
Unsets the outline_progress property.
Sourcepub fn unset_border_progress(self) -> Self
pub fn unset_border_progress(self) -> Self
Unsets the border_progress property.
Sourcepub fn unset_border_combined(self) -> Self
pub fn unset_border_combined(self) -> Self
Unsets the border_combined property.
Sourcepub fn unset_border_color_combined(self) -> Self
pub fn unset_border_color_combined(self) -> Self
Unsets the border_color_combined property.
Sourcepub fn unset_border_radius_combined(self) -> Self
pub fn unset_border_radius_combined(self) -> Self
Unsets the border_radius_combined property.
Sourcepub fn unset_padding_combined(self) -> Self
pub fn unset_padding_combined(self) -> Self
Unsets the padding_combined property.
Sourcepub fn unset_margin_combined(self) -> Self
pub fn unset_margin_combined(self) -> Self
Unsets the margin_combined property.
Sourcepub fn unset_inset_left(self) -> Self
pub fn unset_inset_left(self) -> Self
Unsets the inset_left property.
Sourcepub fn unset_inset_top(self) -> Self
pub fn unset_inset_top(self) -> Self
Unsets the inset_top property.
Sourcepub fn unset_inset_right(self) -> Self
pub fn unset_inset_right(self) -> Self
Unsets the inset_right property.
Sourcepub fn unset_inset_bottom(self) -> Self
pub fn unset_inset_bottom(self) -> Self
Unsets the inset_bottom property.
Sourcepub fn unset_pointer_events(self) -> Self
pub fn unset_pointer_events(self) -> Self
Unsets the pointer_events property.
Sourcepub fn unset_z_index(self) -> Self
pub fn unset_z_index(self) -> Self
Unsets the z_index property.
Sourcepub fn unset_cursor(self) -> Self
pub fn unset_cursor(self) -> Self
Unsets the cursor property.
Sourcepub fn unset_color(self) -> Self
pub fn unset_color(self) -> Self
Unsets the color property.
Sourcepub fn unset_background(self) -> Self
pub fn unset_background(self) -> Self
Unsets the background property.
Sourcepub fn unset_foreground(self) -> Self
pub fn unset_foreground(self) -> Self
Unsets the foreground property.
Sourcepub fn unset_box_shadow(self) -> Self
pub fn unset_box_shadow(self) -> Self
Unsets the box_shadow property.
Sourcepub fn unset_font_size(self) -> Self
pub fn unset_font_size(self) -> Self
Unsets the font_size property.
Sourcepub fn unset_font_family(self) -> Self
pub fn unset_font_family(self) -> Self
Unsets the font_family property.
Sourcepub fn unset_font_weight(self) -> Self
pub fn unset_font_weight(self) -> Self
Unsets the font_weight property.
Sourcepub fn unset_font_style(self) -> Self
pub fn unset_font_style(self) -> Self
Unsets the font_style property.
Sourcepub fn unset_cursor_color(self) -> Self
pub fn unset_cursor_color(self) -> Self
Unsets the cursor_color property.
Sourcepub fn unset_selection_corer_radius(self) -> Self
pub fn unset_selection_corer_radius(self) -> Self
Unsets the selection_corer_radius property.
Sourcepub fn unset_selectable(self) -> Self
pub fn unset_selectable(self) -> Self
Unsets the selectable property.
Sourcepub fn unset_text_overflow(self) -> Self
pub fn unset_text_overflow(self) -> Self
Unsets the text_overflow property.
Sourcepub fn unset_text_align(self) -> Self
pub fn unset_text_align(self) -> Self
Unsets the text_align property.
Sourcepub fn unset_line_height(self) -> Self
pub fn unset_line_height(self) -> Self
Unsets the line_height property.
Sourcepub fn unset_aspect_ratio(self) -> Self
pub fn unset_aspect_ratio(self) -> Self
Unsets the aspect_ratio property.
Sourcepub fn unset_col_gap(self) -> Self
pub fn unset_col_gap(self) -> Self
Unsets the col_gap property.
Sourcepub fn unset_row_gap(self) -> Self
pub fn unset_row_gap(self) -> Self
Unsets the row_gap property.
Sourcepub fn unset_scale_x(self) -> Self
pub fn unset_scale_x(self) -> Self
Unsets the scale_x property.
Sourcepub fn unset_scale_y(self) -> Self
pub fn unset_scale_y(self) -> Self
Unsets the scale_y property.
Sourcepub fn unset_translate_x(self) -> Self
pub fn unset_translate_x(self) -> Self
Unsets the translate_x property.
Sourcepub fn unset_translate_y(self) -> Self
pub fn unset_translate_y(self) -> Self
Unsets the translate_y property.
Sourcepub fn unset_rotate(self) -> Self
pub fn unset_rotate(self) -> Self
Unsets the rotate property.
Sourcepub fn unset_rotate_about(self) -> Self
pub fn unset_rotate_about(self) -> Self
Unsets the rotate_about property.
Sourcepub fn unset_scale_about(self) -> Self
pub fn unset_scale_about(self) -> Self
Unsets the scale_about property.
Sourcepub fn unset_opacity(self) -> Self
pub fn unset_opacity(self) -> Self
Unsets the opacity property.
Sourcepub fn unset_set_selected(self) -> Self
pub fn unset_set_selected(self) -> Self
Unsets the set_selected property.
Sourcepub fn unset_set_disabled(self) -> Self
pub fn unset_set_disabled(self) -> Self
Unsets the set_disabled property.
Sourcepub fn unset_focusable(self) -> Self
pub fn unset_focusable(self) -> Self
Unsets the focusable property.
Sourcepub fn unset_draggable(self) -> Self
pub fn unset_draggable(self) -> Self
Unsets the draggable property.
Sourcepub fn transition_width(self, transition: impl Into<Transition>) -> Self
pub fn transition_width(self, transition: impl Into<Transition>) -> Self
Sets a transition for the width property.
Sets the width of the view.
Can be specified in pixels, percentages, or auto.
Sourcepub fn transition_height(self, transition: impl Into<Transition>) -> Self
pub fn transition_height(self, transition: impl Into<Transition>) -> Self
Sets a transition for the height property.
Sets the height of the view.
Can be specified in pixels, percentages, or auto.
Sourcepub fn transition_min_width(self, transition: impl Into<Transition>) -> Self
pub fn transition_min_width(self, transition: impl Into<Transition>) -> Self
Sets a transition for the min_width property.
Sets the minimum width of the view.
The view will not shrink below this width.
Sourcepub fn transition_min_height(self, transition: impl Into<Transition>) -> Self
pub fn transition_min_height(self, transition: impl Into<Transition>) -> Self
Sets a transition for the min_height property.
Sets the minimum height of the view.
The view will not shrink below this height.
Sourcepub fn transition_max_width(self, transition: impl Into<Transition>) -> Self
pub fn transition_max_width(self, transition: impl Into<Transition>) -> Self
Sets a transition for the max_width property.
Sets the maximum width of the view.
The view will not grow beyond this width.
Sourcepub fn transition_max_height(self, transition: impl Into<Transition>) -> Self
pub fn transition_max_height(self, transition: impl Into<Transition>) -> Self
Sets a transition for the max_height property.
Sets the maximum height of the view.
The view will not grow beyond this height.
Sourcepub fn transition_flex_basis(self, transition: impl Into<Transition>) -> Self
pub fn transition_flex_basis(self, transition: impl Into<Transition>) -> Self
Sets a transition for the flex_basis property.
Sets the initial main size of a flex item.
This is the size of the item before free space is distributed.
Sourcepub fn transition_outline_color(self, transition: impl Into<Transition>) -> Self
pub fn transition_outline_color(self, transition: impl Into<Transition>) -> Self
Sets a transition for the outline_color property.
Sets the color of the view’s outline.
The outline is drawn outside the border and doesn’t affect layout.
Sourcepub fn transition_outline(self, transition: impl Into<Transition>) -> Self
pub fn transition_outline(self, transition: impl Into<Transition>) -> Self
Sets a transition for the outline property.
Sets the outline stroke properties.
Defines the width, style, and other properties of the outline.
Sourcepub fn transition_outline_progress(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_outline_progress( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the outline_progress property.
Controls the progress/completion of the outline animation.
Useful for creating animated outline effects.
Sourcepub fn transition_border_progress(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_border_progress( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the border_progress property.
Controls the progress/completion of the border animation.
Useful for creating animated border effects.
Sourcepub fn transition_border_combined(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_border_combined( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the border_combined property.
Sets the border properties for all sides.
Defines width, style, and other border characteristics.
Sourcepub fn transition_border_color_combined(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_border_color_combined( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the border_color_combined property.
Sets the border color for all sides.
Can be set individually for each side or all at once.
Sourcepub fn transition_border_radius_combined(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_border_radius_combined( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the border_radius_combined property.
Sets the border radius for all corners.
Controls how rounded the corners of the view are.
Sourcepub fn transition_padding_combined(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_padding_combined( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the padding_combined property.
Sets the padding for all sides.
Padding is the space between the view’s content and its border.
Sourcepub fn transition_margin_combined(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_margin_combined( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the margin_combined property.
Sets the margin for all sides.
Margin is the space outside the view’s border.
Sourcepub fn transition_inset_left(self, transition: impl Into<Transition>) -> Self
pub fn transition_inset_left(self, transition: impl Into<Transition>) -> Self
Sets a transition for the inset_left property.
Sets the left offset for positioned views.
Sourcepub fn transition_inset_top(self, transition: impl Into<Transition>) -> Self
pub fn transition_inset_top(self, transition: impl Into<Transition>) -> Self
Sets a transition for the inset_top property.
Sets the top offset for positioned views.
Sourcepub fn transition_inset_right(self, transition: impl Into<Transition>) -> Self
pub fn transition_inset_right(self, transition: impl Into<Transition>) -> Self
Sets a transition for the inset_right property.
Sets the right offset for positioned views.
Sourcepub fn transition_inset_bottom(self, transition: impl Into<Transition>) -> Self
pub fn transition_inset_bottom(self, transition: impl Into<Transition>) -> Self
Sets a transition for the inset_bottom property.
Sets the bottom offset for positioned views.
Sourcepub fn transition_z_index(self, transition: impl Into<Transition>) -> Self
pub fn transition_z_index(self, transition: impl Into<Transition>) -> Self
Sets a transition for the z_index property.
Controls the stack order of positioned views.
Higher values appear in front of lower values.
Sourcepub fn transition_color(self, transition: impl Into<Transition>) -> Self
pub fn transition_color(self, transition: impl Into<Transition>) -> Self
Sets a transition for the color property.
Sets the text color.
This property is inherited by child views.
Sourcepub fn transition_background(self, transition: impl Into<Transition>) -> Self
pub fn transition_background(self, transition: impl Into<Transition>) -> Self
Sets a transition for the background property.
Sets the background color or image.
Can be a solid color, gradient, or image.
Sourcepub fn transition_foreground(self, transition: impl Into<Transition>) -> Self
pub fn transition_foreground(self, transition: impl Into<Transition>) -> Self
Sets a transition for the foreground property.
Sets the foreground color or pattern.
Used for drawing content like icons or shapes.
Sourcepub fn transition_box_shadow(self, transition: impl Into<Transition>) -> Self
pub fn transition_box_shadow(self, transition: impl Into<Transition>) -> Self
Sets a transition for the box_shadow property.
Adds one or more drop shadows to the view.
Can create depth and visual separation effects.
Sourcepub fn transition_font_size(self, transition: impl Into<Transition>) -> Self
pub fn transition_font_size(self, transition: impl Into<Transition>) -> Self
Sets a transition for the font_size property.
Sets the font size for text content.
This property is inherited by child views.
Sourcepub fn transition_cursor_color(self, transition: impl Into<Transition>) -> Self
pub fn transition_cursor_color(self, transition: impl Into<Transition>) -> Self
Sets a transition for the cursor_color property.
Sets the color of the text cursor.
Visible when text input views have focus.
Sourcepub fn transition_selection_corer_radius(
self,
transition: impl Into<Transition>,
) -> Self
pub fn transition_selection_corer_radius( self, transition: impl Into<Transition>, ) -> Self
Sets a transition for the selection_corer_radius property.
Sets the corner radius of text selections.
Controls how rounded the corners of selected text appear.
Sourcepub fn transition_line_height(self, transition: impl Into<Transition>) -> Self
pub fn transition_line_height(self, transition: impl Into<Transition>) -> Self
Sets a transition for the line_height property.
Sets the line height for text content.
This property is inherited by child views.
Sourcepub fn transition_aspect_ratio(self, transition: impl Into<Transition>) -> Self
pub fn transition_aspect_ratio(self, transition: impl Into<Transition>) -> Self
Sets a transition for the aspect_ratio property.
Sets the preferred aspect ratio for the view.
Maintains width-to-height proportions during layout.
Sourcepub fn transition_col_gap(self, transition: impl Into<Transition>) -> Self
pub fn transition_col_gap(self, transition: impl Into<Transition>) -> Self
Sets a transition for the col_gap property.
Sets the gap between columns in grid or flex layouts.
Creates space between items in the horizontal direction.
Sourcepub fn transition_row_gap(self, transition: impl Into<Transition>) -> Self
pub fn transition_row_gap(self, transition: impl Into<Transition>) -> Self
Sets a transition for the row_gap property.
Sets the gap between rows in grid or flex layouts.
Creates space between items in the vertical direction.
Sourcepub fn transition_scale_x(self, transition: impl Into<Transition>) -> Self
pub fn transition_scale_x(self, transition: impl Into<Transition>) -> Self
Sets a transition for the scale_x property.
Sets the horizontal scale transform.
Values less than 100% shrink the view, greater than 100% enlarge it.
Sourcepub fn transition_scale_y(self, transition: impl Into<Transition>) -> Self
pub fn transition_scale_y(self, transition: impl Into<Transition>) -> Self
Sets a transition for the scale_y property.
Sets the vertical scale transform.
Values less than 100% shrink the view, greater than 100% enlarge it.
Sourcepub fn transition_translate_x(self, transition: impl Into<Transition>) -> Self
pub fn transition_translate_x(self, transition: impl Into<Transition>) -> Self
Sets a transition for the translate_x property.
Sets the horizontal translation transform.
Moves the view left (negative) or right (positive).
Sourcepub fn transition_translate_y(self, transition: impl Into<Transition>) -> Self
pub fn transition_translate_y(self, transition: impl Into<Transition>) -> Self
Sets a transition for the translate_y property.
Sets the vertical translation transform.
Moves the view up (negative) or down (positive).
Sourcepub fn transition_rotate(self, transition: impl Into<Transition>) -> Self
pub fn transition_rotate(self, transition: impl Into<Transition>) -> Self
Sets a transition for the rotate property.
Sets the rotation transform angle.
Positive values rotate clockwise, negative values rotate counter-clockwise.
Use .deg() or .rad() methods to specify the angle unit.
Sourcepub fn transition_scale_about(self, transition: impl Into<Transition>) -> Self
pub fn transition_scale_about(self, transition: impl Into<Transition>) -> Self
Sets a transition for the scale_about property.
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.
Sourcepub fn transition_opacity(self, transition: impl Into<Transition>) -> Self
pub fn transition_opacity(self, transition: impl Into<Transition>) -> Self
Sets a transition for the opacity property.
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§impl Style
impl Style
Sourcepub fn get<P: StyleProp>(&self, _prop: P) -> P::Type
pub fn get<P: StyleProp>(&self, _prop: P) -> P::Type
Gets the value of a style property, returning the default if not set.
Sourcepub fn get_style_value<P: StyleProp>(&self, _prop: P) -> StyleValue<P::Type>
pub fn get_style_value<P: StyleProp>(&self, _prop: P) -> StyleValue<P::Type>
Gets the raw style value of a property, including unset and base states.
Sourcepub fn set<P: StyleProp>(self, prop: P, value: impl Into<P::Type>) -> Self
pub fn set<P: StyleProp>(self, prop: P, value: impl Into<P::Type>) -> Self
Sets a style property to a specific value.
pub fn set_style_value<P: StyleProp>( self, _prop: P, value: StyleValue<P::Type>, ) -> Self
Sourcepub fn transition<P: StyleProp>(self, _prop: P, transition: Transition) -> Self
pub fn transition<P: StyleProp>(self, _prop: P, transition: Transition) -> Self
Sets a transition animation for a specific style property.
Sourcepub fn hover(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn hover(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the mouse hovers over the view
Sourcepub fn focus(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn focus(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the view has keyboard focus.
Sourcepub fn focus_visible(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn focus_visible(self, style: impl FnOnce(Style) -> Style) -> Self
Similar to the :focus-visible css selector, this style only activates when tab navigation is used.
Sourcepub fn selected(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn selected(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the view is in a selected state.
Sourcepub fn drag(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn drag(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the view is being dragged
Sourcepub fn disabled(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn disabled(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the view is disabled.
Sourcepub fn dark_mode(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn dark_mode(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the application is in dark mode.
Sourcepub fn file_hover(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn file_hover(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when a file is being dragged over the view.
Sourcepub fn active(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn active(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the view is being actively pressed.
Sourcepub fn responsive(
self,
size: ScreenSize,
style: impl FnOnce(Style) -> Style,
) -> Self
pub fn responsive( self, size: ScreenSize, style: impl FnOnce(Style) -> Style, ) -> Self
Applies styles that activate at specific screen sizes (responsive design).
Sourcepub fn class<C: StyleClass>(
self,
_class: C,
style: impl FnOnce(Style) -> Style,
) -> Self
pub fn class<C: StyleClass>( self, _class: C, style: impl FnOnce(Style) -> Style, ) -> Self
Applies styles to views with a specific CSS class.
Sourcepub fn custom_style_class<CS: CustomStyle>(
self,
style: impl FnOnce(CS) -> CS,
) -> Self
pub fn custom_style_class<CS: CustomStyle>( self, style: impl FnOnce(CS) -> CS, ) -> Self
Applies a CustomStyle type to the CustomStyle’s associated style class.
For example: if the CustomStyle you use is DropdownCustomStyle then it
will apply the custom style to that custom style type’s associated style class
which, in this example, is DropdownClass.
This is especially useful when building a stylesheet or targeting a child view.
§Examples
// In a style sheet or on a parent view
use floem::prelude::*;
use floem::style::Style;
Style::new().custom_style_class(|s: dropdown::DropdownCustomStyle| s.close_on_accept(false));
// This property is now set on the `DropdownClass` class and will be applied to any dropdowns that are children of this view.See also: Style::custom and Style::apply_custom.
Sourcepub fn width_full(self) -> Self
pub fn width_full(self) -> Self
Sets the width to 100% of the parent container.
Sourcepub fn width_pct(self, width: f64) -> Self
pub fn width_pct(self, width: f64) -> Self
Sets the width as a percentage of the parent container.
Sourcepub fn height_full(self) -> Self
pub fn height_full(self) -> Self
Sets the height to 100% of the parent container.
Sourcepub fn height_pct(self, height: f64) -> Self
pub fn height_pct(self, height: f64) -> Self
Sets the height as a percentage of the parent container.
Sourcepub fn col_gap(self, width: impl Into<PxPct>) -> Self
pub fn col_gap(self, width: impl Into<PxPct>) -> Self
Sets the gap between columns in grid or flex layouts.
Sourcepub fn row_gap(self, height: impl Into<PxPct>) -> Self
pub fn row_gap(self, height: impl Into<PxPct>) -> Self
Sets the gap between rows in grid or flex layouts.
Sourcepub fn row_col_gap(
self,
width: impl Into<PxPct>,
height: impl Into<PxPct>,
) -> Self
pub fn row_col_gap( self, width: impl Into<PxPct>, height: impl Into<PxPct>, ) -> Self
Sets different gaps for rows and columns in grid or flex layouts.
Sourcepub fn gap(self, gap: impl Into<PxPct>) -> Self
pub fn gap(self, gap: impl Into<PxPct>) -> Self
Sets the same gap for both rows and columns in grid or flex layouts.
Sourcepub fn size(
self,
width: impl Into<PxPctAuto>,
height: impl Into<PxPctAuto>,
) -> Self
pub fn size( self, width: impl Into<PxPctAuto>, height: impl Into<PxPctAuto>, ) -> Self
Sets both width and height of the view.
Sourcepub fn size_pct(self, width: f64, height: f64) -> Self
pub fn size_pct(self, width: f64, height: f64) -> Self
Sets both width and height as percentages of the parent container.
Sourcepub fn min_width_full(self) -> Self
pub fn min_width_full(self) -> Self
Sets the minimum width to 100% of the parent container.
Sourcepub fn min_width_pct(self, min_width: f64) -> Self
pub fn min_width_pct(self, min_width: f64) -> Self
Sets the minimum width as a percentage of the parent container.
Sourcepub fn min_height_full(self) -> Self
pub fn min_height_full(self) -> Self
Sets the minimum height to 100% of the parent container.
Sourcepub fn min_height_pct(self, min_height: f64) -> Self
pub fn min_height_pct(self, min_height: f64) -> Self
Sets the minimum height as a percentage of the parent container.
Sourcepub fn min_size_full(self) -> Self
pub fn min_size_full(self) -> Self
Sets both minimum width and height to 100% of the parent container.
Sourcepub fn min_size(
self,
min_width: impl Into<PxPctAuto>,
min_height: impl Into<PxPctAuto>,
) -> Self
pub fn min_size( self, min_width: impl Into<PxPctAuto>, min_height: impl Into<PxPctAuto>, ) -> Self
Sets both minimum width and height of the view.
Sourcepub fn min_size_pct(self, min_width: f64, min_height: f64) -> Self
pub fn min_size_pct(self, min_width: f64, min_height: f64) -> Self
Sets both minimum width and height as percentages of the parent container.
Sourcepub fn max_width_full(self) -> Self
pub fn max_width_full(self) -> Self
Sets the maximum width to 100% of the parent container.
Sourcepub fn max_width_pct(self, max_width: f64) -> Self
pub fn max_width_pct(self, max_width: f64) -> Self
Sets the maximum width as a percentage of the parent container.
Sourcepub fn max_height_full(self) -> Self
pub fn max_height_full(self) -> Self
Sets the maximum height to 100% of the parent container.
Sourcepub fn max_height_pct(self, max_height: f64) -> Self
pub fn max_height_pct(self, max_height: f64) -> Self
Sets the maximum height as a percentage of the parent container.
Sourcepub fn max_size(
self,
max_width: impl Into<PxPctAuto>,
max_height: impl Into<PxPctAuto>,
) -> Self
pub fn max_size( self, max_width: impl Into<PxPctAuto>, max_height: impl Into<PxPctAuto>, ) -> Self
Sets both maximum width and height of the view.
Sourcepub fn max_size_full(self) -> Self
pub fn max_size_full(self) -> Self
Sets both maximum width and height to 100% of the parent container.
Sourcepub fn max_size_pct(self, max_width: f64, max_height: f64) -> Self
pub fn max_size_pct(self, max_width: f64, max_height: f64) -> Self
Sets both maximum width and height as percentages of the parent container.
Sourcepub fn border_color(self, color: impl Into<Brush>) -> Self
pub fn border_color(self, color: impl Into<Brush>) -> Self
Sets the border color for all sides of the view.
Sourcepub fn border(self, border: impl Into<StrokeWrap>) -> Self
pub fn border(self, border: impl Into<StrokeWrap>) -> Self
Sets the border properties for all sides of the view.
Sourcepub fn outline(self, outline: impl Into<StrokeWrap>) -> Self
pub fn outline(self, outline: impl Into<StrokeWrap>) -> Self
Sets the outline properties of the view.
Sourcepub fn border_horiz(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_horiz(self, border: impl Into<StrokeWrap>) -> Self
Sets border_left and border_right to border
Sourcepub fn border_vert(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_vert(self, border: impl Into<StrokeWrap>) -> Self
Sets border_top and border_bottom to border
Sourcepub fn padding_left_pct(self, padding: f64) -> Self
pub fn padding_left_pct(self, padding: f64) -> Self
Sets the left padding as a percentage of the parent container width.
Sourcepub fn padding_right_pct(self, padding: f64) -> Self
pub fn padding_right_pct(self, padding: f64) -> Self
Sets the right padding as a percentage of the parent container width.
Sourcepub fn padding_top_pct(self, padding: f64) -> Self
pub fn padding_top_pct(self, padding: f64) -> Self
Sets the top padding as a percentage of the parent container width.
Sourcepub fn padding_bottom_pct(self, padding: f64) -> Self
pub fn padding_bottom_pct(self, padding: f64) -> Self
Sets the bottom padding as a percentage of the parent container width.
Sourcepub fn padding_pct(self, padding: f64) -> Self
pub fn padding_pct(self, padding: f64) -> Self
Sets padding on all sides as a percentage of the parent container width.
Sourcepub fn padding_horiz(self, padding: impl Into<PxPct>) -> Self
pub fn padding_horiz(self, padding: impl Into<PxPct>) -> Self
Sets padding_left and padding_right to padding
Sourcepub fn padding_horiz_pct(self, padding: f64) -> Self
pub fn padding_horiz_pct(self, padding: f64) -> Self
Sets horizontal padding as a percentage of the parent container width.
Sourcepub fn padding_vert(self, padding: impl Into<PxPct>) -> Self
pub fn padding_vert(self, padding: impl Into<PxPct>) -> Self
Sets padding_top and padding_bottom to padding
Sourcepub fn padding_vert_pct(self, padding: f64) -> Self
pub fn padding_vert_pct(self, padding: f64) -> Self
Sets vertical padding as a percentage of the parent container width.
Sourcepub fn margin_left_pct(self, margin: f64) -> Self
pub fn margin_left_pct(self, margin: f64) -> Self
Sets the left margin as a percentage of the parent container width.
Sourcepub fn margin_right_pct(self, margin: f64) -> Self
pub fn margin_right_pct(self, margin: f64) -> Self
Sets the right margin as a percentage of the parent container width.
Sourcepub fn margin_top_pct(self, margin: f64) -> Self
pub fn margin_top_pct(self, margin: f64) -> Self
Sets the top margin as a percentage of the parent container width.
Sourcepub fn margin_bottom_pct(self, margin: f64) -> Self
pub fn margin_bottom_pct(self, margin: f64) -> Self
Sets the bottom margin as a percentage of the parent container width.
Sourcepub fn margin(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin(self, margin: impl Into<PxPctAuto>) -> Self
Sets margin on all sides of the view.
Sourcepub fn margin_pct(self, margin: f64) -> Self
pub fn margin_pct(self, margin: f64) -> Self
Sets margin on all sides as a percentage of the parent container width.
Sourcepub fn margin_horiz(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_horiz(self, margin: impl Into<PxPctAuto>) -> Self
Sets margin_left and margin_right to margin
Sourcepub fn margin_horiz_pct(self, margin: f64) -> Self
pub fn margin_horiz_pct(self, margin: f64) -> Self
Sets horizontal margin as a percentage of the parent container width.
Sourcepub fn margin_vert(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_vert(self, margin: impl Into<PxPctAuto>) -> Self
Sets margin_top and margin_bottom to margin
Sourcepub fn margin_vert_pct(self, margin: f64) -> Self
pub fn margin_vert_pct(self, margin: f64) -> Self
Sets vertical margin as a percentage of the parent container width.
Sourcepub fn padding_left(self, padding: impl Into<PxPct>) -> Self
pub fn padding_left(self, padding: impl Into<PxPct>) -> Self
Sets the left padding of the view.
Sourcepub fn padding_right(self, padding: impl Into<PxPct>) -> Self
pub fn padding_right(self, padding: impl Into<PxPct>) -> Self
Sets the right padding of the view.
Sourcepub fn padding_top(self, padding: impl Into<PxPct>) -> Self
pub fn padding_top(self, padding: impl Into<PxPct>) -> Self
Sets the top padding of the view.
Sourcepub fn padding_bottom(self, padding: impl Into<PxPct>) -> Self
pub fn padding_bottom(self, padding: impl Into<PxPct>) -> Self
Sets the bottom padding of the view.
Sourcepub fn margin_left(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_left(self, margin: impl Into<PxPctAuto>) -> Self
Sets the left margin of the view.
Sourcepub fn margin_right(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_right(self, margin: impl Into<PxPctAuto>) -> Self
Sets the right margin of the view.
Sourcepub fn margin_top(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_top(self, margin: impl Into<PxPctAuto>) -> Self
Sets the top margin of the view.
Sourcepub fn margin_bottom(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_bottom(self, margin: impl Into<PxPctAuto>) -> Self
Sets the bottom margin of the view.
Sourcepub fn apply_padding(self, padding: Padding) -> Self
pub fn apply_padding(self, padding: Padding) -> Self
Applies a complete padding configuration to the view.
Sourcepub fn apply_margin(self, margin: Margin) -> Self
pub fn apply_margin(self, margin: Margin) -> Self
Applies a complete margin configuration to the view.
Sourcepub fn border_radius(self, radius: impl Into<PxPct>) -> Self
pub fn border_radius(self, radius: impl Into<PxPct>) -> Self
Sets the border radius for all corners of the view.
Sourcepub fn border_left(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_left(self, border: impl Into<StrokeWrap>) -> Self
Sets the left border of the view.
Sourcepub fn border_right(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_right(self, border: impl Into<StrokeWrap>) -> Self
Sets the right border of the view.
Sourcepub fn border_top(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_top(self, border: impl Into<StrokeWrap>) -> Self
Sets the top border of the view.
Sourcepub fn border_bottom(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_bottom(self, border: impl Into<StrokeWrap>) -> Self
Sets the bottom border of the view.
Sourcepub fn border_left_color(self, color: impl Into<Brush>) -> Self
pub fn border_left_color(self, color: impl Into<Brush>) -> Self
Sets the left border color of the view.
Sourcepub fn border_right_color(self, color: impl Into<Brush>) -> Self
pub fn border_right_color(self, color: impl Into<Brush>) -> Self
Sets the right border color of the view.
Sourcepub fn border_top_color(self, color: impl Into<Brush>) -> Self
pub fn border_top_color(self, color: impl Into<Brush>) -> Self
Sets the top border color of the view.
Sourcepub fn border_bottom_color(self, color: impl Into<Brush>) -> Self
pub fn border_bottom_color(self, color: impl Into<Brush>) -> Self
Sets the bottom border color of the view.
Sourcepub fn border_top_left_radius(self, radius: impl Into<PxPct>) -> Self
pub fn border_top_left_radius(self, radius: impl Into<PxPct>) -> Self
Sets the top-left border radius of the view.
Sourcepub fn border_top_right_radius(self, radius: impl Into<PxPct>) -> Self
pub fn border_top_right_radius(self, radius: impl Into<PxPct>) -> Self
Sets the top-right border radius of the view.
Sourcepub fn border_bottom_left_radius(self, radius: impl Into<PxPct>) -> Self
pub fn border_bottom_left_radius(self, radius: impl Into<PxPct>) -> Self
Sets the bottom-left border radius of the view.
Sourcepub fn border_bottom_right_radius(self, radius: impl Into<PxPct>) -> Self
pub fn border_bottom_right_radius(self, radius: impl Into<PxPct>) -> Self
Sets the bottom-right border radius of the view.
Sourcepub fn apply_border(self, border: Border) -> Self
pub fn apply_border(self, border: Border) -> Self
Applies a complete border configuration to the view.
Sourcepub fn apply_border_color(self, border_color: BorderColor) -> Self
pub fn apply_border_color(self, border_color: BorderColor) -> Self
Applies a complete border color configuration to the view.
Sourcepub fn apply_border_radius(self, border_radius: BorderRadius) -> Self
pub fn apply_border_radius(self, border_radius: BorderRadius) -> Self
Applies a complete border radius configuration to the view.
Sourcepub fn inset_left_pct(self, inset: f64) -> Self
pub fn inset_left_pct(self, inset: f64) -> Self
Sets the left inset as a percentage of the parent container width.
Sourcepub fn inset_right_pct(self, inset: f64) -> Self
pub fn inset_right_pct(self, inset: f64) -> Self
Sets the right inset as a percentage of the parent container width.
Sourcepub fn inset_top_pct(self, inset: f64) -> Self
pub fn inset_top_pct(self, inset: f64) -> Self
Sets the top inset as a percentage of the parent container height.
Sourcepub fn inset_bottom_pct(self, inset: f64) -> Self
pub fn inset_bottom_pct(self, inset: f64) -> Self
Sets the bottom inset as a percentage of the parent container height.
Sourcepub fn inset(self, inset: impl Into<PxPctAuto>) -> Self
pub fn inset(self, inset: impl Into<PxPctAuto>) -> Self
Sets all insets (left, top, right, bottom) to the same value.
Sourcepub fn inset_pct(self, inset: f64) -> Self
pub fn inset_pct(self, inset: f64) -> Self
Sets all insets as percentages of the parent container.
Sourcepub fn cursor(self, cursor: impl Into<StyleValue<CursorStyle>>) -> Self
pub fn cursor(self, cursor: impl Into<StyleValue<CursorStyle>>) -> Self
Sets the cursor style when hovering over the view.
Sourcepub fn color(self, color: impl Into<StyleValue<Color>>) -> Self
pub fn color(self, color: impl Into<StyleValue<Color>>) -> Self
Specifies text color for the view.
Sourcepub fn background(self, color: impl Into<Brush>) -> Self
pub fn background(self, color: impl Into<Brush>) -> Self
Sets the background color or pattern of the view.
Sourcepub fn box_shadow_blur(self, blur_radius: impl Into<PxPct>) -> Self
pub fn box_shadow_blur(self, blur_radius: impl Into<PxPct>) -> Self
Specifies shadow blur. The larger this value, the bigger the blur, so the shadow becomes bigger and lighter.
Sourcepub fn box_shadow_color(self, color: Color) -> Self
pub fn box_shadow_color(self, color: Color) -> Self
Specifies color for the shadow.
Sourcepub fn box_shadow_spread(self, spread: impl Into<PxPct>) -> Self
pub fn box_shadow_spread(self, spread: impl Into<PxPct>) -> Self
Specifies shadow blur spread. Positive values will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink.
Sourcepub fn apply_box_shadows(
self,
shadow: impl Into<SmallVec<[BoxShadow; 3]>>,
) -> Self
pub fn apply_box_shadows( self, shadow: impl Into<SmallVec<[BoxShadow; 3]>>, ) -> Self
Applies a shadow for the stylized view. Use BoxShadow builder to construct each shadow.
use floem::prelude::*;
use floem::prelude::palette::css;
use floem::style::BoxShadow;
empty().style(|s| s.apply_box_shadows(vec![
BoxShadow::new()
.color(css::BLACK)
.top_offset(5.)
.bottom_offset(-30.)
.right_offset(-20.)
.left_offset(10.)
.blur_radius(5.)
.spread(10.)
]));§Info
If you only specify one shadow on the view, use standard style methods directly on Style struct:
use floem::prelude::*;
empty().style(|s| s
.box_shadow_top_offset(-5.)
.box_shadow_bottom_offset(30.)
.box_shadow_right_offset(20.)
.box_shadow_left_offset(-10.)
.box_shadow_spread(1.)
.box_shadow_blur(3.)
);Sourcepub fn box_shadow_h_offset(self, h_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_h_offset(self, h_offset: impl Into<PxPct>) -> Self
Specifies the offset on horizontal axis. Negative offset value places the shadow to the left of the view.
Sourcepub fn box_shadow_v_offset(self, v_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_v_offset(self, v_offset: impl Into<PxPct>) -> Self
Specifies the offset on vertical axis. Negative offset value places the shadow above the view.
Sourcepub fn box_shadow_left_offset(self, left_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_left_offset(self, left_offset: impl Into<PxPct>) -> Self
Specifies the offset of the left edge.
Sourcepub fn box_shadow_right_offset(self, right_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_right_offset(self, right_offset: impl Into<PxPct>) -> Self
Specifies the offset of the right edge.
Sourcepub fn box_shadow_top_offset(self, top_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_top_offset(self, top_offset: impl Into<PxPct>) -> Self
Specifies the offset of the top edge.
Sourcepub fn box_shadow_bottom_offset(self, bottom_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_bottom_offset(self, bottom_offset: impl Into<PxPct>) -> Self
Specifies the offset of the bottom edge.
Sourcepub fn font_family(self, family: impl Into<StyleValue<String>>) -> Self
pub fn font_family(self, family: impl Into<StyleValue<String>>) -> Self
Sets the font family for text content.
Sourcepub fn font_weight(self, weight: impl Into<StyleValue<Weight>>) -> Self
pub fn font_weight(self, weight: impl Into<StyleValue<Weight>>) -> Self
Sets the font weight (boldness) for text content.
Sourcepub fn font_style(self, style: impl Into<StyleValue<Style>>) -> Self
pub fn font_style(self, style: impl Into<StyleValue<Style>>) -> Self
Sets the font style (italic, normal) for text content.
Sourcepub fn cursor_color(self, color: impl Into<Brush>) -> Self
pub fn cursor_color(self, color: impl Into<Brush>) -> Self
Sets the color of the text cursor.
Sourcepub fn line_height(self, normal: f32) -> Self
pub fn line_height(self, normal: f32) -> Self
Sets the line height for text content.
Sourcepub fn pointer_events_auto(self) -> Self
pub fn pointer_events_auto(self) -> Self
Enables pointer events for the view (allows mouse interaction).
Sourcepub fn pointer_events_none(self) -> Self
pub fn pointer_events_none(self) -> Self
Disables pointer events for the view (mouse events pass through).
Sourcepub fn text_ellipsis(self) -> Self
pub fn text_ellipsis(self) -> Self
Sets text overflow to show ellipsis (…) when text is clipped.
Sourcepub fn fixed(self) -> Self
pub fn fixed(self) -> Self
Sets the view to fixed positioning relative to the viewport.
This is similar to CSS position: fixed. The view will:
- Be positioned relative to the window viewport
- Use
insetproperties relative to the viewport - Have percentage sizes relative to the viewport
- Be painted above all other content
§Example
use floem::style::Style;
// Create a full-screen overlay
Style::new().fixed().inset(0.0);Sourcepub fn items_stretch(self) -> Self
pub fn items_stretch(self) -> Self
Aligns flex items to stretch and fill the cross axis.
Sourcepub fn items_start(self) -> Self
pub fn items_start(self) -> Self
Aligns flex items to the start of the cross axis.
Sourcepub fn items_center(self) -> Self
pub fn items_center(self) -> Self
Defines the alignment along the cross axis as Centered
Sourcepub fn items_baseline(self) -> Self
pub fn items_baseline(self) -> Self
Aligns flex items along their baselines.
Sourcepub fn justify_start(self) -> Self
pub fn justify_start(self) -> Self
Aligns flex items to the start of the main axis.
Sourcepub fn justify_end(self) -> Self
pub fn justify_end(self) -> Self
Aligns flex items to the end of the main axis.
Sourcepub fn justify_center(self) -> Self
pub fn justify_center(self) -> Self
Defines the alignment along the main axis as Centered
Sourcepub fn justify_between(self) -> Self
pub fn justify_between(self) -> Self
Distributes flex items with space between them.
Sourcepub fn justify_around(self) -> Self
pub fn justify_around(self) -> Self
Distributes flex items with space around them.
Sourcepub fn justify_evenly(self) -> Self
pub fn justify_evenly(self) -> Self
Distributes flex items with equal space around them.
Sourcepub fn apply_opt<T>(
self,
opt: Option<T>,
f: impl FnOnce(Self, T) -> Self,
) -> Self
pub fn apply_opt<T>( self, opt: Option<T>, f: impl FnOnce(Self, T) -> Self, ) -> Self
Allow the application of a function if the option exists. This is useful for chaining together a bunch of optional style changes.
use floem::style::Style;
let maybe_none: Option<i32> = None;
let style = Style::default()
.apply_opt(Some(5.0), Style::padding) // ran
.apply_opt(maybe_none, Style::margin) // not ran
.apply_opt(Some(5.0), |s, v| s.border_right(v * 2.0))
.border_left(5.0); // ran, obviouslySourcepub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
pub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
Allow the application of a function if the condition holds. This is useful for chaining together optional style changes.
use floem::style::Style;
let style = Style::default()
.apply_if(true, |s| s.padding(5.0)) // ran
.apply_if(false, |s| s.margin(5.0)); // not ranSourcepub fn custom<CS: CustomStyle>(self, custom: impl FnOnce(CS) -> CS) -> Self
pub fn custom<CS: CustomStyle>(self, custom: impl FnOnce(CS) -> CS) -> Self
Applies a CustomStyle type into this style.
§Examples
use floem::prelude::*;
text("test").style(|s| s.custom(|s: LabelCustomStyle| s.selectable(false)));See also: apply_custom, custom_style_class
Sourcepub fn apply_custom<CS: Into<Style>>(self, custom_style: CS) -> Self
pub fn apply_custom<CS: Into<Style>>(self, custom_style: CS) -> Self
Applies a CustomStyle type into this style.
§Examples
use floem::prelude::*;
text("test").style(|s| s.apply_custom(LabelCustomStyle::new().selectable(false)));See also: custom, custom_style_class
Source§impl Style
impl Style
pub fn to_taffy_style(&self) -> TaffyStyle
Trait Implementations§
Source§impl From<DropdownCustomStyle> for Style
impl From<DropdownCustomStyle> for Style
Source§fn from(val: DropdownCustomStyle) -> Self
fn from(val: DropdownCustomStyle) -> Self
Source§impl From<LabelCustomStyle> for Style
impl From<LabelCustomStyle> for Style
Source§fn from(value: LabelCustomStyle) -> Self
fn from(value: LabelCustomStyle) -> Self
Source§impl From<ResizableCustomStyle> for Style
impl From<ResizableCustomStyle> for Style
Source§fn from(val: ResizableCustomStyle) -> Self
fn from(val: ResizableCustomStyle) -> Self
Source§impl From<ScrollCustomStyle> for Style
impl From<ScrollCustomStyle> for Style
Source§fn from(value: ScrollCustomStyle) -> Self
fn from(value: ScrollCustomStyle) -> Self
Source§impl From<SliderCustomStyle> for Style
impl From<SliderCustomStyle> for Style
Source§fn from(val: SliderCustomStyle) -> Self
fn from(val: SliderCustomStyle) -> Self
Source§impl From<Style> for DropdownCustomStyle
impl From<Style> for DropdownCustomStyle
Source§impl From<Style> for KeyFrameStyle
impl From<Style> for KeyFrameStyle
Source§impl From<Style> for LabelCustomStyle
impl From<Style> for LabelCustomStyle
Source§impl From<Style> for ResizableCustomStyle
impl From<Style> for ResizableCustomStyle
Source§impl From<Style> for ScrollCustomStyle
impl From<Style> for ScrollCustomStyle
Source§impl From<Style> for SliderCustomStyle
impl From<Style> for SliderCustomStyle
Source§impl From<ToggleButtonCustomStyle> for Style
impl From<ToggleButtonCustomStyle> for Style
Source§fn from(value: ToggleButtonCustomStyle) -> Self
fn from(value: ToggleButtonCustomStyle) -> Self
Source§impl StyleThemeExt for Style
impl StyleThemeExt for Style
fn theme(self, theme: DesignSystem) -> Self
fn with_theme(self, f: impl Fn(Self, &DesignSystem) -> Self + 'static) -> Self
Auto Trait Implementations§
impl Freeze for Style
impl !RefUnwindSafe for Style
impl !Send for Style
impl !Sync for Style
impl Unpin for Style
impl !UnwindSafe for Style
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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