Skip to main content

FlexProps

Struct FlexProps 

Source
pub struct FlexProps {
    pub class: MaybeProp<String>,
    pub gap: FlexGap,
    pub vertical: bool,
    pub inline: Signal<bool>,
    pub align: MaybeProp<FlexAlign>,
    pub justify: MaybeProp<FlexJustify>,
    pub wrap: FlexWrap,
    pub fill: bool,
    pub full_width: bool,
    pub padding: MaybeProp<SpacingInset>,
    pub margin: MaybeProp<SpacingInset>,
    pub children: Children,
}
Expand description

Props for the Flex component.

Flexbox layout container for arranging children in a row or column.

The canonical one-dimensional layout primitive. Stack and Space are convenience wrappers with opinionated defaults.

Orbital-only props beyond basic flex direction and gap: wrap, fill (height 100%), full_width, and token-based padding / margin via SpacingInset.

§When to use

  • Full control over direction, wrap, inline, fill, and inset padding - Toolbars and form rows that need alignment along both axes - Inline clusters beside text or other inline content (inline=true) - When Stack (even-gap column) or Space (space-between) defaults do not fit

§Usage

  1. Choose direction: default row, or vertical=true for a column stack. 2. Set gap to a FlexGap preset or custom size — avoid margin hacks. 3. Tune align (cross-axis) and justify (main-axis) for centering or distribution. 4. Set inline=true when the flex container should sit in flowing text or inline UI.

§Best Practices

§Do’s

  • Use gap instead of margin hacks between items * Set vertical for stacked form fields or list actions * Pair with align / justify for centering and distribution * Use FlexGap::Size or FlexGap::WH when presets do not match your spacing rhythm * Put borders, fixed heights, and backgrounds on a native wrapper div; use Flex for direction, gap, and alignment * Use wrap, fill, and full_width props instead of inline flex CSS on Flex * Use SpacingInset with [SpacingHorizontal] / [SpacingVertical] for theme-aware padding and margin * Prefer Stack for simple even-gap vertical sections — Stack defaults to column + full-width * Prefer Space for opposite-edge distribution — Space defaults to space-between + full-width

§Don’ts

  • Do not use Flex for two-dimensional page grids — prefer Grid * Avoid nesting many Flex containers when a single grid suffices * Do not reach for Flex when Stack or Space defaults already match your layout

§Layout primitives

When Flex is not the right fit:

  • Even gap between every sibling on one axisStack. - Opposite edges / space-between on one axisSpace. - Full flex control (wrap, inline, fill, inset padding) — Flex (this component). - Fixed column count with span/offset per cellGrid + GridItem. - Fluid card tiles that reflow by viewport widthAutoGrid in the orbital crate. - Single node with padding/surface tokens, no sibling gapsBox. - Page max-width centering inside the shellContainer in the orbital crate. - Doc-style content + sticky aside railContentWithAside. - Application shell (header, sidebar, main) — Layout.

Spacing vocabulary: FlexGap presets for Flex, Stack, and Space; pixel gaps on Grid; SpacingSize on AutoGrid. Pick the token type each component expects.

§Examples

§Default

Horizontal flex row with medium gap between items—the baseline for toolbars, button groups, and inline control rows.

use crate::DemoBox;
view! {
    <div data-testid="flex-preview">
        <Flex gap=FlexGap::Medium>
            <DemoBox data_testid="flex-item-a">"Item A"</DemoBox>
            <DemoBox data_testid="flex-item-b">"Item B"</DemoBox>
        </Flex>
    </div>
}

§Vertical stack

Column direction stacks children for form fields, settings sections, and vertically listed actions.

use crate::DemoBox;
view! {
    <div data-testid="flex-vertical">
        <Flex vertical=true gap=FlexGap::Small>
            <DemoBox data_testid="flex-stack-1">"First"</DemoBox>
            <DemoBox data_testid="flex-stack-2">"Second"</DemoBox>
        </Flex>
    </div>
}

§Inline flex

inline-flex keeps the container in the text flow so compact clusters sit beside surrounding copy without breaking the line.

view! {
    <div data-testid="flex-inline">
        <span>"Before "</span>
        <Flex inline=true gap=FlexGap::Small>
            <span data-testid="inline-a" style="padding: var(--orb-space-inline-sm); border: 1px dashed var(--orb-color-border-default); border-radius: var(--orb-radius-md);">"A"</span>
            <span data-testid="inline-b" style="padding: var(--orb-space-inline-sm); border: 1px dashed var(--orb-color-border-default); border-radius: var(--orb-radius-md);">"B"</span>
        </Flex>
        <span>" after"</span>
    </div>
}

§Gap matrix

Compare Small, Medium, and Large presets plus custom Size and WH values so spacing stays consistent without margin hacks.

use crate::DemoBox;
view! {
    <div data-testid="flex-gap-matrix">
        <Flex vertical=true gap=FlexGap::Medium>
            <Flex gap=FlexGap::Small>
                <DemoBox data_testid="gap-small-a">"Small"</DemoBox>
                <DemoBox data_testid="gap-small-b">"Small"</DemoBox>
            </Flex>
            <Flex gap=FlexGap::Medium>
                <DemoBox data_testid="gap-medium-a">"Medium"</DemoBox>
                <DemoBox data_testid="gap-medium-b">"Medium"</DemoBox>
            </Flex>
            <Flex gap=FlexGap::Large>
                <DemoBox data_testid="gap-large-a">"Large"</DemoBox>
                <DemoBox data_testid="gap-large-b">"Large"</DemoBox>
            </Flex>
            <Flex gap=FlexGap::Size(20)>
                <DemoBox data_testid="gap-size-a">"Size(20)"</DemoBox>
                <DemoBox data_testid="gap-size-b">"Size(20)"</DemoBox>
            </Flex>
            <Flex gap=FlexGap::WH(8, 24)>
                <DemoBox data_testid="gap-wh-a">"WH(8,24)"</DemoBox>
                <DemoBox data_testid="gap-wh-b">"WH(8,24)"</DemoBox>
            </Flex>
        </Flex>
    </div>
}

§Centered content

Center on both axes when a single block should sit in the middle of a fixed-height region (empty states, compact panels).

use crate::DemoBox;
view! {
    <div data-testid="flex-centered" style="width: 100%; max-width: 560px; height: 160px; border: 1px dashed var(--orb-color-border-default); border-radius: var(--orb-radius-md);">
        <Flex
            fill=true
            full_width=true
            justify=FlexJustify::Center
            align=FlexAlign::Center
        >
            <DemoBox data_testid="flex-center-label">"Centered"</DemoBox>
        </Flex>
    </div>
}

§Align (cross-axis)

Start, Center, and End alignment along the cross axis when row height exceeds item height.

use crate::{DemoBox, Flex, FlexAlign, FlexGap};
view! {
    <div data-testid="flex-align" style="height: 120px;">
        <Flex vertical=true gap=FlexGap::Medium>
            <Flex align=FlexAlign::Start gap=FlexGap::Small>
                <DemoBox height="24px">"Start"</DemoBox>
                <DemoBox height="48px">"Start"</DemoBox>
            </Flex>
            <Flex align=FlexAlign::Center gap=FlexGap::Small>
                <DemoBox height="24px">"Center"</DemoBox>
                <DemoBox height="48px">"Center"</DemoBox>
            </Flex>
            <Flex align=FlexAlign::End gap=FlexGap::Small>
                <DemoBox height="24px">"End"</DemoBox>
                <DemoBox height="48px">"End"</DemoBox>
            </Flex>
        </Flex>
    </div>
}

§Justify (main-axis)

Start, Center, End, and SpaceBetween distribute items along the main axis—SpaceBetween is common for footer action bars.

use crate::{DemoBox, Flex, FlexGap, FlexJustify};
view! {
    <div data-testid="flex-justify">
        <Flex vertical=true gap=FlexGap::Medium>
            <Flex justify=FlexJustify::Start gap=FlexGap::Small full_width=true>
                <DemoBox>"Start"</DemoBox>
                <DemoBox>"Start"</DemoBox>
            </Flex>
            <Flex justify=FlexJustify::Center gap=FlexGap::Small full_width=true>
                <DemoBox>"Center"</DemoBox>
                <DemoBox>"Center"</DemoBox>
            </Flex>
            <Flex justify=FlexJustify::End gap=FlexGap::Small full_width=true>
                <DemoBox>"End"</DemoBox>
                <DemoBox>"End"</DemoBox>
            </Flex>
            <Flex justify=FlexJustify::SpaceBetween gap=FlexGap::Small full_width=true>
                <DemoBox>"Between"</DemoBox>
                <DemoBox>"Between"</DemoBox>
            </Flex>
        </Flex>
    </div>
}

§Required Props

  • children: Children
    • Flex item children.

§Optional Props

Fields§

§class: MaybeProp<String>

Optional CSS class names merged onto the flex container.

§gap: FlexGap

Spacing between flex items. Presets: Small, Medium (default), Large; or custom via Size(px) / WH(row_px, col_px).

§vertical: bool

When true, lays out children in a column (flex-direction: column).

§inline: Signal<bool>

When true, uses display: inline-flex so the container flows inline.

§align: MaybeProp<FlexAlign>

Cross-axis alignment (align-items).

§justify: MaybeProp<FlexJustify>

Main-axis distribution (justify-content).

§wrap: FlexWrap

Whether flex items wrap onto multiple lines.

§fill: bool

When true, the container fills the height of its parent (height: 100%).

§full_width: bool

When true, the container spans the full width of its parent.

§padding: MaybeProp<SpacingInset>

Theme-aware padding using Orbital spacing tokens.

§margin: MaybeProp<SpacingInset>

Theme-aware margin using Orbital spacing tokens.

§children: Children

Flex item children.

Implementations§

Source§

impl FlexProps

Source

pub fn builder() -> FlexPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building FlexProps. On the builder, call .class(...)(optional), .gap(...)(optional), .vertical(...)(optional), .inline(...)(optional), .align(...)(optional), .justify(...)(optional), .wrap(...)(optional), .fill(...)(optional), .full_width(...)(optional), .padding(...)(optional), .margin(...)(optional), .children(...) to set the values of the fields. Finally, call .build() to create the instance of FlexProps.

Trait Implementations§

Source§

impl Props for FlexProps

Source§

type Builder = FlexPropsBuilder

Source§

fn builder() -> Self::Builder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
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<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> SerializableKey for T

Source§

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more