Toast
Presents timed, stacked notifications with action, close, and swipe behavior.
Loading interactive demo…
func ToastExample() *ui.Element {
toast := ui.NewToast(ui.ToastProviderProps{Timeout: 5000, Limit: 3})
return toast.Provider().Child(func() *native.Node {
manager := ui.UseToastManager()
save := ui.Button().Child("Save").OnClick(func() {
manager.Add(ui.ToastRequest{Title: "Saved", Type: "success"})
})
viewport := toast.Viewport().Child(
ui.For(manager.Toasts, func(item ui.ToastDeclaration, _ func() int) *ui.Element {
return toast.Root(ui.ToastPartProps{ToastID: item.ID}).Children(
toast.Title(ui.ToastPartProps{ToastID: item.ID}).Child(item.Title),
toast.Close(ui.ToastPartProps{ToastID: item.ID}).Child("Dismiss"),
)
}, func(item ui.ToastDeclaration) any {
return item.ID
}, nil),
)
return ui.Fragment(save, viewport)
})
}#Import
Import ui from github.com/egoist/quickgui/go/ui.
import (
"github.com/egoist/quickgui/go/ui"
)#Usage
func ToastExample() *ui.Element {
toast := ui.NewToast(ui.ToastProviderProps{Timeout: 5000, Limit: 3})
return toast.Provider().Child(func() *native.Node {
manager := ui.UseToastManager()
save := ui.Button().Child("Save").OnClick(func() {
manager.Add(ui.ToastRequest{Title: "Saved", Type: "success"})
})
viewport := toast.Viewport().Child(
ui.For(manager.Toasts, func(item ui.ToastDeclaration, _ func() int) *ui.Element {
return toast.Root(ui.ToastPartProps{ToastID: item.ID}).Children(
toast.Title(ui.ToastPartProps{ToastID: item.ID}).Child(item.Title),
toast.Close(ui.ToastPartProps{ToastID: item.ID}).Child("Dismiss"),
)
}, func(item ui.ToastDeclaration) any {
return item.ID
}, nil),
)
return ui.Fragment(save, viewport)
})
}#Anatomy
toast.Providertoast.Portaltoast.Viewporttoast.Positionertoast.Roottoast.Contenttoast.Titletoast.Descriptiontoast.Actiontoast.Close
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
NewToast
View sourceui.NewToast(props ...ToastProviderProps) *ToastComponentNewToast declares a Toast instance. Optional props provide initial settings.
ChildrenComponent—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
ComponentView sourceTimeoutany—
Limitany—
Expanded*bool—
SwipeDirectionToastSwipeDirection—
Pitchany—
Toast.Timeout
View sourcetoast.Timeout(value any) *ToastComponentInherited auto-dismiss duration or warm-provider timeout.
Toast.Limit
View sourcetoast.Limit(value any) *ToastComponentMaximum number of notifications visible at once.
Toast.Expanded
View sourcetoast.Expanded(value bool) *ToastComponentControlled expanded tree node identifiers.
Toast.SwipeDirection
View sourcetoast.SwipeDirection(value ToastSwipeDirection) *ToastComponentEdge toward which a swipe dismisses or moves the surface.
Toast.Pitch
View sourcetoast.Pitch(value any) *ToastComponentLogical pixels of scrub motion required for one step.
Toast.Provider
View sourcetoast.Provider() *ElementShared context coordinating related component instances.
Toast.Portal
View sourcetoast.Portal(options ...PartProps) *ElementConfigures portal for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Toast.Viewport
View sourcetoast.Viewport(options ...ToastViewportProps) *ElementConfigures viewport for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Toastsfunc() []ToastDeclaration—
Timeoutany—
Limitany—
Expanded*bool—
SwipeDirectionToastSwipeDirection—
Pitchany—
OnDismissfunc([]string, *native.Event)—
OnStackChangefunc([]ToastStackEntry, *native.Event)—
Callback for stack change. The signature below lists the event payload.
func([]ToastStackEntry, *native.Event)View sourceToast.Positioner
View sourcetoast.Positioner(options ...ToastPartProps) *ElementConfigures positioner for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Toast.Root
View sourcetoast.Root(options ...ToastPartProps) *ElementConfigures root for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Toast.Content
View sourcetoast.Content(options ...ToastPartProps) *ElementConfigures content for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Toast.Title
View sourcetoast.Title(options ...ToastPartProps) *ElementConfigures title for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Toast.Description
View sourcetoast.Description(options ...ToastPartProps) *ElementConfigures description for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Toast.Action
View sourcetoast.Action(options ...ToastPartProps) *ElementConfigures action for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Toast.Close
View sourcetoast.Close(options ...ToastPartProps) *ElementConfigures close for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
ToastIDstring—
Element
View sourcepart.Child(content).Style(style)Every part returns a fluent element. Strings, numbers, elements, and deferred child factories compose directly.
ChildChild(child any) *Element—
Child appends content and returns this element. Content can be an element, native node, scalar, accessor, or node-returning construction callback.
Child(child any) *ElementView sourceChildrenChildren(children ...any) *Element—
Children appends multiple children in order without replacing existing content. It also accepts []any, []*Element, and []*native.Node slices as arguments. Read the retained child nodes through element.Node.Children.
Children(children ...any) *ElementView sourceStyleStyle(style StyleBuilder) *Element—
Style merges a reusable style. Scalar accessors retain independent native bindings.
Style(style StyleBuilder) *ElementView sourceOnClickOnClick(handler func()) *Element—
OnClick handles a click without an unused event parameter.
OnClick(handler func()) *ElementView sourceRefRef(handler func(*native.Node)) *Element—
Ref exposes the native handle once at this point in the declaration chain.
Ref(handler func(*native.Node)) *ElementView source