Skip to main content

CrossAxisAlignment

Enum CrossAxisAlignment 

Source
pub enum CrossAxisAlignment {
    Start,
    End,
    Center,
    Stretch,
    Baseline,
}
Expand description

How the children should be placed along the cross axis in a flex layout.

See also:

Variants§

§

Start

Place the children with their start edge aligned with the start side of the cross axis.

For example, in a column (a flex with a vertical axis) whose TextDirection is TextDirection::Ltr, this aligns the left edge of the children along the left edge of the column.

If this value is used in a horizontal direction, a TextDirection must be available to determine if the start is the left or the right.

If this value is used in a vertical direction, a VerticalDirection must be available to determine if the start is the top or the bottom.

§

End

Place the children as close to the end of the cross axis as possible.

For example, in a column (a flex with a vertical axis) whose TextDirection is TextDirection::Ltr, this aligns the right edge of the children along the right edge of the column.

If this value is used in a horizontal direction, a TextDirection must be available to determine if the end is the left or the right.

If this value is used in a vertical direction, a VerticalDirection must be available to determine if the end is the top or the bottom.

§

Center

Place the children so that their centers align with the middle of the cross axis.

This is the default cross-axis alignment.

§

Stretch

Require the children to fill the cross axis.

This causes the constraints passed to the children to be tight in the cross axis.

§

Baseline

Place the children along the cross axis such that their baselines match.

Consider using this value for any horizontal main axis (as with a row) where the children primarily contain text. If the different children have text with different font metrics (for example because they differ in font size or other text style properties, or because they use different fonts due to being written in different scripts), then this typically produces better visual alignment than the other CrossAxisAlignment values, which use no information about where the text sits vertically within its bounding box.

The baseline of a widget is typically the typographic baseline of the first text in the first text widget it encloses, if any. The typographic baseline is a horizontal line used for aligning text, which is specified by each font; for alphabetic scripts, it ordinarily runs along the bottom of letters excluding any descenders.

Because baselines are always horizontal, this alignment is intended for horizontal main axes (as with a row). If the main axis is vertical (as with a column), then this value is treated like Start.

For horizontal main axes, if the minimum height constraint passed to the flex layout exceeds the intrinsic height of the cross axis, children will be aligned as close to the top as they can be while honoring the baseline alignment. In other words, the extra space will be below all the children.

Children who report no baseline will be top-aligned.

See also:

Trait Implementations§

Source§

impl Clone for CrossAxisAlignment

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CrossAxisAlignment

Source§

impl Debug for CrossAxisAlignment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CrossAxisAlignment

Source§

impl PartialEq for CrossAxisAlignment

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CrossAxisAlignment

Auto Trait Implementations§

Blanket Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,