kit

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 20 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, tone Tone, text string, actions func()) ui.Element

Alert is the design's one colored message bar, with optional actions after the text: tone is ToneWarning, ToneDanger or ToneInfo. Its actions are small Outline buttons of the same tone.

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 AvatarImageSized added in v1.39.4

func AvatarImageSized(c *ui.Context, name string, image ui.ImageSource, size float32) ui.Element

AvatarImageSized is AvatarImage at size × size.

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 (at least Text.Xs).

func AvatarStack added in v1.39.4

func AvatarStack(c *ui.Context, items []AvatarStackItem, size float32) ui.Element

AvatarStack draws overlapping avatars of size, each ringed by Background so overlapping edges separate cleanly on paper cards.

func Badge

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

Badge is a small gray label.

func BadgeButton added in v1.38.0

func BadgeButton(c *ui.Context, text string, o BadgeOpts) ui.Element

BadgeButton is a badge that acts, at a badge's size so that it sits in a row of them, as 标签 and 退订 beside a mail's label chips: neutral or outline, a step darker hovered and another pressed. Give it its OnClick or its Menu; elsewhere what acts is a Button.

func BadgeWith added in v1.38.0

func BadgeWith(c *ui.Context, text string, o BadgeOpts) ui.Element

BadgeWith is a badge styled by o, the one small label of the interface: as high as a label chip (20), xs text, 6 at its sides, radius-sm. It names and does not act: one that is clicked is a BadgeButton.

func Bar added in v1.19.0

func Bar(tint ui.Color) ui.Material

Bar fills a bar the content scrolls under (the reader's sticky header and floating reply card) with tint, theme.Tokens.MaterialBar, over what is behind it blurred. On macOS 26+, it also backs the bar with AppKit's NSGlassEffectView under the surface so live web views blur in sync with CoreAnimation; elsewhere the web view blurs its covered strips itself (the reader's BodyGlass).

func Block added in v1.38.0

func Block(c *ui.Context, e ui.Element, tone Tone) ui.Element

Block makes e a region inside a page or a card and returns it: tone's fill at radius-lg. Give it its Padding, Gap and Children; a page rounds and fills no box of its own.

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.

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, e ui.Element, tone Tone) ui.Element

Card makes e a section of a page and returns it: tone's fill at radius-xl, the card gray in a hairline too.

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 Chevron added in v1.39.4

func Chevron(c *ui.Context, open bool, size float32) ui.Element

Chevron is the arrow of what opens: muted, a quarter turn clockwise while open, over MotionBase. size is theme.IconXs for a sidebar's rows and theme.IconSm for a Collapsible's.

func ChoiceCard added in v1.39.4

func ChoiceCard(c *ui.Context, e ui.Element, o ChoiceCardOpts, content func()) ui.Element

ChoiceCard makes e a card one of several is picked from, or a tile that acts on a click (selected is then false), around content. e is the caller's control, a RadioBase or a Pressable{Bare}: its role, state and corner are its own, and so are the padding and gap of a card that has no radio dot (the radio card is full width, 8 padded, 8 apart, in corners of Lg).

func ChoiceText added in v1.39.4

func ChoiceText(c *ui.Context, label, help string)

ChoiceText is a ChoiceCard's usual content: label, and help under it.

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 DateTimeDialog added in v1.40.0

func DateTimeDialog(c *ui.Context, open *bool, at *time.Time, o DateTimeDialogOpts, onConfirm func())

DateTimeDialog is a Dialog choosing *at in a DateTimePicker, the time chosen read out under its title. Confirm, or ⌘↩ wherever the focus is, closes it and calls onConfirm, unless Check refuses the time: the reason is then read out in Danger until the time changes. Cancel, Escape and the close button close it, *at as chosen.

func DateTimePicker added in v1.40.0

func DateTimePicker(c *ui.Context, at *time.Time, o DateTimeOpts) ui.Element

DateTimePicker chooses *at: a month's calendar beside a clock, the time typed in a field over a face whose hands both drag. A day is a large button (SizeLg) and the calendar seven of them wide, the face six tall; too narrow for both, the face goes under.

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.

func Field

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

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

func FieldWith added in v1.39.4

func FieldWith(c *ui.Context, o FieldOpts, label, help, errText string, control func()) ui.Element

FieldWith is Field laid out as o says: a column, or with a Switch a row.

func FloatCard added in v1.39.4

func FloatCard(c *ui.Context, e ui.Element) ui.Element

FloatCard gives e the floating composer surface: 16 round translucent frosted glass (MaterialBar over blurred content), ShadowFloat in either appearance plus FloatInset's inner edge in the dark.

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. shortcut: its 0.7 tint has no design token, as it is a drag effect and not a material; give it one if the design names it.

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 read-only popover card w wide below anchor, at its start, as Tooltip shows its text (after 600 ms of hover, at once on keyboard focus, the pointer passing through it): 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 SizeMini one, 16 round, and a SizeXs one, 24, hold a 12 icon; the others a 16.

func Input

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

Input is a single-line text input, 32 high unless o.Size says otherwise. With a Leading or Trailing slot it is the text field in a frame of the same height, and what it returns is the text field: its gap is 8, its text is cut where the right padding starts (4 when there is a Trailing slot).

func InputButton added in v1.39.4

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

InputButton is a press target that looks as an Input of o's size, for a field that opens something else (a palette) instead of taking text: it shows what the caller puts in it, left-aligned, as a placeholder and the keys that open it. Give it its Label, Gap and Children.

func InputIcon added in v1.39.4

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

InputIcon is the icon an Input's Leading slot shows: 16, muted.

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 LabelledRow added in v1.39.4

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

LabelledRow is a settings row: label with help (or errText in its place) on the left, and at the right the element control returns, which a click on the label focuses, as a Field's label does. control returns ui.Element{} for a row that ends in a button, a link or plain text, which keeps its own label.

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 MenuAvatar(c *ui.Context, name string, image ui.ImageSource) ui.Element

MenuAvatar is Avatar or AvatarImage for a native menu's small icon, which the theme doesn't reach: the sender's color solid, to sit on a menu of either appearance, and the initial large enough to read at half size.

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 NewFrame added in v1.18.0

func NewFrame(c *ui.Context)

NewFrame starts the window's frame: WebView goes by whether its 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 PaletteAvatar added in v1.39.4

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

PaletteAvatar is the 24 avatar leading a PaletteRow: image, once its sender's is read and allowed, else the initial of name.

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 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 PreparingWebView added in v1.40.2

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

PreparingWebView lays out a live page invisibly, even under a modal: a screenshot cannot render the first frame that the reader is waiting for.

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 Progress added in v1.38.0

func Progress(c *ui.Context, done, total float32, label string) ui.Element

Progress is a bar of how far a job has come, done of total: 4 high, the primary filling a track of the border gray, named label.

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 Readout added in v1.40.0

func Readout(locale string, at, now time.Time) string

Readout is at as a DateTimeDialog reads it out in locale at now: the month, the day, the weekday and the time, "Today · " or "Tomorrow · " before it for those days, as Intl writes them.

func Resizer

func Resizer(c *ui.Context, size *float32, gap float32, 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.

func ResizerOver added in v1.39.4

func ResizerOver(c *ui.Context, size *float32, gripWidth float32, label string, onClick func(), first, second func()) (changed, dragging bool)

ResizerOver is Resizer with no layout gap between first and second: first reaches second's edge (so a sidebar's scroll bar sits right along the content panel's border) and a grip of width gripWidth rides that edge.

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 SelectButton added in v1.38.0

func SelectButton(c *ui.Context, text string, o SelectOpts) ui.Element

SelectButton is a button with a select's face showing text, for a choice a Select cannot hold, as several at once: it opens the caller's popover. Give it a Label and an OnClick.

func SelectWith

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

SelectWith is Select styled by o. Its options open as the system's menu under the trigger, the current one checked; Changed reports a new choice.

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 SidebarDropHighlight added in v1.42.0

func SidebarDropHighlight(c *ui.Context, item ui.Element)

SidebarDropHighlight marks a SidebarItem as an active drag-and-drop target, using an overlay stroke so hovering does not shift the row's layout.

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, unless it is a group's title: it folds the rows of Group by *Open, shows Title, a Chevron and Count, and is the row to give a ContextMenu.

func SidebarSpringHighlight added in v1.42.0

func SidebarSpringHighlight(c *ui.Context, item ui.Element)

SidebarSpringHighlight marks a collapsed SidebarItem that will spring open if a drag lingers over it, without implying it takes a drop itself.

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), gray Idle.

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 Tabs

func Tabs(c *ui.Context, sel *int, o TabsOpts, items []TabItem) ui.Element

Tabs is a tab list choosing *sel among items, one Tab stop whose arrow keys, Home and End move the choice; OnChange on it reports a new one. A segmented list is a track 32 high at radius-lg, its tabs 28 at radius-md in 500, the chosen one on the background under ShadowSm. An underlined one is tabs 32 high over a hairline, muted at 400, the chosen one in the foreground at 500 over a 2 px primary line. A pill list's tabs are 28 high in xs, the chosen one tinted.

An item's icon is muted line style before its label, the foreground when chosen (the fill style in a segmented list). A hugging segmented list whose items all have icons shows only the chosen one's label: the others are 28 wide icon-only tabs named by a tooltip, in the foreground on hover.

The labels of a segmented list are a row of their own over its tabs: an absolute element paints over its siblings, and the pill sliding past would cover the labels of the tabs before it. The tabs of an icon-only list take their new widths at once, so that what slides heads for where it ends.

func TemplateField added in v1.26.0

func TemplateField(c *ui.Context, value *string, o TemplateOpts) ui.Element

TemplateField edits *value, a template of literal text and {id} tokens (a 命名模板): tokens show as chips that a button takes out, then an input for the text after them; the buttons below add a token at the end, and Backspace in the empty input takes out the last one. Text between tokens stays as typed. An {id} not in Tokens is text.

func Text

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

Text is text at a step of the text scale, on the interface's line (theme.LineUI, which every text inherits).

func TextArea

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

TextArea is a multi-line text input.

func ThinkingDots added in v1.39.4

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

ThinkingDots shows three horizontal dots pulsing in sequence while AI prepares its output, taking one reading line's height so the first line of streamed text arrives without a vertical jump. It stays still under ReduceMotion, which Loop does not honor itself.

func Tile added in v1.38.0

func Tile(c *ui.Context, w, h float32, tone Tone) ui.Element

Tile is a box w by h holding a glyph or a few letters, centered: a service's mark, a file's kind, a template's icon. It rounds as a control of its shorter side and fills as tone; give it its Children.

func TitledAlert added in v1.39.4

func TitledAlert(c *ui.Context, tone Tone, title, text string, actions func()) ui.Element

TitledAlert is the design's Alert: its tone's mark level with the first line, however tall the actions make the bar; title in medium weight over text (either may be ""); the actions at the end, centred.

func ToastAnchor added in v1.39.4

func ToastAnchor(c *ui.Context, panel ui.Element)

ToastAnchor registers panel, the content panel the toasts sit in the bottom right corner of; call it every frame, before ToastHost.

func ToastHost

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

ToastHost draws the window's toasts (c.Toast, c.AddToast) in the bottom right corner (of ToastAnchor's panel), over everything, the newest in front and at most theme.ToastMax; call it once in the view, after the page. Only the newest is in the layout, so it never moves: the older ones are placed against the window beside it, behind it and narrower, showing their edge, until the pointer over them or the keyboard focus in them (Enter opens, Escape closes) spreads them into a column above it. A toast with a ToastData deadline loses its action then. One that goes by itself has no close button (Escape closes it); one that stays (Timeout < 0) has, named closeLabel (pass the translated "Close"). Its look is always neutral: only the leading icon tells a success, warning or error.

func ToastNow added in v1.39.4

func ToastNow(c *ui.Context, now time.Time)

ToastNow registers the time ToastHost judges deadlines by, the app's clock; without it, the window's.

func ToggleChip added in v1.38.0

func ToggleChip(c *ui.Context, label string, on bool, look ChoiceLook) ui.Element

ToggleChip is a ToggleChipFrame showing label: a filter that is on or off, a model added or not.

func ToggleChipFrame added in v1.38.0

func ToggleChipFrame(c *ui.Context, on bool, look ChoiceLook) ui.Element

ToggleChipFrame is a chip that is on or off without its content: 28 high in xs text, muted while off. Give it its Label, Children and OnClick.

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 AvatarStackItem added in v1.39.4

type AvatarStackItem struct {
	Name  string
	Image ui.ImageSource
}

AvatarStackItem is one participant in an AvatarStack.

type BadgeOpts added in v1.38.0

type BadgeOpts struct {
	Tone            BadgeTone
	Icon, IconLabel string
	Muted, Mono     bool
}

BadgeOpts style a BadgeWith: Icon is a 12 icon before the text, named IconLabel to assistive technology when it says what the text does not; Muted is its text in the muted color (the status tones keep theirs), Mono the monospace font.

type BadgeTone added in v1.38.0

type BadgeTone uint8

BadgeTone is a badge's colors.

const (
	BadgeNeutral BadgeTone = iota // the hover gray: a kind, a count, a tag
	BadgeOutline                  // a hairline and no fill: a state of the row it is in
	BadgeSurface                  // the background, for a badge on a card or a tinted row
	BadgeSuccess                  // the status tints: their -bg under their -text
	BadgeWarning
	BadgeDanger
)

type ButtonOpts

type ButtonOpts struct {
	Variant  Variant
	Size     Size
	Disabled bool
	Flat     bool // Outline without its shadow
	Round    bool // fully rounded (pill or circle, Radius.Full)
	Icon     string
	Trailing string // an icon after the label, as a menu's chevron
	// Tone colors an Outline button (ToneWarning, ToneDanger, ToneSuccess,
	// ToneInfo: the tone's border and text on Background, its fill on hover,
	// no shadow), as the actions of a colored Alert, Toast or notice, and a
	// Ghost one (ToneDanger: Danger text, DangerBg on hover), as a delete
	// in a confirmation. Other looks and the neutral tones ignore it.
	Tone Tone
}

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

type ChoiceCardOpts added in v1.39.4

type ChoiceCardOpts struct {
	Selected bool
	Look     ChoiceLook
	Radio    bool
}

ChoiceCardOpts say how a ChoiceCard looks. Radio draws a radio dot before the content, filled while Selected.

type ChoiceLook added in v1.39.4

type ChoiceLook uint8

ChoiceLook is how a ChoiceCard looks while it is not the one chosen: ChoiceDefault the background in the border's outline; ChoiceOnCard the card gray with no outline, as a tile among others on a card; ChoiceDashed in a dashed outline, as a model on offer but not added.

const (
	ChoiceDefault ChoiceLook = iota
	ChoiceOnCard
	ChoiceDashed
)

type DateTimeDialogOpts added in v1.40.0

type DateTimeDialogOpts struct {
	DateTimeOpts
	Title, Note, Confirm, Cancel, Close string
	Readout                             func(at time.Time) string
	Check                               func(at time.Time) string
}

DateTimeDialogOpts are a DateTimeDialog's: its picker's, its title, the note under the picker ("" for none), and its buttons' labels. Readout writes the time chosen under the title (nil: Readout's). Check says why a time cannot be confirmed, "" when it can (nil: any can).

type DateTimeOpts added in v1.40.0

type DateTimeOpts struct {
	Min                              time.Time
	Date, Time, PrevMonth, NextMonth string
	Untimed                          *bool
	AnyTime                          string
	Locale                           string
}

DateTimeOpts are a DateTimePicker's: Min, the first day that can be chosen (zero for any); the accessible names of the calendar (Date), the clock (Time) and the calendar's month buttons; and, for a time that may be left out, Untimed with AnyTime, the label of the switch that leaves it out. Locale is the interface language the month, the weekdays and the readout are written in, "" for the window's (Context.Locale); the first day of the week stays the region's.

type DialogOpts added in v0.1.0

type DialogOpts struct {
	Size               DialogSize
	Desc, Close        string
	Danger, Alert, Top bool
	// DescStyle restyles the description, as a readout that turns Danger.
	DescStyle func(ui.Element)
}

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 FieldOpts added in v1.39.4

type FieldOpts struct {
	Horizontal, Disabled bool
	Switch               *bool
}

FieldOpts style a FieldWith. Horizontal with Switch makes it a switch row: label with help or error on the left, a switch on *Switch at the right (the row takes no control), and the whole row its target: one Tab stop, a click anywhere toggles it, the focus ring runs round the row. Disabled disables it and dims the switch only, the label and help staying readable as the design's. Horizontal without Switch does nothing: LabelledRow builds the other settings rows.

type GalleryState

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

GalleryState holds the values the gallery's controls edit.

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
	Size                    Size
	Password, Mono, Invalid bool
	Flat                    bool     // no shadow
	Bare                    bool     // unframed text field (no border, fill, shadow or ring), for a floating composer
	Glass                   bool     // frosted glass appearance with hairline border (no blur)
	Tint                    bool     // the hover tint for the fill, as on the window material (not with Glass)
	Autocomplete            bool     // an Autocomplete, framed as a slotted input: Suggest are its options, none at times
	Suggest                 []string // what an Autocomplete offers as the user types
	Leading, Trailing       func()
	Box                     *ui.Element // set to the frame an input with slots is drawn in
}

InputOpts style a text input. Size is its height on the control scale: SizeSm 28, the default 32 and SizeLg 36 (any other is the default), with a button's corner and 8, 10 and 12 at its sides. Leading and Trailing are slots before and after the text, drawn inside the frame: a search icon, a clear IconButton, a Kbd.

type LabelChipOpts added in v0.3.0

type LabelChipOpts struct {
	Text, Icon, Tip string
	Display         string
	Color           theme.LabelColor
	Auto            bool
	Menu            func(*ui.Menu) // set: the chip is a button with this menu
	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 Option

type Option[T comparable] struct {
	Value    T
	Label    string
	Disabled bool // listed, muted, and not chosen
}

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 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 {
	Size               Size
	MinWidth, MaxWidth float32
	Flat               bool
}

SelectOpts style a SelectWith: Size is its height as an Input's, 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
	Covered  bool    // selected, but something covers the page: it clicks, to show it
	Muted    bool    // a secondary action, as Add account; a group's title, in small muted text
	Small    bool    // 28 high, as a nested row or compact footer action (keeps default text size)
	Indent   float32 // more left padding, in spacing steps, as a folder under its account
	Open     *bool   // a group's fold, which must outlive the frame
	Title    func()  // a group's title: its content, before its Chevron and Count
	Group    func()  // the rows a group folds: set, the row is the group's title, and Title and Open are too
	Count    string  // at a group title's end, in the column of its rows' counts
	OnClick  func()
}

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

type Size added in v1.38.0

type Size int

Size is a control's height, a step of the control scale: a button's, an input's or a select's. The zero value is the 32 px default.

const (
	SizeDefault Size = iota
	SizeMini         // IconButton only: 16 round with a 12 icon, as a chip's ×
	SizeXs           // 24, in xs text with a 12 icon: an action among chips or in a dense row; buttons only
	SizeSm           // 28, in xs text with a 14 icon beside it (an icon alone stays 16)
	SizeLg           // 36
)

type Status

type Status int

Status is what a StatusDot tells.

const (
	OK Status = iota
	Attention
	Error
	Idle // nothing to report yet, as a test under way
)

type TabItem added in v1.39.4

type TabItem struct{ Icon, Label string }

TabItem is a tab: its label, and the icon before it if Icon is set.

func TabLabels added in v1.39.4

func TabLabels(labels ...string) []TabItem

TabLabels are the items of tabs that have labels alone.

type TabsLook added in v1.39.4

type TabsLook uint8

TabsLook is how a Tabs list is drawn.

const (
	TabsSegmented TabsLook = iota // a hover-tinted track, the chosen tab raised on the background
	TabsUnderline                 // a hairline under the tabs, the chosen one over a primary line
	TabsPill                      // tabs on no track, the chosen one tinted: a palette's kinds
)

type TabsOpts added in v1.39.4

type TabsOpts struct {
	Look TabsLook
	Fill bool // segmented only: across its row, every tab the same width
}

TabsOpts say how a Tabs list looks.

type TemplateOpts added in v1.26.0

type TemplateOpts struct {
	Label        string          // the field's name, for its input
	Tokens       []TemplateToken // the tokens, in the order their buttons show
	Insert       string          // the heading before the token buttons
	Remove       func(label string) string
	Placeholder  string
	Error        string // in place of Preview; the box turns red
	Preview      string // what the value gives, as an example
	PreviewLabel string // before Preview, as 示例
}

TemplateOpts name a TemplateField and what it offers.

type TemplateToken added in v1.26.0

type TemplateToken struct{ ID, Label string }

TemplateToken is a token a TemplateField offers: stored as {ID}, shown as Label.

type ToastData added in v1.39.4

type ToastData struct{ Deadline time.Time }

ToastData is ui.Toast's Data for a toast whose action is only valid until Deadline (an undo with a durable window): the host hides the action from then on, however long the toast itself stays (it stays while hovered).

type Tone added in v1.38.0

type Tone uint8

Tone is the fill of a Block or a Card.

const (
	ToneCard    Tone = iota // the card gray: a region apart from the page around it
	ToneTint                // the hover tint: one that stands out more, as a note or a group being edited
	ToneOutline             // the background in a hairline: a region on the page's own white
	ToneRaised              // the background, bare: a white block on a card
	ToneWarning             // the status tints, each its -bg in a hairline of its -border under its -text: a note that warns,
	ToneDanger              // one that says what failed,
	ToneSuccess             // and one that says what went well
	ToneInfo                // blue, a note to read before acting (a draft a program wrote): the blue label's fill halfway to the background in a hairline of its edge under its text
)

type Variant

type Variant int

Variant is a button's look: Default is the primary, filled one. Danger and the colored tones are a Tone on an Outline or Ghost button.

const (
	Default Variant = iota
	Secondary
	Outline
	Ghost
	Link
)

Jump to

Keyboard shortcuts

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