Skip to content

Alert

Inline messages in four semantic colors (info, success, warning, danger). Supports dismiss, action links, action buttons, and list content.

Default Rendered example
Usage Example
@alert.Alert(alert.Config{
    Title:       "Update Available",
    Description: "A new version is available.",
    Tone:     alert.ToneInfo,
})

Dismissible

Dismissible: true adds a close button that fades the alert out via an Alpine transition.

Dismissible Rendered example
Dismissible
@alert.Alert(alert.Config{
    Title:       "Successfully Subscribed",
    Description: "Welcome aboard!",
    Tone:     alert.ToneSuccess,
    Dismissible: true,
})

Attach a Link config to render a trailing action link.

With Link Rendered example
With Link

With List

Pass ListItems to render a bulleted list under the description.

With List Rendered example
With List
@alert.Alert(alert.Config{
    Title:       "Password Requirements",
    Description: "Make sure your password:",
    Tone:     alert.ToneInfo,
    ListItems: []string{
        "has minimum 8 characters",
        "includes both upper and lower cases",
        "contains at least one number",
    },
})

With Action Buttons

Attach an Action config for primary + dismiss buttons.

With Action Buttons Rendered example
With Action Buttons
@alert.Alert(alert.Config{
    Title:       "Update Available",
    Description: "A new version is available.",
    Tone:     alert.ToneInfo,
    Action: &alert.ActionConfig{
        PrimaryLabel:    "Update Now",
        PrimaryOnClick: "alert('Updating...')",
        DismissLabel:   "Dismiss",
    },
})

Go API

v0.2.7

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso/components/alert
Open v0.2.7 API