leptos_meta

Struct TitleProps

Source
pub struct TitleProps {
    pub formatter: Option<Formatter>,
    pub text: Option<TextProp>,
}
Expand description

Props for the Title component.

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::prelude::*;
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

Fields§

§formatter: Option<Formatter>

A function that will be applied to any text value before it’s set as the title.

§text: Option<TextProp>

Sets the current document.title.

Implementations§

Source§

impl TitleProps

Source

pub fn builder() -> TitlePropsBuilder<((), ())>

Create a builder for building TitleProps. On the builder, call .formatter(...)(optional), .text(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of TitleProps.

Trait Implementations§

Source§

impl Props for TitleProps

Source§

type Builder = TitlePropsBuilder

Source§

fn builder() -> Self::Builder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T