kit

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

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

Documentation

Overview

Package kit is Godwit's component set: shadcn/ui Nova looks (neutral) built on mygo's *Base widgets. Colors come only from theme.Of(c); variants are arguments, not method chains.

Index

Constants

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

The kinds of toast, for ui.Toast's Type; "" is a plain one.

Variables

View Source
var BackdropBlur = true

BackdropBlur turns the frosted panels' blur on. Tests turn it off: the CPU renderer the Tester draws with blurs pixel by pixel, which under -race runs every dialog test many times slower.

View Source
var Glass bool

Glass frosts the panels of dialogs and the search palette: set where the window sits on a material (Deps.Vibrancy); elsewhere they are opaque. The backdrop under them only tints the window.

Functions

func Alert

func Alert(c *ui.Context, kind AlertKind, text string, actions func()) ui.Element

Alert is a bordered message bar with optional actions after the text.

func AlertAction

func AlertAction(c *ui.Context, kind AlertKind, label string, onClick func()) ui.Element

AlertAction is a solid button for an Alert's actions: filled with the kind's text color and white text (the kind's background in dark) (Info: Primary with PrimaryText).

func Avatar

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

Avatar is a rounded square with the initial of name, labelled name, in a label color the name picks, so each sender keeps theirs.

func AvatarImage added in v0.3.0

func AvatarImage(c *ui.Context, name string, image ui.ImageSource) ui.Element

AvatarImage shows an image in its own colors, with the same labelled square and size as the initial placeholder.

func AvatarSized added in v1.22.0

func AvatarSized(c *ui.Context, name string, size float32) ui.Element

AvatarSized is Avatar size wide, its initial grown in step.

func Badge

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

Badge is a small gray label.

func Bar added in v1.19.0

func Bar(fill ui.Color) ui.Material

Bar fills a bar the content scrolls under (the reader's toolbar and reply bar) with fill over what is behind it blurred. The blur cannot see a native view: a web view's page under it blurs itself (the reader's BodyGlass).

func Button

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

Button is a button of a label.

func ButtonFrame

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

ButtonFrame is the styled button without children; it is never Disabled (no label for the cover).

func ButtonGroup

func ButtonGroup(c *ui.Context, items ...GroupItem) ui.Element

ButtonGroup is ghost icon buttons side by side, unframed; GroupDivider parts groups. The icons are Foreground, not a lone icon button's Muted.

func Card

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

Card is a bordered panel.

func CardFooter

func CardFooter(c *ui.Context, children func())

CardFooter is a right-aligned row for a Card's actions.

func CardHeader

func CardHeader(c *ui.Context, title, description string)

CardHeader is a Card's title with an optional description under it.

func Checkbox

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

Checkbox is a 16×16 check box before its label.

func Collapsible

func Collapsible(c *ui.Context, open *bool, trigger, panel func()) ui.Element

Collapsible is a muted, small trigger row with a turning chevron, and panel below it while *open. *open must outlive the frame. It returns the trigger.

func Dialog

func Dialog(c *ui.Context, open *bool, title string, o DialogOpts, body, footer func())

Dialog is a modal panel anchored near the top: a header with the title, the description and a close button, a scrolling body, and a footer bar holding footer's buttons at the end. body and footer may be nil. Escape, a click outside and the close button close it.

func DialogShown added in v0.1.0

func DialogShown() bool

DialogShown reports whether a Dialog was built since it was last called, and forgets it. A window on a transparent material paints itself opaque under one: the panel's frost covers only what is opaque, and sharp text on the material would show through it.

func Elevate

func Elevate(c *ui.Context, e ui.Element, s theme.Elevation) ui.Element

Elevate gives e the shadow s, each layer in the ink: dark in either appearance, as shadcn's black shadows are.

func Empty

func Empty(c *ui.Context, o EmptyOpts) ui.Element

Empty is a centered empty state: an icon tile, a title, a description and actions; Dashed draws a dashed frame around it.

func EmptyAction

func EmptyAction(c *ui.Context, label string, o ButtonOpts) ui.Element

EmptyAction is a button for Empty's Actions: the default size, 12 to each side as the design's.

func Field

func Field(c *ui.Context, label, help, errText string, control func())

Field is a labelled form control with help text, or an error in its place.

func Frost added in v0.3.0

func Frost(fill ui.Color) ui.Material

Frost fills a row with fill (the surface it sits on) over what is behind it blurred: plain at rest, frosted glass as a drag lifts the row over others.

func Gallery(c *ui.Context, g *GalleryState)

Gallery shows every kit component, section by section. Dev builds only.

func GroupDivider added in v1.18.0

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

GroupDivider is the hairline between ButtonGroups in a toolbar.

func HoverCard added in v1.19.0

func HoverCard(c *ui.Context, anchor ui.Element, w float32, body func())

HoverCard shows a card w wide below anchor, at its start, as Tooltip shows its text: body fills it.

func IconButton

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

IconButton is a square button showing only an icon, named label for assistive technology and tests. A SizeXs one, 16 round, holds a 12 icon.

func Input

func Input(c *ui.Context, s *string, o InputOpts) ui.Element

Input is a 32-high single-line text input.

func InputGroup added in v1.3.0

func InputGroup(c *ui.Context, o InputOpts) ui.Element

InputGroup is a 32-high input frame for a bare input and its icons or actions. It shares Input's border, shadow, error and focus styles; o uses Invalid and Flat.

func Kbd

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

Kbd shows a key or shortcut, a keycap each key: ⇧⌘K is three, Esc one.

func LabelChip added in v0.3.0

func LabelChip(c *ui.Context, o LabelChipOpts) ui.Element

LabelChip is a mail label's chip: 20 high, its icon and name in the label's color.

func LiquidGlass added in v1.19.0

func LiquidGlass(tint ui.Color) ui.Material

LiquidGlass creates the unified Liquid Glass material: true Gaussian backdrop blur tinted with the surface color. Call it while building the panel.

func List

func List(c *ui.Context, s *ui.ListState, n int, row func(i int)) ui.Element

List is ui.List with the selected rows in the sidebar's selected gray and the foreground, not mygo's accent (the primary, near-black). mygo styles a row from the theme current when it builds it, so the rows' content gets the frame's own theme back. A reordered list that chooses no rows keeps the accent: the line showing where dragged rows go is drawn in it.

func MenuAt(c *ui.Context, anchor ui.Element, open *bool, at, self ui.Anchor, topOffset float32, label string, body func())

MenuAt is a menu anchored as PopoverAt: a tight panel of MenuItems, perhaps under a MenuLabel, labelled label.

func MenuItem(c *ui.Context, selected bool) ui.Element

MenuItem is an item of a menu, tinted while selected (the keys' choice); give it its Label and Children.

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

MenuLabel is a muted heading over a menu's items.

func NavSwitch(c *ui.Context, items ...NavItem) ui.Element

NavSwitch is a segmented row of page links on the window material: the page shown raised on the background in the fill icon with its name, the others muted icons named by a tooltip. Picking another slides the raised background over and widens it to the name, which it uncovers.

The buttons take their new widths at once, so that what slides heads for where it ends: a pill chasing a button still on its way overshoots it. The icons and names are a row of their own over the buttons, as an absolute element paints over its siblings and the pill would cover those before it.

func NewFrame added in v1.18.0

func NewFrame()

NewFrame starts a frame: WebView goes by whether the last one frosted a panel, as dialogs build after the pages under them.

func Palette added in v1.18.0

func Palette(c *ui.Context, open *bool, query *string, o PaletteOpts, head, body func())

Palette is a modal search panel near the top of the window: a search box bound to query with a close button, head (the kind tabs) under it, body (the result list, of PaletteRows) scrolling under that, and a bar of o.Hints. The box has the focus; Escape, a click outside and the close button close it.

func PaletteChip added in v1.18.0

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

PaletteChip is a filter set in a Palette's search row: its label and a button, named remove, which it returns for the caller's OnClick.

func PalettePreview added in v1.18.0

func PalettePreview(c *ui.Context, body func())

PalettePreview is a card 8px off a Palette's right edge, level with the selected PaletteRow, which it follows as the list scrolls; body builds its content. Build it after the Palette in the same frame, while open.

func PaletteRow added in v1.18.0

func PaletteRow(c *ui.Context, selected bool) ui.Element

PaletteRow is a one-line result of a Palette for content the caller builds: an option of its list, tinted while selected. Give it its Label, Gap and Children.

func PaletteTab added in v1.18.0

func PaletteTab(c *ui.Context, label string, chosen bool) ui.Element

PaletteTab is a kind tab of a Palette's head, tinted while chosen.

func Panel

func Panel(c *ui.Context, radius float32) ui.Element

Panel is a region of a page on the window material, as the mail list or the reading pane: a white card in the border's hairline with ShadowXs, corners of radius. Give it its size and Children.

func Popover

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

Popover is a panel below anchor while *open; a press outside or Escape closes it.

func PopoverAt added in v1.17.0

func PopoverAt(c *ui.Context, anchor ui.Element, open *bool, at, self ui.Anchor, topOffset float32, body func())

PopoverAt is a panel anchored to anchor at (at, self) with topOffset while *open; a press outside or Escape closes it.

func Pressable

func Pressable(c *ui.Context, o PressableOpts) ui.Element

Pressable is a clickable surface for content the caller builds, left-aligned. Give it its Label, Padding, Gap and Children. A selected one does not click.

func Radio

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

Radio is a radio button choosing v into *sel.

func Resizer

func Resizer(c *ui.Context, size *float32, gap float32, over bool, label string, onClick func(), first, second func()) (changed, dragging bool)

Resizer is first, *size wide, beside second, with a gap of gap between them that the user drags (or, focused, moves with the arrows) to set *size, as Claude's: hovered, dragged or focused, a GripWidth line of the foreground at 20% shows down the gap's middle, and hovering that names it (label) beside it. It reports whether *size changed, and whether the grip is being dragged; the caller clamps *size. onClick, if any, is what a click on the grip does. With over, the panels touch (they differ enough to need no gap, as a sidebar and the content beside it): the grip, gap wide, rides second's edge (a Stroke astride it, on whole pixels) down the middle, reaching as little into either. Gap is then GripWidth: first's scroll bar keeps further from its edge than the grip reaches, so the grip runs beside it, not over it.

func RoundAction added in v1.22.0

func RoundAction(c *ui.Context, icon, name, tip string, disabled, on bool) ui.Element

RoundAction is an action named under its icon, as a contact's under their name: the icon in a round tint, then name; tip, if set, is its label and tooltip, saying more than name. On is a state the action turns off, as being blocked.

func Select

func Select[T comparable](c *ui.Context, sel *T, opts []Option[T]) ui.Element

Select is a 32-high select of opts; give it a Label.

func SelectWith

func SelectWith[T comparable](c *ui.Context, o SelectOpts, sel *T, opts []Option[T]) ui.Element

SelectWith is Select styled by o.

func Separator

func Separator(c *ui.Context, vertical bool) ui.Element

Separator is a hairline: horizontal across its parent, or a short vertical one. In a row, give it Grow(1). It takes a Stroke's room but draws one device pixel, as a border (a box that thin rounds away).

func SidebarChevron added in v1.5.0

func SidebarChevron(c *ui.Context, open float32) ui.Element

SidebarChevron is a sidebar row's 12 muted chevron, turned a quarter at open 1.

func SidebarCollapsible added in v1.5.0

func SidebarCollapsible(c *ui.Context, open *bool, muted bool, trigger, panel func()) ui.Element

SidebarCollapsible is a sidebar row (SidebarItem's size and padding) that folds the rows below it: trigger's children, then a 12 chevron at its right, turned a quarter while open. Muted is a group's title: small muted text. *open must outlive the frame. It returns the trigger.

func SidebarIcon

func SidebarIcon(c *ui.Context, item ui.Element, icon string, selected bool)

SidebarIcon is a SidebarItem's leading icon: muted line style until item is hovered; selected, the foreground fill style.

func SidebarItem

func SidebarItem(c *ui.Context, o SidebarItemOpts) ui.Element

SidebarItem is a row of a page's sidebar, its children left-aligned: 32 high, highlighted while selected or hovered. Give it its Children.

func Skeleton

func Skeleton(c *ui.Context, w, h float32) ui.Element

Skeleton is a pulsing placeholder w wide (0: the full width) and h high. It stays still under ReduceMotion, which Loop does not honor itself.

func Spinner

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

Spinner shows that something is under way.

func StatusDot

func StatusDot(c *ui.Context, s Status) ui.Element

StatusDot is a 6×6 dot: green OK, amber Attention (clears by itself), red Error (needs the user).

func SwapButton added in v1.5.0

func SwapButton(c *ui.Context, label string, o ButtonOpts, others ...string) ui.Element

SwapButton is a Button whose label changes in place, as Copy turning into Copied: the old label fades out as the new one fades in. It is as wide as the widest of label and others, the labels it may show, and its content starts at its left edge, so neither it nor its icon moves.

func Switch

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

Switch is a 32×18 switch; give it a Label.

func SwitchRow

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

SwitchRow is a full-width switch named label in the settings row shape (8/16 padding, at least 48 high): label and help on the left, the track on the right; a click anywhere on the row toggles it.

func Tabs

func Tabs(c *ui.Context, sel *int, labels ...string) ui.Element

Tabs is a segmented tab list choosing *sel, each tab as wide as its label.

func TabsFill added in v1.22.0

func TabsFill(c *ui.Context, sel *int, labels ...string) ui.Element

TabsFill is Tabs across its row, every tab the same width: a choice between whole views, as Gmail's 应用专用密码 | 浏览器登录.

func TabsUnderline

func TabsUnderline(c *ui.Context, sel *int, labels ...string) ui.Element

TabsUnderline is Tabs as a row over a hairline, in Base type: Muted, the chosen tab Foreground and 600 over a Primary bottom border.

func Text

func Text(c *ui.Context, s string, size float32) ui.Element

Text is text at a step of the text scale with that step's line height. Leaves only: a line height passes down as a multiplier, so on a container it would reach texts of other sizes.

func TextArea

func TextArea(c *ui.Context, s *string, o InputOpts) ui.Element

TextArea is a multi-line text input.

func TextLink(c *ui.Context, label string, color ui.Color, size float32) ui.Element

TextLink is an underlined text button of size in color (a notice's action).

func ToastHost

func ToastHost(c *ui.Context, closeLabel string)

ToastHost draws the window's toasts (c.Toast, c.AddToast) centered under the top bar, the oldest first and at most theme.ToastMax; call it once in the view. closeLabel names the close buttons (pass the translated "Close"). A success, warning or error toast is tinted: its color's 50 behind, 200 around, 700 for the text and its leading icon; a plain one is white, without an icon.

func ToggleGroup

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

ToggleGroup groups the buttons fn builds: one Tab stop, the arrow keys move between them.

func Tooltip

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

Tooltip shows text by anchor on keyboard focus at once and on hover after a pause, and describes anchor to assistive technology.

func TooltipLabelled

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

TooltipLabelled is Tooltip for an anchor whose Label already says text.

func WebView added in v1.18.0

func WebView(c *ui.Context, v ui.NativeWebView) ui.Element

WebView shows v as ui.WebView does, but while a frosted panel is up a screenshot of its page stands in for it: a web view is a native view under the window's surface, which a panel's blur cannot see. The page is modal behind the panel, so a still of it loses nothing.

Types

type AlertKind

type AlertKind int

AlertKind is an Alert's look.

const (
	Warning AlertKind = iota
	Danger
	Info
)

type ButtonOpts

type ButtonOpts struct {
	Variant  Variant
	Size     ButtonSize
	Disabled bool
	Flat     bool // Outline without its shadow
	Icon     string
}

ButtonOpts style a button. Icon is an icons name shown before the label.

type ButtonSize

type ButtonSize int

ButtonSize is a button's height; the zero value is the 32 px default.

const (
	SizeDefault ButtonSize = iota
	SizeXs                 // IconButton only, round
	SizeSm
	SizeLg
)

type DialogOpts added in v0.1.0

type DialogOpts struct {
	Size               DialogSize
	Desc, Close        string
	Danger, Alert, Top bool
}

DialogOpts are a dialog's size, the muted line under its title, the label of its close button, and Danger, which tints the footer for a confirmation. Alert makes it one question (confirm, delete, open a link): the alert backdrop and no close button, Cancel, Escape or a click outside closing it. Top keeps it near the window's top instead of above centre, for a form whose height changes as it is used (steps, results): it grows down.

type DialogSize added in v0.1.0

type DialogSize uint8

DialogSize is a dialog's width: DialogMd for a form, DialogSm for a confirmation, DialogLg for a larger form.

const (
	DialogMd DialogSize = iota
	DialogSm
	DialogLg
)

type EmptyOpts

type EmptyOpts struct {
	Icon, Title, Desc string
	Actions           func()
	Dashed            bool
}

EmptyOpts fill an Empty. Actions builds the buttons under the text.

type GalleryState

type GalleryState struct {
	Switch, Switch2, Check                bool
	Radio, Select, Tabs                   int
	Toggle                                int
	Input, Password, Mono, Bare, Area     string
	InvalidIn, HelpIn, ErrorIn            string
	Dialog, Confirm, Popover, Collapsible bool
}

GalleryState holds the values the gallery's controls edit.

type GlassMaterial added in v1.19.0

type GlassMaterial struct {
	Blur float32
	Tint ui.Color
}

GlassMaterial blurs what is behind it with genuine Gaussian backdrop blur, then fills with tint.

func (GlassMaterial) PaintMaterial added in v1.19.0

func (g GlassMaterial) PaintMaterial(p *ui.Painter, box ui.Rect, radii [4]float32)

type GroupItem

type GroupItem struct {
	Icon, Tip string
	OnClick   func()
	Disabled  bool
}

GroupItem is one icon button of a ButtonGroup; Tip is its tooltip and label.

type InputOpts

type InputOpts struct {
	Placeholder             string
	Password, Mono, Invalid bool
	Bare                    bool // raw Base geometry: the row around it draws the box
	Flat                    bool // no shadow
	Glass                   bool // frosted glass appearance with hairline border (no blur)
}

InputOpts style a text input.

type LabelChipOpts added in v0.3.0

type LabelChipOpts struct {
	Text, Icon, Tip string
	Display         string
	Color           theme.LabelColor
	Auto            bool
	OnClick         func() // set: the chip is a button
	OnRemove        func() // set: a trailing × named RemoveLabel
	RemoveLabel     string
}

LabelChipOpts is a mail label as a chip. Icon is a label icon's name without the "label-" prefix; Tip shows on hover. Auto draws the chip the model set: the same color, an edge instead of a fill. Display is core.LabelDisplay*: "both" (the default; "" too), "icon" or "text".

type NavItem struct {
	Icon, Label string
	Selected    bool // the page shown: raised, and it does not click
	OnClick     func()
}

NavItem is a page a NavSwitch goes to.

type Option

type Option[T comparable] struct {
	Value T
	Label string
}

Option is one choice of a Select.

type PaletteHint added in v1.18.0

type PaletteHint struct {
	Label, Key string
	OnClick    func()
}

PaletteHint is a shortcut the palette's bottom bar names: Key, then Label. With OnClick it is a button too, at the bar's end: give it last.

type PaletteOpts added in v1.18.0

type PaletteOpts struct {
	Label, Placeholder, Close string
	OnKey                     func(k ui.TextKey) bool
	Keys                      func(mods ui.Modifiers, key ui.Key) bool
	Send                      string
	OnSend                    func()
	Hints                     []PaletteHint
	Chips                     func()
}

PaletteOpts name a Palette and its search box. OnKey sees the keys the box types no text with (the arrows, Enter, Tab, those with Cmd or Ctrl) before it does, as ui's OnTextKey: true takes the key. Chips, when set, builds the PaletteChips before the box. Keys, when set, holds the box: it types no text, and Keys sees every key pressed first (a menu's letters). Send, when set, makes the box a message to send instead of a search: a framed text area and a button named Send, and no head or body. Its panel is a dialog's (Glass).

type PressableOpts

type PressableOpts struct {
	Selected, Bordered bool
	Glass              bool // frosted glass appearance with hairline border and GlassHover (no blur)
	Bare               bool // no hover or selected background: the caller draws its own
	OnClick            func()
}

PressableOpts say how a Pressable looks and what clicking it does.

type SelectOpts

type SelectOpts struct {
	Radius, MinWidth, MaxWidth float32
	Flat                       bool
}

SelectOpts style a SelectWith: zero Radius is Md, zero MinWidth the default, zero MaxWidth unbounded; Flat drops the shadow.

type SidebarItemOpts

type SidebarItemOpts struct {
	Selected bool    // the page shown: highlighted, and it does not click
	Muted    bool    // a secondary action, as Add account
	Small    bool    // 30 high in the small text, as an account's header
	Indent   float32 // more left padding, in spacing steps, as a folder under its account
	OnClick  func()
}

SidebarItemOpts says how a sidebar row looks and what clicking it does.

type Status

type Status int

Status is what a StatusDot tells.

const (
	OK Status = iota
	Attention
	Error
)

type Variant

type Variant int

Variant is a button's look.

const (
	Default Variant = iota
	Secondary
	Outline
	Ghost
	Destructive
	Link
	DestructiveOutline
)

Jump to

Keyboard shortcuts

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