astryx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 13 Imported by: 0

README

MyGo / Astryx

参考 Astryx 设计体系、基于 MyGo 实现的 Go 原生 UI 组件库。

提供 11 类、147 个公开组件入口、57 组可操作演示,覆盖固定版本 Astryx 根入口的 99 个 UI 组件族。组件包括自有外观、原生组合与 MyGo 高阶适配,尺寸与配色不重复计数。复合部件通过 Go 模型或插槽表示;具体映射和平台差异见 Astryx 覆盖清单。

要求 Go 1.27.3+,MyGo 固定为 v0.7.4。支持 MyGo 所支持的桌面平台,真实平台验证情况见下文。

go run ./cmd/gallery

也可以先构建再运行:

go build -o bin/gallery ./cmd/gallery
./bin/gallery

Gallery 包含分类导航、组件搜索与单项选择、系统/浅色/深色主题、代码示例、表单、菜单、浮层、数据和聊天控件。窄窗口自动改为分类选择器,Ctrl/⌘ K 打开命令面板。可用 Astryx 的原始名称搜索等价组件,并展开各演示的固定源码对照。

go run ./cmd/gallery -theme dark -page forms
go run ./cmd/gallery -theme dark -component Chat
go run ./cmd/gallery -focus
go run ./cmd/gallery -list
go run ./cmd/gallery -snapshot artifacts/gallery-light.png -theme light
go run ./cmd/gallery -snapshot artifacts/gallery-dark.png -theme dark
go run ./cmd/gallery -snapshot artifacts/gallery-narrow.png -width 420 -height 780

可用分类:layout、typography、actions、forms、navigation、feedback、overlays、data、menus、media、chat,以及 overview。

使用组件

通过 Go module 安装 v0.1.0:

go get github.com/Viking602/mygo-astryx@v0.1.0

在代码中引入并使用:

import (
    astryx "github.com/Viking602/mygo-astryx"
    "github.com/Viking602/mygo-astryx/theme"
    "github.com/egoist/mygo/ui"
)

func (app *State) view(c *ui.Context) {
    tokens := theme.Neutral(c.Theme().Dark, c.Preferences())
    astryx.Scope(c, tokens, func(k *astryx.UI) {
        k.Container().Children(func() {
            k.Heading("项目设置", 2)
            k.Field("名称", func() {
                k.Key("project-name").TextInput(&app.Name).FillWidth()
            })
            k.Button("保存", astryx.ButtonOptions{Variant: astryx.Primary}).
                OnClick(app.Save)
        })
        k.ToastViewport()
    }).Fill()
}

State、Name 和 Save 属于使用方自己的应用模型。完整可运行示例:

go run ./examples/basic

每次视图构建重新创建 builder。UI、ui.Element 和组合部件不跨构建保存;需要持久控件身份时使用 ui.Handle。有状态控件使用 k.Key(id).Control(...),它等价于在构造前调用 c.Key(id)。

组件范围

分类 数量 内容
布局 16 Stack、Grid、Layout 插槽、Resizable、AppShell 等
文字与展示 21 Markdown、CodeBlock、Citation、AvatarGroup、ClickableCard 等
动作 5 Button、IconButton、Toggle、ButtonGroup、Link
输入与选择 34 MultiSelector、Typeahead、PowerSearch、FileInput、Tokenizer、可替换指示器等
导航 16 TopNav、SideNav、MobileNav、MegaMenu、Outline、Stepper 等
反馈 10 Banner、StatusDot、Timer、Timestamp、Toast 等
浮层 9 Dialog、Drawer、HoverCard、BottomSheet、Overlay 等
数据与日期 11 Table、List、TreeList、DateRangeInput、DateTimeInput 等
菜单与命令 6 DropdownMenu、MoreMenu、ContextMenu、NavMenu、Toolbar、CommandPalette
图片与媒体 3 Thumbnail、Carousel、Lightbox
聊天与上下文 16 Chat、消息、输入、工具详情、上下文、反馈与听写服务接口

完整 API 与实现方式 · Astryx 覆盖清单 · 验证记录 · 架构

检查与预览

go test ./...
go vet ./...
make snapshots
make snapshots-all

测试覆盖关键交互、中文 IME、禁用选项、弹窗嵌套与焦点恢复、文件拖放与校验、筛选增删改、聊天发送与失败保留,以及每个公开组件在浅深色、1280/320 宽窗口下的渲染。snapshots-all 生成 57 组演示的 228 张截图,以及 10 种交互状态的 40 张截图和 JSON 报告。中性主题的主要文字颜色组合有对比度检查。

原生窗口冒烟验证需 Python 3 和可用的桌面会话:

make smoke-native

该命令仅在 e2e 构建中启用 MyGo 本地自动化,逐项选择全部 147 个入口并操作代表性控件,验证后关闭它启动的 Gallery。普通构建不包含此服务。结果、窗口截图和日志写入 artifacts/。

AI 后端、文件上传和系统听写由使用方接入;Gallery 的聊天与听写明确标为本地演示。本轮无窗口测试与截图通过,macOS 原生复验遇到首帧后不刷新的运行环境问题,最小 MyGo 程序也复现;原生遍历尚未完成。Windows/Linux 真实窗口、各平台读屏和完整视觉回归仍需分别验收。组件族覆盖不等于与 Astryx 的 React API 完全兼容,TabMenu 与 TableFooter 的保留差异已明确登记。

Documentation

Overview

Package astryx provides composable native Go UI components for MyGo.

Create a UI builder with New during each view build, or use Scope to apply a theme to an entire subtree. Builders, elements and component parts belong to that build pass; keep model state and ui.Handle values in your app. Stateful components should receive their identity through Context.Key before construction. The module path is local until a publishing repository is chosen.

Index

Constants

This section is empty.

Variables

View Source
var (
	IconPlus         = mustIcon(`<path d="M12 5v14M5 12h14"/>`)
	IconMinus        = mustIcon(`<path d="M5 12h14"/>`)
	IconClose        = mustIcon(`<path d="m6 6 12 12M18 6 6 18"/>`)
	IconCheck        = mustIcon(`<path d="m5 12.5 4.5 4.5L19 7.5"/>`)
	IconChevronDown  = mustIcon(`<path d="m6 9 6 6 6-6"/>`)
	IconChevronRight = mustIcon(`<path d="m9 6 6 6-6 6"/>`)
	IconChevronLeft  = mustIcon(`<path d="m15 6-6 6 6 6"/>`)
	IconMore         = mustIcon(`<circle cx="5" cy="12" r="1.2" fill="currentColor"/><circle cx="12" cy="12" r="1.2" fill="currentColor"/><circle cx="19" cy="12" r="1.2" fill="currentColor"/>`)
	IconCopy         = mustIcon(`<rect x="9" y="9" width="10" height="10" rx="2"/><path d="M15 9V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2"/>`)
	IconInfo         = mustIcon(`<circle cx="12" cy="12" r="9"/><path d="M12 16v-4M12 8h.01"/>`)
	IconUpload       = mustIcon(`<path d="M12 15V4m0 0-4 4m4-4 4 4M4 17v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"/>`)
	IconSearch       = mustIcon(`<circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 5 5"/>`)
	IconArrow        = mustIcon(`<path d="M5 12h14m-6-6 6 6-6 6"/>`)
	IconSettings     = mustIcon(`<path d="M4 7h16M4 17h16"/><circle cx="8" cy="7" r="3"/><circle cx="16" cy="17" r="3"/>`)
)

These original outline icons use the current text color. They are provided for examples and common actions; callers can supply any MyGo SVG.

Functions

func AddUploadPaths

func AddUploadPaths(state *FileInputState, paths []string, o FileInputOptions) bool

func Scope

func Scope(c *ui.Context, tokens theme.Theme, build func(*UI)) ui.Element

Scope builds a themed subtree. Its floating panels inherit this theme too. The returned container can be sized with ordinary MyGo element methods.

func ValidateDateRange

func ValidateDateRange(value DateRange, o DateRangeOptions) string

Types

type AlertDialogOptions

type AlertDialogOptions struct {
	Confirm, Cancel string
	Destructive     bool
	OnConfirm       func()
}

type AvatarGroupOptions

type AvatarGroupOptions struct {
	OverflowLabel string
	OnOverflow    func()
	Disabled      bool
}

type AvatarOptions

type AvatarOptions struct {
	Size       float32
	Status     string
	StatusTone Tone
	OnClick    func()
}

type AvatarStatusOptions

type AvatarStatusOptions struct {
	AvatarSize float32
	Icon       *ui.SVG
}

type BannerOptions

type BannerOptions struct {
	Tone                Tone
	Action, ActionLabel string
	OnAction            func()
	Dismissed           *bool
}
type Breadcrumb struct {
	Label   string
	OnClick func()
	Menu    []MenuEntry
}

type ButtonOptions

type ButtonOptions struct {
	Variant           Variant
	Size              Size
	Disabled, Loading bool
	Icon, EndIcon     *ui.SVG
}

ButtonOptions configures a button at construction. Native element methods remain available on the returned element for layout and event handling.

type CardOptions

type CardOptions struct {
	Padding  float32
	Elevated bool
}

type CarouselOptions

type CarouselOptions struct {
	Height float32
	Loop   bool
}

type CarouselSlide

type CarouselSlide struct {
	ID, Label string
	Content   func()
}

type ChatComposerInputOptions

type ChatComposerInputOptions struct {
	InputOptions
	MultilineEnter bool
	OnSend         func(string) bool
}

type ChatDraft

type ChatDraft struct {
	Text   string
	Tokens []ChatToken
}

type ChatMessageData

type ChatMessageData struct {
	ID, Role, Author, Text, Status, Reasoning string
	Time                                      time.Time
	Streaming, ReasoningOpen                  bool
	Tools                                     []ChatToolCall
	Reactions                                 []ChatReaction
	Tokens                                    []ChatToken
}

type ChatMessageOptions

type ChatMessageOptions struct {
	OnRetry    func(string)
	OnReaction func(string, int)
}

type ChatOptions

type ChatOptions struct {
	Placeholder                        string
	Disabled, ReadOnly, MultilineEnter bool
	OnSend                             func(ChatDraft) error
	OnStop                             func()
	Extras                             func()
	MessageOptions                     ChatMessageOptions
}

type ChatReaction

type ChatReaction struct {
	Label  string
	Count  int
	Active bool
}

type ChatState

type ChatState struct {
	Messages []ChatMessageData
	Draft    string
	Tokens   []ChatToken
	Busy     bool
	Error    string
	List     ui.ListState
	// contains filtered or unexported fields
}

type ChatTextRun

type ChatTextRun struct {
	Text  string
	Token *ChatToken
}

type ChatToken

type ChatToken struct{ ID, Label, Kind string }

type ChatToolCall

type ChatToolCall struct {
	ID, Name, Status, Input, Output string
	Expanded                        bool
}

type ChoiceOptions

type ChoiceOptions struct {
	Disabled, Mixed bool
	Size            Size
}

type CitationOptions

type CitationOptions struct {
	Detail, URL string
	OnClick     func()
}

type Command

type Command struct {
	ID, Label, Description, Group, Shortcut string
	Disabled                                bool
	Run                                     func()
}

type CommandPaletteOptions

type CommandPaletteOptions struct {
	Title, Placeholder, Empty string
	Width                     float32
	Inline                    bool
	Footer                    func()
}

type CommandPaletteState

type CommandPaletteState struct {
	Query  string
	Active int
	Chosen string
	// contains filtered or unexported fields
}

type ContextMenuOptions

type ContextMenuOptions struct{ Native bool }

type DateRange

type DateRange struct {
	Start, End time.Time
	Empty      bool
}

type DateRangeOptions

type DateRangeOptions struct {
	Label    string
	Min, Max time.Time
	MaxDays  int
	Disabled bool
	Presets  []DateRangePreset
	Allowed  func(time.Time) bool
	OnChange func(DateRange)
}

type DateRangePreset

type DateRangePreset struct {
	Label      string
	Start, End time.Time
}

type DialogOptions

type DialogOptions struct {
	Width       float32
	Description string
	Footer      func()
	Header      func()
}

type DictationOptions

type DictationOptions struct{ Start, Stop func() error }

type DictationState

type DictationState struct {
	Available, Recording bool
	Error                string
}

Dictation is a UI/service boundary. Native speech recognition is supplied by the host application; without both callbacks this control stays unavailable.

type Disclosure

type Disclosure struct {
	ID, Title string
	Open      *bool
	Content   func()
}

type FileInputOptions

type FileInputOptions struct {
	Label, Accept      string
	Multiple, Disabled bool
	MaxFiles           int
	MaxSize            int64
	Browse             func() ([]string, error)
	OnChange           func([]UploadFile)
}

type FileInputState

type FileInputState struct {
	Files    []UploadFile
	Error    string
	Busy     bool
	Progress float64
	// contains filtered or unexported fields
}

type FilterField

type FilterField struct {
	ID, Label, Kind string
	Operators       []string
	Options         []Option
	Validate        func(string) error
	Editor          func(*UI, *string)
}

type HoverCardOptions

type HoverCardOptions struct {
	Delay, HideDelay      time.Duration
	Disabled, OpenOnClick bool
	FocusOnOpen           bool
	Label                 string
	Width                 float32
	MaxHeight             float32
}

type ImageAsset

type ImageAsset struct {
	ID, Label string
	Source    ui.ImageSource
}

type IndicatorOptions

type IndicatorOptions struct {
	Size     Size
	Disabled bool
	Kind     string
}

type IndicatorState

type IndicatorState string
const (
	IndicatorUnchecked IndicatorState = "unchecked"
	IndicatorChecked   IndicatorState = "checked"
	IndicatorMixed     IndicatorState = "mixed"
)

type InputOptions

type InputOptions struct {
	Size                                   Size
	Label, Placeholder, Description, Error string
	Disabled, ReadOnly                     bool
	Focus                                  *ui.Handle
}

type ItemOptions

type ItemOptions struct {
	Description, Trailing, Avatar, Badge string
	BadgeTone                            Tone
	Icon                                 *ui.SVG
	Disabled, Selected                   bool
	OnClick                              func()
}

type LayoutSlots

type LayoutSlots struct {
	Header, Content, Panel, Footer func()
	PanelWidth                     float32
}

type MarkdownOptions

type MarkdownOptions struct {
	Native    *markdown.Options
	Streaming bool
}
type MenuEntry struct {
	ID, Label           string
	Group               string
	Disabled, Separator bool
	Checked             *bool
	Radio               *string
	Value               string
	Children            []MenuEntry
	Modifiers           ui.Modifiers
	Shortcut            ui.Key
	OnSelect            func()
}

MenuEntry is a stable, application-owned menu model. Checked and Radio bindings allow controlled checkbox/radio items; Children creates a submenu.

type Metadata

type Metadata struct{ Label, Value string }
type NavItem struct {
	ID, Label string
	Badge     string
	Icon      *ui.SVG
	Disabled  bool
	Section   string
	Children  []NavItem
}
type NavOptions struct {
	Label     string
	Collapsed *bool
}

type Option

type Option struct {
	Value, Label string
	Disabled     bool
}

Option separates a choice's stable value from its display label.

type OutlineItem

type OutlineItem struct {
	ID, Title string
	Level     int
}

type OverlayOptions

type OverlayOptions struct {
	NonModal, DismissOnOutside bool
	Label                      string
}

type Person

type Person struct {
	Name, Role, Status string
	StatusTone         Tone
	Image              *ui.Bitmap
}

type PowerSearchOptions

type PowerSearchOptions struct {
	Label              string
	Disabled, ReadOnly bool
	OnChange           func([]SearchFilter)
}

type PowerSearchState

type PowerSearchState struct {
	Query                                  string
	Filters                                []SearchFilter
	Field, Operator, Value, Editing, Error string
	// contains filtered or unexported fields
}

type ResizableOptions

type ResizableOptions struct {
	Min, Max                       float32
	Vertical, Percent, Collapsible bool
	OnResize                       func(float32)
}

type ResizableState

type ResizableState struct {
	Size      float32
	Collapsed bool
}

type ScrollOptions

type ScrollOptions struct{ Horizontal, Both bool }

type SearchFilter

type SearchFilter struct {
	ID, Field, Operator, Value string
	ReadOnly                   bool
}

type SelectionOptions

type SelectionOptions struct {
	Label       string
	Disabled    bool
	MaxSelected int
	OnChange    func([]string)
}

type Size

type Size uint8
const (
	Medium Size = iota
	Small
	Large
)

type Step

type Step struct {
	ID, Label, Description string
	Disabled, Error        bool
}

type StepperOptions

type StepperOptions struct {
	Vertical, ReadOnly, Linear bool
	OnChange                   func(int)
}

type Suggestion

type Suggestion struct {
	ID, Label, Description, Group string
	Disabled                      bool
}

type ThumbnailOptions

type ThumbnailOptions struct {
	Width, Height float32
	Selected      bool
	OnClick       func()
}

type TimerOptions

type TimerOptions struct {
	Clock bool
	Label string
}

type TimerState

type TimerState struct {
	Elapsed time.Duration
	Running bool
	// contains filtered or unexported fields
}

TimerState is an application-owned stopwatch model. Start/Pause use the caller's clock, which also makes tests deterministic.

func (*TimerState) Duration

func (s *TimerState) Duration(now time.Time) time.Duration

func (*TimerState) Pause

func (s *TimerState) Pause(now time.Time)

func (*TimerState) Reset

func (s *TimerState) Reset()

func (*TimerState) Start

func (s *TimerState) Start(now time.Time)

type TimestampOptions

type TimestampOptions struct {
	Format   string
	Location *time.Location
	Static   bool
	Copy     bool
}

type Tone

type Tone uint8
const (
	Neutral Tone = iota
	Info
	Success
	Warning
	Danger
)

type TypeaheadOptions

type TypeaheadOptions struct {
	InputOptions
	OnSelect func(Suggestion)
	OnQuery  func(string)
}

type TypeaheadState

type TypeaheadState struct {
	Query, Value string
	Loading      bool
	Error        string
}

type UI

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

UI builds components in one MyGo build pass. Do not store it in app state.

func New

func New(c *ui.Context) *UI

New follows the current host or scoped theme without changing it.

func (*UI) Accordion

func (k *UI) Accordion(items []Disclosure) ui.Element

func (*UI) Alert

func (k *UI) Alert(title, description string, tones ...Tone) ui.Element

func (*UI) AlertDialog

func (k *UI) AlertDialog(title, description string, open *bool, options ...AlertDialogOptions) ui.Element

func (*UI) AppShell

func (k *UI) AppShell(navigation, content func()) ui.Element

AppShell creates an adaptive navigation/content shell with an immersive window title bar region. At narrow widths the navigation becomes a compact top section; neither callback is omitted.

func (*UI) AspectRatio

func (k *UI) AspectRatio(ratio float32) ui.Element

func (*UI) Avatar

func (k *UI) Avatar(name string, image *ui.Bitmap, options ...AvatarOptions) ui.Element

Avatar composes the status into its accessible name. The status lives above the circular image's clipping boundary, so it stays visible at every size.

func (*UI) AvatarGroup

func (k *UI) AvatarGroup(people []Person, maximum int, options ...AvatarGroupOptions) ui.Element

func (*UI) AvatarGroupOverflow

func (k *UI) AvatarGroupOverflow(count int, options ...AvatarGroupOptions) ui.Element

AvatarGroupOverflow keeps the true hidden count in the accessible label, even when the visible text is customized (for example, "99+").

func (*UI) AvatarStatusDot

func (k *UI) AvatarStatusDot(label string, tone Tone, options ...AvatarStatusOptions) ui.Element

AvatarStatusDot distinguishes states by shape as well as color: filled for success, a ring for neutral, and a minus for danger.

func (*UI) Badge

func (k *UI) Badge(text string, tones ...Tone) ui.Element

func (*UI) Banner

func (k *UI) Banner(title, description string, options ...BannerOptions) ui.Element

func (*UI) Blockquote

func (k *UI) Blockquote(text, attribution string) ui.Element

func (*UI) BottomSheet

func (k *UI) BottomSheet(title string, open *bool, content func(), options ...DialogOptions) ui.Element

func (*UI) Breadcrumbs

func (k *UI) Breadcrumbs(items []Breadcrumb) ui.Element

func (*UI) Button

func (k *UI) Button(label string, options ...ButtonOptions) ui.Element

func (*UI) ButtonGroup

func (k *UI) ButtonGroup(build func()) ui.Element

func (*UI) Calendar

func (k *UI) Calendar(value *time.Time) ui.Element

func (*UI) Caption

func (k *UI) Caption(text string) ui.Element

func (*UI) Card

func (k *UI) Card(options ...CardOptions) ui.Element

func (*UI) Carousel

func (k *UI) Carousel(index *int, slides []CarouselSlide, options ...CarouselOptions) ui.Element

func (*UI) Center

func (k *UI) Center() ui.Element

func (*UI) Chat

func (k *UI) Chat(state *ChatState, options ...ChatOptions) ui.Element

func (*UI) ChatComposer

func (k *UI) ChatComposer(state *ChatState, options ...ChatOptions) ui.Element

func (*UI) ChatComposerDrawer

func (k *UI) ChatComposerDrawer(label string, open *bool, content func()) ui.Element

func (*UI) ChatComposerInput

func (k *UI) ChatComposerInput(value *string, options ...ChatComposerInputOptions) ui.Element

func (*UI) ChatComposerTokenElement

func (k *UI) ChatComposerTokenElement(token ChatToken, onRemove func()) ui.Element

func (*UI) ChatDictationButton

func (k *UI) ChatDictationButton(state *DictationState, options ...DictationOptions) ui.Element

func (*UI) ChatLayout

func (k *UI) ChatLayout(messages, composer func()) ui.Element

func (*UI) ChatLayoutScrollButton

func (k *UI) ChatLayoutScrollButton(state *ui.ListState, label string) ui.Element

func (*UI) ChatMessage

func (k *UI) ChatMessage(message *ChatMessageData, options ...ChatMessageOptions) ui.Element

func (*UI) ChatMessageBubble

func (k *UI) ChatMessageBubble(message ChatMessageData) ui.Element

func (*UI) ChatMessageList

func (k *UI) ChatMessageList(state *ui.ListState, messages []ChatMessageData, options ...ChatMessageOptions) ui.Element

func (*UI) ChatMessageMetadata

func (k *UI) ChatMessageMetadata(message ChatMessageData) ui.Element

func (*UI) ChatSendButton

func (k *UI) ChatSendButton(busy, canSend bool, onSend, onStop func()) ui.Element

func (*UI) ChatSystemMessage

func (k *UI) ChatSystemMessage(text string) ui.Element

func (*UI) ChatTokenizedText

func (k *UI) ChatTokenizedText(runs []ChatTextRun) ui.Element

func (*UI) ChatToolCalls

func (k *UI) ChatToolCalls(calls []ChatToolCall) ui.Element

func (*UI) CheckIndicator

func (k *UI) CheckIndicator(state IndicatorState, options ...IndicatorOptions) ui.Element

func (*UI) Checkbox

func (k *UI) Checkbox(value *bool, label string, options ...ChoiceOptions) ui.Element

func (*UI) CheckboxIndicator

func (k *UI) CheckboxIndicator(state IndicatorState, options ...IndicatorOptions) ui.Element

func (*UI) CheckboxList

func (k *UI) CheckboxList(values *[]string, items []Option, options ...SelectionOptions) ui.Element

func (*UI) Citation

func (k *UI) Citation(label string, options ...CitationOptions) ui.Element

func (*UI) ClickableCard

func (k *UI) ClickableCard(label string, build func(), options ...CardOptions) ui.Element

func (*UI) Code

func (k *UI) Code(text string) ui.Element

Code displays selectable monospace text, without interpreting it as markup.

func (*UI) CodeBlock

func (k *UI) CodeBlock(source, language string) ui.Element

CodeBlock uses MyGo's Markdown renderer for native syntax highlighting, selection and the copy action. A longer fence prevents source injection.

func (*UI) Collapsible

func (k *UI) Collapsible(label string, open *bool, build func()) ui.Element

func (*UI) ColorPicker

func (k *UI) ColorPicker(value *ui.Color) ui.Element

func (*UI) Combobox

func (k *UI) Combobox(value *string, items []string, options ...InputOptions) ui.Element

Combobox returns the editable input. It keeps MyGo's native text editing and keyboard selection; the model contains the selected or newly typed string.

func (*UI) CommandPalette

func (k *UI) CommandPalette(open *bool, state *CommandPaletteState, items []Command, options ...CommandPaletteOptions) ui.Element

func (*UI) ComplexSelector

func (k *UI) ComplexSelector(label string, open *bool, summary string, content func(close func()), options ...InputOptions) ui.Element

ComplexSelector delegates its popup body to the caller. The close callback captures only application state, so the caller may safely attach it to actions.

func (*UI) Container

func (k *UI) Container() ui.Element

func (*UI) ContextMenu

func (k *UI) ContextMenu(target ui.Element, entries []MenuEntry, options ...ContextMenuOptions) ui.Element

func (*UI) DateInput

func (k *UI) DateInput(value *time.Time) ui.Element

func (*UI) DateRangeInput

func (k *UI) DateRangeInput(value *DateRange, options ...DateRangeOptions) ui.Element

func (*UI) DateTimeInput

func (k *UI) DateTimeInput(value *time.Time, options ...InputOptions) ui.Element

func (*UI) Dialog

func (k *UI) Dialog(title string, open *bool, content func(), options ...DialogOptions) ui.Element

func (*UI) Divider

func (k *UI) Divider() ui.Element

func (*UI) Drawer

func (k *UI) Drawer(title string, open *bool, content func(), options ...DialogOptions) ui.Element

func (*UI) DropdownMenu

func (k *UI) DropdownMenu(label string, entries []MenuEntry, options ...ButtonOptions) ui.Element

func (*UI) EmptyState

func (k *UI) EmptyState(title, description string, action func()) ui.Element

func (*UI) Field

func (k *UI) Field(label string, build func(), options ...InputOptions) ui.Element

Field preserves MyGo's label-to-control and error-description relationships.

func (*UI) FieldStatus

func (k *UI) FieldStatus(message string, tone Tone) ui.Element

func (*UI) Fieldset

func (k *UI) Fieldset(legend string, build func()) ui.Element

func (*UI) FileInput

func (k *UI) FileInput(state *FileInputState, options ...FileInputOptions) ui.Element

func (*UI) Form

func (k *UI) Form(build func()) ui.Element

func (*UI) FormLayout

func (k *UI) FormLayout(columns int) ui.Element

func (*UI) Grid

func (k *UI) Grid(columns int) ui.Element

func (*UI) GridSpan

func (k *UI) GridSpan(columns int) ui.Element

func (*UI) HStack

func (k *UI) HStack() ui.Element

func (*UI) Heading

func (k *UI) Heading(text string, level int) ui.Element

func (*UI) HoverCard

func (k *UI) HoverCard(anchor ui.Element, content func(), options ...HoverCardOptions) ui.Element

func (*UI) Icon

func (k *UI) Icon(icon *ui.SVG) ui.Element

func (*UI) IconButton

func (k *UI) IconButton(label string, icon *ui.SVG, options ...ButtonOptions) ui.Element

IconButton requires a descriptive label, which is exposed to assistive tools.

func (*UI) Indicator

func (k *UI) Indicator(state IndicatorState, options ...IndicatorOptions) ui.Element

Indicator is a decorative control visual, not a notification badge. Its parent remains responsible for role, state, keyboard and focus behavior.

func (*UI) InfoTip

func (k *UI) InfoTip(label, description string) ui.Element

func (*UI) Inline

func (k *UI) Inline() ui.Element

Inline is a wrapping row, suitable for actions and compact controls.

func (*UI) InputClearButton

func (k *UI) InputClearButton(value *string, focus *ui.Handle, options ...ButtonOptions) ui.Element

func (*UI) InputGroup

func (k *UI) InputGroup(value *string, leading, trailing func(), options ...InputOptions) ui.Element

InputGroup adds leading/trailing content around an IME-aware native input. The root is returned for layout; the input can be customized inside Field.

func (*UI) Item

func (k *UI) Item(label string, options ...ItemOptions) ui.Element

func (*UI) Kbd

func (k *UI) Kbd(keys string) ui.Element

func (*UI) Key

func (k *UI) Key(id any) *UI

Key gives the next outer control a stable identity before it initializes state. It is equivalent to c.Key(id), and is intended for immediate chaining.

func (*UI) Layout

func (k *UI) Layout(slots LayoutSlots) ui.Element

func (*UI) Lightbox

func (k *UI) Lightbox(open *bool, index *int, images []ImageAsset) ui.Element
func (k *UI) Link(label, url string) ui.Element

func (*UI) List

func (k *UI) List(state *ui.ListState, count int, row func(int)) ui.Element

func (*UI) Markdown

func (k *UI) Markdown(source string, options ...MarkdownOptions) ui.Element

func (*UI) MetadataList

func (k *UI) MetadataList(items []Metadata) ui.Element

func (*UI) MobileNav

func (k *UI) MobileNav(selected *string, items []NavItem) ui.Element

func (*UI) MobileNavToggle

func (k *UI) MobileNavToggle(label string, open *bool, options ...ButtonOptions) ui.Element

MobileNavToggle binds an application's drawer/sheet visibility. The same boolean must be passed to that surface so Escape and outside presses update the trigger's expanded state as well.

func (*UI) MoreMenu

func (k *UI) MoreMenu(label string, entries []MenuEntry) ui.Element

func (*UI) MultiSelector

func (k *UI) MultiSelector(values *[]string, items []Option, options ...SelectionOptions) ui.Element

func (*UI) NavMenu

func (k *UI) NavMenu(label string, entries []MenuEntry) ui.Element

func (*UI) NumberInput

func (k *UI) NumberInput(value *float64, low, high, step float64, options ...InputOptions) ui.Element

NumberInput and SearchField are themed adapters to MyGo's complete controls.

func (*UI) Outline

func (k *UI) Outline(selected *string, items []OutlineItem, onNavigate func(string)) ui.Element

func (*UI) OverflowList

func (k *UI) OverflowList(items []NavItem, visible int, onSelect func(string)) ui.Element

func (*UI) Overlay

func (k *UI) Overlay(open *bool, build func(), options ...OverlayOptions) ui.Element

func (*UI) Pagination

func (k *UI) Pagination(page *int, pages int) ui.Element

Pagination uses one-based page numbers and clamps its model when totals shrink.

func (*UI) Popover

func (k *UI) Popover(anchor ui.Element, open *bool, content func()) ui.Element

func (*UI) PowerSearch

func (k *UI) PowerSearch(state *PowerSearchState, fields []FilterField, options ...PowerSearchOptions) ui.Element

func (*UI) Progress

func (k *UI) Progress(value float64) ui.Element

func (*UI) Radio

func (k *UI) Radio(value *string, choice, label string, options ...ChoiceOptions) ui.Element

func (*UI) RadioGroup

func (k *UI) RadioGroup(label string, build func()) ui.Element

func (*UI) RadioIndicator

func (k *UI) RadioIndicator(state IndicatorState, options ...IndicatorOptions) ui.Element

func (*UI) RadioList

func (k *UI) RadioList(value *string, items []Option, options ...InputOptions) ui.Element

func (*UI) RangeSlider

func (k *UI) RangeSlider(lowValue, highValue *float64, low, high, step float64) ui.Element

func (*UI) Rating

func (k *UI) Rating(value *int, maximum int) ui.Element

func (*UI) Resizable

func (k *UI) Resizable(state *ResizableState, first, second func(), options ...ResizableOptions) ui.Element

func (*UI) Scroll

func (k *UI) Scroll(options ...ScrollOptions) ui.Element

func (*UI) SearchField

func (k *UI) SearchField(value *string, options ...InputOptions) ui.Element

func (*UI) Section

func (k *UI) Section(title, description string, build func()) ui.Element

func (*UI) Segmented

func (k *UI) Segmented(selected *int, labels []string) ui.Element

func (*UI) Select

func (k *UI) Select(value *string, items []Option, options ...InputOptions) ui.Element

func (*UI) SelectableCard

func (k *UI) SelectableCard(selected *bool, label string, build func()) ui.Element

func (*UI) SideNav

func (k *UI) SideNav(selected *string, items []NavItem, options ...NavOptions) ui.Element

func (*UI) Sidebar

func (k *UI) Sidebar(selected *string, items []NavItem) ui.Element

func (*UI) Skeleton

func (k *UI) Skeleton(width, height float32) ui.Element

Skeleton is deliberately static: idle placeholders do not keep the window rendering and are suitable for users who request reduced motion.

func (*UI) Slider

func (k *UI) Slider(value *float64, low, high float64, options ...InputOptions) ui.Element

func (*UI) Spacer

func (k *UI) Spacer() ui.Element

func (*UI) Spinner

func (k *UI) Spinner() ui.Element

func (*UI) Split

func (k *UI) Split(position *float32, first, second func()) ui.Element

Split adapts the native resizable split view to this component set.

func (*UI) Stack

func (k *UI) Stack() ui.Element

Stack arranges children vertically with the design system's default gap.

func (*UI) StatusDot

func (k *UI) StatusDot(label string, tone Tone) ui.Element

func (*UI) Stepper

func (k *UI) Stepper(current *int, steps []Step, options ...StepperOptions) ui.Element

func (*UI) Switch

func (k *UI) Switch(value *bool, label string, options ...ChoiceOptions) ui.Element

func (*UI) Table

func (k *UI) Table(state *ui.ListState, columns []ui.TableColumn, count int, cell func(row, col int)) ui.Element

Table preserves MyGo's virtualized rows, selection, sorting and resizing. Configure ListState on the app model before calling Table.

func (*UI) Tabs

func (k *UI) Tabs(selected *int, labels []string) ui.Element

Tabs returns the tab list; the app renders its selected panel separately.

func (*UI) Text

func (k *UI) Text(text string) ui.Element

func (*UI) TextArea

func (k *UI) TextArea(value *string, options ...InputOptions) ui.Element

func (*UI) TextInput

func (k *UI) TextInput(value *string, options ...InputOptions) ui.Element

func (*UI) Thumbnail

func (k *UI) Thumbnail(image ImageAsset, options ...ThumbnailOptions) ui.Element

func (*UI) TimeInput

func (k *UI) TimeInput(value *time.Time) ui.Element

func (*UI) Timer

func (k *UI) Timer(state *TimerState, options ...TimerOptions) ui.Element

func (*UI) Timestamp

func (k *UI) Timestamp(value time.Time, options ...TimestampOptions) ui.Element

func (*UI) Toast

func (k *UI) Toast(message ui.Toast) string

Toast queues a message. Call it in response to an action, not unconditionally in a view. Include ToastViewport once in the view for the custom appearance.

func (*UI) ToastViewport

func (k *UI) ToastViewport() ui.Element

func (*UI) Toggle

func (k *UI) Toggle(on *bool, label string, options ...ButtonOptions) ui.Element

func (*UI) Token

func (k *UI) Token(label string, onRemove func()) ui.Element

func (*UI) Tokenizer

func (k *UI) Tokenizer(values *[]string, suggestions []string, options ...InputOptions) ui.Element

func (*UI) Tokens

func (k *UI) Tokens() theme.Theme

Tokens returns a copy of this builder's resolved tokens.

func (*UI) Toolbar

func (k *UI) Toolbar(label string, build func()) ui.Element

func (*UI) Tooltip

func (k *UI) Tooltip(anchor ui.Element, description string) ui.Element

func (*UI) TopNav

func (k *UI) TopNav(selected *string, items []NavItem, options ...NavOptions) ui.Element

func (*UI) TopNavMegaMenu

func (k *UI) TopNavMegaMenu(label string, items, featured func(), options ...HoverCardOptions) ui.Element

TopNavMegaMenu composes rich menu items with an optional featured panel. Pointer and keyboard users get the same content; narrow windows use a drawer.

func (*UI) TopNavMegaMenuItem

func (k *UI) TopNavMegaMenuItem(label string, options ...ItemOptions) ui.Element

TopNavMegaMenuItem closes its containing mega menu before running the host action. Ordinary Item remains suitable for controls that should keep it open.

func (*UI) Tree

func (k *UI) Tree(build func()) ui.Element

func (*UI) TreeItem

func (k *UI) TreeItem(label string, open *bool, build func()) ui.Element

func (*UI) TreeList

func (k *UI) TreeList(state *ui.OutlineState[string], roots []string, children func(string) []string, label func(string) string) ui.Element

func (*UI) Typeahead

func (k *UI) Typeahead(state *TypeaheadState, items []Suggestion, options ...TypeaheadOptions) ui.Element

func (*UI) VisuallyHidden

func (k *UI) VisuallyHidden(text string) ui.Element

VisuallyHidden keeps text available to assistive technology without taking layout room or pointer/keyboard input.

type UploadFile

type UploadFile struct {
	Path, Name, MIME string
	Size             int64
}

type Variant

type Variant uint8
const (
	Default Variant = iota
	Primary
	Outline
	Ghost
	Destructive
)

Directories

Path Synopsis
cmd
gallery command
Gallery is the native component explorer.
Gallery is the native component explorer.
examples
basic command
A small consumer of the public library, independent of Gallery internals.
A small consumer of the public library, independent of Gallery internals.
internal
catalog
Package catalog is the shared index for the Gallery and component docs.
Package catalog is the shared index for the Gallery and component docs.
gallery
Package gallery is the native, interactive component showcase.
Package gallery is the native, interactive component showcase.
Package theme defines semantic design tokens and their MyGo theme mapping.
Package theme defines semantic design tokens and their MyGo theme mapping.

Jump to

Keyboard shortcuts

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