Length

Length describes a size before layout has resolved it. This distinction lets the same widget ask for fixed points, a share of its parent or a share of the viewport without computing pixel values while building the view. Container, BoxStyle, positioning, padding and margin use the same type.
Variant or constructor
Meaning
Length::points(x)
Fixed logical points.
Length::percent(x)
Percentage of the containing axis. 50.0 means 50%.
Length::vw(x)
Percentage of active viewport width.
Length::vh(x)
Percentage of active viewport height.
Length::clamp(min, preferred, max)
Preferred value bounded by min and max.
Length::min(values)
Smallest resolved value.
Length::max(values)
Largest resolved value.
Length::fit_content(limit)
Intrinsic content size, optionally capped.
Length::MinContent
Minimum intrinsic content size.
Length::MaxContent
Preferred intrinsic content size.
Length::Auto
Let the active layout algorithm choose.
const PROFILE_MIN_WIDTH: f32 = 280.0;
const PROFILE_MAX_WIDTH: f32 = 480.0;

fission_component! {
    pub ProfilePanel<AppState>
    view(_panel, _state, _cx) =>
    Container(ProfileCard)
        .width_length(Length::clamp(
            Length::points(PROFILE_MIN_WIDTH),
            Length::percent(36.0),
            Length::points(PROFILE_MAX_WIDTH),
        ))
}
The preferred width is 36% of the containing axis, bounded by the two fixed limits. It is not 36% of the screen; use vw when the viewport is the intended reference.