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
- Variables
- func Alert(c *ui.Context, tone Tone, text string, actions func()) ui.Element
- func Avatar(c *ui.Context, name string) ui.Element
- func AvatarImage(c *ui.Context, name string, image ui.ImageSource) ui.Element
- func AvatarImageSized(c *ui.Context, name string, image ui.ImageSource, size float32) ui.Element
- func AvatarSized(c *ui.Context, name string, size float32) ui.Element
- func AvatarStack(c *ui.Context, items []AvatarStackItem, size float32) ui.Element
- func Badge(c *ui.Context, text string) ui.Element
- func BadgeButton(c *ui.Context, text string, o BadgeOpts) ui.Element
- func BadgeWith(c *ui.Context, text string, o BadgeOpts) ui.Element
- func Bar(tint ui.Color) ui.Material
- func Block(c *ui.Context, e ui.Element, tone Tone) ui.Element
- func Button(c *ui.Context, label string, o ButtonOpts) ui.Element
- func ButtonFrame(c *ui.Context, o ButtonOpts) ui.Element
- func ButtonGroup(c *ui.Context, items ...GroupItem) ui.Element
- func Card(c *ui.Context, e ui.Element, tone Tone) ui.Element
- func CardFooter(c *ui.Context, children func())
- func CardHeader(c *ui.Context, title, description string)
- func Checkbox(c *ui.Context, on *bool, label string) ui.Element
- func Chevron(c *ui.Context, open bool, size float32) ui.Element
- func ChoiceCard(c *ui.Context, e ui.Element, o ChoiceCardOpts, content func()) ui.Element
- func ChoiceText(c *ui.Context, label, help string)
- func Collapsible(c *ui.Context, open *bool, trigger, panel func()) ui.Element
- func Dialog(c *ui.Context, open *bool, title string, o DialogOpts, body, footer func())
- func DialogShown() bool
- func Elevate(c *ui.Context, e ui.Element, s theme.Elevation) ui.Element
- func Empty(c *ui.Context, o EmptyOpts) ui.Element
- func EmptyAction(c *ui.Context, label string, o ButtonOpts) ui.Element
- func Field(c *ui.Context, label, help, errText string, control func()) ui.Element
- func FieldWith(c *ui.Context, o FieldOpts, label, help, errText string, control func()) ui.Element
- func FloatCard(c *ui.Context, e ui.Element) ui.Element
- func Frost(fill ui.Color) ui.Material
- func Gallery(c *ui.Context, g *GalleryState)
- func GroupDivider(c *ui.Context) ui.Element
- func HoverCard(c *ui.Context, anchor ui.Element, w float32, body func())
- func IconButton(c *ui.Context, icon, label string, o ButtonOpts) ui.Element
- func Input(c *ui.Context, s *string, o InputOpts) ui.Element
- func InputButton(c *ui.Context, o InputOpts, onClick func()) ui.Element
- func InputIcon(c *ui.Context, name string) ui.Element
- func Kbd(c *ui.Context, text string) ui.Element
- func LabelChip(c *ui.Context, o LabelChipOpts) ui.Element
- func LabelledRow(c *ui.Context, label, help, errText string, control func() ui.Element) ui.Element
- func List(c *ui.Context, s *ui.ListState, n int, row func(i int)) ui.Element
- func MenuAt(c *ui.Context, anchor ui.Element, open *bool, at, self ui.Anchor, ...)
- func MenuAvatar(c *ui.Context, name string, image ui.ImageSource) ui.Element
- func MenuItem(c *ui.Context, selected bool) ui.Element
- func MenuLabel(c *ui.Context, text string) ui.Element
- func NewFrame(c *ui.Context)
- func Palette(c *ui.Context, open *bool, query *string, o PaletteOpts, head, body func())
- func PaletteAvatar(c *ui.Context, name string, image ui.ImageSource) ui.Element
- func PaletteChip(c *ui.Context, label, remove string) ui.Element
- func PalettePreview(c *ui.Context, body func())
- func PaletteRow(c *ui.Context, selected bool) ui.Element
- func Panel(c *ui.Context, radius float32) ui.Element
- func Popover(c *ui.Context, anchor ui.Element, open *bool, body func())
- func PopoverAt(c *ui.Context, anchor ui.Element, open *bool, at, self ui.Anchor, ...)
- func Pressable(c *ui.Context, o PressableOpts) ui.Element
- func Progress(c *ui.Context, done, total float32, label string) ui.Element
- func Radio[T comparable](c *ui.Context, sel *T, v T, label string) ui.Element
- func Resizer(c *ui.Context, size *float32, gap float32, label string, onClick func(), ...) (changed, dragging bool)
- func ResizerOver(c *ui.Context, size *float32, gripWidth float32, label string, onClick func(), ...) (changed, dragging bool)
- func Select[T comparable](c *ui.Context, sel *T, opts []Option[T]) ui.Element
- func SelectButton(c *ui.Context, text string, o SelectOpts) ui.Element
- func SelectWith[T comparable](c *ui.Context, o SelectOpts, sel *T, opts []Option[T]) ui.Element
- func Separator(c *ui.Context, vertical bool) ui.Element
- func SidebarIcon(c *ui.Context, item ui.Element, icon string, selected bool)
- func SidebarItem(c *ui.Context, o SidebarItemOpts) ui.Element
- func Skeleton(c *ui.Context, w, h float32) ui.Element
- func Spinner(c *ui.Context) ui.Element
- func StatusDot(c *ui.Context, s Status) ui.Element
- func SwapButton(c *ui.Context, label string, o ButtonOpts, others ...string) ui.Element
- func Switch(c *ui.Context, on *bool) ui.Element
- func Tabs(c *ui.Context, sel *int, o TabsOpts, items []TabItem) ui.Element
- func TemplateField(c *ui.Context, value *string, o TemplateOpts) ui.Element
- func Text(c *ui.Context, s string, size float32) ui.Element
- func TextArea(c *ui.Context, s *string, o InputOpts) ui.Element
- func ThinkingDots(c *ui.Context) ui.Element
- func Tile(c *ui.Context, w, h float32, tone Tone) ui.Element
- func TitledAlert(c *ui.Context, tone Tone, title, text string, actions func()) ui.Element
- func ToastAnchor(c *ui.Context, panel ui.Element)
- func ToastBar(c *ui.Context, bar, field ui.Element)
- func ToastBarRect(c *ui.Context, bar, field ui.Rect)
- func ToastHost(c *ui.Context, closeLabel string)
- func ToastNow(c *ui.Context, now time.Time)
- func ToggleChip(c *ui.Context, label string, on bool, look ChoiceLook) ui.Element
- func ToggleChipFrame(c *ui.Context, on bool, look ChoiceLook) ui.Element
- func Tooltip(c *ui.Context, anchor ui.Element, text string)
- func TooltipLabelled(c *ui.Context, anchor ui.Element, text string)
- func WebView(c *ui.Context, v ui.NativeWebView) ui.Element
- type AvatarStackItem
- type BadgeOpts
- type BadgeTone
- type ButtonOpts
- type ChoiceCardOpts
- type ChoiceLook
- type DialogOpts
- type DialogSize
- type EmptyOpts
- type FieldOpts
- type GalleryState
- type GroupItem
- type InputOpts
- type LabelChipOpts
- type Option
- type PaletteHint
- type PaletteOpts
- type PressableOpts
- type SelectOpts
- type SidebarItemOpts
- type Size
- type Status
- type TabItem
- type TabsLook
- type TabsOpts
- type TemplateOpts
- type TemplateToken
- type ToastData
- type Tone
- type Variant
Constants ¶
const ( ToastSuccess = "success" ToastWarning = "warning" ToastError = "error" )
The kinds of toast, for ui.Toast's Type; "" is a plain one.
Variables ¶
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.
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 ¶
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 ¶
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
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
AvatarImageSized is AvatarImage at size × size.
func AvatarSized ¶ added in v1.22.0
AvatarSized is Avatar size wide, its initial grown in step (at least Text.Xs).
func AvatarStack ¶ added in v1.39.4
AvatarStack draws overlapping avatars of size, each ringed by Background so overlapping edges separate cleanly on paper cards.
func BadgeButton ¶ added in v1.38.0
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
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
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
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 ButtonFrame ¶
func ButtonFrame(c *ui.Context, o ButtonOpts) ui.Element
ButtonFrame is the styled button without children.
func ButtonGroup ¶
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 ¶
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 ¶
CardFooter is a right-aligned row for a Card's actions.
func CardHeader ¶
CardHeader is a Card's title with an optional description under it.
func Chevron ¶ added in v1.39.4
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
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
ChoiceText is a ChoiceCard's usual content: label, and help under it.
func Collapsible ¶
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 ¶
Elevate gives e the shadow s, each layer in the ink: dark in either appearance, as shadcn's black shadows are.
func Empty ¶
Empty is a centered empty state: an icon tile, a title, a description and actions; Dashed draws a dashed frame around it.
func EmptyAction ¶
EmptyAction is a button for Empty's Actions, the default size.
func FieldWith ¶ added in v1.39.4
FieldWith is Field laid out as o says: a column, or with a Switch a row.
func FloatCard ¶ added in v1.39.4
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
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 ¶
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
GroupDivider is the hairline between ButtonGroups in a toolbar.
func HoverCard ¶ added in v1.19.0
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 ¶
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 ¶
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
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 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
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 ¶
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 ¶ added in v1.18.0
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 ¶ added in v1.28.0
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 ¶ added in v1.18.0
MenuItem is an item of a menu, tinted while selected (the keys' choice); give it its Label and Children.
func NewFrame ¶ added in v1.18.0
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
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
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
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
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 ¶
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 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 Progress ¶ added in v1.38.0
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 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 SelectButton ¶ added in v1.38.0
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 ¶
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 SidebarIcon ¶
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 Skeleton ¶
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 StatusDot ¶
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
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 Tabs ¶
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
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 ¶
Text is text at a step of the text scale, on the interface's line (theme.LineUI, which every text inherits).
func ThinkingDots ¶ added in v1.39.4
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
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
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
ToastAnchor registers panel, the content panel the toasts sit in the bottom right corner of; call it every frame, before ToastHost.
func ToastBar ¶ added in v1.39.4
ToastBar registers a bar along the panel's foot, and field, its input: the toasts rise above bar and line up with field's right edge. Call it every frame the bar shows; a frame without it puts them back in the panel's corner.
func ToastBarRect ¶ added in v1.39.4
ToastBarRect is ToastBar for a bar drawn by a page in a web view: bar and field are where it is in the window.
func ToastHost ¶
ToastHost draws the window's toasts (c.Toast, c.AddToast) in the bottom right corner, where ToastAnchor and ToastBar put it, 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
ToastNow registers the time ToastHost judges deadlines by, the app's clock; without it, the window's.
func ToggleChip ¶ added in v1.38.0
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
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 ¶
Tooltip shows text by anchor on keyboard focus at once and on hover after a pause, and describes anchor to assistive technology.
func TooltipLabelled ¶
TooltipLabelled is Tooltip for an anchor whose Label already says text.
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
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 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 FieldOpts ¶ added in v1.39.4
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
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 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 ¶
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.
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.
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
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 )