Overview
TheSize enum defines how elements calculate their width and height. It supports various sizing modes including pixels, percentages, fill, flex, and custom functions.
Size Variants
Pixels
Fixed size in pixels:Percentage
Size relative to parent (0-100):Fill
Expands to fill available space:Fill Minimum
Fills available space but respects content minimum:Inner (Auto)
Sizes based on content (default):Root Percentage
Size relative to root element:Flex
Flexible size with grow factor:Custom Function
Dynamic size calculated at runtime:Size Function Context
When usingSize::Fn, the context provides:
Usage Examples
Basic Sizing
Responsive Sizing
Flex Layout
Content-Based Sizing
Mixed Sizing
Convenience Methods
Elements provide shorthand methods for common sizes:Size Constraints
Combine sizes with min/max constraints:Length Type
Length is a wrapper around f32 used by Size variants: