Function leptos_meta::Title

source ·
pub fn Title(props: TitleProps) -> impl IntoView
Expand description

A component to set the document’s title by creating an HTMLTitleElement.

The title and formatter can be set independently of one another. For example, you can create a root-level <Title formatter=.../> that will wrap each of the text values of <Title/> components created lower in the tree.

use leptos::*;
use leptos_meta::*;

#[component]
fn MyApp() -> impl IntoView {
    provide_meta_context();
    let formatter = |text| format!("{text} — Leptos Online");

    view! {
      <main>
        <Title formatter/>
        // ... routing logic here
      </main>
    }
}

#[component]
fn PageA() -> impl IntoView {
    view! {
      <main>
        <Title text="Page A"/> // sets title to "Page A — Leptos Online"
      </main>
    }
}

#[component]
fn PageB() -> impl IntoView {
    view! {
      <main>
        <Title text="Page B"/> // sets title to "Page B — Leptos Online"
      </main>
    }
}

§Optional Props