Function leptos_meta::Body
source · pub fn Body() -> impl IntoView
Expand description
A component to set metadata on the document’s <body>
element from
within the application.
This component takes no props, but can take any number of spread attributes
following the {..}
operator.
use leptos::prelude::*;
use leptos_meta::*;
#[component]
fn MyApp() -> impl IntoView {
provide_meta_context();
let (prefers_dark, set_prefers_dark) = signal(false);
let body_class = move || {
if prefers_dark.get() {
"dark".to_string()
} else {
"light".to_string()
}
};
view! {
<main>
<Body {..} class=body_class id="body"/>
</main>
}
}