8 releases

0.1.7 May 20, 2024
0.1.6 May 2, 2024
0.1.3 Mar 9, 2024
0.1.2 Feb 6, 2024

#1332 in Web programming

Download history 56/week @ 2024-08-04 44/week @ 2024-08-11 57/week @ 2024-08-18 62/week @ 2024-08-25 46/week @ 2024-09-01 29/week @ 2024-09-08 16/week @ 2024-09-15 69/week @ 2024-09-22 65/week @ 2024-09-29 113/week @ 2024-10-06 60/week @ 2024-10-13 57/week @ 2024-10-20 46/week @ 2024-10-27 42/week @ 2024-11-03 7/week @ 2024-11-10 10/week @ 2024-11-17

109 downloads per month

MIT license

525KB
711 lines

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

Dependencies

~20–33MB
~515K SLoC