mygoui

package module
v0.1.0 Latest Latest
Warning

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

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

README

MyGo UI

A native Go component library for MyGo, reconstructing the component catalog and visual language of coss ui.

Typed options, explicit application state, semantic light/dark colors, and native editing, selection, focus and scrolling. Components compose through Go callbacks and typed collections. Applications run without a JavaScript runtime or WebView.

The native chart family adds the 19 Bklit chart subjects and composable axes, legends, brush and annotations, using the same coss theme. Its capability matrix records native subsets rather than full React parity.

The coss branch replaces the previous design and tokens. The capability matrix maps every component found across the pinned coss catalogs, plus their two documented hooks. A mapping records the native implementation and its limits; it does not certify visual or behavioral parity. Current verification belongs in VALIDATION.md.

The module targets Go 1.27.3 and pins MyGo v0.9.0 and mygoicons v0.2.1.

Development uses OpenSpec and Impeccable for requirements, scoped changes and native design review in Claude Code and Codex, sharing .agents/skills through .claude/skills. Start with make agents; these tools are optional development dependencies.

Try it

go run ./examples/basic
go run ./examples/gallery

make dev
make app

The gallery is a native component workbench with a custom title bar, grouped sidebar, Cmd/Ctrl+K search, an appearance popover, and Preview / Code / API / Tokens views. It reserves the platform's actual window-control insets rather than drawing replacement window buttons. Try it in the browser or download it for macOS, Windows or Linux from the latest release. Examples and snippets are consumers of the public API; the capability matrix records native adaptations and limits.

For external native-app tests, build the Gallery with -tags e2e and set MYGO_AUTOMATION to a socket path in a private directory. Normal builds do not import the automation plugin. See MyGo integration.

Use

Apply the theme at the start of each view build. Keep values and widget state with the window's model:

import (
    "github.com/Cyenoch/mygoui"
    "github.com/Cyenoch/mygoui/form"
    "github.com/Cyenoch/mygoui/theme"
    "github.com/egoist/mygo/ui"
)

type settings struct {
    name  string
    saved bool
}

func (s *settings) View(c *ui.Context) {
    theme.Apply(c)
    mygoui.Card(c, mygoui.CardOptions{}, func() {
        mygoui.CardHeader(c, func() {
            mygoui.CardTitle(c, "Project")
        })
        mygoui.CardContent(c, func() {
            form.Input(c, &s.name, form.InputOptions{
                Label: "Name", FullWidth: true,
            })
        })
        mygoui.CardFooter(c, func() {
            mygoui.Button(c, mygoui.ButtonOptions{
                Label: "Save",
                OnClick: func() { s.saved = true },
            })
        })
    })
}

ui.Element, custom parts and *ui.Context belong to the current build. Retain model values, component state and ui.Handle instead. Use native services for clipboard and URL actions; publish worker results through Window.Update. See ownership rules.

Customize

The canonical colors are coss roles such as Primary, Secondary, MutedBackground, MutedForeground, Accent, Card, Popover, Destructive, Input and Ring. Each has an independent override in theme.PalettePatch; light and dark appearances have separate patches.

primary := ui.RGB(30, 90, 180)
onPrimary := ui.RGB(255, 255, 255)
theme.Configure(theme.Preferences{
    Radius: 10,
    Palette: theme.PaletteOverrides{
        Light: &theme.PalettePatch{
            Primary: &primary, PrimaryForeground: &onPrimary,
        },
    },
})

Call Configure before building views, or use UpdatePreferences on the UI thread and invalidate the affected windows. Read colors live with theme.Colors(c). See theme tokens and provenance.

Body, heading and mono font families are independently configurable. Defaults use native system fonts, so text metrics differ from the coss site. Applications can opt into the embedded, independently OFL-licensed Cal Sans faces:

if err := fonts.Register(); err != nil {
    return err
}
theme.UpdatePreferences(func(p *theme.Preferences) {
    p.FontFamily = fonts.Family
    p.HeadingFontFamily = fonts.Family
})

Import github.com/Cyenoch/mygoui/fonts and call this during application startup in a function returning an error. Registration is explicit and idempotent; browser builds return an error. Mono keeps native fallbacks unless the host independently registers another face. See font sources, registration and limits. Configuring a family name alone does not load that font.

Scrolling

ScrollArea supports ScrollVertical, ScrollHorizontal and ScrollBoth. ScrollFade can also decorate an existing viewport and its ui.ScrollState. MaskFade fades the native subtree to transparency through a shader effect. ShadowFade paints an edge shadow; SurfaceFade blends into the actual opaque surface color. Effect layers have an 8192-pixel side limit and exclude embedded webviews; GPU/platform checks remain separate from headless rendering. See scroll examples and limits.

References and license

The visual reference is coss ui commit 3d8ca28e7d90123e9e0f44665944dc240b026ccb. Run make refs to check out its source at references/coss. Reference provenance identifies the MIT apps/ui registry and documentation. The upstream monorepo has mixed licensing; packages/* is outside that MIT scope, and its source and font assets must not be copied as MIT material.

Project code retains its MIT license. See third-party notices for reference attribution, dependencies and optional font licenses. This is an independent native implementation.

Documentation

Overview

Package mygoui provides native MyGo components following coss ui.

Apply theme.Apply at the start of a view. Callers own model values and widget state per window; constructors consume a build-scoped *ui.Context and return build-scoped ui.Element values. Retain ui.Handle for persistent focus and geometry, never elements or custom parts from an earlier build.

Composition uses typed options, content callbacks and keyed collections. Related controls live in form, navigation, overlay, date, data and other family packages. A card composes ordinary native children:

mygoui.Card(c, mygoui.CardOptions{}, func() {
	mygoui.CardHeader(c, func() {
		mygoui.CardTitle(c, "Project")
	})
	mygoui.CardContent(c, func() {
		mygoui.Paragraph(c, "Ready to deploy", false)
	})
})

Colors are read live through theme.Colors. Host preferences configure semantic roles, radii and body/heading/mono families; applications register their own fonts explicitly. Importing this library does not initialize an application or start I/O or background jobs.

ScrollArea wraps native scrolling. ScrollFade provides subtree alpha masking, shadow and opaque-surface edge treatments through native paint and effects. docs/components.md maps the coss catalog and native limits, docs/theme.md describes customization, and docs/references.md records source provenance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert

func Alert(c *ui.Context, o AlertOptions) ui.Element

Alert renders a status callout with an optional icon and action. It exposes ui.RoleStatus; MyGo does not have a separate alert role.

func Avatar

func Avatar(c *ui.Context, o AvatarOptions) ui.Element

Avatar shows an already-loaded image or initials. It never fetches.

func AvatarGroup

func AvatarGroup(c *ui.Context, o AvatarGroupOptions) ui.Element

AvatarGroup overlaps avatars by 30% of the group size and optionally adds background-colored rings. A Total above the displayed count adds overflow.

func Badge

func Badge(c *ui.Context, o BadgeOptions) ui.Element

Badge renders a compact COSS status label with a size-dependent minimum.

func BadgeAnchor

func BadgeAnchor(c *ui.Context, o BadgeAnchorOptions, body func()) ui.Element

BadgeAnchor places a badge at one corner without changing the content's layout. The badge can extend beyond the box and follows ancestor clipping.

func Button

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

Button builds a coss action on MyGo's native focusable button base. The pending spinner overlays invisible content, preserving the button width.

func ButtonGroup

func ButtonGroup(c *ui.Context, o ButtonGroupOptions, buttons ...ButtonOptions) ui.Element

ButtonGroup builds buttons with only the outer corners rounded, as coss ui does. The caller supplies complete button options, avoiding an ambient context and keeping each action independently focusable. Separators paint a half-height divider at each shared edge instead of taking layout width. Adjacent outline edges are removed, and buttons do not scale on press.

func Card

func Card(c *ui.Context, o CardOptions, body func()) ui.Element

Card is a bordered rounded surface. Each section owns its padding.

func CardContent

func CardContent(c *ui.Context, body func()) ui.Element

CardContent grows to fill the card, with horizontal padding and a 4 DIP gap. Standalone content can set vertical padding on the returned element.

func CardDescription

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

CardDescription renders coss ui's 14/20 muted card description.

func CardFooter

func CardFooter(c *ui.Context, body func()) ui.Element

CardFooter aligns actions in a wrapping row.

func CardFrame

func CardFrame(c *ui.Context, o CardFrameOptions, body func()) ui.Element

CardFrame builds a muted, bordered container for cards and frame sections.

func CardFrameDescription

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

CardFrameDescription renders secondary frame text.

func CardFrameFooter

func CardFrameFooter(c *ui.Context, body func()) ui.Element

CardFrameFooter hosts frame-level content below its cards.

func CardFrameHeader

func CardFrameHeader(c *ui.Context, body func()) ui.Element

CardFrameHeader groups frame metadata above its cards.

func CardFrameTitle

func CardFrameTitle(c *ui.Context, title string) ui.Element

CardFrameTitle renders a compact semibold frame title.

func CardHeader

func CardHeader(c *ui.Context, body func()) ui.Element

CardHeader groups a title and description.

func CardTitle

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

CardTitle renders coss ui's 18 DIP semibold heading.

func Chip

func Chip(c *ui.Context, o ChipOptions) ui.Element

Chip renders a compact status label. Its icon follows the label size.

func CloseButton

func CloseButton(c *ui.Context, o CloseButtonOptions) ui.Element

CloseButton is a 24 DIP dismiss button with a native focus ring and an animated hover face.

func Code

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

Code renders selectable inline code.

func EmptyState

func EmptyState(c *ui.Context, o EmptyStateOptions) ui.Element

EmptyState centers an icon, title, description and optional recovery action. With no content it shows the localized empty placeholder.

func Frame

func Frame(c *ui.Context, o FrameOptions, body func()) ui.Element

Frame builds coss's muted outer frame. Panels remain independently composable.

func FrameDescription

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

FrameDescription renders the frame's secondary text.

func FrameFooter

func FrameFooter(c *ui.Context, body func()) ui.Element

FrameFooter hosts frame-level actions outside its panels.

func FrameHeader

func FrameHeader(c *ui.Context, body func()) ui.Element

FrameHeader groups a frame's title and description.

func FramePanel

func FramePanel(c *ui.Context, body func()) ui.Element

FramePanel builds a bordered panel; callers can override native layout on return.

func FrameTitle

func FrameTitle(c *ui.Context, title string) ui.Element

FrameTitle renders a compact semibold frame title.

func Group

func Group(c *ui.Context, o GroupOptions, items ...GroupItem) ui.Element

Group composes native controls without an ambient provider or child inspection.

func GuideCard

func GuideCard(c *ui.Context, o GuideCardOptions) ui.Element

GuideCard is a card introducing a feature: cover, title, description, actions and a close button.

func Header(c *ui.Context, o HeaderOptions) ui.Element

Header is a small muted section heading used by menus and lists.

func Heading

func Heading(c *ui.Context, level int, text string) ui.Element

Heading renders a heading level 1–6.

func Image

func Image(c *ui.Context, o ImageOptions) ui.Element

Image shows an already-decoded picture in a rounded box, a skeleton while the caller loads it and a fallback when loading failed or there is no picture. It never fetches or decodes.

func Kbd

func Kbd(c *ui.Context, o KbdOptions) ui.Element

Kbd renders one coss ui keycap. Multiple keys form a chord separated by a thin gap, with the concatenated chord as its accessible text.

func KbdGroup

func KbdGroup(c *ui.Context, o KbdOptions) ui.Element

KbdGroup renders each key in a chord as a separate keycap.

func Link(c *ui.Context, o LinkOptions) ui.Element

Link is an inline, keyboard-focusable action. Hover, press and keyboard focus underline the label, and the trailing icon fades from 60% to full opacity. The underline is painted over the native text so the static layout does not shift. URL opening remains application work; the library performs no I/O.

func LinkButton

func LinkButton(c *ui.Context, o LinkButtonOptions) ui.Element

LinkButton is a text action with no hover background, padding or minimum height. It uses native button activation and focus.

func ListGroup

func ListGroup(c *ui.Context, o ListGroupOptions, body func()) ui.Element

ListGroup is a rounded surface containing related rows.

func ListGroupItem

func ListGroupItem(c *ui.Context, o ListGroupItemOptions) ui.Element

ListGroupItem renders a 16 DIP padded row with an optional chevron and real native activation. Prefix and suffix callbacks own their layout.

func Meter

func Meter(c *ui.Context, o MeterOptions) ui.Element

Meter renders a coss ui meter with its label and output.

func Paragraph

func Paragraph(c *ui.Context, text string, small bool) ui.Element

Paragraph renders selectable body copy at base or small size.

func PressableFeedback

func PressableFeedback(c *ui.Context, o PressableFeedbackOptions, body func()) ui.Element

PressableFeedback animates a 0.985 press scale and fades its hover and pressed surfaces. It does not draw a ripple.

func ProgressBar

func ProgressBar(c *ui.Context, o ProgressOptions) ui.Element

ProgressBar draws a linear determinate or indeterminate indicator, with an optional label and value output above the track.

func ProgressCircle

func ProgressCircle(c *ui.Context, o ProgressCircleOptions) ui.Element

ProgressCircle draws a determinate ring or an indeterminate native spinner and exposes its progress through native accessibility semantics.

func Prose

func Prose(c *ui.Context, body func()) ui.Element

Prose arranges caller-composed typography with an 8 DIP gap.

func ResizablePanel

func ResizablePanel(c *ui.Context, o ResizablePanelOptions, body func()) ui.Element

ResizablePanel sizes body along one axis and lets the user move the edge on Side by pointer or keyboard: arrows step 16 DIPs, Home and End go to Min and Max, and on a collapsible panel Enter or a double click toggles it. The cross axis stretches to the parent.

func Result

func Result(c *ui.Context, o ResultOptions) ui.Element

Result centers a status icon, title, description, actions and optional detail. Text and actions are an EmptyState; the icon carries the status.

func ScrollArea

func ScrollArea(c *ui.Context, state *ui.ScrollState, o ScrollAreaOptions, body func()) ui.Element

ScrollArea retains native scrolling, focus, wheel and scrollbar behavior.

func ScrollFade

func ScrollFade(c *ui.Context, viewport ui.Element, state *ui.ScrollState, o ScrollFadeOptions) ui.Element

ScrollFade decorates any native viewport tracking state, including existing application scroll views. It preserves native hit testing and adds no timer. MaskFade uses an effect on the viewport, replacing any existing effect; MyGo draws oversized effect layers normally and excludes embedded web views.

func ScrollShadow

func ScrollShadow(c *ui.Context, s *ui.ScrollState, o ScrollShadowOptions, body func()) ui.Element

ScrollShadow wraps caller-owned content in a native scroll viewport and fades both edges in proportion to the remaining scroll distance.

func Separator

func Separator(c *ui.Context, o SeparatorOptions) ui.Element

Separator draws a decorative 1 DIP rule. Vertical rules stretch to the row height.

func Sidebar(c *ui.Context, o SidebarOptions) ui.Element

Sidebar builds a scrollable navigation sidebar with a native collapse toggle and individually focusable navigation actions. The caller owns the selected ID, collapse state and the work performed by an activation.

func Skeleton

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

Skeleton paints a muted placeholder with a paint-only shimmer or pulse. Reduced motion and high contrast keep it still.

func SkeletonGroup

func SkeletonGroup(c *ui.Context, o SkeletonGroupOptions, body func()) ui.Element

SkeletonGroup lays out placeholders and animates the entire rendered subtree together. Skeletons inside a group should use SkeletonNone. While animated, MyGo excludes embedded web views and skips the effect if either layer side exceeds 8192 pixels.

func Spinner

func Spinner(c *ui.Context, o SpinnerOptions) ui.Element

Spinner uses MyGo's maintained arc indicator. The toolkit owns frame scheduling and reduced-motion poses. The native arc approximates COSS's rotating loading icon.

func StatusIcon

func StatusIcon(color StatusColor) *ui.SVG

StatusIcon is the coss icon for a status: info, check, triangle alert, or circle alert for danger.

func Surface

func Surface(c *ui.Context, o SurfaceOptions, body func()) ui.Element

Surface paints a theme surface and exposes the matching foreground.

func Tag

func Tag(c *ui.Context, o TagOptions) ui.Element

Tag renders one tag. Most callers use TagGroup; Tag is available for a standalone label.

func TagGroup

func TagGroup(c *ui.Context, o TagGroupOptions, tags []TagOptions) ui.Element

TagGroup lays out removable, optionally selectable tags. Tags stay smaller than buttons and expose native focus and removal actions.

func ToggleButton

func ToggleButton(c *ui.Context, o ToggleButtonOptions) ui.Element

ToggleButton is a focusable native toggle whose selected paint follows the caller's bool. It is not a radio: each button owns its state.

func ToggleButtonGroup

func ToggleButtonGroup(c *ui.Context, o ToggleButtonGroupOptions, buttons ...ToggleButtonOptions) ui.Element

ToggleButtonGroup lays out caller-owned toggle states. Each option carries its own Selected pointer, so single- and multi-select are both explicit Go state rather than an ambient group context. Outline-only groups join their items; other groups use independent rounded items with a 2 DIP gap.

func Typography

func Typography(c *ui.Context, text string, o TypographyOptions) ui.Element

Typography renders a semantic theme type role. Headings expose a heading role and level to assistive technology; body and code remain ordinary text.

Types

type AlertOptions

type AlertOptions struct {
	Title, Description string
	Status             StatusColor
	Icon               *ui.SVG
	// ShowIcon uses the status glyph when Icon is nil.
	ShowIcon bool
	Action   func()
}

AlertOptions configures a coss ui status callout.

type Align

type Align uint8

Align is placement alignment along the chosen edge.

const (
	AlignCenter Align = iota
	AlignStart
	AlignEnd
)

type AvatarGroupOptions

type AvatarGroupOptions struct {
	Size    AvatarSize
	Overlap float32
	Ring    bool
	Grid    bool
	Total   int
	Avatars []AvatarOptions
}

AvatarGroupOptions configures an avatar stack or grid.

type AvatarOptions

type AvatarOptions struct {
	Image    ui.ImageSource
	Name     string
	Fallback string
	Size     AvatarSize
	Soft     bool
	Ring     bool
	Color    StatusColor
	Badge    func()
}

AvatarOptions configures a caller-loaded avatar. Name is the accessible name; Fallback overrides generated initials.

type AvatarSize

type AvatarSize uint8

AvatarSize selects a native avatar size.

const (
	AvatarMedium AvatarSize = iota
	AvatarSmall
	AvatarLarge
)

type BadgeAnchorOptions

type BadgeAnchorOptions struct {
	Placement BadgePlacement
	Badge     BadgeOptions
}

BadgeAnchorOptions places a badge over caller content.

type BadgeOptions

type BadgeOptions struct {
	Label   string
	Variant BadgeVariant
	Size    BadgeSize
	Icon    *ui.SVG
}

BadgeOptions configures a coss ui badge.

type BadgePlacement

type BadgePlacement uint8

BadgePlacement is the corner used by BadgeAnchor.

const (
	BadgeTopRight BadgePlacement = iota
	BadgeTopLeft
	BadgeBottomRight
	BadgeBottomLeft
)

type BadgeSize

type BadgeSize uint8

BadgeSize is coss ui's badge scale.

const (
	BadgeMedium BadgeSize = iota
	BadgeSmall
	BadgeLarge
)

type BadgeVariant

type BadgeVariant uint8

BadgeVariant selects a coss ui badge surface treatment.

const (
	BadgePrimary BadgeVariant = iota
	BadgeSecondary
	BadgeOutline
	BadgeDestructive
	BadgeError
	BadgeInfo
	BadgeSuccess
	BadgeWarning
)

type ButtonAlign

type ButtonAlign uint8

ButtonAlign places button content.

const (
	ButtonAlignCenter ButtonAlign = iota
	ButtonAlignStart
	ButtonAlignEnd
)

type ButtonGroupOptions

type ButtonGroupOptions struct {
	Orientation ButtonGroupOrientation
	FullWidth   bool
	Separators  bool
}

ButtonGroupOptions controls a joined set of coss ui buttons.

type ButtonGroupOrientation

type ButtonGroupOrientation uint8

ButtonGroupOrientation selects the join axis.

const (
	GroupHorizontal ButtonGroupOrientation = iota
	GroupVertical
)

type ButtonOptions

type ButtonOptions struct {
	Label     string
	Icon      *ui.SVG
	EndIcon   *ui.SVG
	Variant   ButtonVariant
	Size      theme.ButtonSize
	IconOnly  bool
	FullWidth bool
	Loading   bool
	Disabled  bool
	OnClick   func()
	Handle    *ui.Handle
	Tooltip   string
	Content   func()

	// Align overrides the centered label placement, for navigation rows and
	// other left-aligned actions.
	Align ButtonAlign

	// Corners overrides the uniform coss ui radius. Nil keeps the default;
	// a zero array makes square corners.
	Corners *[4]float32
}

ButtonOptions configures a native button. Label is always the accessible name, including icon-only layouts and custom content.

type ButtonVariant

type ButtonVariant uint8

ButtonVariant selects a button face, including native theme extensions.

const (
	ButtonPrimary ButtonVariant = iota
	ButtonSecondary
	ButtonTertiary
	ButtonOutline
	ButtonGhost
	ButtonDanger
	ButtonDangerSoft
	ButtonDestructiveOutline
	ButtonLink
)

type CardFrameOptions

type CardFrameOptions struct {
	Label string
}

CardFrameOptions configures a framed group of cards and supporting content.

type CardOptions

type CardOptions struct {
	Variant CardVariant
	Label   string
	OnClick func()
	Handle  *ui.Handle
}

CardOptions customizes a coss ui Card. OnClick makes the whole card a real native action without changing its visual variants.

type CardVariant

type CardVariant uint8

CardVariant selects a card surface, including native theme extensions.

const (
	CardDefault CardVariant = iota
	CardSecondary
	CardTertiary
	CardTransparent
)

type ChipOptions

type ChipOptions struct {
	Label   string
	Color   StatusColor
	Variant ChipVariant
	Size    ChipSize
	Icon    *ui.SVG
}

ChipOptions configures a compact native chip.

type ChipSize

type ChipSize uint8

ChipSize selects the chip's density.

const (
	ChipMedium ChipSize = iota
	ChipSmall
	ChipLarge
)

type ChipVariant

type ChipVariant uint8

ChipVariant selects a native chip surface treatment.

const (
	ChipSecondary ChipVariant = iota
	ChipPrimary
	ChipSoft
	ChipTertiary
)

type CloseButtonOptions

type CloseButtonOptions struct {
	Label    string
	Disabled bool
	OnClick  func()
}

CloseButtonOptions configures the compact dismiss control.

type EmptyStateOptions

type EmptyStateOptions struct {
	Title, Description string
	Icon               *ui.SVG
	Action             func()
}

EmptyStateOptions configures a quiet empty result.

type FlyoutHost

type FlyoutHost struct {
	Window *mygo.Window
}

FlyoutHost lets anchored popups open as native flyouts of Window, so they can extend beyond it. Keep one per window and pass a pointer to it in a popup's options. A nil host, a nil Window or a platform without flyouts (WebAssembly) keeps the popup inside the window.

type FrameOptions

type FrameOptions struct {
	Padding, Gap float32
	Label        string
}

FrameOptions configures the inset between a frame and its independent panels.

type GroupItem

type GroupItem struct {
	Key   string
	Build func(corners [4]float32) ui.Element
}

GroupItem builds one control with the supplied outer-only corner radii. A mixed group can combine buttons, editors and application-defined controls.

type GroupOptions

type GroupOptions struct {
	Orientation Orientation
	FullWidth   bool
	Label       string
}

GroupOptions configures joined controls. Each item receives its own corners before construction, so its paint and keyboard focus use the same geometry.

type GuideCardOptions

type GuideCardOptions struct {
	Title, Description string
	Cover              ui.ImageSource
	CoverContent       func()
	Actions            func()
	OnDismiss          func()
}

GuideCardOptions configures a dismissible tip. Cover is an already-decoded picture shown across the top at its own ratio; CoverContent builds a custom cover instead. OnDismiss adds the close button: the caller stops rendering the card.

type HeaderOptions

type HeaderOptions struct {
	Text string
}

HeaderOptions configures a section header.

type ImageFit

type ImageFit uint8

ImageFit selects how the picture fills its box.

const (
	ImageCover ImageFit = iota
	ImageContain
)

type ImageOptions

type ImageOptions struct {
	Source        ui.ImageSource
	Label         string
	Width, Height float32
	AspectRatio   float32
	Fit           ImageFit
	Radius        float32
	Status        ImageStatus
	// Fallback adds content under the failed icon.
	Fallback func()
	// OnClick makes a shown picture a button, as for opening a preview.
	OnClick func()
}

ImageOptions configures a caller-loaded image. Label is the accessible name. A zero Width fills the parent. Height wins over AspectRatio (width / height); with neither, the box takes the picture's own ratio, or 16:9 while there is none. A nonpositive Radius uses the theme's large radius.

type ImageStatus

type ImageStatus uint8

ImageStatus is the caller's load state for an Image.

const (
	ImageReady ImageStatus = iota
	ImageLoading
	ImageFailed
)

type IndicatorColor

type IndicatorColor uint8

IndicatorColor is the color of a progress or meter indicator. Its zero value uses the primary color, unlike the status colors used by chips.

const (
	IndicatorAccent IndicatorColor = iota
	IndicatorDefault
	IndicatorSuccess
	IndicatorWarning
	IndicatorDanger
)

type KbdOptions

type KbdOptions struct {
	Keys []string
	// Light removes the default background.
	Light bool
}

KbdOptions configures a keyboard chord.

type LinkButtonOptions

type LinkButtonOptions struct {
	Label    string
	Icon     *ui.SVG
	Disabled bool
	OnClick  func()
}

LinkButtonOptions configures a link-style native button.

type LinkOptions

type LinkOptions struct {
	Label    string
	Icon     *ui.SVG
	Disabled bool
	OnClick  func()
	Tooltip  string
}

LinkOptions configures an inline native action.

type ListGroupItemOptions

type ListGroupItemOptions struct {
	Title, Description string
	Prefix, Suffix     func()
	Chevron            bool
	Disabled           bool
	OnClick            func()
}

ListGroupItemOptions configures one row.

type ListGroupOptions

type ListGroupOptions struct {
	Variant SurfaceVariant
	Label   string
}

ListGroupOptions configures a native list group.

type MeterOptions

type MeterOptions struct {
	Label           string
	Value, Min, Max float64
	Color           IndicatorColor
	Size            ProgressSize
	ShowOutput      bool
	OutputText      string
}

MeterOptions configures a quantity within a known range.

type Orientation

type Orientation uint8

Orientation is a horizontal or vertical layout direction.

const (
	Horizontal Orientation = iota
	Vertical
)

type PanelSide

type PanelSide uint8

PanelSide selects the edge of a ResizablePanel that carries its handle. Start and end follow the layout direction.

const (
	PanelEnd PanelSide = iota
	PanelStart
	PanelTop
	PanelBottom
)

type Placement

type Placement struct {
	Side   Side
	Align  Align
	Offset float32
}

Placement anchors a floating panel. Offset is the gap from the anchor; zero uses the component's default gap, typically 4 DIPs.

type PressableFeedbackOptions

type PressableFeedbackOptions struct {
	Label     string
	Disabled  bool
	FullWidth bool
	OnClick   func()
}

PressableFeedbackOptions configures a native press-feedback container.

type ProgressCircleOptions

type ProgressCircleOptions struct {
	Label           string
	Value, Min, Max float64
	Indeterminate   bool
	Color           IndicatorColor
	Size            ProgressSize
	ShowOutput      bool
}

ProgressCircleOptions configures a circular indicator.

type ProgressOptions

type ProgressOptions struct {
	Label           string
	Value, Min, Max float64
	Indeterminate   bool
	Color           IndicatorColor
	Size            ProgressSize
	ShowOutput      bool
	OutputText      string
}

ProgressOptions configures a coss ui bar indicator.

type ProgressSize

type ProgressSize uint8

ProgressSize selects a native meter or progress track height.

const (
	ProgressMedium ProgressSize = iota
	ProgressSmall
	ProgressLarge
)

type ResizablePanelOptions

type ResizablePanelOptions struct {
	Label            string
	Side             PanelSide
	Size             *float32
	Min, Max         float32
	Collapsed        *bool
	OnResize         func(size float32)
	OnCollapseChange func(collapsed bool)
}

ResizablePanelOptions configures a panel resized from one edge. Size, Min and Max are DIPs along the resized axis before the text scale; Size is always shown within [Min, Max], and a nonpositive Max sets no upper bound. A nil Size is kept by the panel. A non-nil Collapsed makes the panel collapsible. Label names the handle and defaults to the locale's Resize.

type ResultOptions

type ResultOptions struct {
	Status             StatusColor
	Title, Description string
	Icon               *ui.SVG
	// Actions builds the buttons under the text.
	Actions func()
	// Content builds supporting detail under the actions.
	Content func()
}

ResultOptions configures the outcome of an operation. Status picks the tint and the default icon; Icon replaces the glyph and keeps the tint.

type ScrollAreaOptions

type ScrollAreaOptions struct {
	Axis   ScrollAxis
	Height float32
	Label  string
	Fade   *ScrollFadeOptions
}

ScrollAreaOptions configures coss's scroll viewport with native scrollbars.

type ScrollAxis

type ScrollAxis uint8

ScrollAxis selects the axes of a native scroll area.

const (
	ScrollVertical ScrollAxis = iota
	ScrollHorizontal
	ScrollBoth
)

type ScrollFadeEdges

type ScrollFadeEdges uint8

ScrollFadeEdges selects physical viewport edges; zero enables every edge.

const (
	FadeTop ScrollFadeEdges = 1 << iota
	FadeRight
	FadeBottom
	FadeLeft
)

type ScrollFadeMode

type ScrollFadeMode uint8

ScrollFadeMode selects a native edge treatment.

const (
	ShadowFade ScrollFadeMode = iota
	SurfaceFade
	// MaskFade fades the viewport and its descendants to transparency.
	MaskFade
)

type ScrollFadeOptions

type ScrollFadeOptions struct {
	Mode    ScrollFadeMode
	Edges   ScrollFadeEdges
	Size    float32
	Surface ui.Color
	Color   ui.Color
}

ScrollFadeOptions customizes an edge fade independently of scrolling. SurfaceFade requires the actual opaque surface. Color customizes a shadow. MaskFade uses a subtree effect and needs neither Surface nor Color.

type ScrollShadowOptions

type ScrollShadowOptions struct {
	Orientation ScrollShadowOrientation
	Surface     ui.Color
	Size        float32
	Height      float32
	Label       string
}

ScrollShadowOptions describes an opaque scrolling surface. The edge fade is painted in Surface, which should be the actual opaque background. ScrollArea with MaskFade instead fades content to transparency.

type ScrollShadowOrientation

type ScrollShadowOrientation uint8

ScrollShadowOrientation selects the scroll axis; vertical is the default.

const (
	ScrollShadowVertical ScrollShadowOrientation = iota
	ScrollShadowHorizontal
)

type SeparatorColor

type SeparatorColor uint8

SeparatorColor selects the divider's emphasis.

const (
	SeparatorDefault SeparatorColor = iota
	SeparatorSecondary
	SeparatorTertiary
)

type SeparatorOptions

type SeparatorOptions struct {
	Orientation Orientation
	Color       SeparatorColor
}

SeparatorOptions configures a semantic divider.

type Side

type Side uint8

Side is a placement edge. SideAuto selects the component's default edge.

const (
	SideAuto Side = iota
	SideTop
	SideBottom
	SideLeft
	SideRight
)

type SidebarGroupOptions

type SidebarGroupOptions struct {
	Key   string
	Label string
	Items []SidebarItemOptions
}

SidebarGroupOptions groups navigation actions under an optional label. Key preserves the group's identity when groups are reordered and must be unique among groups when set. Without a key, its position is its identity.

type SidebarItemOptions

type SidebarItemOptions struct {
	ID       string
	Label    string
	Icon     *ui.SVG
	Disabled bool
	OnClick  func()
}

SidebarItemOptions describes one navigation action. ID must be nonempty and unique within the sidebar; Label is its accessible name. OnClick runs after the selection is updated.

type SidebarOptions

type SidebarOptions struct {
	Selected         *string
	Collapsed        *bool
	Groups           []SidebarGroupOptions
	Header           func()
	Footer           func()
	Width            float32
	CollapsedWidth   float32
	Label            string
	ToggleLabel      string
	OnSelect         func(id string)
	OnCollapseChange func(collapsed bool)
}

SidebarOptions configures a sidebar. Selected and Collapsed are required caller-owned per-window state, and an empty Selected means no selection. Width and CollapsedWidth scale with the text size; nonpositive values use coss ui's 256 and 48 DIP defaults. Header and Footer build their own content in both states and can read Collapsed to adapt their layout. A collapsed item without an icon retains its text so it remains usable.

OnSelect runs for every enabled activation, including the current item, before the item's OnClick. ToggleLabel can replace the English accessible name of the toggle.

type SkeletonAnimation

type SkeletonAnimation uint8

SkeletonAnimation selects placeholder motion; shimmer is the COSS default.

const (
	SkeletonShimmer SkeletonAnimation = iota
	SkeletonPulse
	SkeletonNone
)

type SkeletonGroupOptions

type SkeletonGroupOptions struct {
	Animation SkeletonAnimation
}

SkeletonGroupOptions coordinates placeholder animation.

type SkeletonOptions

type SkeletonOptions struct {
	Width, Height float32
	Radius        float32
	Circle        bool
	Animation     SkeletonAnimation
}

SkeletonOptions reserves the shape of loading content.

type SpinnerOptions

type SpinnerOptions struct {
	Size  SpinnerSize
	Color StatusColor
	Label string
}

SpinnerOptions configures a loading indicator.

type SpinnerSize

type SpinnerSize uint8

SpinnerSize selects a native loading indicator size.

const (
	SpinnerMedium SpinnerSize = iota
	SpinnerSmall
	SpinnerLarge
	SpinnerExtraLarge
)

type StatusColor

type StatusColor uint8

StatusColor selects a semantic color for native status components.

const (
	ColorDefault StatusColor = iota
	ColorAccent
	ColorSuccess
	ColorWarning
	ColorDanger
	// ColorInfo uses the theme's informational color.
	ColorInfo
)

type StatusPalette

type StatusPalette struct {
	Solid, SolidForeground ui.Color
	Hover                  ui.Color
	Soft, SoftForeground   ui.Color
	SoftHover              ui.Color
	Foreground             ui.Color
}

StatusPalette is the resolved color set for one coss ui status. Components and applications use it to paint custom status surfaces consistently.

func StatusColors

func StatusColors(c *ui.Context, color StatusColor) StatusPalette

StatusColors resolves a status against the live theme.

type SurfaceOptions

type SurfaceOptions struct {
	Variant   SurfaceVariant
	Padding   float32
	Radius    float32
	FillWidth bool
	Label     string
}

SurfaceOptions customizes a native Surface. Padding and Radius default to zero so callers can compose their own layout.

type SurfaceVariant

type SurfaceVariant uint8

SurfaceVariant selects a native container surface.

const (
	SurfaceDefault SurfaceVariant = iota
	SurfaceSecondary
	SurfaceTertiary
	SurfaceTransparent
)

type TagGroupOptions

type TagGroupOptions struct {
	Label, Description, Error string
	Selection                 TagSelection
	Size                      TagSize
	Variant                   TagVariant
	State                     *TagGroupState
	OnChange                  func(keys []string)
}

TagGroupOptions configures a focusable tag collection.

type TagGroupState

type TagGroupState struct {
	Selected map[string]bool
}

TagGroupState is caller-owned tag selection.

func (*TagGroupState) IsSelected

func (s *TagGroupState) IsSelected(key string) bool

IsSelected reports whether key is chosen.

type TagOptions

type TagOptions struct {
	Key       string
	Label     string
	Icon      *ui.SVG
	Removable bool
	Disabled  bool
	OnRemove  func()
	OnClick   func()
}

TagOptions configures one tag.

type TagSelection

type TagSelection uint8

TagSelection selects the tag group's selection behavior.

const (
	TagSelectNone TagSelection = iota
	TagSelectSingle
	TagSelectMultiple
)

type TagSize

type TagSize uint8

TagSize selects the tag's density.

const (
	TagMedium TagSize = iota
	TagSmall
	TagLarge
)

type TagVariant

type TagVariant uint8

TagVariant selects the unselected tag surface.

const (
	TagDefault TagVariant = iota
	TagSurface
)

type ToggleButtonGroupOptions

type ToggleButtonGroupOptions struct {
	Orientation Orientation
	FullWidth   bool
	// Detached keeps a 4 DIP gap even for outline toggles.
	Detached bool
	// Separators paints a divider at the shared edges of joined outline toggles.
	Separators bool
}

ToggleButtonGroupOptions controls a joined or detached toggle set.

type ToggleButtonOptions

type ToggleButtonOptions struct {
	Label     string
	Icon      *ui.SVG
	Variant   ToggleButtonVariant
	Size      theme.ButtonSize
	IconOnly  bool
	FullWidth bool
	Selected  *bool
	Disabled  bool
	OnChange  func(bool)
	Tooltip   string
	// Corners overrides the uniform radius. Nil keeps it.
	Corners *[4]float32
}

ToggleButtonOptions configures a persistent pressed-state button. Selected is caller-owned; clicking flips it and reports the new value.

type ToggleButtonVariant

type ToggleButtonVariant uint8

ToggleButtonVariant selects a toggle surface, including a native ghost variant.

const (
	ToggleDefault ToggleButtonVariant = iota
	ToggleGhost
	ToggleOutline
)

type TypographyOptions

type TypographyOptions struct {
	Type       theme.SemanticType
	Muted      bool
	Truncate   bool
	Align      ui.Align
	Weight     int
	Selectable bool
	Level      int
}

TypographyOptions selects a semantic theme role and emphasis.

Directories

Path Synopsis
Package chart provides native, coss-themed charts inspired by Bklit's MIT chart catalog.
Package chart provides native, coss-themed charts inspired by Bklit's MIT chart catalog.
Package color implements color controls with native MyGo painting, keyboard handling and accessibility.
Package color implements color controls with native MyGo painting, keyboard handling and accessibility.
Package content provides native components that copy, colour and render text: a copy button, a one-line snippet, a highlighted code block, themed Markdown and a QR code.
Package content provides native components that copy, colour and render text: a copy button, a one-line snippet, a highlighted code block, themed Markdown and a QR code.
Package data provides a COSS-inspired native table.
Package data provides a COSS-inspired native table.
Package date provides COSS-inspired Gregorian date and time controls: Calendar, RangeCalendar, DateField, DatePicker, DateRangePicker and TimeField.
Package date provides COSS-inspired Gregorian date and time controls: Calendar, RangeCalendar, DateField, DatePicker, DateRangePicker and TimeField.
examples
basic command
Command basic demonstrates a small native application using mygoui.
Command basic demonstrates a small native application using mygoui.
gallery command
Command gallery opens the native MyGo UI component workbench.
Command gallery opens the native MyGo UI component workbench.
Package fonts provides the optional Cal Sans font family.
Package fonts provides the optional Cal Sans font family.
Package form provides Coss-inspired form controls with native MyGo editing, focus, selection and accessibility.
Package form provides Coss-inspired form controls with native MyGo editing, focus, selection and accessibility.
internal
anchored
Package anchored maps typed placements onto MyGo's native anchor engine.
Package anchored maps typed placements onto MyGo's native anchor engine.
apidoc
Package apidoc derives the gallery's API reference from the library source.
Package apidoc derives the gallery's API reference from the library source.
apidoc/cmd/apidoc command
Command apidoc writes the gallery's generated API and example tables.
Command apidoc writes the gallery's generated API and example tables.
formstyle
Package formstyle shares Coss field chrome between native form and date controls.
Package formstyle shares Coss field chrome between native form and date controls.
gallery
Package gallery is the interactive native workbench for mygoui.
Package gallery is the interactive native workbench for mygoui.
style
Package style centralizes typography and state styling shared by components.
Package style centralizes typography and state styling shared by components.
Package list provides virtualized, selectable rows with Coss-inspired appearance and optional labelled sections.
Package list provides virtualized, selectable rows with Coss-inspired appearance and optional labelled sections.
Package locale owns library-level accessible labels.
Package locale owns library-level accessible labels.
Package navigation provides Coss-inspired native navigation controls: accordions, disclosures, tabs, segmented controls, breadcrumbs, pagination, toolbars, menus, context menus, and searchable commands.
Package navigation provides Coss-inspired native navigation controls: accordions, disclosures, tabs, segmented controls, breadcrumbs, pagination, toolbars, menus, context menus, and searchable commands.
Package overlay implements COSS-inspired transient surfaces on MyGo's native overlay, focus and toast engines.
Package overlay implements COSS-inspired transient surfaces on MyGo's native overlay, focus and toast engines.
Package theme owns coss ui's semantic tokens, geometry and typography.
Package theme owns coss ui's semantic tokens, geometry and typography.

Jump to

Keyboard shortcuts

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