Expand description
Layout building blocks for WaterUI.
This crate bridges the declarative View system with
the imperative, backend-driven layout pass. It contains:
- the low-level
Layouttrait and its geometry helpers, - reusable containers such as
spacer(),padding::Padding, and stacks, - thin wrappers (for example
scroll()) that signal backend-specific behaviour.
§Logical Pixels (Points)
All layout values use logical pixels (points/dp) - the same unit as design tools like Figma, Sketch, and Adobe XD. Native backends handle conversion to physical pixels based on screen density:
- iOS/macOS: Uses points natively
- Android: Converts dp → pixels via
displayMetrics.density
This ensures spacing(8.0) or width(100.0) renders at the same physical
size across all platforms, matching your design specifications exactly.
§Example
ⓘ
use waterui_layout::{stack, spacer};
use waterui_text::text;
pub fn toolbar() -> impl waterui_core::View {
stack::hstack((
text("WaterUI"),
spacer(),
stack::vstack((text("Docs"), text("Blog"))),
))
.spacing(8.0) // 8pt spacing - same as Figma/Sketch
}For a broader tour see the crate README.
Re-exports§
pub use spacer::Spacer;pub use spacer::spacer;pub use scroll::ScrollView;pub use scroll::scroll;pub use container::LazyContainer;pub use overlay::Overlay;pub use overlay::OverlayLayout;pub use overlay::overlay;pub use safe_area::EdgeSet;pub use safe_area::IgnoreSafeArea;
Modules§
- container
- View wrapper that lets arbitrary
Layoutimplementations participate in theWaterUIview tree. - frame
- Placeholder for fixed-size frame layouts.
- grid
- A two-dimensional layout that arranges views in columns and rows.
- overlay
- Overlay helpers for layering content on top of a base view.
- padding
- Padding layouts that inset a child by fixed edge distances.
- safe_
area - Safe area handling for layout containers.
- scroll
- Scroll containers that defer behaviour to the active renderer backend.
- spacer
- Flexible layout gaps used by stacks and other containers.
- stack
- Stack-based layout primitives.
Structs§
- Point
- Absolute coordinate relative to a parent layout’s origin.
- Proposal
Size - A size proposal from parent to child during layout negotiation.
- Rect
- Axis-aligned rectangle relative to its parent.
- Size
- Two-dimensional size expressed in points.
Enums§
- Stretch
Axis - Specifies which axis (or axes) a view wants to stretch to fill available space.