Documentation
¶
Overview ¶
templ: version: v0.3.977
Index ¶
- Constants
- func Show(sse *datastar.ServerSentEventGenerator, level Level, message string, ...) error
- func ShowAction(sse *datastar.ServerSentEventGenerator, level Level, message string, ...) error
- func ShowComponent(sse *datastar.ServerSentEventGenerator, component templ.Component) error
- func ShowLink(sse *datastar.ServerSentEventGenerator, level Level, message string, ...) error
- func ShowPersistent(sse *datastar.ServerSentEventGenerator, level Level, message string) error
- func Toast(props ...Props) templ.Component
- type HorizontalPosition
- type Level
- type Props
- type VerticalPosition
Constants ¶
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 ¶ added in v0.0.12
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.
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.
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" )