Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SorenHolstHansen/leptos_toaster
A Toaster component for Leptos
https://github.com/SorenHolstHansen/leptos_toaster
Last synced: 2 months ago
JSON representation
A Toaster component for Leptos
- Host: GitHub
- URL: https://github.com/SorenHolstHansen/leptos_toaster
- Owner: SorenHolstHansen
- License: mit
- Created: 2024-02-04T20:36:35.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-05-20T16:06:54.000Z (8 months ago)
- Last Synced: 2024-10-31T11:55:54.020Z (2 months ago)
- Language: Rust
- Size: 564 KB
- Stars: 21
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-leptos - leptos_toaster
README
![Example](assets/example.gif)
# leptos_toaster
A Toaster component for Leptos heavily inspired by [sonner](https://sonner.emilkowal.ski/)
## SSR
If using SSR don't forget to set the features in your own Project correctly
```toml
[features]
ssr = ["leptos_toaster/ssr"]
hydrate = ["leptos_toaster/hydrate"]```
## Usage
Somewhere, probably near the top of your component tree, add the Toaster component
```rust
view! {
// ...
}
```
and then whenever you need a toast, do```rust
let toast_context = expect_context::();let create_toast = move || {
let toast_id = ToastId::new();
toast_context.toast(
// This uses the built in toast component that requires the `builtin_toast` feature.
// You can use your own components here
view! {
},
Some(toast_id),
None // options
);
}
```