Function leptos_meta::Body

source ·
pub fn Body(props: BodyProps) -> impl IntoView
Expand description

A component to set metadata on the document’s <body> element from within the application.

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

#[component]
fn MyApp() -> impl IntoView {
    provide_meta_context();
    let (prefers_dark, set_prefers_dark) = create_signal(false);
    let body_class = move || {
        if prefers_dark.get() {
            "dark".to_string()
        } else {
            "light".to_string()
        }
    };

    view! {
      <main>
        <Body class=body_class attr:class="foo"/>
      </main>
    }
}

§Required Props

  • attributes: [Vec<(&'static str, Attribute)>]
    • Arbitrary attributes to add to the <body>

§Optional Props