pub trait TextView: View {
// Required method
fn text_node(&mut self) -> &mut TextStyle;
// Provided methods
fn text_alignment(self, justify_text: JustifyText) -> Self { ... }
fn text_linebreak(self, line_break: LineBreak) -> Self { ... }
fn text(self, text: impl Into<String>) -> Self { ... }
fn text_color(self, color: impl Into<Color>) -> Self { ... }
fn font(self, font: Handle<Font>) -> Self { ... }
fn font_size(self, font_size: f32) -> Self { ... }
fn line_height(self, line_height: LineHeight) -> Self { ... }
fn font_smoothing(self, font_smoothing: FontSmoothing) -> Self { ... }
}Expand description
A trait for views that support styled text content using a TextStyle bundle.
Required Methods§
Provided Methods§
Sourcefn text_alignment(self, justify_text: JustifyText) -> Self
fn text_alignment(self, justify_text: JustifyText) -> Self
Sets the text alignment mode within the layout container.
Controls horizontal alignment of multiline text, such as left-aligned, right-aligned, centered, or justified.
§Arguments
justify_text- AJustifyTextvariant indicating the desired alignment mode.
§Example
ⓘ
view.text_alignment(JustifyText::Center);Sourcefn text_linebreak(self, line_break: LineBreak) -> Self
fn text_linebreak(self, line_break: LineBreak) -> Self
Sets the line-breaking behavior of the text content.
Determines how and when lines wrap, such as breaking on word boundaries, characters, or disabling wrapping altogether.
§Arguments
line_break- ALineBreakvariant specifying the wrapping strategy.
§Example
ⓘ
view.text_linebreak(LineBreak::WordWrap);Sourcefn text_color(self, color: impl Into<Color>) -> Self
fn text_color(self, color: impl Into<Color>) -> Self
Sets the text color of the node.
§Arguments
color- A color value (e.g.,Color::WHITE,Color::rgb(...)).
Sourcefn font_size(self, font_size: f32) -> Self
fn font_size(self, font_size: f32) -> Self
Sets the size of the font in logical pixels.
§Arguments
font_size- The font size, typically in points or pixels.
Sourcefn line_height(self, line_height: LineHeight) -> Self
fn line_height(self, line_height: LineHeight) -> Self
Sets the line height for the text, controlling vertical spacing between lines.
§Arguments
line_height- ALineHeightvalue representing relative or absolute spacing.
Sourcefn font_smoothing(self, font_smoothing: FontSmoothing) -> Self
fn font_smoothing(self, font_smoothing: FontSmoothing) -> Self
Sets the font smoothing mode for the text.
§Arguments
font_smoothing- AFontSmoothingstrategy (e.g.,FontSmoothing::None,Subpixel).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.