pub struct Text {Show 19 fields
pub color: Option<Color>,
pub direction: Option<Direction>,
pub letter_spacing: Option<LetterSpacing>,
pub word_spacing: Option<WordSpacing>,
pub line_height: Option<LineHeight>,
pub align: Option<TextAlign>,
pub align_last: Option<TextAlignLast>,
pub justify: Option<TextJustify>,
pub shadow: Option<TextShadow>,
pub indent: Option<TextIndent>,
pub decoration: Option<TextDecoration>,
pub white_space: Option<WhiteSpace>,
pub unicode_bidi: Option<UnicodeBidi>,
pub transform: Option<TextTransform>,
pub overflow: Option<TextOverflow>,
pub vertical_align: Option<VerticalAlign>,
pub writing_mode: Option<WritingMode>,
pub word_wrap: Option<WordWrap>,
pub word_break: Option<WordBreak>,
}
Expand description
use css_style::{prelude::*, color, unit::{em, px}, text::{TextAlign, TextTransform}};
use palette::rgb::Rgb;
style()
.and_text(|conf| {
conf.line_height(1.7)
// rgb value f32 based, we can pass u32 hex value too e.g. 0xFFFFFFFF
.color((0.5, 0.1, 0.1))
// or we can use HTML colors
.color(color::named::BLUEVIOLET)
.align(TextAlign::Center)
.transform(TextTransform::Capitalize)
.indent(em(2.))
// for single text shadow
.and_shadow(|conf| {
conf.x(px(3))
.y(px(4))
.color(color::named::BLUE)
.blur(px(2))
})
// for multiple text shadows
.and_shadow(|conf| {
conf.push(|conf| conf.x(px(2))).y(px(-4))
.push(|conf| conf.x(px(9)))
})
});
Fields§
§color: Option<Color>
§direction: Option<Direction>
§letter_spacing: Option<LetterSpacing>
§word_spacing: Option<WordSpacing>
§line_height: Option<LineHeight>
§align: Option<TextAlign>
§align_last: Option<TextAlignLast>
§justify: Option<TextJustify>
§shadow: Option<TextShadow>
§indent: Option<TextIndent>
§decoration: Option<TextDecoration>
§white_space: Option<WhiteSpace>
§unicode_bidi: Option<UnicodeBidi>
§transform: Option<TextTransform>
§overflow: Option<TextOverflow>
§vertical_align: Option<VerticalAlign>
§writing_mode: Option<WritingMode>
§word_wrap: Option<WordWrap>
§word_break: Option<WordBreak>
Implementations§
Source§impl Text
impl Text
pub fn color(self, value: impl Into<Color>) -> Self
pub fn try_color(self, value: Option<impl Into<Color>>) -> Self
pub fn direction(self, value: impl Into<Direction>) -> Self
pub fn try_direction(self, value: Option<impl Into<Direction>>) -> Self
pub fn letter_spacing(self, value: impl Into<LetterSpacing>) -> Self
pub fn try_letter_spacing(self, value: Option<impl Into<LetterSpacing>>) -> Self
pub fn word_spacing(self, value: impl Into<WordSpacing>) -> Self
pub fn try_word_spacing(self, value: Option<impl Into<WordSpacing>>) -> Self
pub fn line_height(self, value: impl Into<LineHeight>) -> Self
pub fn try_line_height(self, value: Option<impl Into<LineHeight>>) -> Self
pub fn align(self, value: impl Into<TextAlign>) -> Self
pub fn try_align(self, value: Option<impl Into<TextAlign>>) -> Self
pub fn align_last(self, value: impl Into<TextAlignLast>) -> Self
pub fn try_align_last(self, value: Option<impl Into<TextAlignLast>>) -> Self
pub fn justify(self, value: impl Into<TextJustify>) -> Self
pub fn try_justify(self, value: Option<impl Into<TextJustify>>) -> Self
pub fn shadow(self, value: impl Into<TextShadow>) -> Self
pub fn try_shadow(self, value: Option<impl Into<TextShadow>>) -> Self
pub fn and_shadow(
self,
set_value: impl FnOnce(TextShadow) -> TextShadow,
) -> Selfwhere
TextShadow: Default,
pub fn indent(self, value: impl Into<TextIndent>) -> Self
pub fn try_indent(self, value: Option<impl Into<TextIndent>>) -> Self
pub fn decoration(self, value: impl Into<TextDecoration>) -> Self
pub fn try_decoration(self, value: Option<impl Into<TextDecoration>>) -> Self
pub fn and_decoration(
self,
set_value: impl FnOnce(TextDecoration) -> TextDecoration,
) -> Selfwhere
TextDecoration: Default,
pub fn white_space(self, value: impl Into<WhiteSpace>) -> Self
pub fn try_white_space(self, value: Option<impl Into<WhiteSpace>>) -> Self
pub fn unicode_bidi(self, value: impl Into<UnicodeBidi>) -> Self
pub fn try_unicode_bidi(self, value: Option<impl Into<UnicodeBidi>>) -> Self
pub fn transform(self, value: impl Into<TextTransform>) -> Self
pub fn try_transform(self, value: Option<impl Into<TextTransform>>) -> Self
pub fn overflow(self, value: impl Into<TextOverflow>) -> Self
pub fn try_overflow(self, value: Option<impl Into<TextOverflow>>) -> Self
pub fn vertical_align(self, value: impl Into<VerticalAlign>) -> Self
pub fn try_vertical_align(self, value: Option<impl Into<VerticalAlign>>) -> Self
pub fn writing_mode(self, value: impl Into<WritingMode>) -> Self
pub fn try_writing_mode(self, value: Option<impl Into<WritingMode>>) -> Self
pub fn word_wrap(self, value: impl Into<WordWrap>) -> Self
pub fn try_word_wrap(self, value: Option<impl Into<WordWrap>>) -> Self
pub fn word_break(self, value: impl Into<WordBreak>) -> Self
pub fn try_word_break(self, value: Option<impl Into<WordBreak>>) -> Self
Trait Implementations§
Source§impl StyleUpdater for Text
impl StyleUpdater for Text
fn update_style(self, style: Style) -> Style
impl StructuralPartialEq for Text
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<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
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 Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
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