pub struct text;Expand description
text element is simply a text span used for the paragraph element.
Implementations§
Source§impl text
impl text
Sourcepub const color: AttributeDescription
pub const color: AttributeDescription
The color attribute lets you specify the color of the text.
You can learn about the syntax of this attribute in Color Syntax.
§Example
fn app() -> Element {
rsx!(
label {
color: "green",
"Hello, World!"
}
)
}Another example showing inheritance:
fn app() -> Element {
rsx!(
rect {
color: "blue",
label {
"Hello, World!"
}
}
)
}Sourcepub const font_size: AttributeDescription
pub const font_size: AttributeDescription
You can specify the size of the text using font_size.
§Example
fn app() -> Element {
rsx!(
label {
font_size: "50",
"Hellooooo!"
}
)
}Sourcepub const font_family: AttributeDescription
pub const font_family: AttributeDescription
With the font_family you can specify what font you want to use for the inner text.
Check out the custom font example to see how you can load your own fonts.
§Example
fn app() -> Element {
rsx!(
label {
font_family: "Inter",
"Hello, World!"
}
)
}Sourcepub const font_style: AttributeDescription
pub const font_style: AttributeDescription
You can choose a style for a text using the font_style attribute.
Accepted values:
upright(default)italicoblique
§Example
fn app() -> Element {
rsx!(
label {
font_style: "italic",
"Hello, italic World!"
}
)
}You can also specify multiple fonts in order of priority, if one is not found it will fallback to the next one.
Example:
fn app() -> Element {
rsx!(
label {
font_family: "DoesntExist Font, Impact",
"Hello, World!"
}
)
}Sourcepub const font_weight: AttributeDescription
pub const font_weight: AttributeDescription
You can choose a weight for text using the font_weight attribute.
Accepted values:
invisiblethinextra-lightlightnormal(default)mediumsemi-boldboldextra-boldblackextra-black50100200300400500600700800900950
§Example
fn app() -> Element {
rsx!(
label {
font_weight: "bold",
"Hello, bold World!"
}
)
}Sourcepub const font_width: AttributeDescription
pub const font_width: AttributeDescription
You can choose a width for a text using the font_width attribute.
⚠️ Only fonts with variable widths will be affected.
Accepted values:
ultra-condensedextra-condensedcondensednormal(default)semi-expandedexpandedextra-expandedultra-expanded
§Example
fn app() -> Element {
rsx!(
label {
font_width: "ultra-expanded",
"Hello, wide World!"
}
)
}Sourcepub const text_align: AttributeDescription
pub const text_align: AttributeDescription
You can change the alignment of the text using the text_align attribute.
Accepted values:
centerendjustifyleft(default)rightstart
§Example
fn app() -> Element {
rsx!(
label {
text_align: "right",
"Hello, World!"
}
)
}Sourcepub const line_height: AttributeDescription
pub const line_height: AttributeDescription
Sourcepub const text_shadow: AttributeDescription
pub const text_shadow: AttributeDescription
Specify the shadow of a text.
Syntax: <x> <y> <size> <color>
§Example
fn app() -> Element {
rsx!(
label {
text_shadow: "0 18 12 rgb(0, 0, 0)",
"Hello, World!"
}
)
}Sourcepub const decoration: AttributeDescription
pub const decoration: AttributeDescription
Specify the decoration in a text.
Accepted values:
underlineline-throughoverline
§Example
fn app() -> Element {
rsx!(
label {
decoration: "line-through",
"Hello, World!"
}
)
}Sourcepub const decoration_style: AttributeDescription
pub const decoration_style: AttributeDescription
Specify the decoration’s style in a text.
Accepted values:
solid(default)doubledotteddashedwavy
§Example
fn app() -> Element {
rsx!(
label {
decoration: "line-through",
decoration_style: "dotted",
"Hello, World!"
}
)
}Sourcepub const decoration_color: AttributeDescription
pub const decoration_color: AttributeDescription
Specify the decoration’s color in a text.
You can learn about the syntax of this attribute in Color Syntax.
§Example
fn app() -> Element {
rsx!(
label {
decoration: "line-through",
decoration_color: "orange",
"Hello, World!"
}
)
}Sourcepub const letter_spacing: AttributeDescription
pub const letter_spacing: AttributeDescription
Specify the spacing between characters of the text.
§Example
fn app() -> Element {
rsx!(
label {
letter_spacing: "10",
"Hello, World!"
}
)
}Sourcepub const word_spacing: AttributeDescription
pub const word_spacing: AttributeDescription
Specify the spacing between words of the text.
§Example
fn app() -> Element {
rsx!(
label {
word_spacing: "10",
"Hello, World!"
}
)
}Auto Trait Implementations§
impl Freeze for text
impl RefUnwindSafe for text
impl Send for text
impl Sync for text
impl Unpin for text
impl UnwindSafe for text
Blanket Implementations§
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more