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§
Trait Implementations§
Source§impl<C, F, V> View for HStack<ForEach<C, F, V>>where
C: Collection,
<C as Collection>::Item: Identifiable,
F: 'static + Fn(<C as Collection>::Item) -> V,
V: View,
impl<C, F, V> View for HStack<ForEach<C, F, V>>where
C: Collection,
<C as Collection>::Item: Identifiable,
F: 'static + Fn(<C as Collection>::Item) -> V,
V: View,
Auto Trait Implementations§
impl<C> Freeze for HStack<C>where
C: Freeze,
impl<C> RefUnwindSafe for HStack<C>where
C: RefUnwindSafe,
impl<C> Send for HStack<C>where
C: Send,
impl<C> Sync for HStack<C>where
C: Sync,
impl<C> Unpin for HStack<C>where
C: Unpin,
impl<C> UnwindSafe for HStack<C>where
C: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IdentifiableExt for T
impl<T> IdentifiableExt for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn metadata<T: MetadataKey>(self, metadata: T) -> Metadata<T>
fn metadata<T: MetadataKey>(self, metadata: T) -> Metadata<T>
Attaches metadata to a view. Read more
Source§fn with<T: 'static>(self, value: T) -> With<Self, T>
fn with<T: 'static>(self, value: T) -> With<Self, T>
Associates a value with this view in the environment.
Source§fn title(self, title: impl Into<Text>) -> NavigationView
fn title(self, title: impl Into<Text>) -> NavigationView
Sets this view as the content of a navigation view with the specified title. Read more
Source§fn focused<T: 'static + Eq + Clone>(
self,
value: &Binding<Option<T>>,
equals: T,
) -> Metadata<Focused>
fn focused<T: 'static + Eq + Clone>( self, value: &Binding<Option<T>>, equals: T, ) -> Metadata<Focused>
Marks this view as focused when the binding matches the specified value. Read more
Source§fn on_change<C, F>(self, source: &C, handler: F) -> OnChange<Self, C::Guard>
fn on_change<C, F>(self, source: &C, handler: F) -> OnChange<Self, C::Guard>
Monitors a signal for changes and triggers a handler when the signal’s value changes. Read more
Source§fn task<Fut>(self, task: Fut) -> Metadata<Retain>
fn task<Fut>(self, task: Fut) -> Metadata<Retain>
Spawns an asynchronous task tied to the lifecycle of this view. Read more
Source§fn background(self, background: impl Into<Background>) -> Metadata<Background>
fn background(self, background: impl Into<Background>) -> Metadata<Background>
Sets the background of this view. Read more
Source§fn foreground(
self,
color: impl IntoComputed<Color>,
) -> Metadata<ForegroundColor>
fn foreground( self, color: impl IntoComputed<Color>, ) -> Metadata<ForegroundColor>
Sets the foreground color of this view. Read more
Source§fn event<H: 'static>(
self,
event: Event,
handler: impl HandlerFnOnce<H, ()> + 'static,
) -> Metadata<OnEvent>
fn event<H: 'static>( self, event: Event, handler: impl HandlerFnOnce<H, ()> + 'static, ) -> Metadata<OnEvent>
Adds an event handler for the specified event. Read more
Source§fn on_disappear<H: 'static>(
self,
handler: impl HandlerFnOnce<H, ()> + 'static,
) -> Metadata<OnEvent>
fn on_disappear<H: 'static>( self, handler: impl HandlerFnOnce<H, ()> + 'static, ) -> Metadata<OnEvent>
Adds a handler that triggers when the view disappears. Read more
Source§fn on_appear<H: 'static>(
self,
handler: impl HandlerFnOnce<H, ()> + 'static,
) -> Metadata<OnEvent>
fn on_appear<H: 'static>( self, handler: impl HandlerFnOnce<H, ()> + 'static, ) -> Metadata<OnEvent>
Adds a handler that triggers when the view appears. Read more
Source§fn min_height(self, height: f32) -> Frame
fn min_height(self, height: f32) -> Frame
Applies a minimum height constraint.
Source§fn max_height(self, height: f32) -> Frame
fn max_height(self, height: f32) -> Frame
Applies a maximum height constraint.
Source§fn alignment(self, alignment: Alignment) -> Frame
fn alignment(self, alignment: Alignment) -> Frame
Aligns this view within its frame using the provided alignment.
Source§fn padding_with(self, edge: impl Into<EdgeInsets>) -> Padding
fn padding_with(self, edge: impl Into<EdgeInsets>) -> Padding
Adds padding to this view with custom edge insets. Read more
Source§fn tag<T>(self, tag: T) -> TaggedView<T, Self>
fn tag<T>(self, tag: T) -> TaggedView<T, Self>
Tags this view with a custom tag for identification. Read more
Source§fn a11y_label(
self,
label: impl Into<Str>,
) -> IgnorableMetadata<AccessibilityLabel>
fn a11y_label( self, label: impl Into<Str>, ) -> IgnorableMetadata<AccessibilityLabel>
Sets the accessibility label for this view. Read more
Source§fn a11y_role(
self,
role: AccessibilityRole,
) -> IgnorableMetadata<AccessibilityRole>
fn a11y_role( self, role: AccessibilityRole, ) -> IgnorableMetadata<AccessibilityRole>
Sets the accessibility role for this view. Read more
Source§fn gesture<P: 'static>(
self,
gesture: impl Into<Gesture>,
action: impl HandlerFn<P, ()> + 'static,
) -> Metadata<GestureObserver>
fn gesture<P: 'static>( self, gesture: impl Into<Gesture>, action: impl HandlerFn<P, ()> + 'static, ) -> Metadata<GestureObserver>
Observes a gesture and executes an action when the gesture is recognized. Read more
Source§fn on_tap<P: 'static>(
self,
action: impl HandlerFn<P, ()> + 'static,
) -> Metadata<GestureObserver>
fn on_tap<P: 'static>( self, action: impl HandlerFn<P, ()> + 'static, ) -> Metadata<GestureObserver>
Adds a tap gesture recognizer to this view that triggers the specified action. Read more
Source§fn shadow(self, shadow: impl Into<Shadow>) -> Metadata<Shadow>
fn shadow(self, shadow: impl Into<Shadow>) -> Metadata<Shadow>
Applies a shadow effect to this view.
Source§fn ignore_safe_area(self, edges: EdgeSet) -> Metadata<IgnoreSafeArea>
fn ignore_safe_area(self, edges: EdgeSet) -> Metadata<IgnoreSafeArea>
Extends this view’s bounds to ignore safe area insets on the specified edges. Read more