pub struct TextProps {Show 16 fields
pub tag: TextTag,
pub align: TextAlign,
pub block: bool,
pub font: TextFont,
pub italic: bool,
pub size: TextSize,
pub strikethrough: bool,
pub truncate: bool,
pub underline: bool,
pub weight: TextWeight,
pub wrap: bool,
pub color: MaybeProp<ThemeColor>,
pub class: MaybeProp<String>,
pub style: MaybeProp<String>,
pub test_id: MaybeProp<String>,
pub children: Children,
}Expand description
Props for the Text component.
Low-level typography control when presets do not match your need.
Prefer named presets (Body1, Title2, Display, …) for hierarchy — each locks size and weight to a step on Orbital’s typography scale. Use Text when you need a custom token combination, a semantic TextTag, or decorations without a matching preset.
There is no bundled variant prop — pick a preset or set TextSize and TextWeight explicitly. Use [tag] to choose the rendered HTML element; use [truncate] for single-line ellipsis inside a bounded container.
§When to use
- Explicit size/weight/font combinations outside the preset matrix - Semantic HTML via
TextTag(H1,P,Code, …) with token styling - One-off decorations (italic,underline,strikethrough) on any scale step - For field labels, hints, and settings headings, useFormLabel,FormHint, orSectionTitleinstead
§Examples
§Preset vs low-level
use leptos::prelude::*;
use orbital_core_components::{Body1, Text, TextSize, TextWeight};
#[component]
fn Example() -> impl IntoView {
view! {
<Body1>"Default body copy from the typography scale."</Body1>
<Text size=TextSize::S400 weight=TextWeight::Semibold>"Custom emphasis step."</Text>
}
}§Required Props
- children:
Children
§Optional Props
- tag:
TextTag- HTML element to render — default
Span. UseH1–H6,P,Label, orCodefor document structure.
- HTML element to render — default
- align:
TextAlign- Horizontal alignment inside a block container:
Start,Center,End, orJustify.
- Horizontal alignment inside a block container:
- block:
bool- Render as a block-level box (
display: block) instead of inline.
- Render as a block-level box (
- font:
TextFont- Font family preset:
Base,Numeric(tabular figures), orMonospace.
- Font family preset:
- italic:
bool- Italic emphasis.
- size:
TextSize- Typography scale step from theme tokens (
S100smallest throughS1000largest).
- Typography scale step from theme tokens (
- strikethrough:
bool- Line-through decoration for deleted or superseded copy.
- truncate:
bool- Single-line ellipsis overflow — pair with
block=trueinside a bounded-width container.
- Single-line ellipsis overflow — pair with
- underline:
bool- Underline decoration — use for inline links or emphasized phrases.
- weight:
TextWeight- Font weight preset:
Regular,Medium,Semibold, orBold.
- Font weight preset:
- wrap:
bool-
Allow line breaks at whitespace. Set
falseto keep copy on one line (may overflow).Note: use
#[prop(default = true)], not#[prop(optional = true)]. In Leptos,optionalonly means the prop may be omitted; omittedboolstill defaults tofalse.
-
- color:
impl Into<MaybeProp<ThemeColor>>- Foreground color from the active theme palette.
- class:
impl Into<MaybeProp<String>> - style:
impl Into<MaybeProp<String>> - test_id:
impl Into<MaybeProp<String>>- Test id hook (maps to
data-testid).
- Test id hook (maps to
Fields§
§tag: TextTagHTML element to render — default Span. Use H1–H6, P, Label, or Code for document structure.
align: TextAlignHorizontal alignment inside a block container: Start, Center, End, or Justify.
block: boolRender as a block-level box (display: block) instead of inline.
font: TextFontFont family preset: Base, Numeric (tabular figures), or Monospace.
italic: boolItalic emphasis.
size: TextSizeTypography scale step from theme tokens (S100 smallest through S1000 largest).
strikethrough: boolLine-through decoration for deleted or superseded copy.
truncate: boolSingle-line ellipsis overflow — pair with block=true inside a bounded-width container.
underline: boolUnderline decoration — use for inline links or emphasized phrases.
weight: TextWeightFont weight preset: Regular, Medium, Semibold, or Bold.
wrap: boolAllow line breaks at whitespace. Set false to keep copy on one line (may overflow).
Note: use #[prop(default = true)], not #[prop(optional = true)]. In Leptos, optional only means the prop may be omitted; omitted bool still defaults to false.
color: MaybeProp<ThemeColor>Foreground color from the active theme palette.
class: MaybeProp<String>§style: MaybeProp<String>§test_id: MaybeProp<String>Test id hook (maps to data-testid).
children: ChildrenImplementations§
Source§impl TextProps
impl TextProps
Sourcepub fn builder() -> TextPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> TextPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building TextProps.
On the builder, call .tag(...)(optional), .align(...)(optional), .block(...)(optional), .font(...)(optional), .italic(...)(optional), .size(...)(optional), .strikethrough(...)(optional), .truncate(...)(optional), .underline(...)(optional), .weight(...)(optional), .wrap(...)(optional), .color(...)(optional), .class(...)(optional), .style(...)(optional), .test_id(...)(optional), .children(...) to set the values of the fields.
Finally, call .build() to create the instance of TextProps.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TextProps
impl !Sync for TextProps
impl !UnwindSafe for TextProps
impl Freeze for TextProps
impl Send for TextProps
impl Unpin for TextProps
impl UnsafeUnpin for TextProps
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.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
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
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> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
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>>
OutOfBounds error is returned which contains
the unclamped color. Read more