components

package
v0.2026.19 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package components provides product-neutral common controls built on MyGo. Callers own business state, localized text and actions. Native window and page composition belong to the separate shells/sidebar package.

Element handles are MyGo values valid only during the current build pass. Do not retain them across frames; bind a ui.Handle for persistent identity.

Common controls use MyGo's unstyled bases, which own pointer, keyboard, focus and accessibility semantics. Colors and sizes come from the frame theme (see the theme package); interaction states are read from the base every frame, and Draw and DrawOver provide Onevra's appearance. Disabled controls use the style's opacity treatment. The shells/sidebar package installs the theme before content builds; without Shell, callers can apply it through the theme package.

Complex components live in independent subpackages: chart, command and chat. These may compose common controls; this package does not depend on its subpackages.

The package covers everyday controls, not MyGo's full catalog. For anything else, compose MyGo's styled widgets or its bases directly. Import components alongside MyGo's ui package; neither requires an import alias.

Collection behavior is adapted from MyGo v0.3.3 (MIT); see LICENSE.mygo.

Table behavior is adapted from MyGo v0.4.1 (MIT); see LICENSE.mygo.

Table behavior is adapted from MyGo v0.4.1 (MIT); see LICENSE.mygo.

Collection behavior is adapted from MyGo v0.3.3 (MIT); see LICENSE.mygo.

Collection behavior is adapted from MyGo v0.3.3 (MIT); see LICENSE.mygo.

Index

Examples

Constants

View Source
const (
	ToastInfo    = "info"
	ToastSuccess = "success"
	ToastWarning = "warning"
	ToastError   = "error"
)

Toast types for ui.Toast.Type select a colored leading status icon. Other types, including the empty one, show no icon.

Variables

This section is empty.

Functions

func Accordion

func Accordion(c *ui.Context, fn func(group *AccordionGroup)) ui.Element

Accordion builds independently expandable sections in MyGo's bordered box, without hover styling. Use group.Item inside fn. Up, Down, Home and End move focus between headers; Tab still visits controls inside open panels.

func Avatar added in v0.2026.12

func Avatar(c *ui.Context, name string, options AvatarOptions) ui.Element

Avatar creates a circular identity marker for a person or account named name: a photo, or up to two initials on a muted surface. It draws no outline, so it sits on any surface without a seam. Applications own loading, decoding and caching photos. Assistive technology sees an image named name and its status. Key a parent for identity.

func AvatarGroup added in v0.2026.12

func AvatarGroup(c *ui.Context, members []AvatarGroupMember, options AvatarGroupOptions) ui.Element

AvatarGroup creates an overlapping stack of members in order. Members past Max collapse into an overflow chip, so long lists build only what shows. Pointing at the stack loosens it and lifts the member under the pointer, which names itself in a tooltip; members joining or leaving open or close their slots and the overflow count rolls the way it moved. Reduced Motion keeps the stack still. Overlap and Reverse adjust how the avatars cover one another. Applications own members, photos and localized labels. Key a parent for identity.

func Badge

func Badge(c *ui.Context, text string, options ...BadgeOptions) ui.Element

Badge creates a compact, non-interactive status label. Applications own its text and may override the inherited foreground and background colors.

Keep a badge built in the same place and change its text or icon to morph it: the new label rises in while the old one lifts away, icons crossfade and the pill's width springs to fit. Reduced Motion fades the swap in place and resizes at once. A badge appearing with its parent shows without animation.

func Button

func Button(c *ui.Context, label string, variant ButtonVariant) ui.Element

Button creates a labeled button in the Onevra style with a single standard size. Ask Clicked whether it was clicked; give it other content with Children and an empty label. The label is also the accessible name. ButtonLink uses text height without padding or a background and supports RichText composition; its children must be text. For stable identity, key a parent container rather than this element: interaction styling is resolved during construction.

func Carousel(c *ui.Context, state *CarouselState, options CarouselOptions) ui.Element

Carousel shows Count slides in a centered row, with neighbors partly in view as a hint that there is more. The active slide sits in the center; the others shrink and dim with their distance from it, frame by frame as the track moves. Below the slides, a row of indicators stretches the active one into a pill that travels with the slides, beside previous and next arrows and, with an Interval, a play control whose pill drains to show the time left on the slide.

Dragging the track follows the pointer and settles with momentum, rubber banding past the ends; a flick moves at least one slide, a horizontal touchpad swipe moves it as well, and a click on a neighbor centers it. The arrows, Home and End move the slides while the slide area has the focus, and the indicators are tabs. Presses on interactive slide content stay with that content. Inactive slides are disabled, so their controls take neither focus nor clicks. Slide changes the user makes are announced. Reduced Motion moves without gliding.

Applications own the state, slide content and labels. Changed on the returned element reports an Index the user chose in this frame.

func Checkbox

func Checkbox(c *ui.Context, checked *bool, label string) ui.Element

Checkbox creates a check box toggling *checked, with a label. The label is also the accessible name.

func ContextMenu added in v0.2026.18

func ContextMenu(c *ui.Context, target ui.Element, build func(m *Menu))

ContextMenu gives target a menu, drawn in a Popover with the look of the other popovers, that opens where target is right-clicked (Control-clicked on macOS), or for the menu key or Shift+F10 while it or an element inside it has the focus, below it unless the pointer rests on it. It leaves target's clicks to it and its parents. Call it every frame after building target, which must be keyed where it repeats. build fills the menu while it shows, and the item chosen reports Chosen, which closes it:

components.ContextMenu(c, row, func(m *components.Menu) {
	if m.Item("Rename").Chosen() {
		app.renaming = i
	}
	m.Group("Move to", func(m *components.Menu) {
		for _, f := range app.folders {
			if m.Item(f.Name).Chosen() {
				app.move(i, f)
			}
		}
	})
	m.Separator()
	if m.Item("Delete").Disabled(note.Locked).Chosen() {
		app.delete(i)
	}
})

A disabled target opens none. Up and Down move among the items, past the disabled ones, Enter and Space choose one, and Escape or a press outside closes the menu.

func Dialog

func Dialog(c *ui.Context, open *bool, options DialogOptions, build func(panel ui.Element)) ui.Element

Dialog builds arbitrary content in a modal panel and returns its frame-local handle (absent when closed). Applications own open and call Dialog every frame. Build layers in back-to-front order, with stable keyed parents for independent dialogs. Nested calls are supported. MyGo owns focus trapping and restoration. The panel is horizontally centered with spare vertical space biased below it. Its default maximum size leaves 20 logical pixels clear on every viewport edge; Inset overrides the clearance; WindowDragHeight can increase it. Content may customize the panel and should provide scrolling for long pages. The returned panel does not report Dismissed; use DisableBackdropClose and DisableEscapeClose to keep a layer open.

func FileIcon added in v0.2026.18

func FileIcon(c *ui.Context, name string) ui.Element

FileIcon creates the type icon of a file named name, as code editors' file trees show: a Lucide icon chosen by its whole name, such as go.mod or .gitignore, or else its extension, tinted in its ecosystem's color. name may be a path; only its last element counts. Unknown types show a plain file icon in the inherited text color.

Like Icon, it inherits font size; use Size for explicit dimensions and TextColor to override the tint.

func GridView

func GridView(c *ui.Context, s *GridState, count int, minWidth, height float32, item func(int)) ui.Element

GridView builds a virtualized, responsive grid with neutral, hover-free selection. minWidth and height describe each cell's content area in DIPs; a transparent two-DIP inset on each side is reserved by MyGo. Values below one are clamped to one. Item spacing follows MyGo's theme-scaled grid gap. Give the grid a height or fill a bounded parent. Builders may run during layout and must not perform application work. A nil state scrolls without selection. MyGo owns layout, virtualization, scrolling and stable cell keys.

func Honeycomb added in v0.2026.10

func Honeycomb(c *ui.Context, options HoneycombOptions) string

Honeycomb draws the items as a honeycomb, as on a watch face, in a view that fills the width and grows into the height of its column. The honeycomb is magnified most in the middle of the view, shifted by OffsetY, so items and the space between them shrink smoothly the further out they are, and shrink further and fade out as they near the edge of the view. The honeycomb lies on the surface of a ball behind it, so each item turns away from the viewer the further out it is, and dragging it pans over that ball. The item nearest the middle wears a ring in its own color or the theme's accent, and its caption under it.

Dragging the items, or scrolling over them, pans the honeycomb, which then settles with the item nearest the middle centered and chosen; choosing an item, here or elsewhere, pans it over to center that item. The keyboard reaches every item and pans to the focused one. Honeycomb returns the ID of an item chosen by input in this frame, or "".

Applications own the items, their decoded images, labels, selected ID and any action a choice triggers. Items without a Content or Image builder draw nothing. Call Honeycomb within a bounded parent; the view takes its height from the space left to it, keeping at least two rows visible.

func Icon

func Icon[T *ui.SVG | func() *ui.SVG](c *ui.Context, source T) ui.Element

Icon creates an SVG icon from a parsed asset or a named accessor such as lucide.Search (without calling it). Accessors run synchronously when the element is built; the asset package owns parsing and caching. A typed nil SVG or accessor produces an empty icon.

Icons inherit text color and font size from their parent. Use Size to set explicit dimensions and Label to supply application-owned accessible text. MyGo owns rendering, aspect ratio and element semantics. No icon registry or dependency on a particular icon pack is introduced.

func IconButton added in v0.2026.10

func IconButton(c *ui.Context, icon *ui.SVG, label string, style IconButtonStyle) ui.Element

IconButton creates an icon-only button with an accessible label and a tooltip. It uses one theme-scaled square size. Applications own the label and handle Clicked on the result; MyGo owns its pointer, keyboard and focus behavior.

IconButtonPlain keeps a transparent face and tints it on hover and press. IconButtonToolbar keeps the raised, shadowed face of ButtonToolbar, matching TabsSegmented's chosen segment. IconButtonCompact shrinks the plain face.

func Image

func Image(c *ui.Context, source ui.ImageSource) ui.Element

Image displays a decoded *ui.Bitmap or *ui.SVG in its own colors. Applications own loading, decoding, caching and errors; reuse decoded assets rather than performing file or network I/O in a content builder.

Images default to their intrinsic size in DIPs and contain-fit when resized. Use Size, Fit, Radius and Grayscale on the returned element to customize its presentation, and Label for application-owned accessible text. A nil source produces an empty element. MyGo owns rendering, layout and image semantics.

func List

func List(c *ui.Context, state *ListState, count int, row func(int)) ui.Element

List builds neutral, hover-free rows inside MyGo's non-selecting virtual list. Give it a height or fill a bounded parent. Applications own row content and spacing; builders can run during layout and must not perform application work. A nil state uses MyGo's local scrolling state, without selection.

func MenuButton(c *ui.Context, button ui.Element, build func(m *Menu))

MenuButton makes button open a menu below it, as ContextMenu's, when it is clicked or activated with Enter or Space, and close it when clicked again. Call it every frame after building button, instead of reading button's Clicked:

more := components.IconButton(c, lucide.Ellipsis(), "More")
components.MenuButton(c, more, func(m *components.Menu) {
	if m.Item("Duplicate").Chosen() {
		app.duplicate()
	}
})

func PixelGrid

func PixelGrid(c *ui.Context, options PixelGridOptions) ui.Element

PixelGrid creates a themed, noninteractive square-line background container. Set its size with the returned element's layout methods. Children render above the grid and are clipped to its bounds. Background can override the canvas color; grid lines use the frame theme and are one DIP wide. Lines coinciding with the top or left edge are omitted so the grid has no leading border.

func Popover

func Popover(c *ui.Context, anchor ui.Element, open *bool, build func(panel ui.Element)) ui.Element

Popover builds a non-modal panel anchored below anchor, flipping above it when needed. Applications own open and trigger activation and call Popover every frame after building the anchor. The returned Element is absent while closed. MyGo owns positioning, focus order and Escape/outside-press dismissal; outside presses continue to the underlying control. Pressing the anchor does not dismiss the panel automatically.

build styles the panel and creates its children. It may override placement with AttachTo or supply scrolling for long content. Keep anchor and panel handles within the current build pass and use keyed parents for independent popovers. Label the panel in build when an accessible name is needed.

func Progress

func Progress(c *ui.Context, value float64) ui.Element

Progress creates a horizontal progress bar. Values in [0, 1] show completion; negative values show indeterminate activity. Values above 1 clamp to 1 and NaN is treated as 0. Name the indicator with Label for accessibility. The default height is theme-scaled; callers control width with layout methods.

func ProgressRing

func ProgressRing(c *ui.Context, value float64) ui.Element

ProgressRing creates a circular progress indicator with the same value semantics as Progress. Completion starts at twelve o'clock and runs clockwise. Its default diameter is theme-scaled. A custom non-square layout keeps the ring circular and centered. Reduced Motion leaves indeterminate activity static.

func Radio

func Radio[T comparable](c *ui.Context, selected *T, value T, label string) ui.Element

Radio creates a radio button that selects value into *selected, with a label. The label is also the accessible name.

func RichText

func RichText(c *ui.Context, spans ...ui.Span) ui.Element

RichText composes styled spans and inline Text or ButtonLink children into a single wrapping paragraph. Zero span fields inherit the surrounding style. MyGo's unstyled text primitive owns shaping, selection, inline interaction and accessibility; only text elements belong in Children.

func ScrollEdge added in v0.2026.13

func ScrollEdge(c *ui.Context, options ScrollEdgeOptions) ui.Element

ScrollEdge is ScrollEdgeBar's effect alone, for hosts that float their own controls over an edge of scrolling content, such as a composer. Build it after the content in the same bounded, clipping container. It never takes input; ScrollEdgeGlass has no edge of its own, so it draws nothing.

func ScrollEdgeBar added in v0.2026.13

func ScrollEdgeBar(c *ui.Context, options ScrollEdgeBarOptions, content func()) ui.Element

ScrollEdgeBar floats a bar of controls over the top or bottom edge of scrolling content, such as a title bar, toolbar or bottom bar, and separates it from the content in the chosen style. Build it after the content, as a child of a bounded, clipping container that the content fills: materials sample what was painted beneath them, and the bar and its effect position themselves absolutely within that container.

ui.Box(c).Fill().Clip().Children(func() {
	inset := components.ScrollEdgeBarExtent(c, options)
	components.ScrollView(c, components.ScrollViewOptions{}).Fill().
		Padding(inset+12, 16, 16).ScrollbarInsets(inset, 0, 0).Children(content)
	components.ScrollEdgeBar(c, options, toolbar).Label("Toolbar")
})

The returned element is the bar, a centered row that content builds the children of; the application owns them, their actions and the bar's accessible label. In styles other than ScrollEdgeGlass, the bar is transparent, so the controls should carry their own surfaces, such as interactive glass. The effect layer never takes input, so content under it beside the bar stays reachable.

func ScrollEdgeBarExtent added in v0.2026.13

func ScrollEdgeBarExtent(c *ui.Context, options ScrollEdgeBarOptions) float32

ScrollEdgeBarExtent returns how far from its edge a ScrollEdgeBar with options reaches, in DIPs: the scroll content's padding on that edge, plus any spacing, and its ScrollbarInsets keep content and scroll bar clear of the bar.

func ScrollView

func ScrollView(c *ui.Context, options ScrollViewOptions) ui.Element

ScrollView creates a scroll container using MyGo's layout, clipping, input and scroll state. Give it a size or Fill/Grow within a bounded parent. Vertical and both-axis views arrange children in a column; horizontal views arrange them in a row. Column/Row on the returned element can override this arrangement without changing the scrolling axes.

ScrollbarInsets on the returned element sets top, right, bottom and left track insets in DIPs (CSS shorthand), independently of content padding:

ScrollView(c, ScrollViewOptions{}).Fill().ScrollbarInsets(48, 0, 16)

TrackScroll accepts application-owned ui.ScrollState. MyGo owns scrollbar appearance and visibility: overflowing axes show bars on hover or while dragging, with color and width from the frame theme. Independent visibility and per-view color/width overrides are not supported by the upstream API.

func Settings

func Settings(c *ui.Context, state *SettingsState, categories []SettingsCategory, opts SettingsOptions) ui.Element

Settings builds a bounded, scrollable settings surface using application-owned state and definitions. Place it in a parent with a finite height. It fills its parent, and can be embedded in Dialog, Shell content, or a standalone window. The host supplies the background or material; navigation adds a subtle tint. Use a keyed parent to distinguish multiple instances. state must not be nil. Navigation clears Query; clearing Query alone restores the selected category.

Example
package main

import (
	"fmt"

	"github.com/egoist/mygo/ui"
	"github.com/oneo-me/onevra/source/components"
)

func main() {
	// Retain state and values in the application, not inside the frame builder.
	state := components.SettingsState{}
	enabled := false
	categories := []components.SettingsCategory{{
		ID: "notifications", Title: "Notifications",
		Groups: []components.SettingsGroup{{ID: "delivery", Title: "Delivery", Actions: func(c *ui.Context) {
			// Group actions sit at the end of the group's header row.
			components.Button(c, "Reset", components.ButtonGhost).OnClick(func() { enabled = false })
		}, Items: []components.SettingsItem{{
			ID: "desktop", Title: "Desktop notifications", Keywords: []string{"alerts"},
			Build: func(c *ui.Context) { components.Switch(c, &enabled, "Enable desktop notifications") },
		}, {
			// Content builds the whole row; its title still matches searches.
			ID: "preview", Title: "Preview", Keywords: []string{"sample"},
			Content: func(c *ui.Context) { components.Text(c, "A notification preview").Wrap() },
		}}}},
	}}
	view := func(c *ui.Context) {
		// The host decides narrow layout from the width allocated to this surface.
		components.Settings(c, &state, categories, components.SettingsOptions{Narrow: true})
	}
	// Use view as window content or inside an application-owned Dialog.
	tester := ui.NewTester(view, 400, 500)
	tester.Frame()
	fmt.Println(tester.HasText("Desktop notifications"))
}
Output:
true
func Sidebar(c *ui.Context) ui.Element

Sidebar creates a transparent column of SidebarSections. Place it inside a ui.Scroll when scrolling is needed. Applications own its width, titlebar inset and selection; it can be used independently of Shell.

func SidebarImageItem added in v0.2026.5

func SidebarImageItem(c *ui.Context, label string, image ui.ImageSource, selected bool) ui.Element

SidebarImageItem is a SidebarItem led by an image, such as an application's project logo, in place of the icon. The image keeps its own colors, fits within the icon's square without cropping and has slightly rounded corners. A nil image leaves no icon space.

func SidebarItem

func SidebarItem(c *ui.Context, label string, icon *ui.SVG, selected bool) ui.Element

SidebarItem creates a navigation button with a neutral selected face and an optional accent-colored icon. Hover does not change its face. The caller supplies selection and handles Clicked; MyGo provides Tab focus and activation with Enter or Space, not tree-style arrow navigation. Key can distinguish items with identical labels. A nil icon leaves no icon space.

func SidebarItemWithContent added in v0.2026.12

func SidebarItemWithContent(c *ui.Context, label string, selected bool, leading func(c *ui.Context, size float32), content func(c *ui.Context) ui.Element, trailing func(c *ui.Context, size float32)) ui.Element

SidebarItemWithContent is a SidebarItemWithSlots whose visible label is application-built, for example animated or styled text; label still keys the item and names it for accessibility. A nil content builder shows label as plain text. With a trailing slot, the returned element takes the remaining room and may shrink below its natural width. Content follows the leading slot's rules.

func SidebarItemWithLeading added in v0.2026.5

func SidebarItemWithLeading(c *ui.Context, label string, selected bool, leading func(c *ui.Context, size float32)) ui.Element

SidebarItemWithLeading is a SidebarItem with an application-built leading slot, for example an image, monogram or status mark. A nil builder leaves no leading space. The builder receives the theme-scaled standard icon size as a suggestion and owns its content's size and appearance. Keep it non-interactive so the navigation button remains the only focus and activation target. It runs synchronously on the UI thread and must not start I/O or background work.

Example
package main

import (
	"fmt"

	"github.com/egoist/mygo/ui"
	"github.com/oneo-me/onevra/source/components"
)

func main() {
	// The application owns what the mark represents; the slot can compose
	// text, images and status decorations without a new component variant.
	mark := func(c *ui.Context, size float32) {
		ui.Box(c).Size(size, size).Shrink(0).Radius(size * .2).Center().
			Background(c.Theme().Accent).Children(func() {
			components.Text(c, "A").FontSize(size * .6).TextColor(c.Theme().AccentText)
		})
	}
	state := components.SettingsState{}
	tester := ui.NewTester(func(c *ui.Context) {
		ui.Column(c).Fill().Children(func() {
			components.SidebarItemWithLeading(c, "Workspace", true, mark)
			components.Settings(c, &state, []components.SettingsCategory{{
				ID: "workspace", Title: "Workspace settings", Leading: mark,
			}}, components.SettingsOptions{})
		})
	}, 800, 500)
	fmt.Println(tester.HasText("A"))
}
Output:
true

func SidebarItemWithSlots added in v0.2026.12

func SidebarItemWithSlots(c *ui.Context, label string, selected bool, leading, trailing func(c *ui.Context, size float32)) ui.Element

SidebarItemWithSlots is a SidebarItemWithLeading with an application-built trailing slot after the label, for example counts or a status mark. The label then takes the remaining room and ends in an ellipsis when it does not fit. Nil builders leave no space. Both builders receive the standard icon size and follow the leading slot's rules: keep them non-interactive and free of I/O or background work.

func SidebarSection

func SidebarSection(c *ui.Context, label string, fn func()) ui.Element

SidebarSection builds a muted heading followed by application-owned items. Sections are always expanded; fn may be nil for a heading alone.

func SidebarSectionWithActions added in v0.2026.13

func SidebarSectionWithActions(c *ui.Context, label string, actions func(c *ui.Context), fn func()) ui.Element

SidebarSectionWithActions is a SidebarSection whose heading ends in application-built controls, such as an add button. IconButtonCompact fits the heading without raising it. A nil actions builder leaves the heading as SidebarSection's. Like the items, actions run on the UI thread and must not start I/O or background work.

func Skeleton added in v0.2026.12

func Skeleton(c *ui.Context, options SkeletonOptions) ui.Element

Skeleton creates a pulsing placeholder of text lines for content whose shape is known. It fills the available width; lines are proportions of it. It is a loading status named by options.Label; the blocks themselves are not exposed. Only drawing animates. Reduced Motion stops the pulse.

func SkeletonContent added in v0.2026.12

func SkeletonContent(c *ui.Context, loading bool, options SkeletonOptions, content func()) ui.Element

SkeletonContent shows a Skeleton while loading and content once it is not. The placeholder fades out as the content fades in, rising into place, and the container's height springs between them; later size changes of the content follow with the same spring. Reduced Motion swaps with fades and no movement. The application owns loading and builds content synchronously.

func Spinner

func Spinner(c *ui.Context, variant SpinnerVariant) ui.Element

Spinner creates an indicator of work of unknown length. Name it with Label for accessibility. Both variants default to a theme-scaled diameter and stay circular and centered in non-square layouts. Reduced Motion freezes activity. Spokes use the theme's muted text color unless overridden with TextColor. Unknown variants use SpinnerRing.

func Switch

func Switch(c *ui.Context, on *bool, label string, options ...SwitchOptions) ui.Element

Switch creates a switch toggling *on, with a label. The label is also the accessible name.

A tap, Space or Enter toggles it, sliding the knob across, as does a click beside the knob. Holding or dragging the knob lifts it as a glass lens; dragging moves it along the track, and releasing settles on the nearer side. Letting go of a held knob without dragging it sets the lens down and leaves the switch as it was. After a drag, the lens sets down once the knob comes to rest.

func Table added in v0.2026.5

func Table(c *ui.Context, state *TableState, columns []ui.TableColumn, rows func()) ui.Element

Table builds a non-virtualized table of TableRows under a header of columns. Applications own rows, selection and sorting; a nil state keeps the column layout on the table without sorting. The table is at least as wide as its columns; place it in a ScrollView when scrolling is needed. Up/Down and Home/End move focus between rows. Dragging a header moves its column and dragging its right edge resizes it, unless the column is Fixed.

func TableRow added in v0.2026.5

func TableRow(c *ui.Context, key any, label string, selected bool, cell func(col int)) ui.Element

TableRow builds a row of a Table, cell building the content of each column by its index in the Table's columns. key identifies the row among its siblings and label names it for assistive technology. Clicked lets the application select or activate the row. Rows alternate with a faint stripe and selection uses the Tree's neutral tint, without a hover face. Call it only while building a Table's rows.

func TableVirtualized added in v0.2026.5

func TableVirtualized(c *ui.Context, state *TableVirtualizedState, columns []ui.TableColumn, count int, cell func(row, col int)) ui.Element

TableVirtualized builds Onevra table rows in MyGo's virtual scrolling container, under a header that scrolls sideways with them when the columns are wider than the table. Give it a height or fill a bounded parent. cell builds the content of a row's column, by its index in columns; it may run during layout and must not perform application work. Rows are at least as high as the header, grow to their tallest cell and alternate with a faint stripe, as in Table.

Clicks, Up/Down, Home/End and Page Up/Down choose rows; Enter and double clicks report List.OnSubmit. Header dragging, resizing and sorting follow Table. All row styling is local; the frame theme is untouched.

func Tabs

func Tabs(c *ui.Context, selected *int, variant TabsVariant, labels ...string) ui.TabsParts

Tabs creates a row of tabs showing labels, of which *selected is the index of the one chosen. A click chooses a tab, as do the arrows, Home and End while one has the keyboard focus, which follows the choice. Reduced Motion skips transitions. List's Changed reports a new choice.

TabsUnderline animates a shared accent underline to the chosen tab and keeps every label's weight, so selection never moves the labels. TabsSegmented raises the chosen tab on a shadowed thumb over a capsule track and shows its label in a heavier weight, like a macOS segmented control. TabsHighlight slides a rounded block behind the chosen tab's label.

func TabsWith added in v0.2026.13

func TabsWith(c *ui.Context, selected *int, options TabsOptions, labels ...string) ui.TabsParts

TabsWith is Tabs configured by options.

func TabsWithLeading added in v0.2026.13

func TabsWithLeading(c *ui.Context, selected *int, variant TabsVariant, leading func(c *ui.Context, i int, size float32), labels ...string) ui.TabsParts

TabsWithLeading is Tabs with an application-built leading slot before each tab's label, for example an icon. The builder receives the tab's index and the theme-scaled icon size as a suggestion, and inherits the tab's text color; a nil builder leaves no leading space. Keep it non-interactive and free of I/O or background work.

func TextBox

func TextBox(c *ui.Context, value *string, options TextBoxOptions) ui.Element

TextBox creates a text input editing *value. Configure mode and read-only state through options, not the returned Element's ReadOnly method, so styling matches behavior. Other MyGo input properties can be chained normally, such as Label, Placeholder, Password (single-line only) and Lines (multiline only). For stable identity, key a parent container rather than this element: interaction styling is resolved during construction.

func TextBoxBuffer

func TextBoxBuffer(c *ui.Context, value *ui.TextBuffer, options TextBoxOptions) ui.Element

TextBoxBuffer creates a text input editing an application-owned buffer. Keep the non-nil buffer across builds; ordinary editing does not materialize the whole document as a string. Options and chained input properties follow TextBox, including its parent-key requirement for stable identity.

func Toasts added in v0.2026.8

func Toasts(c *ui.Context, options ...ToastOptions) ui.Element

Toasts builds the window's MyGo toasts in the Onevra style, replacing MyGo's default look, and returns the viewport. Applications show and close toasts with MyGo's Context.Toast, ToastAction, AddToast and CloseToast; MyGo owns the queue, timing, pausing, Escape dismissal and announcements.

Shell calls Toasts after its content with ShellOptions.Toasts, so applications call it only in standalone hosts; the first options value applies. A view that builds its own ToastViewportBase earlier in the frame keeps its look. Toasts stack at the top center by default, each with an optional action and a close button named by the "onevra.closeToast" message. Older toasts tuck behind the newest one, each peeking out a little further and drawn a little smaller, and fan out while the pointer rests on the stack or the keyboard focus is in it.

func ToggleButton

func ToggleButton(c *ui.Context, on *bool, label string) ui.Element

ToggleButton creates a button that toggles *on by click or focused Space. Changed reports user changes. The label is also the accessible name; for custom content, pass an empty label and use Label and Children. It uses one standard size, a quiet off face and an accent-filled on face. Key a parent container for stable identity, as styling is resolved here.

func Tooltip

func Tooltip(c *ui.Context, anchor ui.Element, text string) ui.Element

Tooltip attaches a non-interactive text hint to anchor. Call it each frame after building the anchor; both handles belong to the current build pass. MyGo owns hover delay, keyboard-focus activation, dismissal and positioning above the anchor (or below when space is limited).

The text also becomes anchor's accessible description. To provide a different description, call anchor.Description after Tooltip. Empty text does nothing. The returned tip is invalid while hidden. Use Popover for interactive content.

func Tree

func Tree(c *ui.Context, children func()) ui.Element

Tree builds a non-virtualized tree from Onevra rows and MyGo primitives. Applications own expansion and selection. Place it in a ScrollView when scrolling is needed. Up/Down and Home/End move focus; Left/Right navigate parents and children or collapse/expand branches. MyGo owns input dispatch, focus, layout and rendering, not the tree's appearance.

func TreeItem

func TreeItem(c *ui.Context, label string, open *bool, selected bool, children func()) ui.Element

TreeItem builds a text row and, when open, its nested TreeItems. A nil open or children makes a leaf. Clicking the arrow or double-clicking the row toggles expansion; Clicked lets the application select or activate the row. Selection uses the Sidebar's neutral tint, without a hover face.

func TreeItemWithLeading added in v0.2026.12

func TreeItemWithLeading(c *ui.Context, label string, open *bool, selected bool, leading func(c *ui.Context, size float32), children func()) ui.Element

TreeItemWithLeading is a TreeItem with an application-built leading slot between its disclosure arrow and label, for example a file type or host mark. A nil builder leaves no leading space. The builder receives the theme-scaled icon size as a suggestion and owns its content's size and appearance. Keep it non-interactive and free of I/O or background work.

func TreeVirtualized

func TreeVirtualized[K comparable](c *ui.Context, state *TreeVirtualizedState[K], roots []K, children func(K) []K, row func(K)) ui.Element

TreeVirtualized builds Onevra tree rows in MyGo's virtual scrolling container. Give it a height or fill a bounded parent. children returns nil for leaves; row builds content after the arrow. Row builders may run during layout and must not perform application work. Only row UI is virtualized: expanded nodes are still traversed each frame.

An arrow click or row double click toggles a branch. Enter activates the current row (and toggles branches); List.OnSubmit also reports activation. Left/Right close/open branches or select parents/children. Option on macOS, Shift elsewhere, with Left/Right applies expansion recursively. Alt-clicking an arrow does the same. All row styling is local; the frame theme is untouched.

func WithDialogWindowDrag

func WithDialogWindowDrag(c *ui.Context, height float32, build func())

WithDialogWindowDrag supplies the default native window drag strip height in DIPs for Dialog and AlertDialog calls made synchronously by build. Shell installs this scope automatically; standalone hosts may use it too. Non-positive heights disable the default. Nested scopes replace the height and restore it on return. This does not add layout or forward pointer events. Call during the UI build; do not retain c or launch asynchronous builders.

Types

type AccordionGroup

type AccordionGroup struct {
	// contains filtered or unexported fields
}

AccordionGroup builds the items of one Accordion. It is valid only inside the Accordion callback; nested accordions have independent groups.

func (*AccordionGroup) Item

func (group *AccordionGroup) Item(title string, open *bool, fn func()) DisclosureParts

Item builds a section, with application-owned expansion state and content. Its Changed method reports trigger activation. To allow just one open item, use that signal to close other application-owned expansion values.

type AlertDialogOptions

type AlertDialogOptions struct {
	DialogOptions
	Title, Message            string
	ConfirmLabel, CancelLabel string
	HideCancel                bool
}

AlertDialogOptions supplies localized text and optional cancellation. ConfirmLabel must be supplied. HideCancel produces a one-button notice; backdrop and Escape dismissal still return DialogCancelled unless disabled.

type ArrowPosition

type ArrowPosition uint8

ArrowPosition places a Collapsible's arrow immediately beside its label.

const (
	ArrowRight ArrowPosition = iota
	ArrowLeft
)

type AvatarGroupMember added in v0.2026.12

type AvatarGroupMember struct {
	// Name is the accessible name, hover hint and source of the initials.
	// Members keep their identity by name, and by order among equal names.
	Name   string
	Image  ui.ImageSource
	Status AvatarStatus
}

AvatarGroupMember is one person in an AvatarGroup.

type AvatarGroupOptions added in v0.2026.12

type AvatarGroupOptions struct {
	// Max is how many avatars show before the rest collapse into one "+N"
	// chip: 4 when zero; a negative Max collapses everyone.
	Max int
	// Size is the avatar and chip diameter in DIPs; zero uses Avatar's
	// standard size.
	Size float32
	// Overlap is how far each avatar covers the one before it, in DIPs: a
	// sixth of the diameter when zero; a negative value leaves that much
	// space between avatars instead.
	Overlap float32
	// Reverse puts the first member in front, so each avatar tucks behind
	// the one before it instead of covering it.
	Reverse bool
	// Label names the group for assistive technology; empty uses the
	// localized "Team members".
	Label string
}

AvatarGroupOptions customize an AvatarGroup.

type AvatarOptions added in v0.2026.12

type AvatarOptions struct {
	// Image is a decoded photo, cover-cropped to the circle. Nil shows the
	// name's initials instead, so an application shows them while loading
	// and after a failure by passing nil.
	Image ui.ImageSource
	// Status adds a presence dot and appends it to the accessible name.
	Status AvatarStatus
	// Size is the diameter in DIPs; zero uses the standard theme-scaled size.
	// Initials and the presence dot scale with it.
	Size float32
}

AvatarOptions customize an Avatar.

type AvatarStatus added in v0.2026.12

type AvatarStatus int

AvatarStatus is the presence an Avatar shows with a corner dot.

const (
	// AvatarNoStatus shows no presence dot.
	AvatarNoStatus AvatarStatus = iota
	// AvatarOnline shows a success-colored dot.
	AvatarOnline
	// AvatarOffline shows a muted dot.
	AvatarOffline
)

type BadgeOptions added in v0.2026.12

type BadgeOptions struct {
	Tone BadgeTone
	// Icon is decorative; the text must state the status on its own.
	Icon *ui.SVG
}

BadgeOptions selects a badge's tone and optional leading icon.

type BadgeTone added in v0.2026.12

type BadgeTone int

BadgeTone selects a badge's status color.

const (
	// BadgeNeutral is the bordered surface face.
	BadgeNeutral BadgeTone = iota
	// BadgeAccent tints the badge with the theme accent.
	BadgeAccent
	// BadgeSuccess tints the badge with the theme success color.
	BadgeSuccess
	// BadgeWarning tints the badge with the theme warning color.
	BadgeWarning
	// BadgeDanger tints the badge with the theme danger color.
	BadgeDanger
)
type BreadcrumbsControl struct {
	ui.Element
	// contains filtered or unexported fields
}

BreadcrumbsControl retains activation separately from Element styling.

func Breadcrumbs(c *ui.Context, items []string, chosen *int) *BreadcrumbsControl

Breadcrumbs displays a path with interactive ancestors and a non-interactive final item. Activation writes the ancestor index to chosen; applications own navigation and the path itself. A nil chosen binding is invalid. Keep the control to query Changed after applying Element layout methods.

The path fills its parent's width. When it does not fit, the ancestors after the first collapse, nearest last, into an ellipsis button whose menu lists them in order; the first and final items stay and truncate if still too wide.

func (b *BreadcrumbsControl) Changed() bool

Changed reports activation of an ancestor, even if chosen already held its index.

type ButtonVariant

type ButtonVariant int

ButtonVariant selects a button's visual weight.

const (
	// ButtonPrimary is the accent-filled main action.
	ButtonPrimary ButtonVariant = iota
	// ButtonSecondary is a bordered action with a subtle text-tinted fill.
	ButtonSecondary
	// ButtonOutline is the bordered quiet action.
	ButtonOutline
	// ButtonGhost is the borderless quiet action.
	ButtonGhost
	// ButtonLink is inline text with an underline on hover.
	ButtonLink
	// ButtonToolbar is a raised toolbar control whose capsule and shadow match
	// the chosen segment of a segmented tab list, with a hairline edge that
	// keeps it readable outside a track.
	ButtonToolbar
)

type CalendarControl

type CalendarControl struct {
	ui.Element
	// contains filtered or unexported fields
}

CalendarControl exposes layout and frame-local date changes. Keep this handle when applying Element layout methods, which return ui.Element.

func Calendar

func Calendar(c *ui.Context, value *time.Time) *CalendarControl

Calendar builds the fixed-size six-week view (Monday-first by default) used inside CalendarPicker. Arrows move its cursor; Page Up/Down change months with day clamping; Home/End move to month boundaries. Enter/Space or a day click selects a date, preserving its time and location. Navigation alone does not select. Click the title to switch from days to months, then to a twelve-year grid. Choose a year to open months, and a month to open days. In these grids, arrows move by cell and Page Up/Down changes pages. Today returns to today's day view without committing a value. All modes retain the same fixed size. Key or disable a parent before construction.

func CalendarPicker

func CalendarPicker(c *ui.Context, value *time.Time) *CalendarControl

CalendarPicker displays a leading calendar icon and an ISO date. Click, Enter or Space opens Calendar in a dismissible Popover; choosing a date closes it and restores trigger focus, including when choosing the existing date. Escape/outside press cancel navigation. The application owns value; selection preserves its time of day and location. Changed excludes opening/navigation. Key or disable a parent before construction; Label names the trigger.

func (*CalendarControl) Changed

func (c *CalendarControl) Changed() bool

Changed reports a selected date changed by input, not cursor navigation.

type CardDecision added in v0.2026.12

type CardDecision int

CardDecision is the side a card of a CardStack is sent to.

const (
	// CardLeft passes on a card, by its left action.
	CardLeft CardDecision = iota + 1
	// CardRight keeps it, by its right, primary action.
	CardRight
)

type CardStackAction added in v0.2026.12

type CardStackAction int

CardStackAction is what the stack's own input did in a frame.

const (
	CardStackNone CardStackAction = iota
	// CardStackDecided decided the card ID.
	CardStackDecided
	// CardStackUndone brought the card ID back with its Decision undone.
	CardStackUndone
	// CardStackReset brought every card back.
	CardStackReset
)

type CardStackDecision added in v0.2026.12

type CardStackDecision struct {
	ID       string
	Decision CardDecision
}

CardStackDecision is a card decided, by its ID.

type CardStackEvent added in v0.2026.12

type CardStackEvent struct {
	Action   CardStackAction
	ID       string
	Decision CardDecision
}

CardStackEvent reports a change the stack's input made to its state.

func CardStack added in v0.2026.12

func CardStack(c *ui.Context, state *CardStackState, options CardStackOptions) CardStackEvent

CardStack shows a deck reviewed one card at a time: drag or flick the top card left or right, or use the buttons or the arrow keys, to decide it. The card follows the pointer with a tilt and a stamp naming the action, and a throw carries it off with the pointer's velocity while the cards behind rise. Undo, by its button, Backspace or Command/Ctrl+Z, flies the last card back from where it left; once all are decided, Start over deals them back.

state holds the decisions, which applications own and may change; the stack returns the change its own input made this frame. Applications supply the cards' stable IDs, localized labels and content, and act on decisions. Reduced Motion moves cards at once.

type CardStackItem added in v0.2026.12

type CardStackItem struct {
	// ID identifies the card in CardStackState.Decisions. Keep IDs stable and
	// unique.
	ID string
	// Label is a short name for the card, such as "Lisbon", in its accessible
	// name and announcements.
	Label string
	// Content builds the card's face, which fills it. The stack takes the
	// pointer over the top card for its drag, so the content is presentation.
	// The card does not clip it: a clip that moves and turns with a drag
	// would take a mask rasterized anew every frame. Content reaching the
	// card's edges rounds its own corners to radius, the card's.
	Content func(c *ui.Context, radius float32)
}

CardStackItem is one card of a CardStack.

type CardStackOptions added in v0.2026.12

type CardStackOptions struct {
	Items []CardStackItem
	// LeftLabel and RightLabel name the actions on the buttons and on the
	// stamps a dragged card shows: "Pass" and "Keep" from Onevra's catalog
	// when empty.
	LeftLabel, RightLabel string
	// LeftOutcome and RightOutcome, the past tense of each action, such as
	// "skipped" and "shortlisted", phrase announcements; without them they
	// name the action.
	LeftOutcome, RightOutcome string
	// Label is the accessible name of the stack: "Cards" when empty.
	Label string
	// Empty, if set, builds what shows once every card is decided, given a
	// function that brings all cards back, in place of the default title and
	// Start over button.
	Empty func(c *ui.Context, reset func())
}

CardStackOptions configure a CardStack.

type CardStackState added in v0.2026.12

type CardStackState struct {
	// Decisions are the cards decided so far, in order; the next card on top
	// is Items[len(Decisions)]. Appending, removing or clearing them, here or
	// by the stack's own input, throws cards off or brings them back.
	Decisions []CardStackDecision
}

CardStackState is the application-owned progress of a CardStack.

type CarouselOptions added in v0.2026.12

type CarouselOptions struct {
	// Label names the carousel for assistive technology, such as "Harbour
	// suites".
	Label string
	// Count is the number of slides, and Slide builds slide i to fill the
	// slide's width. Slides share the height of the tallest. Every slide stays
	// built, so keep the set short.
	Count int
	Slide func(c *ui.Context, i int)
	// SlideWidth is the widest a slide grows, in DIPs: 340 scaled to the
	// theme's spacing when zero. Slides take at most 80% of the carousel's
	// width, so their neighbors stay in view.
	SlideWidth float32
	// SlideLabel names slide i of count and its indicator: "2 of 5" from
	// Onevra's catalog when nil.
	SlideLabel func(i, count int) string
	// Interval, when positive, adds a play control that rotates to the next
	// slide every Interval while CarouselState.Playing. Rotation pauses on
	// hover, keyboard focus, dragging and off screen, and is unavailable
	// with Reduced Motion.
	Interval time.Duration
}

CarouselOptions configures a Carousel.

type CarouselState added in v0.2026.12

type CarouselState struct {
	// Index is the slide in the center. The carousel sets it as the user
	// browses; setting it glides the slides there.
	Index int
	// Playing rotates through the slides every CarouselOptions.Interval.
	// The play control toggles it; set it to start rotating on show.
	Playing bool
}

CarouselState is the application-owned state of a Carousel.

type CollapsibleOptions

type CollapsibleOptions struct {
	ArrowPosition ArrowPosition
	Leading       func()
	Trailing      func()
}

CollapsibleOptions configures the disclosure arrow, whose default is right, optional leading content, such as an icon, built inside the trigger before its label, and optional trailing content, such as a count, built at the header's end outside the trigger and vertically centered on it.

type ColorControl

type ColorControl struct {
	ui.Element
	// contains filtered or unexported fields
}

ColorControl exposes layout and an input-driven Changed result. Keep this handle when applying Element layout methods, which return ui.Element.

func ColorPicker

func ColorPicker(c *ui.Context, value *ui.Color) *ColorControl

ColorPicker creates a rectangular color swatch opening ColorView in a dismissible Popover. Size, Border (stroke width/color), Radius and Padding can be customized on the returned Element. Use Label for its accessible name. Enter/Space activate; Escape/outside press dismiss. Changed reports edits, not opening/closing. Key or disable a parent, not the returned element.

func ColorView

func ColorView(c *ui.Context, value *ui.Color) *ColorControl

ColorView edits an application-owned sRGB color in place. It includes a saturation/brightness plane, hue and opacity sliders, RGBA/HSBA/HSLA selection, RGB byte or HSB/HSL degree/percent fields, a six-digit Hex field (also accepts eight-digit RRGGBBAA), and opacity percent. Mode changes do not change the color or report Changed. The Copy color native menu copies RGBA, HSBA, HSLA or HEX text, including alpha. Numeric prefixes scrub horizontally by one unit per theme-scaled DIP and support arrow keys and Home/End. Hex uses a plain text field with a decorative prefix, without numeric stepping or scrubbing. Unsupported text is rejected; valid text applies immediately. Incomplete drafts survive while focused and reset on submission or blur. External changes replace drafts. Hue is retained through gray/black edits. RGB/HSV edits map wide-gamut inputs to sRGB; opacity-only edits preserve their gamut. Disable or key a parent before construction. The plane supports arrow keys; sliders retain MyGo keyboard/accessibility input.

func (*ColorControl) Changed

func (c *ColorControl) Changed() bool

Changed reports a color value changed by input during this build.

type DialogOptions

type DialogOptions struct {
	DisableBackdropClose bool
	DisableEscapeClose   bool
	// Label is the accessible name. Applications supply localized text.
	Label string
	// Inset is the minimum viewport clearance in DIPs on every edge.
	// Non-positive values use 20. WindowDragHeight can increase this clearance.
	Inset float32
	// WindowDragHeight overrides the host's native window drag strip height
	// in DIPs. Non-positive values inherit WithDialogWindowDrag (zero without
	// a host). MyGo owns native drag and focus behavior.
	WindowDragHeight float32
	// DisableWindowDrag disables the strip, including an explicit height.
	DisableWindowDrag bool
}

DialogOptions controls dismissal independently for each layer. The zero value allows backdrop clicks and Escape to dismiss the dialog.

type DialogResult

type DialogResult uint8

DialogResult is emitted only in the frame of a user action. Store it in application state if needed later; this UI-thread API never blocks.

const (
	DialogNone DialogResult = iota
	DialogConfirmed
	DialogCancelled
)

func AlertDialog

func AlertDialog(c *ui.Context, open *bool, options AlertDialogOptions) DialogResult

AlertDialog is a preset Dialog returning confirmation or cancellation. Programmatically closing open does not emit a result.

type DisclosureParts

type DisclosureParts struct {
	Root    ui.Element
	Trigger ui.Element
}

DisclosureParts exposes the container and disclosure button for this frame. Changed reports activation of the trigger, not application-owned state edits.

func Collapsible

func Collapsible(c *ui.Context, label string, open *bool, options CollapsibleOptions, fn func()) DisclosureParts

Collapsible shows an animated disclosure with MyGo's spacing and appearance, without hover styling. The caller owns open; Enter and Space toggle it.

func (DisclosureParts) Changed

func (p DisclosureParts) Changed() bool

type FloatingButtonGroupControl added in v0.2026.12

type FloatingButtonGroupControl struct {
	ui.Element
	// contains filtered or unexported fields
}

FloatingButtonGroupControl is the tray of a FloatingButtonGroup.

func FloatingButtonGroup added in v0.2026.12

func FloatingButtonGroup(c *ui.Context, label string, variant FloatingButtonGroupVariant, orientation ui.Orientation, items []FloatingButtonGroupItem) *FloatingButtonGroupControl

FloatingButtonGroup creates a toolbar of separate soft buttons in a quiet tray, laid out along orientation, ui.Horizontal or ui.Vertical; label names it for assistive technology. Use it for actions; for a choice that stays selected use Tabs or a toggle.

One shared highlight marks the button under the pointer, or with keyboard focus, and springs between buttons in position and size. It stays put as the pointer crosses a gap or separator and fades as it leaves the tray. Appearing, it grows in place; a press darkens it and settles it slightly smaller, while the buttons themselves never move. A changed label or icon crossfades in place. Reduced Motion moves the highlight at once.

The tray is one Tab stop; the arrows of its orientation move among the enabled buttons, wrapping at the ends, Home and End go to the ends, and Enter or Space activates. Icon-only buttons and buttons with a Shortcut show a tooltip, above a row and beside a column. A column's buttons share the width of its widest one. Applications own the labels, the state of toggles and the actions; ask Clicked for the activated button.

func (*FloatingButtonGroupControl) Clicked added in v0.2026.12

func (g *FloatingButtonGroupControl) Clicked() string

Clicked returns the ID of the button activated in this frame, or "".

type FloatingButtonGroupItem added in v0.2026.12

type FloatingButtonGroupItem struct {
	// ID identifies the button across frames, so its label can change, and
	// is what Clicked reports.
	ID string
	// Label is the visible text and the accessible name; IconOnly moves it
	// into a tooltip.
	Label string
	Icon  func() *ui.SVG
	// IconOnly shows only Icon, when there is one.
	IconOnly bool
	Disabled bool
	// Toggle marks an action that switches a mode, such as Present, whose
	// state On holds: assistive technology sees a toggle button, and a
	// quiet tint marks it while on.
	Toggle, On bool
	// Shortcut is a key hint, such as "⌘Z", shown in the tooltip after
	// Label. The group does not bind the key.
	Shortcut string
	// ReserveLabels lists the other labels the button can switch to, such
	// as "Copied" for "Share". The button keeps the widest one's width, so
	// a label change never moves anything.
	ReserveLabels []string
	// Separator makes the item a short rule between clusters of buttons;
	// its other fields are ignored.
	Separator bool
}

FloatingButtonGroupItem is a button, or a separator, of a FloatingButtonGroup.

type FloatingButtonGroupVariant added in v0.2026.12

type FloatingButtonGroupVariant int

FloatingButtonGroupVariant selects the tray of a FloatingButtonGroup.

const (
	// FloatingButtonGroupMuted sits quietly on a page or panel, on a
	// translucent tint of the text color. This is the default.
	FloatingButtonGroupMuted FloatingButtonGroupVariant = iota
	// FloatingButtonGroupRaised lifts the tray on the raised surface with a
	// hairline edge and a floating shadow, for toolbars over content such as
	// a canvas or a text selection.
	FloatingButtonGroupRaised
)

type GridState

type GridState struct {
	Selected  *int
	Selection *ui.Selection[any]
	Key       func(int) any
	Label     func(int) string
	OnChange  func()
	OnSubmit  func(int)
	// contains filtered or unexported fields
}

GridState keeps selection and scrolling for a GridView. Keep one state per grid; do not copy it after first use. Keys must be unique and comparable. A nil Selected and Selection disables selection. Selection holds item keys; Selected optionally exposes the keyboard cursor. OnChange and OnSubmit, rather than Element.Changed/Submitted, report selection and activation. Drag reordering and MyGo's private collection accessibility actions are not exposed by this composition.

func (*GridState) Focus

func (s *GridState) Focus(c *ui.Context)

func (*GridState) FocusWithin

func (s *GridState) FocusWithin(c *ui.Context) bool

func (*GridState) Focused

func (s *GridState) Focused(c *ui.Context) bool

func (*GridState) ScrollIntoView

func (s *GridState) ScrollIntoView(item int)

func (*GridState) ScrollTo

func (s *GridState) ScrollTo(item int, align ui.Align)

type HoldToConfirmControl added in v0.2026.12

type HoldToConfirmControl struct {
	ui.Element
	// contains filtered or unexported fields
}

HoldToConfirmControl exposes the button element. Keep this handle to query Changed and Holding after applying Element methods, which return ui.Element.

func HoldToConfirm added in v0.2026.12

func HoldToConfirm(c *ui.Context, confirmed *bool, label string, options ...HoldToConfirmOptions) *HoldToConfirmControl

HoldToConfirm creates a button that sets *confirmed only after it is held, for destructive or hard-to-undo actions a stray click must not trigger. A fill tracks the hold linearly from the leading edge; letting go early, or sliding well off the button, rewinds it, and completing morphs the label and icon into a done state. Holding Space or Enter works too; moving the focus away cancels. Set *confirmed back to false to reset the button.

h := HoldToConfirm(c, &deleted, "Hold to delete", HoldToConfirmOptions{ConfirmedLabel: "Deleted", Tone: HoldDanger})
if h.Changed() { /* delete */ }

Prefer AlertDialog when people need to read the consequences first. The label is the accessible name; a localized description explains the hold, and completion is announced. Applications own both labels. Key a parent container, or pass c.Key, for stable identity: the hold is element state.

func (*HoldToConfirmControl) Changed added in v0.2026.12

func (h *HoldToConfirmControl) Changed() bool

Changed reports the frame in which a hold completed and set *confirmed.

func (*HoldToConfirmControl) Holding added in v0.2026.12

func (h *HoldToConfirmControl) Holding() bool

Holding reports a hold in progress, for nearby hints such as "Keep holding".

type HoldToConfirmOptions added in v0.2026.12

type HoldToConfirmOptions struct {
	// ConfirmedLabel replaces the label once the hold completes, such as
	// "Deleted"; empty uses the catalog's "Done".
	ConfirmedLabel string
	// Duration is how long the hold takes; zero is 1.2 seconds.
	Duration time.Duration
	// Icon leads the label until the hold completes; nil uses lucide.Trash.
	Icon *ui.SVG
	Tone HoldToConfirmTone
}

HoldToConfirmOptions customizes a hold; the zero value is a 1.2-second accent hold with a trash icon and the catalog's done label.

type HoldToConfirmTone added in v0.2026.12

type HoldToConfirmTone int

HoldToConfirmTone selects the color a hold fills with.

const (
	// HoldAccent fills with the theme accent.
	HoldAccent HoldToConfirmTone = iota
	// HoldDanger tints the face and fills with the danger color, for an
	// irreversible action.
	HoldDanger
	// HoldNeutral fills with the text color.
	HoldNeutral
)

type HoneycombImage added in v0.2026.18

type HoneycombImage struct {
	// Image draws a decoded bitmap or SVG filling the image's circle,
	// replaced by Content when that is set.
	Image ui.ImageSource
	// Content, when set, builds the image at the given size instead of
	// drawing Image. Like HoneycombItem.Content it fills its circle itself.
	Content func(c *ui.Context, size float32)
}

HoneycombImage is one round image of a HoneycombItem's Images.

type HoneycombItem added in v0.2026.10

type HoneycombItem struct {
	// ID is returned when the item is chosen and matched against
	// HoneycombOptions.Selected. Keep IDs stable and unique.
	ID, Label string
	// Image draws a decoded bitmap or SVG centered in the cell, replaced by
	// Content when that is set.
	Image ui.ImageSource
	// Content, when set, builds the item at the given size instead of drawing
	// Image, such as a generated monogram. It fills the cell's circle itself:
	// the cell does not clip it, so a rectangular mark would show its corners.
	// A clipped cell would take a mask the GPU makes anew every frame as the
	// honeycomb turns it, which costs the frame.
	Content func(c *ui.Context, size float32)
	// Images, when it holds more than one image, draws them in the cell
	// instead of Content or Image, overlapping as a group: the first is the
	// largest and lies in front, each is edged in the theme's background and
	// wears the ring, and a badge counts those beyond the first three when
	// there are more than four. A single image fills the cell alone.
	Images []HoneycombImage
	// Overlay, when set, builds content over the item and its ring at the
	// given size, such as a badge on its edge. Like Content it is not clipped.
	Overlay func(c *ui.Context, size float32)
	// Ring colors the ring the item nearest the middle of the view wears, such
	// as the main color of its image; transparent uses the theme's accent.
	Ring ui.Color
	// Caption, when set, shows under the item while it is nearest the middle
	// of the view, such as its name, fading in and out with its ring. It lies
	// on a glass label over the items below.
	Caption string
	// Menu, when set, fills the item's context menu, which opens where the
	// item is right-clicked, without choosing it, and, while it has the
	// focus, from the menu key or Shift+F10.
	Menu func(m *ui.Menu)
}

HoneycombItem describes one round cell of a Honeycomb.

type HoneycombOptions added in v0.2026.10

type HoneycombOptions struct {
	// Items keep their order from frame to frame: each takes the cell of its
	// position, so a reordered list moves them around. They slide to their new
	// cells, fading in and out, as items are added and removed.
	Items []HoneycombItem
	// Selected is the chosen item's ID, which the honeycomb pans to center.
	Selected string
	// SelectedLabel names the selected item for assistive technology and
	// tests; the others are named by their own labels.
	SelectedLabel string
	// OnPress runs as the honeycomb is built after the primary button goes
	// down on it. The honeycomb takes the press for its pan and choice, so
	// it does not reach elements around it, such as a background that
	// ripples where the pointer presses.
	OnPress func()
	// Curvature scales how sharply the ball the honeycomb lies on curves:
	// how far items further out turn away, how much smaller they are than the
	// one in the middle, and how far in from the edge of the view they shrink
	// and fade out. Zero uses 1. Negative values lay the honeycomb flat, with
	// every item at the same size, to show many at once; values above 1 curve
	// it more, up to 2.
	Curvature float32
	// OffsetY shifts the honeycomb, and the point it settles and chooses
	// around, up or down within its view in DIPs: negative moves it up. Use it
	// when content floating over one edge leaves less room there, such as a
	// composer at the bottom, so the honeycomb centers in the visible space.
	// The view and its edge fade stay where they are.
	OffsetY float32
	// Gap is the space between neighboring items in DIPs, unmagnified, which
	// the lens magnifies with the items, scaled to the theme's spacing like
	// the rest of the honeycomb. Zero uses 10; negative values set the items
	// edge to edge; values above 56 are 56, the size of an item.
	Gap float32
}

HoneycombOptions configures a Honeycomb.

type IconButtonStyle added in v0.2026.10

type IconButtonStyle int

IconButtonStyle selects an icon button's face.

const (
	// IconButtonPlain tints a transparent face on hover and press.
	IconButtonPlain IconButtonStyle = iota
	// IconButtonToolbar raises the face, shadowed, as the chosen segment of a
	// segmented tab list is raised.
	IconButtonToolbar
	// IconButtonCompact is IconButtonPlain at a smaller square, for dense
	// rows such as a SidebarSectionWithActions heading.
	IconButtonCompact
)

type ImageCompareControl added in v0.2026.12

type ImageCompareControl struct {
	ui.Element
	// contains filtered or unexported fields
}

ImageCompareControl exposes the frame element. Keep this handle to query Changed after Element layout methods, which return ui.Element.

func ImageCompare added in v0.2026.12

func ImageCompare(c *ui.Context, position *float32, before, after func(), options ...ImageCompareOptions) *ImageCompareControl

ImageCompare overlays before on after in a rounded, clipped frame and reveals before up to a draggable divider. *position is the application-owned share of the frame, from 0 to 100, that before covers; it must be nonnil and finite, and values outside the range are clamped when shown. Both builders lay out at the full frame size so their content stays aligned, and both remain built at every position. Nil builders leave their side empty. Content receives no pointer input.

ImageCompare(c, &position, func() { Image(c, raw).Fill().Fit(ui.Cover) },
	func() { Image(c, edited).Fill().Fit(ui.Cover) },
	ImageCompareOptions{BeforeLabel: "Before", AfterLabel: "After"}).
	Label("Comparison").FillWidth()

Pressing anywhere on the frame moves the divider there with a spring; dragging tracks the pointer and keeps its release velocity as it settles, while the handle stretches into a capsule. Double-clicking the handle restores Default. The focusable handle reports its position as a slider: axis arrows move it by 1, or 10 with Shift, PageUp/PageDown by 10, and Home/End to 0 and 100. Captions fade as the divider nears them. Reduced Motion moves the divider at once. Label defaults to "Divider".

func (*ImageCompareControl) AutoFocus added in v0.2026.12

func (s *ImageCompareControl) AutoFocus() *ImageCompareControl

AutoFocus focuses the divider handle.

func (*ImageCompareControl) Changed added in v0.2026.12

func (s *ImageCompareControl) Changed() bool

Changed reports an input-driven position change.

func (*ImageCompareControl) Label added in v0.2026.12

Label sets the accessible name of the focusable divider handle.

type ImageCompareOptions added in v0.2026.12

type ImageCompareOptions struct {
	// Orientation defaults to Horizontal, with before on the left; Vertical
	// puts before on top. Unrecognized values are Horizontal.
	Orientation Orientation
	// BeforeLabel and AfterLabel caption the two sides; an empty string
	// omits its caption. Captions are decorative and hidden from assistive
	// technology; name the comparison with ImageCompareControl.Label.
	BeforeLabel, AfterLabel string
	// AspectRatio is the frame's width divided by its height. Zero uses 3/2;
	// a negative value leaves the height to the host. Nonfinite is invalid.
	AspectRatio float32
	// Default, from 0 to 100, is the position double-clicking the handle
	// restores. Zero uses 50; values outside the range are clamped.
	Default float32
}

ImageCompareOptions configures a before-and-after comparison.

type ListState

type ListState struct {
	Selected   *int
	Selection  *ui.Selection[any]
	Key        func(int) any
	Label      func(int) string
	KeepOffset bool
	FollowEnd  bool
	OnChange   func()
	OnSubmit   func(int)
	// contains filtered or unexported fields
}

ListState owns a Onevra list's selection and MyGo's virtual scroll state. Keep one state per list and do not copy it after first use. Keys must be comparable and unique. Without Key, selection identifies rows by index. Selection uses ui.Selection[any] so keys can have any comparable type. Selection, when set, controls the chosen rows; Selected optionally exposes the keyboard cursor as well. A nil Selected and Selection disables selection. KeepOffset keeps a keyed list's scroll offset as its rows move, such as when they are sorted again, while selection still follows its keys.

OnChange and OnSubmit report user selection and activation respectively; use these callbacks rather than the returned Element's Changed/Submitted. MyGo still owns virtualization, variable-height measurement and scrolling. This state intentionally does not expose table sorting, reordering or headers.

func (*ListState) Focus

func (s *ListState) Focus(c *ui.Context) bool

func (*ListState) FocusWithin

func (s *ListState) FocusWithin(c *ui.Context) bool

func (*ListState) Focused

func (s *ListState) Focused(c *ui.Context) bool

func (*ListState) ScrollIntoView

func (s *ListState) ScrollIntoView(row int)

func (*ListState) ScrollTo

func (s *ListState) ScrollTo(row int, align ui.Align)

func (*ListState) ScrollToEnd

func (s *ListState) ScrollToEnd()

func (*ListState) Visible

func (s *ListState) Visible() (first, last int)
type Menu struct {
	// contains filtered or unexported fields
}

Menu is a menu being built, by the function given to ContextMenu or MenuButton. Its items show in the order they are added.

func (m *Menu) Group(label string, build func(m *Menu))

Group adds the items build adds under a heading of label, which sets them apart without a separator.

func (m *Menu) Item(label string) *MenuItem

Item adds an item showing label.

func (m *Menu) Separator()

Separator adds a line between groups of items. It shows only between items, once.

type MenuItem struct {
	// contains filtered or unexported fields
}

MenuItem is an item of a Menu. Its options are set before Chosen, which reports whether it was chosen.

func (it *MenuItem) Checked(on bool) *MenuItem

Checked shows a check mark by the item when on is true, as for a setting that choosing the item toggles. The menu leaves room for it either way.

func (it *MenuItem) Chosen() bool

Chosen reports whether the item was chosen in this frame, which closes the menu.

func (it *MenuItem) Disabled(d bool) *MenuItem

Disabled shows the item grayed out when d is true: it cannot be chosen.

func (it *MenuItem) Shortcut(hint string) *MenuItem

Shortcut shows a key hint, such as "⌘B", after the item's label. It only shows the key; the application handles it.

type NativeSelectOption

type NativeSelectOption[T comparable] struct {
	Value    T
	Label    string
	Disabled bool
}

NativeSelectOption associates an application value with localized menu text. Values should be unique. Disabled options remain visible but cannot be chosen.

type NativeSelectParts

type NativeSelectParts struct {
	Trigger ui.Element
	// contains filtered or unexported fields
}

NativeSelectParts exposes the styled trigger and the current build's change. Trigger.Changed is not used: native menu choices are reported by Changed.

func NativeSelect

func NativeSelect[T comparable](c *ui.Context, selected *T, options []NativeSelectOption[T]) *NativeSelectParts

NativeSelect chooses a value through MyGo's operating-system menu. The trigger uses Onevra styling, not an OS select widget. It displays the selected option's label (empty if absent); callers may replace its Children and should supply an accessible Label. Enter, Space and Down open the focused trigger's menu. An empty option list disables the trigger. Keep option order stable while open.

func (*NativeSelectParts) Changed

func (s *NativeSelectParts) Changed() bool

Changed reports a different value chosen in this build. Handle it immediately after NativeSelect, on the UI thread; applications own persistence and effects.

type NumberInputControl

type NumberInputControl struct {
	ui.Element
	// contains filtered or unexported fields
}

NumberInputControl exposes layout on Element and editing on the text field. Keep this handle to query Changed after applying Element layout methods.

func NumberInput

func NumberInput(c *ui.Context, value *float64, lo, hi, step float64, options ...NumberInputOptions) *NumberInputControl

NumberInput creates a numeric text field with optional prefix scrubbing and an optional vertical stepper. Bounds and value must be finite, hi >= lo, and step finite and positive. Valid in-range text updates value immediately without snapping to step. Partial or invalid text is retained while editing and restored on Enter or focus loss. Up/Down and the buttons add/subtract step and clamp to the bounds. Application changes replace even a focused draft. Disable a parent to disable the control. Key a parent for stable identity; construction resolves interaction state.

func (*NumberInputControl) AutoFocus

func (n *NumberInputControl) AutoFocus() *NumberInputControl

AutoFocus focuses the editable text field.

func (*NumberInputControl) Changed

func (n *NumberInputControl) Changed() bool

Changed reports an input-driven value change, not initial clamping.

func (*NumberInputControl) Label

func (n *NumberInputControl) Label(label string) *NumberInputControl

Label names the text field and any optional drag handle and step buttons.

type NumberInputOptions

type NumberInputOptions struct {
	// LeadingText and LeadingIcon provide a horizontal drag handle inside the field.
	// Dragging changes the value by step per theme-scaled DIP. Arrow keys change
	// it by step; Home/End select the bounds. Omit both for an ordinary text field.
	LeadingText string
	LeadingIcon *ui.SVG
	// HideStepper hides the right-hand up/down buttons, which are shown by default.
	HideStepper bool
}

NumberInputOptions configures optional controls around the editor.

type Orientation

type Orientation uint8

Orientation describes the arrangement of a control's parts, such as a Split's panes, not its divider line, or a Stepper's steps.

const (
	Horizontal Orientation = iota // Left and right panes; steps in a row.
	Vertical                      // Top and bottom panes; steps in a column.
)

type PixelGridOptions

type PixelGridOptions struct {
	// Spacing defaults to 16 for nonpositive or nonfinite values. Positive
	// values are clamped to at least 4 to keep dense grids legible.
	Spacing float32
	// MajorEvery emphasizes every nth line. Zero defaults to 8; negative
	// values disable emphasis. Main and minor lines share the same origin.
	MajorEvery int
}

PixelGridOptions configures a canvas grid in device-independent pixels. The grid origin is fixed at the container's top-left corner; changing Spacing changes the cell size without transforming children.

type RatingControl

type RatingControl struct {
	ui.Element
	// contains filtered or unexported fields
}

RatingControl retains value changes separately from Element styling.

func Rating

func Rating(c *ui.Context, value *int, maximum int) *RatingControl

Rating creates max stars bound to an application-owned integer. Values are clamped to [0, max]; a negative max means zero stars. A nil value is invalid. Clicking the selected star clears the rating. Arrows, Home and End operate on the focused control. Label supplies its accessible name. Keep the control to query Changed after applying Element methods. Key a parent for identity.

func (*RatingControl) Changed

func (r *RatingControl) Changed() bool

Changed reports a user-driven value change, not initial clamping.

type ScrollAxes

type ScrollAxes uint8

ScrollAxes selects the directions in which a ScrollView can scroll.

const (
	ScrollVertical ScrollAxes = iota
	ScrollHorizontal
	ScrollBoth
)

type ScrollEdgeBarOptions added in v0.2026.13

type ScrollEdgeBarOptions struct {
	Style ScrollEdgeStyle
	// Bottom docks the bar at the bottom edge, with its effect rising from
	// it, rather than at the top.
	Bottom bool
	// Height is the bar's height in DIPs; zero is 52, which fits 40-DIP
	// buttons.
	Height float32
	// Inset is the bar's distance from its edge and from the sides in DIPs;
	// zero is three theme spacing units.
	Inset float32
	// Glass is the bar's material in ScrollEdgeGlass, such as glass.Clear
	// or a tint; Interactive is ignored. The zero value is regular glass.
	Glass glass.Glass
	// Color makes the bar less see-through: it lays over the glass in
	// ScrollEdgeGlass, over the blur in ScrollEdgeBlur, fading out with it,
	// and is the bar's own surface in ScrollEdgeSoft and ScrollEdgeHard.
	// Unset, glass takes Background at 85% and blur at 93%; soft and hard
	// bars stay transparent.
	Color ui.Color
	// Uncolored leaves glass and blur bare, without Color.
	Uncolored bool
	// Background is what the content scrolls over, which ScrollEdgeSoft and
	// ScrollEdgeHard fade toward; unset, the theme's Background.
	Background ui.Color
}

ScrollEdgeBarOptions configures a ScrollEdgeBar.

type ScrollEdgeOptions added in v0.2026.13

type ScrollEdgeOptions struct {
	Style  ScrollEdgeStyle
	Bottom bool
	// Extent is how far from its edge the effect reaches in DIPs, such as
	// the height of the controls floating there; soft edges and progressive
	// blur fade out a little beyond it.
	Extent float32
	// Background is what the content scrolls over, which ScrollEdgeSoft and
	// ScrollEdgeHard fade toward; unset, the theme's Background.
	Background ui.Color
	// Color tints ScrollEdgeBlur's blur, fading out with it, so that
	// controls over it stay legible; unset, Background at 93%.
	Color ui.Color
	// Uncolored leaves the blur bare, without Color.
	Uncolored bool
}

ScrollEdgeOptions configures a ScrollEdge.

type ScrollEdgeStyle added in v0.2026.13

type ScrollEdgeStyle int

ScrollEdgeStyle selects what separates a ScrollEdgeBar from the content scrolling under it.

const (
	// ScrollEdgeGlass sets the whole bar on one capsule of Liquid Glass and
	// leaves the content beside it untouched. This is the default.
	ScrollEdgeGlass ScrollEdgeStyle = iota
	// ScrollEdgeSoft fades the content into the background toward the edge,
	// without a blur, as macOS's soft scroll edge effect.
	ScrollEdgeSoft
	// ScrollEdgeHard frosts the content evenly under the bar and draws a
	// hairline where it ends, as macOS's hard scroll edge effect.
	ScrollEdgeHard
	// ScrollEdgeBlur blurs the content progressively, the more the nearer
	// the edge.
	ScrollEdgeBlur
)

type ScrollViewOptions

type ScrollViewOptions struct {
	// Axes defaults to ScrollVertical, including for unrecognized values.
	Axes ScrollAxes
}

ScrollViewOptions configures a ScrollView.

type SelectParts

type SelectParts[T comparable] struct {
	ui.SelectParts[T]
	// contains filtered or unexported fields
}

SelectParts composes MyGo's select behavior with a themed popup and an optional search field. Applications own the query, filtering and option text. Embedded MyGo parts retain trigger, item and open-state behavior.

func Select

func Select[T comparable](c *ui.Context, selected *T) *SelectParts[T]

Select creates a drop-down choosing *selected from options the caller builds in Popup with Item. The trigger, popup and items have Onevra styling:

sel := components.Select(c, &choice)
sel.Trigger.Children(func() { components.Text(c, string(choice)).SingleLine() })
sel.Popup(func(panel ui.Element) {
	for _, opt := range options {
		item := sel.Item(opt)
		item.Children(func() { components.Text(c, string(opt)).SingleLine() })
	}
})

The trigger's Changed reports a new choice.

func (*SelectParts[T]) Item

func (s *SelectParts[T]) Item(value T) ui.Element

Item creates a themed option with the same neutral selected face as SidebarItem. Unselected options use a weaker neutral face while hovered. The caller supplies its label and children.

func (*SelectParts[T]) Popup

func (s *SelectParts[T]) Popup(build func(panel ui.Element)) ui.Element

Popup shows a themed, shadowed panel while the select is open. The callback can override its appearance and build a SearchField followed by filtered Items. It returns an absent Element when closed.

func (*SelectParts[T]) SearchField

func (s *SelectParts[T]) SearchField(query *string) ui.Element

SearchField adds an optional search input inside Popup. Give it an accessible Label and localized Placeholder. Build only matching Items after it; an empty result message and query reset policy belong to the caller. The highlight moves to the first enabled result when filtering removes its option. Down or Up returns focus to the trigger, where MyGo handles option navigation and selection.

type SettingsCategory

type SettingsCategory struct {
	ID, Title, Section, Description string
	Icon                            *ui.SVG
	Image                           ui.ImageSource
	// Leading replaces Image and Icon with application-built, non-interactive
	// sidebar content. It follows SidebarItemWithLeading's builder contract
	// and is not built in the narrow category selector or during metadata search.
	Leading func(c *ui.Context, size float32)
	// Placeholder, when set, shows application-built, non-interactive
	// content, such as an empty section's note, in the sidebar in place of
	// the category's navigation item, keeping its Section's heading and
	// actions. Such a category has no page and is never selected, searched
	// or offered by the narrow category selector. It follows Build's rules.
	Placeholder func(c *ui.Context)
	Groups      []SettingsGroup
}

SettingsCategory describes a navigation destination. IDs must be nonempty and unique among siblings; keep them stable across localization and rebuilds. Image, such as a project logo, replaces Icon in the navigation when set.

type SettingsGroup

type SettingsGroup struct {
	ID, Title string
	Items     []SettingsItem
	Actions   func(c *ui.Context)
}

SettingsGroup groups related items. Title may be empty for an unheaded group. Actions optionally builds trailing controls on the group's header row, such as a refresh button; like Build, it runs on the UI thread only when the header is visible and must not start background work during rendering. Actions are not searched.

type SettingsItem

type SettingsItem struct {
	ID, Title, Description string
	Keywords               []string
	Build                  func(c *ui.Context)
	DescriptionContent     func(c *ui.Context)
	// Leading builds content before the title and description, such as an
	// icon, avatar or status indicator.
	Leading func(c *ui.Context)
	// Stacked places Build below the text across the row's width, for wide
	// controls such as text boxes, sliders and option lists. Narrow layouts
	// always stack.
	Stacked bool
	// Content replaces the whole row with application-built content spanning
	// its width, such as a profile card, preview, banner or list; Leading,
	// Build and the displayed title and description are not used. Title,
	// Description and Keywords remain the row's search metadata. Like Build,
	// it runs only when visible.
	Content func(c *ui.Context)
}

SettingsItem describes a searchable row. Build runs synchronously on the UI thread only when visible. Applications own values, accessible control labels, persistence and effects; Build must not start background work during rendering. IDs must be nonempty and unique within the group.

DescriptionContent optionally replaces Description's text with inline text elements, such as Text and a ButtonLink, built into the description's paragraph and styled like it. Only text elements belong in it; like Build, it runs only when visible. Description is still what search matches, so give it the same words.

type SettingsOptions

type SettingsOptions struct {
	Narrow                                                                        bool
	Title, SearchLabel, SearchPlaceholder, CategoryLabel, ResultsTitle, EmptyText string
	// HeaderActions builds optional trailing actions beside the close button.
	HeaderActions func(c *ui.Context)
	// SectionActions builds optional trailing controls on a section's
	// sidebar heading, such as an add button, for each nonempty Section; it
	// may build nothing for a section. The narrow category selector shows the
	// selected category's section actions beside it, so there a section of
	// only Placeholder categories has none. It follows Build's rules.
	// A section shows only while a category belongs to it.
	SectionActions func(c *ui.Context, section string)
	// Close, when set, shows a trailing close button that calls it, for hosts
	// that present Settings in a dialog or window. CloseLabel overrides its
	// accessible name; empty uses Onevra's catalog. Nil omits the button.
	Close      func()
	CloseLabel string
	// HideSearch removes the search field; Query is then ignored.
	HideSearch bool
	// HideSidebar removes category navigation, both the sidebar and the narrow
	// category selector, and shows every category on one page, each under its
	// title when there are several. To navigate from application UI instead,
	// pass only the selected category.
	HideSidebar bool
}

SettingsOptions controls presentation without imposing a window or dialog. Empty text fields use Onevra's catalog in the window's language. Narrow is supplied by the host from its allocated width (not the window width); it replaces the sidebar with a category selector and stacks each row's control below its text.

type SettingsResult

type SettingsResult struct{ Category, Group, Item int }

SettingsResult identifies an item by slice indices in the supplied catalog. Results are valid only for that catalog snapshot and preserve declaration order.

func SearchSettings

func SearchSettings(categories []SettingsCategory, query string) []SettingsResult

SearchSettings searches every category using case-insensitive, whitespace- separated terms. Every term must occur in the combined category, group, title, description or keywords. An empty query returns all items. No builders run.

Example
package main

import (
	"fmt"

	"github.com/oneo-me/onevra/source/components"
)

func main() {
	categories := []components.SettingsCategory{{ID: "appearance", Title: "Appearance", Groups: []components.SettingsGroup{{ID: "theme", Items: []components.SettingsItem{{ID: "mode", Title: "Color mode", Keywords: []string{"dark"}}}}}}}
	for _, result := range components.SearchSettings(categories, "dark appearance") {
		fmt.Println(categories[result.Category].Groups[result.Group].Items[result.Item].Title)
	}
}
Output:
Color mode

type SettingsState

type SettingsState struct {
	Category string
	Query    string
}

SettingsState is application-owned presentation state, independent of setting values. An empty or unknown Category selects the first category. Searching preserves Category.

type SkeletonOptions added in v0.2026.12

type SkeletonOptions struct {
	Lines  int
	Avatar bool
	Label  string
}

SkeletonOptions shapes a Skeleton placeholder: Lines of text, 3 when zero and clamped to 1–6, after an optional round Avatar. Label names the loading status; empty uses "Loading content" from Onevra's catalog.

type SliderControl

type SliderControl struct {
	ui.Element
	// contains filtered or unexported fields
}

SliderControl exposes the underlying layout element. Keep this handle to query Changed after applying Element layout methods, which return ui.Element.

func Slider

func Slider(c *ui.Context, value *float64, lo, hi float64, options ...SliderOptions) *SliderControl

Slider creates a continuous, stepped or two-thumb slider. Existing calls can omit options. Range and Step may be combined. Applications own both values; range values are clamped and ordered on construction. Bounds must be finite with hi >= lo; values and Step must be finite. Nonpositive Step is continuous.

s := Slider(c, &low, 0, 100, SliderOptions{Range: &high, Step: 5})
s.Label("Price").FillWidth()
if s.Changed() { /* use low and high */ }

Pointer input uses MyGo's drag capture. Tab moves between range thumbs; arrows, PageUp/PageDown, Home and End adjust the focused thumb without crossing.

func (*SliderControl) AutoFocus

func (s *SliderControl) AutoFocus() *SliderControl

AutoFocus focuses the single thumb or the minimum thumb of a range.

func (*SliderControl) Changed

func (s *SliderControl) Changed() bool

Changed reports an input-driven change to either value, not initial clamping.

func (*SliderControl) Label

func (s *SliderControl) Label(label string) *SliderControl

Label names the slider and, in range mode, both independently focusable thumbs.

type SliderOptions

type SliderOptions struct {
	// Step > 0 snaps input to multiples of Step from lo and displays ticks.
	// Zero keeps continuous pointer input and a keyboard step of (hi-lo)/100.
	Step float64
	// Range enables two thumbs: value is the minimum and Range is the maximum.
	// The pointers must be distinct. Nil keeps the single-thumb slider.
	Range *float64
	// Accessible names for range thumbs; defaults are "minimum" and "maximum".
	MinimumLabel, MaximumLabel string
}

SliderOptions selects value behavior, not a visual variant.

type SpinnerVariant

type SpinnerVariant int

SpinnerVariant selects the appearance of an indeterminate activity indicator.

const (
	// SpinnerRing uses the same track and rotating arc as ProgressRing.
	SpinnerRing SpinnerVariant = iota
	// SpinnerSpokes uses twelve fading spokes, like MyGo's built-in spinner.
	SpinnerSpokes
)

type SplitControl

type SplitControl struct {
	ui.Element
	// contains filtered or unexported fields
}

SplitControl exposes the layout element. Keep this handle to query Changed after Element layout methods, which return ui.Element.

func Split

func Split(c *ui.Context, size *float32, first, second func(), options ...SplitOptions) *SplitControl

Split arranges two clipped panes separated by a one-DIP line. size is the application-owned preferred width (Horizontal) or height (Vertical) of the first pane and must be nonnil and finite. Give the split a bounded size. Changing orientation reinterprets size in the new axis; applications that need independent sizes should keep separate bindings.

Split(c, &width, files, editor).Fill()
Split(c, &height, preview, console, SplitOptions{Orientation: Vertical}).Fill()

A transparent, theme-scaled handle captures pointer drags. The line keeps Theme.Border on hover and while dragging; the cursor and keyboard focus ring provide feedback. Tab focuses the divider between the panes; axis arrow keys move it by Theme.Space(2.5), and Home/End move to the effective limits. Label defaults to "Divider". Nil builders leave their panes empty. Double-clicking the divider restores SplitOptions.Default when set.

func SplitPercent added in v0.2026.11

func SplitPercent(c *ui.Context, percent *float32, first, second func(), options ...SplitOptions) *SplitControl

SplitPercent is Split with *percent the share of the room, from 0 to 100, that the first pane takes, so both panes grow and shrink with the split in proportion. Values outside that range are clamped when shown. The minima still apply and are not written back, so the preferred share returns when there is room again. The divider reports its position to assistive technology as a percentage, and SplitOptions.Default is a share.

SplitPercent(c, &percent, files, editor).Fill()
SplitPercent(c, &percent, preview, console, SplitOptions{Orientation: Vertical}).Fill()

func (*SplitControl) AutoFocus

func (s *SplitControl) AutoFocus() *SplitControl

AutoFocus focuses the divider.

func (*SplitControl) Changed

func (s *SplitControl) Changed() bool

Changed reports an input-driven size change, not a layout constraint.

func (*SplitControl) Label

func (s *SplitControl) Label(label string) *SplitControl

Label sets the accessible name of the keyboard-focusable divider.

type SplitOptions

type SplitOptions struct {
	// Orientation defaults to Horizontal, including for unrecognized values.
	Orientation Orientation
	// Minimum pane sizes in DIPs. Zero uses Theme.Space(10); negative or
	// nonfinite values are invalid. When both minima cannot fit, they shrink
	// proportionally. Layout constraints do not overwrite the preferred size.
	FirstMin, SecondMin float32
	// Default, when positive, is the size of the first pane that
	// double-clicking the divider restores, within the effective limits: DIPs
	// for Split and a share from 0 to 100 for SplitPercent. Negative or
	// nonfinite values are invalid.
	Default float32
}

SplitOptions configures a two-pane resizable layout.

type StepperControl added in v0.2026.12

type StepperControl struct {
	ui.Element
	// contains filtered or unexported fields
}

StepperControl retains step choice separately from Element styling.

func Stepper added in v0.2026.12

func Stepper(c *ui.Context, steps []StepperStep, current int, opts StepperOptions) *StepperControl

Stepper shows where a person is in a multi-step flow, for onboarding, checkout and setup. current is the index of the step in progress; set it to len(steps) once every step is done. Out-of-range values clamp. Applications own the steps, the flow and its content, placed beside it.

Completed steps show a check, the current step a ring around its number and failed steps an alert. With Selectable, completed steps are buttons: Tab enters the steps, the arrows move among those already reached, and Home and End go to the first and the last of them. Changes of the current step are announced. Reduced Motion skips the motion.

func (*StepperControl) Chosen added in v0.2026.12

func (s *StepperControl) Chosen() (int, bool)

Chosen reports the completed step chosen in this frame.

type StepperOptions added in v0.2026.12

type StepperOptions struct {
	// Orientation Vertical stacks the steps for a sidebar or a narrow column,
	// with labels beside the markers. Steps run in a row by default.
	Orientation Orientation
	// Selectable lets people return to a completed step by click or keyboard;
	// StepperControl.Chosen reports it. Otherwise the stepper is a read-only
	// indicator.
	Selectable bool
	// CurrentDescription shows only the current step's description, for tight
	// spaces. Errors always show.
	CurrentDescription bool
	// Compact shows markers only, keeping labels for assistive technology. A
	// horizontal compact stepper names the current step underneath. Hosts
	// choose it from the space they give the stepper.
	Compact bool
	// Label names the stepper for assistive technology; Onevra's catalog
	// supplies one when empty.
	Label string
	// CompleteLabel is announced, and shown in the compact caption, once every
	// step is complete; Onevra's catalog supplies one when empty.
	CompleteLabel string
}

StepperOptions configure a Stepper.

type StepperStep added in v0.2026.12

type StepperStep struct {
	Label string
	// Description is a short hint under the label.
	Description string
	// Error marks the step as failed: its marker turns into an alert and the
	// message replaces the description.
	Error string
}

StepperStep is one step of a Stepper, identified by its position.

type SwitchOptions

type SwitchOptions struct {
	// HideLabel hides the adjacent text while retaining the switch's accessible name.
	HideLabel bool
	// Compact draws a smaller switch for dense rows, such as table cells and
	// toolbars. Its knob grows into the same glass lens, scaled with it.
	Compact bool
}

SwitchOptions controls the visible label independently of the accessible name.

type TableState added in v0.2026.5

type TableState struct {
	Columns ui.TableLayout
	Sort    *ui.SortOrder
	OnSort  func()
	// contains filtered or unexported fields
}

TableState keeps the column layout and sort order of a Table or TableVirtualized. Keep one state per table and do not copy it after first use. Columns holds the order and widths chosen by dragging headers, keyed by column ID, and can be persisted by the application. Sort, when set, lets a click on a Sortable header choose the order; the application sorts its rows and OnSort reports the user's change.

type TableVirtualizedState added in v0.2026.5

type TableVirtualizedState struct {
	TableState
	List ListState
}

TableVirtualizedState keeps a virtualized table's column layout, sort order, row selection and scrolling. Use one state per table and do not copy it after first use. List follows ListState's selection and activation contract: a nil List.Selected and List.Selection disables selection.

type TabsOptions added in v0.2026.13

type TabsOptions struct {
	Variant TabsVariant
	// Leading, when set, builds the slot before each tab's label, as
	// TabsWithLeading describes.
	Leading func(c *ui.Context, i int, size float32)
	// Trailing, when set, builds the slot after each tab's label, for
	// example a count, receiving and inheriting what Leading does.
	Trailing func(c *ui.Context, i int, size float32)
	// Menu, when set, returns the builder of tab i's context menu, or nil for
	// a tab without one. The menu opens where the tab is right-clicked,
	// without choosing it, and, while it has the focus, from the menu key or
	// Shift+F10.
	Menu func(i int) func(m *ui.Menu)
}

TabsOptions configures TabsWith.

type TabsVariant added in v0.2026.10

type TabsVariant int

TabsVariant selects the look of a tab list.

const (
	// TabsUnderline marks the chosen tab with a shared accent underline that
	// animates to it. This is the default.
	TabsUnderline TabsVariant = iota
	// TabsSegmented draws the tabs as the segments of a rounded track, with
	// the chosen one raised on a shadowed, lighter thumb, as macOS draws a
	// segmented control.
	TabsSegmented
	// TabsHighlight sets the chosen tab on a softly filled, rounded block that
	// slides behind the labels, without a track.
	TabsHighlight
)

type TagInputControl added in v0.2026.12

type TagInputControl struct {
	ui.Element
	// contains filtered or unexported fields
}

TagInputControl exposes layout on Element and editing on the draft field. Keep this handle to query Changed after applying Element layout methods.

func TagInput added in v0.2026.12

func TagInput(c *ui.Context, tags *[]string) *TagInputControl

TagInput edits application-owned *tags, distinct plain strings shown as removable pills before a draft field. Enter or a comma adds the trimmed draft, as does leaving the field; pasted comma-separated text adds each part. A duplicate, compared without case, pulses the existing tag instead; Enter keeps such a draft for correction. Backspace at the start of the draft picks the last tag and removes it when pressed again; Delete removes a picked tag, the arrow keys move the pick and Escape clears it. Clicking a tag picks it. Announcements report additions, removals and picks.

Tags wrap onto new rows while the field's height follows on a spring. New tags blur and scale in, removed tags leave and the rest glide into place; Reduced Motion skips the movement. Applications validate or normalize tags after Changed. Each tag animates individually, which suits dozens of tags, not hundreds. Key a parent for stable identity; construction resolves interaction state.

func (*TagInputControl) AutoFocus added in v0.2026.12

func (n *TagInputControl) AutoFocus() *TagInputControl

AutoFocus focuses the draft field.

func (*TagInputControl) Changed added in v0.2026.12

func (n *TagInputControl) Changed() bool

Changed reports a tag added or removed by the user in this frame.

func (*TagInputControl) Label added in v0.2026.12

func (n *TagInputControl) Label(label string) *TagInputControl

Label names the draft field. Remove buttons are named after their tags.

func (*TagInputControl) Placeholder added in v0.2026.12

func (n *TagInputControl) Placeholder(text string) *TagInputControl

Placeholder shows text in the field while it holds no tags.

type TextBoxOptions

type TextBoxOptions struct {
	// Multiline accepts line breaks; the default is a single-line input.
	Multiline bool
	// ReadOnly allows focus, selection and copying, but not editing. It uses
	// a muted background and neutral border even when focused.
	ReadOnly bool
	// LeadingIcon is an optional decorative SVG, for example lucide.Search().
	// It reserves space on the left and aligns with the first line in multiline
	// mode. Supply the accessible name with Label. Nil leaves no icon or gap.
	LeadingIcon *ui.SVG
	// LeadingText is a non-editable, theme-font prefix inside the field, such as
	// "R", "#" or "$". It follows LeadingIcon when both are set, reserves measured
	// space and does not become part of the value, selection or copied text.
	// Keep it short and single-line; supply the accessible name with Label.
	LeadingText string
}

TextBoxOptions configures TextBox and TextBoxBuffer editing behavior and appearance.

type TextControl

type TextControl struct {
	ui.Element
	// contains filtered or unexported fields
}

TextControl exposes the layout element. Keep this handle to query Changed or Submitted after applying Element methods, which return ui.Element.

func Text

func Text(c *ui.Context, value string, options ...TextOptions) *TextControl

Text creates text inheriting the frame theme and parent font, size and color. With no Editable binding it is MyGo's text primitive, including wrapping and RichText composition. Editable text is single-line, like an inline name, and adds only the native editor's caret and selection, not a background, border, padding or focus ring. MyGo owns input, shaping and rendering.

text := Text(c, name, TextOptions{Editable: &name})
text.Label("Name").Bold()
if text.Changed() { /* use name */ }

Apply layout and typography to the returned Element as usual. When editing, call Label and AutoFocus on TextControl before Element styling methods. Key a parent container for stable identity across reordering, not this element.

func (*TextControl) AutoFocus

func (t *TextControl) AutoFocus() *TextControl

AutoFocus focuses the editor when editing is enabled.

func (*TextControl) Changed

func (t *TextControl) Changed() bool

Changed reports a user edit to the bound value.

func (*TextControl) Label

func (t *TextControl) Label(label string) *TextControl

Label supplies the accessible name of the text or its editor.

func (*TextControl) Submitted

func (t *TextControl) Submitted() bool

Submitted reports Enter in editable text.

type TextOptions

type TextOptions struct {
	// Editable binds single-line editing to application-owned text. Nil keeps
	// display text; otherwise *Editable supplies the text instead of value.
	// Edits update the binding immediately, not on Enter or blur.
	Editable *string
}

TextOptions selects editing behavior without adding input decoration.

type TimeControl

type TimeControl struct {
	ui.Element
	// contains filtered or unexported fields
}

TimeControl exposes layout and a frame-local time change. Keep this handle when applying Element layout methods, which return ui.Element.

func TimePicker

func TimePicker(c *ui.Context, value *time.Time) *TimeControl

TimePicker displays a leading clock icon and a 24-hour HH:mm value. Its fixed popup contains independently scrolling hour (left) and minute (right) columns without scrollbars. Choosing an hour moves focus to minutes; choosing a minute confirms without closing the popup. Up/Down and Home/End move the focused column's draft cursor; Left/Right switch columns; Enter/Space activates it. Escape/outside press discards the draft. Opening reveals the current hour and minute. External changes reset the draft. Confirmation preserves the date, seconds, nanoseconds and location, subject to time.Date's normalization of nonexistent/ambiguous local times at DST changes. Key or disable a parent before construction; Label names the trigger.

func (*TimeControl) Changed

func (t *TimeControl) Changed() bool

Changed reports a confirmed time change, not opening or draft navigation.

type ToastContent added in v0.2026.8

type ToastContent struct {
	Leading func()
}

ToastContent is optional ui.Toast.Data for content slots. Leading replaces the type's status icon, for example with an image or a progress indicator; it runs synchronously while Toasts builds the toast.

type ToastOptions added in v0.2026.8

type ToastOptions struct {
	Placement ToastPlacement
	Inset     float32
}

ToastOptions customizes where Toasts places the window's toasts. The zero value stacks at the top center. Inset adds DIPs at the placement's edge beyond the standard margin, for example to clear a title bar; Shell adds its header height to top placements itself.

type ToastPlacement added in v0.2026.8

type ToastPlacement int

ToastPlacement selects the window edge and side where toasts stack. The zero value stacks at the top center. Top placements put the newest toast first, nearest the top edge, and stack older ones downward; bottom placements put it last, nearest the bottom edge.

const (
	ToastTop ToastPlacement = iota
	ToastTopStart
	ToastTopEnd
	ToastBottom
	ToastBottomStart
	ToastBottomEnd
)

func (ToastPlacement) Top added in v0.2026.8

func (p ToastPlacement) Top() bool

Top reports whether p places toasts at the top edge.

type TreeVirtualizedState

type TreeVirtualizedState[K comparable] struct {
	List ListState
	Open ui.Selection[K]
	// contains filtered or unexported fields
}

TreeVirtualizedState keeps keyed expansion, list selection and scrolling. Use one state per tree and do not copy it after first use. Keys must be unique throughout an acyclic tree. List.Selected optionally exposes the cursor; otherwise an internal cursor is used. List.Selection enables multi-selection.

func (*TreeVirtualizedState[K]) Depth

func (s *TreeVirtualizedState[K]) Depth(row int) int

func (*TreeVirtualizedState[K]) Item

func (s *TreeVirtualizedState[K]) Item(row int) K

func (*TreeVirtualizedState[K]) Rows

func (s *TreeVirtualizedState[K]) Rows() int

Rows reports the number of expanded rows in the last build.

Directories

Path Synopsis
Package chart composes Onevra charts from MyGo's scales, paths and selection.
Package chart composes Onevra charts from MyGo's scales, paths and selection.
Package chat composes native conversation views from Onevra controls and MyGo primitives.
Package chat composes native conversation views from Onevra controls and MyGo primitives.
Package command provides application-owned command views and dialogs.
Package command provides application-owned command views and dialogs.
Package flow draws a directed diagram, such as a workflow, a dependency graph or a plan of tasks, and lays it out automatically: nodes fall into ranks along the edges' direction, ranks are ordered to avoid crossings and edges run between them as orthogonal lines.
Package flow draws a directed diagram, such as a workflow, a dependency graph or a plan of tasks, and lays it out automatically: nodes fall into ranks along the edges' direction, ranks are ordered to avoid crossings and edges run between them as orthogonal lines.
Package gesture turns scroll and touchpad input into pan and zoom for canvases such as graphs, maps and image viewers: a mouse wheel and a touchpad pinch zoom, and two fingers dragged on a touchpad pan.
Package gesture turns scroll and touchpad input into pan and zoom for canvases such as graphs, maps and image viewers: a mouse wheel and a touchpad pinch zoom, and two fingers dragged on a touchpad pan.
Package graph draws an interactive force-directed relationship graph.
Package graph draws an interactive force-directed relationship graph.
Package shaders provides ambient GPU backgrounds for welcome and empty pages: quiet animated fields that follow the pointer and ripple where it clicks, behind application content.
Package shaders provides ambient GPU backgrounds for welcome and empty pages: quiet animated fields that follow the pointer and ripple where it clicks, behind application content.
Package treemap draws hierarchical values as nested, squarified rectangles whose areas follow their values, as disk-usage and budget views do.
Package treemap draws hierarchical values as nested, squarified rectangles whose areas follow their values, as disk-usage and budget views do.

Jump to

Keyboard shortcuts

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