Help us shape the future of Go! Take the 2026 Go Developer Survey

kit

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package kit is the Pando component library of the native desktop: the Web UI design tokens (web-ui/src/styles/tokens.css) ported onto MyGo's ui.Theme, an embedded lucide icon subset, and small components built on MyGo's widget bases. Views import kit for their look; only kit, shell and app/... import MyGo.

Index

Constants

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

Toast types understood by ToastViewport.

View Source
const (
	IconChat        = "message-square"
	IconSimpleChat  = "message-square-plus"
	IconProjects    = "folder-open"
	IconFolder      = "folder"
	IconFile        = "file"
	IconFileText    = "file-text"
	IconEditor      = "code"
	IconTerminal    = "square-terminal"
	IconOrchestrate = "network"
	IconDesign      = "palette"
	IconLogs        = "scroll-text"
	IconAgentVCS    = "git-branch"
	IconEvaluator   = "sparkles"
	IconInstances   = "server"
	IconSettings    = "settings"
	IconExtensions  = "puzzle"
	IconSetup       = "rocket"
	IconPlus        = "plus"
	IconSend        = "send"
	IconStop        = "square"
	IconClose       = "x"
	IconCheck       = "check"
	IconCopy        = "copy"
	IconTrash       = "trash"
	IconEdit        = "pencil"
	IconChevronDown = "chevron-down"
	IconChevronUp   = "chevron-up"
	IconChevronR    = "chevron-right"
	IconChevronL    = "chevron-left"
	IconSearch      = "search"
	IconRefresh     = "refresh-cw"
	IconSpinner     = "loader-circle"
	IconError       = "circle-alert"
	IconWarning     = "triangle-alert"
	IconInfo        = "info"
	IconSuccess     = "circle-check"
	IconThinking    = "brain"
	IconTool        = "wrench"
	IconSun         = "sun"
	IconMoon        = "moon"
	IconMonitor     = "monitor"
	IconPanelLeft   = "panel-left"
	IconPanelRight  = "panel-right"
	IconMore        = "ellipsis"
	IconArrowDown   = "arrow-down"
	IconArrowUp     = "arrow-up"
	IconExternal    = "external-link"
	IconBot         = "bot"
	IconUser        = "user"
	IconClock       = "clock"
	IconTodo        = "list-todo"
	IconHome        = "house"
	IconGlobe       = "globe"
)

Icon names used by the shell and the views. Prefer these constants over raw strings so a missing icon fails at review, not at run time.

View Source
const (
	IconBookOpen = "book-open"
	IconUpdate   = "circle-arrow-up"
	IconCommand  = "command"
	IconLogOut   = "log-out"
	IconKey      = "key"
)

Icons of the window shell (header, overlays).

View Source
const (
	IconMinus    = "minus"
	IconMaximize = "square"
	IconRestore  = "copy"
)

Icons of the custom window controls (minimise, maximise, restore).

Variables

DefaultSettings is Pando, following the system.

View Source
var ErrNoWebView = errors.New("embedded web views are not available in this window")

ErrNoWebView is the reason shown when no window is available to host a web view.

Functions

func Badge

func Badge(c *ui.Context, text string, tone Tone) ui.Element

Badge is a small pill label in a tone.

func Button

func Button(c *ui.Context, o ButtonOpts) ui.Element

Button is a Pando button on MyGo's ButtonBase. Read Clicked on the returned element. Give it a key (c.Key) when it is built in a loop.

func Card

func Card(c *ui.Context, fn func()) ui.Element

Card is a raised panel (bg-card, border, radius-md) holding fn's content in a column.

func CodeBlock

func CodeBlock(c *ui.Context, lang, code string, opts *markdown.Options) ui.Element

CodeBlock shows highlighted code with a copy button, through the markdown renderer (one fenced block). opts may be nil.

func CopyText

func CopyText(s string) bool

CopyText puts s on the system clipboard and reports success.

func Dialog

func Dialog(c *ui.Context, open *bool, o DialogOpts) ui.Element

Dialog shows a modal panel over a scrim while *open is true; Escape and a click outside close it.

func EmptyState

func EmptyState(c *ui.Context, icon, title, description string) ui.Element

EmptyState is a centred icon, title and description, for views with nothing to show yet.

func HasIcon

func HasIcon(name string) bool

HasIcon reports whether an icon is embedded.

func Icon

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

Icon shows an embedded icon in the current text colour, sized to the font size unless resized with FontSize or Size.

func IconButton

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

IconButton is a square ghost button showing an icon, named for assistive technology and the tooltip by label.

func IconNames

func IconNames() []string

IconNames lists the embedded icons.

func Input

func Input(c *ui.Context, value *string, placeholder string) ui.Element

Input is a single-line text input with Pando's field look. Read Changed/Submitted on the returned element.

func NavItem(c *ui.Context, icon, label string, active, collapsed bool) ui.Element

NavItem is an item of the app sidebar: an icon and a label (the label becomes a tooltip when collapsed). Read Clicked on the result.

func OpenWebWindow

func OpenWebWindow(title, url string, apply func(c *ui.Context)) *mygo.Window

OpenWebWindow opens a native window of its own showing url in an embedded web view (the design canvas, a preview). apply sets the theme each frame (usually kit.Apply(c, a.Theme)). Call it on the UI thread. Without WebKitGTK/WebView2 the window shows the fallback with "Open in browser".

func PrimaryButton

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

PrimaryButton is a Primary button with a label.

func SVG

func SVG(name string) *ui.SVG

SVG returns the embedded icon name, parsed once. An unknown name returns the "circle-alert" icon so a typo shows instead of crashing.

func SecondaryButton

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

SecondaryButton is a Secondary button with a label.

func SectionLabel

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

SectionLabel is the small uppercase heading of a sidebar section.

func Select

func Select(c *ui.Context, selected *string, options []string) ui.Element

Select chooses one of options into selected.

func SettingsRow

func SettingsRow(c *ui.Context, label, description string, control func()) ui.Element

SettingsRow is a row of a SettingsSection: a label and description on the left, the control on the right.

func SettingsSection

func SettingsSection(c *ui.Context, title, description string, fn func()) ui.Element

SettingsSection groups settings rows under a title (settings.css .settings-section).

func Spinner

func Spinner(c *ui.Context) ui.Element

Spinner is a rotating loader icon.

func Switch

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

Switch is a labelled on/off switch; the label toggles it too.

func ToastViewport

func ToastViewport(c *ui.Context)

ToastViewport shows the window's toasts bottom-right with Pando's look. Call it once in the root view.

func ToneColors

func ToneColors(tone Tone) (fg, bg ui.Color)

ToneColors returns the foreground and soft background of a tone.

func Tooltip

func Tooltip(el ui.Element, text string) ui.Element

Tooltip gives el a tooltip and an accessible description. It exists so views do not depend on MyGo's method name directly.

Types

type Accent

type Accent string

Accent is an accent preset of the Web UI (data-accent); "" keeps the family's own.

func Accents

func Accents() []Accent

Accents lists the accent presets.

type ButtonOpts

type ButtonOpts struct {
	Variant Variant
	Size    Size
	// Icon is an embedded icon name shown before the label.
	Icon  string
	Label string
	// Tooltip shows on hover; icon-only buttons should set it.
	Tooltip  string
	Disabled bool
	// Active draws a pressed/selected state (toggle buttons).
	Active bool
}

ButtonOpts configures Button.

type DialogOpts

type DialogOpts struct {
	Title       string
	Description string
	// Width of the panel in DIPs (default 440).
	Width float32
	// Body builds the content; Footer the buttons, laid out at the end.
	Body, Footer func()
}

DialogOpts configures Dialog.

type Family

type Family string

Family is a theme family of the Web UI (data-theme-name).

const (
	FamilyPando  Family = "pando"
	FamilyPaper  Family = "paper"
	FamilySlate  Family = "slate"
	FamilyForest Family = "forest"
)

Families.

func Families

func Families() []Family

Families lists the theme families, in the Web UI's order.

type Mode

type Mode string

Mode is the appearance preference: follow the system, or force one.

const (
	ModeSystem Mode = "system"
	ModeLight  Mode = "light"
	ModeDark   Mode = "dark"
)

Modes.

type Settings

type Settings struct {
	Family Family
	Mode   Mode
	Accent Accent
}

Settings selects the theme of the app: a family, an appearance mode and an optional accent preset (the Web UI's appearance settings).

type Size

type Size int

Size is the height of a control.

const (
	SizeMD Size = iota
	SizeSM
)

Control sizes: --control-h (32) and --control-h-sm (28).

type Toaster

type Toaster struct {
	Invalidate func()
	// contains filtered or unexported fields
}

Toaster queues toasts from any goroutine; the view flushes them into the window with Flush (c.AddToast needs the UI thread). Invalidate, when set, asks the window for a frame after Push.

func (*Toaster) Error

func (q *Toaster) Error(title, desc string)

Error queues an error toast that stays 8 seconds.

func (*Toaster) Flush

func (q *Toaster) Flush(c *ui.Context)

Flush adds the queued toasts to the window. Call it in the view.

func (*Toaster) Info

func (q *Toaster) Info(title, desc string)

Info, Success and Error queue a toast with a title and description.

func (*Toaster) Push

func (q *Toaster) Push(t ui.Toast)

Push queues a toast. Safe from any goroutine.

func (*Toaster) Success

func (q *Toaster) Success(title, desc string)

Success queues a success toast.

type Tokens

type Tokens struct {
	Family Family
	Dark   bool

	Bg, BgShell, BgRaised, BgCard, BgInput, BgOverlay, BgHover ui.Color
	Fg, FgMuted, FgFaint                                       ui.Color
	Border, BorderStrong                                       ui.Color
	Accent, AccentFg, AccentSoft, AccentHover, FocusRing       ui.Color
	Danger, Warning, Success, Info                             ui.Color
	DangerSoft, WarningSoft, SuccessSoft, InfoSoft             ui.Color
	Scrim                                                      ui.Color

	// Radii (DIPs): --radius-xs .. --radius-xl.
	RadiusXS, RadiusSM, RadiusMD, RadiusLG, RadiusXL float32
	// Text sizes (DIPs): --text-xs .. --text-2xl.
	TextXS, TextSM, TextBase, TextMD, TextLG, TextXL, Text2XL float32
	// ControlH and ControlHSm are the control heights.
	ControlH, ControlHSm float32
	// MonoFont is the code font family.
	MonoFont string
	// contains filtered or unexported fields
}

Tokens are the resolved design tokens of one theme: the semantic names of tokens.css. Use them for what ui.Theme has no slot for (shell and card backgrounds, faint text, soft status fills).

func Apply

func Apply(c *ui.Context, s Settings) *Tokens

Apply resolves the theme for this frame and installs it: call it first in the window's view. systemDark comes from c.Theme().Dark before any SetTheme, which follows the system appearance.

func Current

func Current() *Tokens

Current returns the tokens installed by the last Apply.

func Resolve

func Resolve(f Family, dark bool, accent Accent) *Tokens

Resolve returns the tokens of a family in light or dark, with an optional accent preset. Unknown families resolve to Pando.

func (*Tokens) Markdown

func (t *Tokens) Markdown() *markdown.Theme

Markdown returns the markdown theme matching the tokens.

func (*Tokens) UI

func (t *Tokens) UI() *ui.Theme

UI maps the tokens onto MyGo's theme, so MyGo's own widgets (lists, inputs, menus, scroll bars, tooltips) look like the rest of Pando.

type Tone

type Tone int

Tone colours badges and notices.

const (
	ToneNeutral Tone = iota
	ToneAccent
	ToneSuccess
	ToneWarning
	ToneDanger
	ToneInfo
)

Tones.

type Variant

type Variant int

Variant is the look of a button (web-ui/src/components/ui/Button).

const (
	Secondary Variant = iota
	Primary
	Ghost
	Danger
	Outline
)

Button variants.

type WebPane

type WebPane struct {
	// Host returns the window to create the web view in (nil in tests).
	Host func() WebViewHost
	// Preload is JavaScript run before the page's own scripts.
	Preload string
	// OnChange asks for a redraw (a load finished or failed).
	OnChange func()
	// contains filtered or unexported fields
}

WebPane is an embedded web view inside the native UI (MyGo ui.WebView): the preview canvas of the Design Studio, extension panels. The web view is created on first use; where the platform cannot provide one (Linux without WebKitGTK) the pane shows a message and an "Open in browser" button instead, so callers need no special case.

All methods run on the UI thread (Build and event handlers), except Eval/EvalAs which may run from any goroutine once Ready reports true.

func (*WebPane) Build

func (p *WebPane) Build(c *ui.Context, browserURL string)

Build draws the web view filling its container, or the fallback. Pass the URL to open in the system browser from the fallback (usually URL()).

func (*WebPane) Err

func (p *WebPane) Err() string

Err is why the web view is unavailable ("" when it is).

func (*WebPane) Eval

func (p *WebPane) Eval(code string) (any, error)

Eval runs JavaScript in the page and returns its value (the body of an async function: use return). Safe from goroutines.

func (*WebPane) Load

func (p *WebPane) Load(url string, force bool)

Load shows url, creating the web view on first use. An empty url keeps the current page. Loading the same URL again reloads it only when force is set.

func (*WebPane) LoadError

func (p *WebPane) LoadError() string

LoadError returns the last page load failure ("" when none).

func (*WebPane) Ready

func (p *WebPane) Ready() bool

Ready reports whether the web view exists.

func (*WebPane) Reload

func (p *WebPane) Reload()

Reload reloads the page.

func (*WebPane) URL

func (p *WebPane) URL() string

URL returns the URL the pane was asked to show.

type WebViewHost

type WebViewHost interface {
	NewWebView(opts mygo.WebViewOptions) (*mygo.WebView, error)
}

WebViewHost creates embedded web views; *mygo.Window implements it.

type WindowControl

type WindowControl int

WindowControl names a button of WindowControls.

const (
	ControlNone WindowControl = iota
	ControlMinimize
	ControlMaximize // maximise or restore, whichever the icon shows
	ControlClose
)

Window controls, in display order.

func WindowControls

func WindowControls(c *ui.Context, o WindowControlsOpts) WindowControl

WindowControls draws the minimise, maximise/restore and close buttons of a window without a native title bar, flush to the right edge of its parent row (the Web UI's DesktopWindowControls look: 44px wide, full height, a red hover on close). It returns the button clicked this frame, or ControlNone. Keys are "winctl:*".

type WindowControlsOpts

type WindowControlsOpts struct {
	// Maximized shows the restore icon instead of the maximise one.
	Maximized bool
	// Labels are the tooltips and accessible names (already translated).
	Minimize, Maximize, Restore, Close string
}

WindowControlsOpts configures WindowControls.

Jump to

Keyboard shortcuts

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