Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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
);
}
```