Default#

Toast default example rendered by the production Go component.

Enable JavaScript to run the preview. Go source and install commands remain available.

Usage
snapshot := components.ToastSnapshot{
    Title: "Project saved", Description: "Changes are safely written locally.", Type: components.ToastSuccess,
}
if open {
    components.PaintToast(canvas, theme, viewport, snapshot, components.ToastOptions{
        Layer: 52, Scope: tree.ID(page, "toast"),
        DismissID: tree.ID(page, "dismiss"), ActionID: tree.ID(page, "action"),
        ActionLabel: "View",
    })
    if canvas.Clicked(tree.ID(page, "dismiss")) { open = false }
}

Types#

Toast types example rendered by the production Go component.

Enable JavaScript to run the preview. Go source and install commands remain available.

Usage
types := [...]components.ToastType{
    components.ToastInfo, components.ToastWarning, components.ToastError,
}
titles := [...]string{"Update available", "Low disk space", "Build failed"}
snapshot := components.ToastSnapshot{
    Title: titles[selected], Description: "Activate the action button to see the next semantic type.",
    Type: types[selected],
}
components.PaintToast(canvas, theme, viewport, snapshot, components.ToastOptions{
    Layer: 52, Scope: tree.ID(page, "toast"), DismissID: tree.ID(page, "dismiss"),
    ActionID: tree.ID(page, "action"), ActionLabel: "Switch",
})
if canvas.Clicked(tree.ID(page, "action")) { selected = (selected + 1) % len(types) }

Swipe#

Toast swipe example rendered by the production Go component.

Enable JavaScript to run the preview. Go source and install commands remain available.

Usage
snapshot := components.ToastSnapshot{
    Title: "Download almost complete", Description: "The horizontal offset comes from the caller's snapshot.",
    Type: components.ToastInfo, SwipeX: -8,
}
components.PaintToast(canvas, theme, viewport, snapshot, components.ToastOptions{
    Layer: 52, Scope: tree.ID(page, "toast"), DismissID: tree.ID(page, "dismiss"),
    ActionID: tree.ID(page, "action"), ActionLabel: "Continue",
})

Installation

Copy the recipe into your own project.

Repository command
go run ./cmd/viva add --out ./components/local toast

Source-owned usage#

This preview calls the production Go component directly. Stable IDs, values and open state remain owned by the application; the component only paints and declares interaction semantics.

  • Read the linked component source for every option and visual decision.
  • Use the native command to verify system text, focus, accessibility and platform integration.
  • The browser preview validates shared layout and scene behavior, not native performance.

Verification boundary#

The examples cover representative states supported by the current API. They do not imply that every desktop backend has completed hardware validation.

Keyboard

Use Tab to move between controls and Ctrl/⌘ K to search the catalog. Inside a preview, the Go runtime handles keyboard input.