toast

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

templ: version: v0.3.977

Index

Constants

View Source
const ContainerID = "toast-container"

ContainerID is the fixed ID of the toast container in the base template.

Variables

This section is empty.

Functions

func Show added in v0.0.11

func Show(sse *datastar.ServerSentEventGenerator, level Level, message string, durationMs int) error

Show appends an auto-dismissing toast notification via SSE. The toast disappears after durationMs (default 3000ms) and has a close button.

func ShowAction added in v0.0.12

func ShowAction(sse *datastar.ServerSentEventGenerator, level Level, message string, actionLabel string, actionURL string) error

ShowAction appends a toast with an action button that triggers a Datastar GET. The toast stays until the action or close button is clicked.

func ShowComponent added in v0.0.11

func ShowComponent(sse *datastar.ServerSentEventGenerator, component templ.Component) error

ShowComponent appends a custom templ component as a toast via SSE. Useful when you need more than a simple text message.

func ShowLink(sse *datastar.ServerSentEventGenerator, level Level, message string, linkText string, linkURL string, durationMs int) error

ShowLink appends a toast with a clickable link. The toast auto-dismisses after durationMs (default 5000ms).

func ShowPersistent added in v0.0.12

func ShowPersistent(sse *datastar.ServerSentEventGenerator, level Level, message string) error

ShowPersistent appends a toast that stays until the user clicks the close button.

func Toast

func Toast(props ...Props) templ.Component

Types

type HorizontalPosition

type HorizontalPosition string

HorizontalPosition controls horizontal alignment.

const (
	HorizontalDefault HorizontalPosition = ""
	HorizontalStart   HorizontalPosition = "toast-start"
	HorizontalCenter  HorizontalPosition = "toast-center"
	HorizontalEnd     HorizontalPosition = "toast-end"
)

type Level added in v0.0.11

type Level string

Level represents the severity of a toast notification.

const (
	LevelInfo    Level = "info"
	LevelSuccess Level = "success"
	LevelWarning Level = "warning"
	LevelError   Level = "error"
)

type Props

type Props struct {
	ID         string
	Class      string
	Attributes templ.Attributes
	Horizontal HorizontalPosition
	Vertical   VerticalPosition
}

Props configures a toast container.

type VerticalPosition

type VerticalPosition string

VerticalPosition controls vertical alignment.

const (
	VerticalDefault VerticalPosition = ""
	VerticalTop     VerticalPosition = "toast-top"
	VerticalMiddle  VerticalPosition = "toast-middle"
	VerticalBottom  VerticalPosition = "toast-bottom"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL