https://github.com/dioxus-community/dioxus-helmet
Small Dioxus component which allows you to place elements in the head of your document
https://github.com/dioxus-community/dioxus-helmet
dioxus helmet
Last synced: 4 months ago
JSON representation
Small Dioxus component which allows you to place elements in the head of your document
- Host: GitHub
- URL: https://github.com/dioxus-community/dioxus-helmet
- Owner: dioxus-community
- License: mit
- Created: 2022-04-17T02:34:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-07T22:31:58.000Z (about 1 year ago)
- Last Synced: 2025-06-06T00:31:09.183Z (4 months ago)
- Topics: dioxus, helmet
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 24
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dioxus-helmet
## General
Inspired by react-helmet, this small [Dioxus](https://github.com/DioxusLabs/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:
```rust
use dioxus_helmet::Helmet;
```Then use it as a component like this:
```rust
#[component]
fn HeadElements(path: String) -> Element {
rsx! {
Helmet {
link { rel: "icon", href: "{path}"}
title { "Helmet" }
style {
[r#"
body {
color: blue;
}
a {
color: red;
}
"#]
}
}
}
}
```Any children passed to the helmet component will then be placed in the `` of your document.
**IMPORTANT**: The nodes inside the `Helmet` component are not reactive, so they won't be updated
when the value of them changes. So it's better to use static values inside the `Helmet`
component instead of signals.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](https://github.com/saicu/dioxus-helmet/blob/main/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.