Ship faster with goilerplate templUI Pro

Toast

Flexible toast component for notifications and feedback.

Source Tailwind CSS JavaScript

Installation

templui add toast
// Template
templ UserForm() {
	<form hx-post="/save" hx-target="#toast">
	   <input name="email" />
	</form>
	<div id="toast"></div>
}
// Handler
func Save(w http.ResponseWriter, r *http.Request) {
	if err != nil {
		toast.Toast(toast.Props{
			Description: err.Error(),
			Variant:     toast.VariantError,
		}).Render(r.Context(), w)
	}
}

Examples

Playground

API Reference

Required parameter
Hover for description

Toast

Notification component that appears temporarily to provide feedback.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-
Title
string
-
Description
string
-
Variant
Variant
default
Position
Position
bottom-right
Duration
int
3000
Dismissible
bool
false
ShowIndicator
bool
false
Icon
bool
false