FixedSize
FixedSize — a layout modifier that pins a child to its natural size, optionally overriding one or both dimensions with a reactive value.
Public functions
FixedSize
| Returns | Function |
|---|---|
| Constructors | |
Self | new() |
| Builder methods | |
Self | child(widget: impl teksilo_core::IntoTeksiChild) |
Self | child_opt(widget: Option<impl teksilo_core::IntoTeksiChild>) |
Self | width(state: impl Into<Prop<f32>>) |
Self | height(state: impl Into<Prop<f32>>) |
Detailed description
Without bindings, FixedSize ignores the parent's size proposal and
always reports the child's intrinsic size. This is useful for widgets
that must not be stretched or compressed by their containing stack —
icons, chips, or thumbnails that must stay at their designed size
regardless of the surrounding layout.
With width or
height, the corresponding dimension is
locked to a reactive Signal<f32> value; the signal change triggers a
relayout automatically. Unbound dimensions still fall back to the child's
natural size.
#![allow(unused)] fn main() { use teksilo_widgets::primitives::{FixedSize, RectWidget}; use teksilo_core::signal::Signal; let sidebar_width = Signal::new(240.0_f32); // Pin the sidebar width to a reactive signal let _sidebar = FixedSize::new() .width(sidebar_width) .child(RectWidget::new()); }
API reference
📖 Full rustdoc API for this module
pub struct FixedSize
Import: use teksilo::widgets::FixedSize;
Layout modifier that prevents a widget from expanding beyond its natural size, or constrains it to specific reactive dimensions.
Without bindings, reports the child's natural size (ignoring parent proposal).
With width/height, constrains to the bound values.
#![allow(unused)] fn main() { pub struct FixedSize { /* fields */ } }
Methods
pub fn new() -> Self
Create a FixedSize with no child and no dimension bindings; the child's
natural size will be used for both axes.
pub fn child(mut self, widget: impl teksilo_core::IntoTeksiChild) -> Self
Set an inline child widget (deferred insertion).
pub fn child_opt(self, widget: Option<impl teksilo_core::IntoTeksiChild>) -> Self
Attach widget when it is Some, and do nothing when it is None.
The conditional-child form. teksu!'s if without an else lowers to
this, and it is what cond.then(|| w) is for in a builder chain. None
adds no arena node, so nothing is laid out, painted, or published to the
accessibility tree, and a stack applies no spacing around it.
pub fn width(mut self, state: impl Into<Prop<f32>>) -> Self (default: None)
Bind width to a reactive state. When the state changes, relayout is triggered.
pub fn height(mut self, state: impl Into<Prop<f32>>) -> Self (default: None)
Bind height to a reactive state. When the state changes, relayout is triggered.