Skip to main content

LabelProps

Struct LabelProps 

Source
pub struct LabelProps {
    pub text: String,
    pub font: FontSpec,
    pub color: Option<Color>,
    pub role: TextRole,
    pub wraps: bool,
    pub max_lines: u32,
    pub align: TextAlign,
    pub runs: Vec<TextRun>,
}

Fields§

§text: String§font: FontSpec§color: Option<Color>§role: TextRole

What the text means, for the color the platform gives it (docs/text.md).

Semantic the way crate::Font is semantic: an app says “this is secondary text” and each platform answers with its own answer: secondaryLabelColor on Apple, ?android:textColorSecondary, GTK’s dim-label. That is the only way a de-emphasized label stays correct in both appearances, since a literal grey that reads well on white is wrong on black. An explicit Self::color still wins; a backend that has no such color renders primary, which is legible and correct, just not dimmed.

§wraps: bool§max_lines: u32

Maximum rendered lines; zero is unlimited. Native Apple plain labels truncate the last line. Other backends may retain their ordinary wrapping behavior.

§align: TextAlign

How the label’s lines sit within its own width. Only observable on a label that wraps or carries explicit newlines: a single line fills its box, so its alignment is the container’s business, not the label’s.

Leading is the default and is what running text wants; Center is for the short, centered block a welcome screen or an empty state uses. A backend that cannot set it renders leading-aligned, which is legible and correct, just not centered.

§runs: Vec<TextRun>

Styled spans within text (docs/text-runs.md). Empty is the overwhelmingly common case and means exactly what a label has always meant: one font, one color. A backend that cannot draw runs ignores this and renders text uniformly, which is legible and correct, just unstyled.

Trait Implementations§

Source§

impl Clone for LabelProps

Source§

fn clone(&self) -> LabelProps

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 Debug for LabelProps

Source§

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

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

impl Default for LabelProps

Source§

fn default() -> LabelProps

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

impl PartialEq for LabelProps

Source§

fn eq(&self, other: &LabelProps) -> 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 LabelProps

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<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> 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> 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 = 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.
Day API ↩ Guides· daybrite.dev