Skip to main content

Text

Function Text 

Source
pub fn Text(props: TextProps) -> impl IntoView
Expand 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, use FormLabel, FormHint, or SectionTitle instead

§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

§Optional Props

  • tag: TextTag
    • HTML element to render — default Span. Use H1H6, P, Label, or Code for document structure.
  • align: TextAlign
    • Horizontal alignment inside a block container: Start, Center, End, or Justify.
  • block: bool
    • Render as a block-level box (display: block) instead of inline.
  • font: TextFont
    • Font family preset: Base, Numeric (tabular figures), or Monospace.
  • italic: bool
    • Italic emphasis.
  • size: TextSize
    • Typography scale step from theme tokens (S100 smallest through S1000 largest).
  • strikethrough: bool
    • Line-through decoration for deleted or superseded copy.
  • truncate: bool
    • Single-line ellipsis overflow — pair with block=true inside a bounded-width container.
  • underline: bool
    • Underline decoration — use for inline links or emphasized phrases.
  • weight: TextWeight
    • Font weight preset: Regular, Medium, Semibold, or Bold.
  • wrap: bool
    • Allow 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: 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).