• Rust 72.6%
  • CSS 27.4%
Find a file
2026-03-06 13:37:35 +01:00
.github/workflows release-plz workflow 2024-02-06 20:43:33 +01:00
.zed Minor Changes to context handling 2025-04-15 20:52:16 +02:00
assets chore: better examples 2024-02-06 21:54:03 +01:00
examples/basic Minor Changes to context handling 2025-04-15 20:52:16 +02:00
src fixed linter 2.0 2025-04-15 21:08:06 +02:00
.gitignore chore: include lock 2024-05-02 08:40:14 +02:00
Cargo.lock Bump Leptos to version 0.8 2026-03-06 13:37:35 +01:00
Cargo.toml Bump Leptos to version 0.8 2026-03-06 13:37:35 +01:00
CHANGELOG.md chore: release 2024-05-20 16:05:06 +00:00
LICENSE example setup 2024-02-04 22:17:08 +01:00
README.md fixed linter 2025-04-15 21:06:48 +02:00
rust-toolchain.toml fully go away from nightly 2024-05-02 18:32:08 +02:00

Example

leptos_toaster

A Toaster component for Leptos heavily inspired by sonner

SSR

If using SSR don't forget to set the features in your own Project correctly

[features]
ssr = ["leptos_toaster/ssr"]
hydrate = ["leptos_toaster/hydrate"]

Usage

Somewhere, probably near the top of your component tree, add the Toaster component

view! {
	<Toaster
	    position=toaster::ToasterPosition::BottomCenter
	>
		// ...
	</Toaster>
}

and then whenever you need a toast, do

let toast_context = expect_context::<Toasts>();

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
		move || view! {
			<Toast
				toast_id
				variant=ToastVariant::Info
				title=|| view! {"My toast"}
			/>
		},
		Some(toast_id),
		None // options
	);
}