pub struct Text { /* private fields */ }Expand description
Single-line Material text. Measurement and painting share Foundation’s shaped glyphs, including font fallback and letter spacing.
Implementations§
Source§impl Text
impl Text
Sourcepub fn new(value: impl Into<SharedString>) -> Self
pub fn new(value: impl Into<SharedString>) -> Self
Creates text with the default TypeRole::BodyLarge typography role.
Sourcepub fn display_large(value: impl Into<SharedString>) -> Self
pub fn display_large(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::DisplayLarge.
Sourcepub fn display_medium(value: impl Into<SharedString>) -> Self
pub fn display_medium(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::DisplayMedium.
Sourcepub fn display_small(value: impl Into<SharedString>) -> Self
pub fn display_small(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::DisplaySmall.
Sourcepub fn headline_large(value: impl Into<SharedString>) -> Self
pub fn headline_large(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::HeadlineLarge.
Sourcepub fn headline_medium(value: impl Into<SharedString>) -> Self
pub fn headline_medium(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::HeadlineMedium.
Sourcepub fn headline_small(value: impl Into<SharedString>) -> Self
pub fn headline_small(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::HeadlineSmall.
Sourcepub fn title_large(value: impl Into<SharedString>) -> Self
pub fn title_large(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::TitleLarge.
Sourcepub fn title_medium(value: impl Into<SharedString>) -> Self
pub fn title_medium(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::TitleMedium.
Sourcepub fn title_small(value: impl Into<SharedString>) -> Self
pub fn title_small(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::TitleSmall.
Sourcepub fn body_large(value: impl Into<SharedString>) -> Self
pub fn body_large(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::BodyLarge.
Sourcepub fn body_medium(value: impl Into<SharedString>) -> Self
pub fn body_medium(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::BodyMedium.
Sourcepub fn body_small(value: impl Into<SharedString>) -> Self
pub fn body_small(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::BodySmall.
Sourcepub fn label_large(value: impl Into<SharedString>) -> Self
pub fn label_large(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::LabelLarge.
Sourcepub fn label_medium(value: impl Into<SharedString>) -> Self
pub fn label_medium(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::LabelMedium.
Sourcepub fn label_small(value: impl Into<SharedString>) -> Self
pub fn label_small(value: impl Into<SharedString>) -> Self
Creates text styled with TypeRole::LabelSmall.
Sourcepub fn id(self, id: impl Into<ElementId>) -> Self
pub fn id(self, id: impl Into<ElementId>) -> Self
Supplies a stable ID for this label within its parent.
Sourcepub fn role(self, role: TypeRole) -> Self
pub fn role(self, role: TypeRole) -> Self
Sets the Material typography scale role. Defaults to TypeRole::BodyLarge.
Sourcepub fn emphasized(self, emphasized: bool) -> Self
pub fn emphasized(self, emphasized: bool) -> Self
Selects emphasized typography weight when true, or baseline weight when false.
Sourcepub fn font_scale(self, scale: f32) -> Self
pub fn font_scale(self, scale: f32) -> Self
Applies an additional font-size multiplier on top of the window theme’s typography scale. Defaults to 1.0.
Sourcepub fn color(self, role: ColorRole) -> Self
pub fn color(self, role: ColorRole) -> Self
Resolves the text color from the window theme’s semantic color role.
Sourcepub fn color_override(self, color: impl Into<Hsla>) -> Self
pub fn color_override(self, color: impl Into<Hsla>) -> Self
Sets a literal text color. A later call to Self::color restores theme-role lookup.
Sourcepub fn muted(self) -> Self
pub fn muted(self) -> Self
Sets the text color to ColorRole::OnSurfaceVariant.
Sourcepub fn align(self, align: TextAlign) -> Self
pub fn align(self, align: TextAlign) -> Self
Sets explicit horizontal text alignment. Defaults to the window’s logical start edge.
Sourcepub fn max_lines(self, lines: usize) -> Self
pub fn max_lines(self, lines: usize) -> Self
Clamps wrapped text to at most lines lines (minimum 1) when .wrap() is enabled.
Trait Implementations§
Source§impl IntoElement for Text
impl IntoElement for Text
Source§type Element = ViewElement<Text>
type Element = ViewElement<Text>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Text
impl RenderOnce for Text
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl Forget for Text
impl Freeze for Text
impl Move for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.