Skip to main content

HStack

Struct HStack 

Source
pub struct HStack;
Expand description

Horizontal stack container — children render left-to-right.

HStack renders nothing itself; it lays children out horizontally. Each child’s width is determined by its WidthConstraint: Fixed(n) reserves exactly n columns, while Fill (the default) splits remaining space equally among all Fill siblings.

element! {
    HStack {
        Column(width: Fixed(3)) {
            Spinner(label: "")
        }
        Column {
            "Status: OK"
        }
    }
}

Trait Implementations§

Source§

impl ChildCollector for HStack

Source§

type Collector = Elements

The type used to accumulate children.
Source§

type Output = ComponentWithSlot<HStack>

The output type after finalizing children. Read more
Source§

fn finish(self, collector: Elements) -> ComponentWithSlot<HStack>

Finalize children collection, producing the output value.
Source§

impl Component for HStack

Source§

type State = ()

State type for this component. The framework wraps it in Tracked<S> for automatic dirty detection.
Source§

fn render(&self, _area: Rect, _buf: &mut Buffer, _state: &())

Render into the given buffer region using current state. Can use any ratatui Widget internally.
Source§

fn desired_height(&self, _width: u16, _state: &()) -> u16

How tall does this component want to be at the given width?
Source§

fn layout(&self) -> Layout

Layout direction for this component’s children. Read more
Source§

fn handle_event_capture( &self, _event: &Event, _state: &mut Tracked<Self::State>, ) -> EventResult

Handle an input event during the capture phase (root → focused). Read more
Source§

fn handle_event( &self, _event: &Event, _state: &mut Tracked<Self::State>, ) -> EventResult

Handle an input event during the bubble phase (focused → root). Read more
Source§

fn is_focusable(&self, _state: &Self::State) -> bool

Whether this component can receive focus. Read more
Source§

fn cursor_position( &self, _area: Rect, _state: &Self::State, ) -> Option<(u16, u16)>

Where to position the terminal’s hardware cursor when this component has focus. Returns (col, row) relative to the component’s render area, or None to hide the cursor. Read more
Source§

fn initial_state(&self) -> Option<Self::State>

Create the initial state for this component. Read more
Source§

fn content_inset(&self, _state: &Self::State) -> Insets

Insets for the content area within this component’s render area. Read more
Source§

fn width_constraint(&self) -> WidthConstraint

Width constraint for this component within a horizontal container. Read more
Source§

fn lifecycle(&self, _hooks: &mut Hooks<Self::State>, _state: &Self::State)

Declare lifecycle effects for this component. Read more
Source§

fn children( &self, _state: &Self::State, slot: Option<Elements>, ) -> Option<Elements>

Return child elements for this component. Read more
Source§

impl Default for HStack

Source§

fn default() -> HStack

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<C> AddTo<Elements> for C
where C: Component,

Source§

type Handle<'a> = ElementHandle<'a>

Handle returned after adding. Supports .key() / .width() chaining.
Source§

fn add_to(self, els: &mut Elements) -> ElementHandle<'_>

Add this value to the collector, returning a handle for chaining .key() and .width().
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.