pub fn Text(props: TextProps) -> impl IntoViewExpand description
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