pub struct HStack<C> { /* private fields */ }Expand description
A view that arranges its children in a horizontal line.
Use an HStack to arrange views side-by-side. The stack sizes itself to fit
its contents, distributing available space among its children.
hstack((
text("Hello"),
text("World"),
))You can customize the spacing between children and their vertical alignment:
HStack::new(VerticalAlignment::Top, 20.0, (
text("First"),
text("Second"),
))Use spacer() to push content to the sides:
hstack((
text("Leading"),
spacer(),
text("Trailing"),
))Implementations§
Source§impl<C: TupleViews> HStack<(C,)>
impl<C: TupleViews> HStack<(C,)>
Sourcepub fn new(alignment: VerticalAlignment, spacing: f32, contents: C) -> Self
pub fn new(alignment: VerticalAlignment, spacing: f32, contents: C) -> Self
Creates a horizontal stack with the provided alignment, spacing, and children.
Source§impl<C> HStack<C>
impl<C> HStack<C>
Sourcepub fn alignment(self, alignment: impl Into<VerticalAlignment>) -> Self
pub fn alignment(self, alignment: impl Into<VerticalAlignment>) -> Self
Sets the vertical alignment for children in the stack — a
VerticalAlignment or one of the tokens Top, Center,
Bottom, FirstBaseline, LastBaseline.
Sourcepub fn first_baseline(self) -> Self
pub fn first_baseline(self) -> Self
Aligns children on their first text baseline.
Sourcepub fn last_baseline(self) -> Self
pub fn last_baseline(self) -> Self
Aligns children on their last text baseline.
Sourcepub fn spacing(self, spacing: impl IntoSignalF32 + 'static) -> Self
pub fn spacing(self, spacing: impl IntoSignalF32 + 'static) -> Self
Sets the spacing between children in the stack.
Accepts any numeric literal or signal of f32. Signal changes invalidate only this stack’s native layout.