dioxus-helmet

Crates.iodioxus-helmet
lib.rsdioxus-helmet
version0.2.4
sourcesrc
created_at2022-05-05 02:21:18.259735
updated_at2022-09-01 22:12:13.298455
descriptionSmall Dioxus component which allows you to place elements in the head of your document
homepage
repositoryhttps://github.com/saicu/dioxus-helmet
max_upload_size
id580781
size12,456
Marc Espin (marc2332)

documentation

README

dioxus-helmet

Crates.io version

General

Inspired by react-helmet, this small Dioxus component allows you to place elements in the head of your code.

Configuration

Add the package as a dependency to your Cargo.toml.

cargo add dioxus-helmet

Usage

Import it in your code:

use dioxus_helmet::Helmet;

Then use it as a component like this:

#[inline_props]
fn HeadElements(cx: Scope, path: String) -> Element {
    cx.render(rsx! {
        Helmet {
            link { rel: "icon", href: "{path}"}
            title { "Helmet" }
            style {
                [r#"
                    body {
                        color: blue;
                    }
                    a {
                        color: red;
                    }
                "#]
            }
        }
    })
}

Reach your dynamic values down as owned properties (eg String and not &'a str).

Also make sure that there are no states in your component where you use Helmet.

Any children passed to the helmet component will then be placed in the <head></head> of your document.

They will be visible while the component is rendered. Duplicates won't get appended multiple times.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in dioxus-helmet by you, shall be licensed as MIT, without any additional terms or conditions.

Commit count: 24

cargo fmt