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
- mut formatter:
impl Into<Formatter>
- A function that will be applied to any text value before it’s set as the title.
- mut text:
impl Into<TextProp>
- Sets the current
document.title
.
- Sets the current
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§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TitleProps
impl !RefUnwindSafe for TitleProps
impl Send for TitleProps
impl Sync for TitleProps
impl Unpin for TitleProps
impl !UnwindSafe for TitleProps
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
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 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>
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 moreSource§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.