Documentation
¶
Overview ¶
Package ui is NSGo's built-in styled components, on base and core: colors, finishes and motion in theme.go, type and small parts in style.go, and a component to a file. A complex component has a package below this one, as chat has. Icons are Lucide's accessors.
The look is NSGo's: a neutral page, flat bordered cards under bold titles, flat bordered controls 28 pt tall in 13 pt text by default, 8 pt corners and one blue accent. On touch devices Button, OtpInput's cells and form rows grow to touch targets; desktops and TVs keep the compact sizes. Its colors are core.DefaultTheme's, which holds every role it reads. A component takes its look from Variant; the few of several sizes take Size, in size.go, or points where they are one shape at any scale.
Components are structs with a Render method: the app sets the fields and handles changes. Each reads its colors where it is built (ColorsOf, TintsOf, FinOf), so a subtree's theme or forced appearance reaches it, and reads them in StyleFuncs, Draws and the like, which follow a change of theme or appearance in place, as NSH's styles do: nothing is built again.
Index ¶
- Constants
- Variables
- func Alpha(c core.Color, a float32) core.Color
- func Black(a float32) core.Color
- func CardStyle(cx *core.Scope) core.Style
- func Chrome(cx *core.Scope) core.Color
- func Colored(c func() core.Color) func() core.Style
- func Dimmed() *core.Style
- func Filled(c func() core.Color) func() core.Style
- func Fixed(c core.Color) func() core.Color
- func FocusRing(cx *core.Scope, offset core.Points) *core.Style
- func HandleLine(cx *core.Scope) func() core.Style
- func HandleThumb(cx *core.Scope) core.Style
- func HandleThumbColor(cx *core.Scope) func() core.Style
- func Hovered(cx *core.Scope) *core.Style
- func Icon(svg func() *core.SVG, size core.Points, tint func() core.Color) core.Node
- func IconOf(svg func() *core.SVG, size core.Points, tint func() core.Color) core.Node
- func Inherited() core.Color
- func Inner(x, y, blur core.Points, c core.Color) core.BoxShadow
- func Lerp(v core.AnimatedNode, from, to float64) core.AnimatedNode
- func Mix(a, b core.Color, t float32) core.Color
- func NavInset(cx *core.Scope) core.Points
- func NavPage(cx *core.Scope, p base.NavPage, header NavHeader) base.NavPage
- func ReduceMotion(cx *core.Scope) bool
- func ScrollbarTheme(cx *core.Scope) *base.ScrollbarTheme
- func Shadow(x, y, blur, spread core.Points, c core.Color) core.BoxShadow
- func ShellHeaderHeight(cx *core.Scope) core.Points
- func Spring(cx *core.Scope, v *core.AnimatedValue, to float64, c core.SpringConfig)
- func TabBarInset(cx *core.Scope) core.Points
- func Tabular(t core.Text) core.Text
- func Text(content string, size core.Points, weight core.FontWeight, c func() core.Color) core.Text
- func TextViewStyles(cx *core.Scope) textview.Styles
- func Textf(fn func() string, size core.Points, weight core.FontWeight, ...) core.Text
- func Themed[T any](cx *core.Scope, build func() T) func() T
- func Timing(cx *core.Scope, v *core.AnimatedValue, to float64, c core.TimingConfig)
- func Touch(cx *core.Scope) bool
- func WarmDuskTheme() *core.Theme
- func White(a float32) core.Color
- type Accordion
- type AccordionItem
- type AlertAction
- type AlertDialog
- type Avatar
- type AvatarGroup
- type AvatarGroupMember
- type AvatarStatus
- type Badge
- type BadgeVariant
- type Breadcrumbs
- type Button
- type ButtonVariant
- type Calendar
- type Carousel
- type Cell
- type Checkbox
- type Collapsible
- type CollapsibleVariant
- type ColorPicker
- type ColorWell
- type Colors
- func (c Colors) Accent() core.Color
- func (c Colors) AccentFill() core.Color
- func (c Colors) Background() core.Color
- func (c Colors) Border() core.Color
- func (c Colors) Code() core.Color
- func (c Colors) Danger() core.Color
- func (c Colors) Down() core.Color
- func (c Colors) Faint() core.Color
- func (c Colors) Field() core.Color
- func (c Colors) FieldBorder() core.Color
- func (c Colors) Hover() core.Color
- func (c Colors) Info() core.Color
- func (c Colors) Inset() core.Color
- func (c Colors) Knob() core.Color
- func (c Colors) Light() core.Color
- func (c Colors) Line() core.Color
- func (c Colors) Muted() core.Color
- func (c Colors) Now() Palette
- func (c Colors) OnAccent() core.Color
- func (c Colors) OnLight() core.Color
- func (c Colors) Pressed() core.Color
- func (c Colors) Raised() core.Color
- func (c Colors) Surface() core.Color
- func (c Colors) Text() core.Color
- func (c Colors) Track() core.Color
- func (c Colors) Up() core.Color
- func (c Colors) Warn() core.Color
- type Combobox
- type Command
- type CommandDialog
- type ContextMenu
- type DatePicker
- type Dialog
- type DockArea
- type DockTabLabel
- type EmojiPicker
- type Field
- type Finish
- type Fins
- func (f Fins) Accent() Finish
- func (f Fins) Card() Finish
- func (f Fins) Chip() Finish
- func (f Fins) Dialog() Finish
- func (f Fins) Field() Finish
- func (f Fins) Glass() Finish
- func (f Fins) Inset() Finish
- func (f Fins) Knob() Finish
- func (f Fins) Light() Finish
- func (f Fins) Menu() Finish
- func (f Fins) Pill() Finish
- func (f Fins) Raised() Finish
- func (f Fins) Track() Finish
- type FormField
- type FormRow
- type FormRowVariant
- type FormSection
- type HStack
- type HoldToConfirm
- type HoldVariant
- type HoverCard
- type IconButton
- type IconButtonVariant
- type Image
- type ImageCompare
- type Input
- type Link
- type List
- type Menu
- type MenuItem
- type MenuItemVariant
- type MenuLabel
- type MenuSeparator
- type Meter
- type MeterVariant
- type NavHeader
- type NumberInput
- type Option
- type OtpInput
- type Pagination
- type Palette
- type PlainShell
- type Popover
- type Press
- type Progress
- type ProgressRing
- type Radio
- type RadioGroup
- type Rating
- type ResizablePanelGroup
- type ResizeHandle
- type ScrollView
- type Scrollbar
- type Select
- type Selection
- type Settings
- type SettingsCategory
- type SettingsDialog
- type SettingsGroup
- type SettingsItem
- type SettingsResult
- type Sheet
- type ShellTab
- type Sidebar
- type SidebarButton
- type SidebarButtonVariant
- type SidebarItem
- type SidebarSection
- type SidebarShell
- type SidebarShellVariant
- type Size
- type Skeleton
- type SkeletonBlock
- type SkeletonContent
- type Slider
- type Spacer
- type Spinner
- type SpinnerVariant
- type StepStatus
- type Stepper
- type StepperStep
- type Submenu
- type SuggestList
- type Switch
- type SwitchLook
- type SwitchVariant
- type TabShell
- type Tabs
- type TabsIndicatorFit
- type TabsVariant
- type TagInput
- type TextView
- type TimeField
- type Tints
- type ToastContent
- type ToastPlacement
- type ToastSwipe
- type ToastType
- type Toaster
- type Toasts
- type ToggleButton
- type ToggleGroup
- type Toolbar
- type ToolbarGroup
- type ToolbarSeparator
- type Tooltip
- type Tree
- type TreeItem
- type Wrap
Constants ¶
const ( Regular = core.FontWeightNormal Medium = core.FontWeightMedium Semibold = core.FontWeightSemibold Bold = core.FontWeightBold )
Weights, short.
const ( RadiusSmall core.Points = 4 RadiusFull core.Points = 9999 )
Smaller and larger radii than RadiusControl: marks inside controls (a checkbox, a chip), and capsules and circles.
const ( RadiusCard core.Points = 12 RadiusInset core.Points = 8 RadiusControl core.Points = 8 )
Corner radii.
const ButtonHeight core.Points = 28
ButtonHeight is a desktop button's height at SizeDefault.
const HeaderHeight core.Points = 48
HeaderHeight is the height of the shell's headers, which an app gives desktop.SetTitleBar for a title bar of its own to match them.
const Mono = core.FontMonospace
Mono is the monospaced family, for code (API names, identifiers).
const RadiusDialog core.Points = 16
RadiusDialog rounds a dialog on desktops.
const RowHeight core.Points = 36
RowHeight is a row's height.
Variables ¶
var ( TypeCaption = core.Style{FontSize: 12, LineHeight: 16} TypeBody = core.Style{FontSize: 13, LineHeight: 18} TypeLabel = core.Style{FontSize: 13, LineHeight: 18, FontWeight: Medium} TypeTitle = core.Style{FontSize: 15, LineHeight: 20, FontWeight: Semibold} TypeHeading = core.Style{FontSize: 20, LineHeight: 26, FontWeight: Semibold} TypeCode = core.Style{FontSize: 12, LineHeight: 18, FontFamily: Mono} )
The type the components set text in, by role: small print, running text, a control's text, a dialog's or a group's title, a page's heading, and code.
var ( SettleSpring = core.SpringConfig{Stiffness: 320, Damping: 30} EaseOutCubic = core.Easing{Kind: core.EasingCubic, Mode: core.EaseModeOut} EnterTiming = core.TimingConfig{Duration: 420 * time.Millisecond, Easing: EaseOutCubic} )
The motion every control shares: quick, slightly springy.
var FillRest = core.Style{FlexGrow: 1, FlexShrink: 1, MinWidth: core.Pt(0), MinHeight: core.Pt(0)}
FillRest grows to fill its container.
Functions ¶
func Chrome ¶
Chrome is the background of the window's chrome (a title bar, the sidebar): none while a window material shows through it, read in a StyleFunc.
func FocusRing ¶
FocusRing is the keyboard focus, for a FocusVisible style: a 2-point ring of info inside the view's edge (offset 2 puts it outside, around a filled button), read in a StyleFunc.
func HandleLine ¶
HandleLine is a handle's line, which stays as it is. It is a StyleFunc.
func HandleThumb ¶
HandleThumb is the thumb of a resize handle on phones, as gpui-component draws it: none at rest, so the hairlines stay quiet; a long solid pill while pressed or dragged. Elsewhere handles have none, the pointer's resize cursor showing where to drag.
func HandleThumbColor ¶
HandleThumbColor is the thumb's color, for a ThumbStyleFunc: none where HandleThumb is none.
func Hovered ¶
Hovered is a pressable under the pointer: a whisper of the text color over its surface, quieter than pressed and than selected. Like the rest of a style, read it in a StyleFunc.
func Icon ¶
Icon draws a Lucide glyph size points square in the tint, which it follows; nothing for nil.
func Lerp ¶
func Lerp(v core.AnimatedNode, from, to float64) core.AnimatedNode
Lerp maps v's 0 to 1 onto from to to.
func NavInset ¶
NavInset is the room to leave at the top of a page's content that does not scroll for a NavPage's system header, and 0 where the header takes room of its own. Scroll views under the header are inset already. It is tracked as the safe area changes.
func NavPage ¶
NavPage returns p, a page of a base.Nav, on the page's background under header, a NavHeader whose title and ends default to p's, unless p has a Header of its own. On iOS and Android a page's own Header becomes the system header's title view, filling the room between its ends when its views grow or take a percentage width and taking its content's size otherwise; it takes precedence over HeaderTitle and keeps p's left and right views, and only header's Scroll is used. Otherwise header supplies the title and ends. The system's back button pops the page, and the transparent header lies over the page, which scrolls under it with a progressive blur. Elsewhere the page's own Header, or NavHeader, is drawn above the page.
func ReduceMotion ¶
ReduceMotion reports whether the user asked for less motion as the tree is built.
func ScrollbarTheme ¶
func ScrollbarTheme(cx *core.Scope) *base.ScrollbarTheme
ScrollbarTheme is ui's bars for every scroll view and list, which base.SetScrollbarTheme installs over the platform's indicators: they show while a view scrolls, as the platforms' overlay scrollers do, and fade out.
func ShellHeaderHeight ¶
ShellHeaderHeight is a shell's header's height: HeaderHeight, or the window controls' height where it is greater.
func Spring ¶
func Spring(cx *core.Scope, v *core.AnimatedValue, to float64, c core.SpringConfig)
Spring and Timing start an animation of v on the platform.
func TabBarInset ¶
TabBarInset is how much of a TabShell section's bottom the floating tab bar covers, read in a StyleFunc: 0 where the bar takes room of its own.
func TextViewStyles ¶
TextViewStyles are TextView's styles where cx is, by part, for a textview.TextView the app styles further. It reads the palette, so read it where Themed does.
func Textf ¶
func Textf(fn func() string, size core.Points, weight core.FontWeight, c func() core.Color) core.Text
Textf is a line whose content follows fn.
func Themed ¶
Themed is what build returns, built again when what it reads (the palette) changes: a component's styles by part, for its StylesFunc.
func Timing ¶
func Timing(cx *core.Scope, v *core.AnimatedValue, to float64, c core.TimingConfig)
func Touch ¶
Touch reports whether the device takes touches rather than a pointer, for what a pointer alone can do: a desktop's pointer and a TV's remote, which moves a focus, take none.
func WarmDuskTheme ¶
WarmDuskTheme returns Warm Dusk (暖暮), a built-in theme: warm paper and charcoal with its terracotta accent, which an app gives to SetTheme as it does DefaultTheme.
Types ¶
type Accordion ¶
type Accordion struct {
Items []AccordionItem
Open func(index int) bool
OnOpenChange func(index int, open bool)
TestID string
Style core.Style
}
Accordion is a bordered box of sections divided by hairlines, as ui's, on base.Accordion: each title a heading over a button, each panel a region that springs open. The app keeps which are open: one at a time, or any.
type AccordionItem ¶
AccordionItem is one section of an Accordion.
type AlertAction ¶
type AlertAction struct {
Text string
TextFunc func() string
Variant ButtonVariant
Color func() core.Color
// Role is core.AlertCancel for the action Escape and back run before the alert closes with ReasonCancel, the first such action; core.AlertDestructive marks one that destroys, for TSX's role names. Variant and Color still choose its look.
Role core.AlertRole
// Default is the action Return chooses, the first such action: it takes the keyboard focus as the alert opens, and Return runs it while the focus is on no other action or field, then closes the alert with ReasonSelect.
Default bool
OnPress func()
TestID string
}
AlertAction is an action of an AlertDialog, a Button of its Variant, or filled with Color.
type AlertDialog ¶
type AlertDialog struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// OnClose follows it being gone, once its motion ended.
OnClose func()
Title string
TitleFunc func() string
Description string
DescriptionFunc func() string
Actions []AlertAction
TestID string
// Style merges over the dialog's surface; StyleFunc merges over Style and follows the signals it reads.
Style core.Style
StyleFunc func() core.Style
}
AlertDialog asks the user to confirm or acknowledge something: a Dialog whose actions close it, kept open by presses outside it.
type Avatar ¶
type Avatar struct {
Name string
Image core.ImageSource
Status AvatarStatus
// Size is the diameter, 32 points when 0. The initials and the dot
// follow it.
Size core.Points
Label string
TestID string
Style core.Style
}
Avatar is a round mark for a person or an account: its Image, or the initials of Name while the image loads, when it fails and without one. Assistive technology reads it as an image named Label, else Name: give Label the status when one shows.
type AvatarGroup ¶
type AvatarGroup struct {
Members []AvatarGroupMember
// Max is how many avatars show before the chip: 4 when 0, none when
// negative.
Max int
// Size is each avatar's diameter, Avatar's standard when 0.
Size core.Points
// Label names the group for assistive technology.
Label string
// MoreLabel names the chip of n more members; "+n" when nil.
MoreLabel func(n int) string
TestID string
Style core.Style
}
AvatarGroup is an overlapping row of avatars, the first Max shown and the rest counted on a chip. On desktops pointing at the row spreads it and names the avatar under the pointer in a tooltip.
type AvatarGroupMember ¶
type AvatarGroupMember struct {
Name string
Image core.ImageSource
Status AvatarStatus
// Label is what assistive technology reads, Name when empty.
Label string
}
AvatarGroupMember is one person of an AvatarGroup.
type AvatarStatus ¶
type AvatarStatus uint8
AvatarStatus is the presence an avatar's corner dot shows.
const ( // AvatarNoStatus shows no dot. AvatarNoStatus AvatarStatus = iota // AvatarOnline is a dot of the up tone. AvatarOnline // AvatarOffline is a faint dot. AvatarOffline )
type Badge ¶
type Badge struct {
Text string
TextFunc func() string
Variant BadgeVariant
VariantFunc func() BadgeVariant
}
Badge is a small label in a capsule: Text, or what TextFunc returns, in Variant, or the one VariantFunc returns.
type BadgeVariant ¶
type BadgeVariant uint8
BadgeVariant is a Badge's look.
const ( // BadgeNeutral is the bordered surface. It is the default. BadgeNeutral BadgeVariant = iota // BadgeAccent tints the capsule with the accent. BadgeAccent // BadgeSuccess tints the capsule with the success color. BadgeSuccess // BadgeWarn tints the capsule with the warning color. BadgeWarn // BadgeDanger tints the capsule with the danger color. BadgeDanger )
type Breadcrumbs ¶
type Breadcrumbs struct {
Items []string
// OnSelect receives the index of a pressed ancestor.
OnSelect func(index int)
TestID string
Style core.Style
}
Breadcrumbs is a path filling its parent's width: its ancestors pressable, the last item the current one. When it does not fit, the ancestors after the first collapse into a menu under an ellipsis, as few as make it fit; the first and last items stay and truncate if still too wide.
type Button ¶
type Button struct {
Ref *core.Ref
LabelledBy []*core.Ref
Text string
TextFunc func() string
// TextStyle overrides the typography of the button's label.
TextStyle core.Style
Variant ButtonVariant
// Color fills it with that color instead.
Color func() core.Color
Icon func() *core.SVG
// Label is what assistive technology reads, Text when empty: give it
// to a button of an icon alone.
Label string
LabelFunc func() string
Disabled func() bool
// Busy says the button's action is still loading, for assistive technology too: while it returns true a spinner in the button's text color shows over its content, which keeps its room, and presses do nothing, so the action does not start twice.
Busy func() bool
// BusyLabel shows beside the spinner and names the busy button for
// assistive technology. BusyLabelFunc supplies the text when set.
BusyLabel string
BusyLabelFunc func() string
// AutoFocus moves the keyboard focus here once it mounts, as base.Button's.
AutoFocus bool
// Flex grows it to share a row with its siblings.
Flex float32
Size Size
// Style is merged onto the pressable, whose face fills its content box: use it for a full-row button (for example, Width: core.Pct(100)), an app-specific size or margins. The face keeps the variant's look, its corners following Style's CornerRadius.
Style core.Style
// Side is the square of a button of an icon alone, its height when 0,
// to line it up with what is not a control's height. IconSize is its
// glyph's, the Size's when 0, and Tint its color, the look's when nil.
Side, IconSize core.Points
Tint func() core.Color
TestID string
OnPress func()
}
Button is ui's button, as tall as its Size: Text with an optional leading Icon, or the Icon alone in a square. base.Button gives the behavior; the look is ui's.
type ButtonVariant ¶
type ButtonVariant uint8
ButtonVariant is a button's look, one of ui's.
const ( // ButtonPrimary is filled with the accent, for the main action. It is // the default. ButtonPrimary ButtonVariant = iota // ButtonSecondary is a quiet fill of the text's color at a low opacity. ButtonSecondary // ButtonOutline is only a rim. ButtonOutline // ButtonGhost has no rim or fill at rest, only a fill under the pointer // and held down, as an IconButton's, such as a menu's trigger in a // toolbar. ButtonGhost // ButtonTinted uses accent text on a quiet accent fill. ButtonTinted // ButtonDanger uses danger text on a quiet danger fill. ButtonDanger )
type Calendar ¶
type Calendar struct {
Value func() base.DateValue
DefaultValue base.DateValue
Range bool
NumberOfMonths int
// FirstDayOfWeek starts the weeks: 1 for Monday to 7 for Sunday, the
// user's when 0.
FirstDayOfWeek int
// DisabledMatcher says which days take no press.
DisabledMatcher func(day time.Time) bool
OnChange func(value base.DateValue)
TestID string
// Style merges over the calendar's.
Style core.Style
}
Calendar is a month of days to pick a date from, or with Range a start and an end, in a fixed-size look: a selected day in the accent, today ringed, the days around the month muted. Its title toggles jump to months and years, and its days are one Tab stop whose keys move through them, turning the months.
type Carousel ¶
type Carousel struct {
Count int
Slide func(cx *core.Scope, i int) core.Node
Index func() int
// OnChange receives the slide the user brings to the center.
OnChange func(i int)
// SlideWidth is the widest a slide grows: 340 points when 0. A slide
// takes at most 80% of the carousel.
SlideWidth core.Points
// Looping goes around the ends, seamlessly while the slides span the
// carousel and one slide more. Read as it is made.
Looping bool
// Label names the carousel, and SlideLabel slide i of count and its
// indicator, "i+1 / count" when nil.
Label string
SlideLabel func(i, count int) string
PreviousLabel, NextLabel string
TestID string
Style core.Style
}
Carousel is base.Carousel in ui's look, a row of Count slides that snaps one to the center, its neighbors in view, smaller and dimmer: a swipe or a trackpad moves it, and the arrows and the indicators below choose a slide. The app keeps the centered slide's Index and sets it from OnChange as the user's scroll rests; setting it glides the slides there. Every slide stays built, so keep the set short.
type Checkbox ¶
type Checkbox struct {
// Ref and LabelledBy are the control view's, as a core.View's.
Ref *core.Ref
LabelledBy []*core.Ref
Invalid func() bool
Checked func() bool
// Indeterminate is neither checked nor unchecked, as "select all" over
// a partial selection; a press then asks for checked.
Indeterminate func() bool
Disabled func() bool
// OnChange receives the value a press asks for.
OnChange func(checked bool)
// OnChangeEvent receives the requested value and the originating press, including its modifier keys. When set, it replaces OnChange.
OnChangeEvent func(checked bool, press core.PressEvent)
Text string
TextFunc func() string
// Children replace Text.
Children []core.Node
// Label is what assistive technology reads, Text when empty.
Label string
LabelFunc func() string
Hint string
HintFunc func() string
TestID string
Style core.Style
}
Checkbox is checked, unchecked or indeterminate, with Text or the app's Children beside its box.
type Collapsible ¶
type Collapsible struct {
Open func() bool
OnOpenChange func(open bool)
Variant CollapsibleVariant
Text string
// Trigger replaces Text in the trigger, beside its arrow.
Trigger []core.Node
Content core.Node
Disabled func() bool
TestID string
Style core.Style
}
Collapsible is a titled region whose Content the trigger shows and hides with a spring: a title beside an arrow, as wide as they are.
type CollapsibleVariant ¶
type CollapsibleVariant uint8
CollapsibleVariant is where a Collapsible's arrow sits beside its title.
const ( // CollapsibleArrowRight follows the title. It is the default. CollapsibleArrowRight CollapsibleVariant = iota // CollapsibleArrowLeft leads the title, and the content lines up under // the title. CollapsibleArrowLeft )
type ColorPicker ¶
type ColorPicker struct {
Value func() core.Color
DefaultValue core.Color
// Format is how OnChange and OnChangeEnd write the color, and the
// notation the fields start in.
Format base.ColorFormat
// NoAlpha leaves the opacity slider and field out.
NoAlpha bool
Disabled func() bool
OnChange func(value core.Color, formatted string)
OnChangeEnd func(value core.Color, formatted string)
TestID string
// Style merges over the picker's.
Style core.Style
}
ColorPicker is a color view: a saturation and brightness plane, hue and opacity sliders, the fields in RGB, HSB or HSL, hex and opacity, and a menu that copies the color, 256 pt wide: base.ColorPicker's parts in a look. An eyedropper shows where the platform has one (core.Env.CanPickScreenColor).
type ColorWell ¶
type ColorWell struct {
Value func() core.Color
// Picker is what opens: its Value and DefaultValue go unused.
Picker ColorPicker
OnChange func(value core.Color)
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// Label names the well for assistive technology.
Label string
TestID string
}
ColorWell is a color picker: a swatch 48 × 32 that opens a ColorPicker beside it.
type Colors ¶
type Colors struct {
// contains filtered or unexported fields
}
Colors are ui's colors where a scope is: each method reads its color from the palette shown there, the theme's roles under ui's names and the ones core.DefaultTheme adds to Palette.Colors. A StyleFunc or Draw that calls one follows the palette; a method value (colors.Muted) is a color to hand to what reads it so.
func (Colors) Accent ¶
Accent is the accent as a foreground: text, icons, lines, small marks. AccentFill is the accent as a fill, with OnAccent on it.
func (Colors) AccentFill ¶
func (Colors) Background ¶
Background is the page behind the cards; Surface a card; Inset a surface inside a card; Raised a control on a card.
func (Colors) Field ¶
Field is an input's well, below the card and the insets it sits on; FieldBorder its edge.
func (Colors) FieldBorder ¶
func (Colors) Light ¶
Light is the main action's button, light on the dark page and dark on the light one, with OnLight on it.
type Combobox ¶
type Combobox[T comparable] struct { Options []Option[T] Multiple bool Value func() []T OnChange func(value []T) Placeholder string // Empty shows while none matches. Empty string Disabled func() bool // Presentation is base's: a popup at the field by default, or a // sheet, which ui chooses on no device of its own. Presentation base.Presentation // Label names the field for assistive technology. Label string // TestID names the box around the field. TestID string // Style merges over the box's. Style core.Style }
Combobox is a text field that filters Options as it is typed in and picks from them: one value that a choice replaces, closing the list, or with Multiple several that a choice toggles. The list marks what is chosen with its rows' selected face. Options' Icon and Content go unused.
type Command ¶
type Command struct {
Items func() []base.CommandItem
// Placeholder and SearchLabel are the field's, Empty what shows while
// none matches, LoadingText while Loading: all have words of their own.
Placeholder, SearchLabel, Empty, LoadingText string
// Query makes the query the app's, nil for the field's own, from
// DefaultQuery.
Query func() *string
DefaultQuery string
OnQueryChange func(query string)
// Filter replaces base.FilterCommands, and NoFilter leaves the items to
// the app, as a search it answers itself.
Filter func(items []base.CommandItem, query string) []base.CommandItem
NoFilter bool
// ExpandOnSearch shows the field alone until the query holds more than
// spaces, then the Height of Style.
ExpandOnSearch bool
// Loading takes the rows' place with LoadingText, Error with what it
// says, while it says something.
Loading func() bool
Error func() string
// InputSource and KeepInputSource are base.Command's.
InputSource string
KeepInputSource bool
// Ref's Focus, Highlight and MatchedCount are the palette's.
Ref *base.CommandRef
AutoFocus bool
OnSelect func(id string)
OnHighlightChange func(highlighted *string)
// OnCancel hears Escape with no query.
OnCancel func()
// Label names the list for assistive technology.
Label string
TestID string
// Style merges over the palette's.
Style core.Style
}
Command is a command palette as Raycast's: a bare search field over the app's commands, ranked as they match and under their sections, the first one lit and Return running it. A row shows an icon, a label with a description, and the item's Trailing and shortcut at its end. Put it in a CommandDialog, or anywhere with a height of its own.
type CommandDialog ¶
type CommandDialog struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// OnClose follows it being gone, once its motion ended.
OnClose func()
// Command is the palette, whose Label, when set, names the dialog.
Command Command
// Inset is the Dialog's.
Inset core.Points
TestID string
// Style merges over the surface's.
Style core.Style
}
CommandDialog hosts a Command in a modal surface, or a sheet on touch screens: 640 points wide and its rows 440 tall. It takes the keyboard as it opens and gives it back as it closes; the app binds what opens it, and closes it from the palette's OnSelect. With ExpandOnSearch it fits the field until the query holds more than spaces.
type ContextMenu ¶
type ContextMenu struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
Disabled bool
// Presentation is base's: a popup at the pointer by default, or a
// sheet, which ui chooses on no device of its own.
Presentation base.Presentation
Trigger core.Node
Children []core.Node
TestID string
// Style is the trigger's.
Style core.Style
}
ContextMenu opens its items about Trigger, as a secondary click or a finger resting on it asks: at the pointer, or as a sheet.
type DatePicker ¶
type DatePicker struct {
Value func() base.DateValue
DefaultValue base.DateValue
Range bool
// TimePrecision edits a date's time too, HourCycle its clock.
TimePrecision base.TimePrecision
HourCycle base.HourCycle
// DefaultTime is a new date's time.
DefaultTime base.TimeOfDay
// TimeLabel says what the time field is, in the popup.
TimeLabel string
// Presets are values offered beside the calendar.
Presets []base.DatePreset
NumberOfMonths int
// FirstDayOfWeek starts the weeks: 1 for Monday to 7 for Sunday, the
// user's when 0.
FirstDayOfWeek int
// DisabledMatcher says which days take no press.
DisabledMatcher func(day time.Time) bool
DateFormat string
Placeholder string
// Cleanable shows a button in the field while a date is chosen.
Cleanable bool
Disabled func() bool
OnChange func(value base.DateValue)
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// Presentation is base's: a popup at the field by default, or a
// sheet, which ui chooses on no device of its own.
Presentation base.Presentation
// Label names the field for assistive technology.
Label string
TestID string
// Style merges over the field's, 200 pt wide: its height, padding and
// type reach the field, as Select's do.
Style core.Style
}
DatePicker is a date, a range or with TimePrecision a date and time in a field that opens a Calendar: a popup at it on desktops, a sheet on touch screens. The field shows the value in DateFormat, strftime's, or Placeholder while there is none.
type Dialog ¶
type Dialog struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// OnClose follows it being gone, once its motion ended.
OnClose func()
// OnConfirm is the default action Return runs before it closes with ReasonSelect, as base.Dialog's.
OnConfirm func()
Title string
TitleFunc func() string
Description string
DescriptionFunc func() string
// Leading and Trailing sit at the start and end of the title row, such as a sheet's Cancel and Done. While either is set, the title is centered between two sides of one width, where it wraps rather than run under them.
Leading []core.Node
Trailing []core.Node
// TitleStyle overrides the title's typography on every presentation.
TitleStyle core.Style
TitleStyleFunc func() core.Style
Children []core.Node
// Footer holds the actions, at the end of a row on desktops, the
// last first in a stack across a sheet.
NoCloseOnEscape bool
NoCloseOnBackdropPress bool
// Inset is the least distance from the window's edges on desktops, 20
// when 0; a title bar the app draws in takes it further. The strip of
// that title bar keeps moving the window under the backdrop.
Inset core.Points
// Bare leaves out the surface's padding, gap and width, for content that fills it, sizes it and is clipped inside its rim to the corners Style and StyleFunc give it.
Bare bool
// NoGrabber hides the touch sheet's default drag handle.
NoGrabber bool
// ContentStyle and ContentStyleFunc override the touch sheet's padding and gap.
ContentStyle core.Style
ContentStyleFunc func() core.Style
// StartingStyle and EndingStyle override the touch sheet's entry and exit styles. Include a Transition for custom timing.
StartingStyle core.Style
EndingStyle core.Style
// Label names the dialog for assistive technology, Title when it and LabelFunc are not given, which reads Description after it. Role makes it an alert dialog, one asking for an answer, as a confirmation.
Label string
LabelFunc func() string
Role core.Role
TestID string
// Style merges over the surface's.
Style core.Style
// StyleFunc merges over Style and follows the signals it reads.
StyleFunc func() core.Style
}
Dialog is a modal surface over a dimmed app and a sheet from the bottom on touch screens: a title, a description, the app's children and its Footer of actions. On desktops it pops in and fades out, centered across and above the middle, nearer to it the more of the window's height it takes.
type DockArea ¶
DockArea is dock.Area in ui's look: tab bars on the inset color with the selected tab on the surface, hairline handles, the selection where a dragged tab would land, and drawers and a sheet as the touch-screen popups are. A tab shows its key unless RenderTab says else; DockTabLabel is the label with a close button.
type DockTabLabel ¶
DockTabLabel is what a DockArea's tab shows: an icon, the text, and while its panel may close, a button named CloseLabel that closes it.
type EmojiPicker ¶
type EmojiPicker struct {
Query func() *string
DefaultQuery string
OnQueryChange func(query string)
NoSearch bool
Placeholder string
PlaceholderFunc func() string
SearchLabel string
SearchLabelFunc func() string
AutoFocus bool
InputSource string
KeepInputSource bool
Category func() base.EmojiCategory
DefaultCategory base.EmojiCategory
OnCategoryChange func(base.EmojiCategory)
Categories []base.EmojiCategory
NoCategories bool
SkinTone func() base.EmojiSkinTone
DefaultSkinTone base.EmojiSkinTone
OnSkinToneChange func(base.EmojiSkinTone)
NoSkinTone bool
// NoPreview hides the highlighted emoji preview in the footer.
NoPreview bool
// Recent supplies recently used emoji strings (e.g. "🔥", "👍").
Recent func() []string
// Languages overrides the app's languages searched for emoji names and
// keywords.
Languages []string
LanguagesFunc func() []string
// Columns is how many emoji sit in each row; 8 when <= 0.
Columns int
Disabled func() bool
Invalid func() bool
OnSelect func(base.Emoji)
OnHighlightChange func(*base.Emoji)
OnCancel func()
Ref *base.EmojiPickerRef
Label string
LabelFunc func() string
TestID string
Style core.Style
StyleFunc func() core.Style
OnLayout func(core.Bounds)
Tooltip core.Node
}
EmojiPicker is a styled emoji picker: a search field matching every Unicode emoji in the app's languages, a category icon bar, a virtualized emoji grid, a highlighted emoji preview and a skin tone selector, 320 × 360 pt by default. Behavior, search and accessibility come from base.EmojiPicker, and all default words come from base/locales.
type Field ¶
Field is the platform's text field with base.Input's fields, in a text box's fill and rim that follow neither the pointer nor focus; its own style sets its size and padding. Its Style and then its StyleFunc merge over that look, so core.Transparent in Background and core.Zero in BorderWidth turn the box off and leave the text alone.
type Finish ¶
type Finish struct {
Background core.Color
Gradients []core.Gradient
Shadows []core.BoxShadow
Border core.Color
Backdrop []core.Filter
}
Finish is a surface's light and depth: a gradient over its color, its shadows, a rim and, for glass, a blur of what is behind.
type Fins ¶
type Fins struct {
// contains filtered or unexported fields
}
Fins are the finishes where a scope is, read as ColorsOf's colors are.
func (Fins) Dialog ¶
Dialog is a modal panel over the dim: a deeper shadow than a menu's and a solid rim, the page's color mixed with the text's, as a translucent one sinks into the dim and the shadow under it. Light takes more of the text: at that mix its rim is the dimmed page's gray.
type FormField ¶
FormField is a row of a FormSection that edits text: Title, then the Input with no box of its own, filling the rest of the row and aligned to its end. The Input's Label is Title unless it has one.
type FormRow ¶
type FormRow struct {
Icon func() *core.SVG
// TileSize is the side of the icon tile in points, 24 when zero.
TileSize core.Points
// Leading replaces the icon. LeadingWidth is the width reserved for
// it in points, 24 when zero, and aligns the section's divider.
Leading core.Node
LeadingWidth core.Points
Title, Detail string
// TitleFunc and DetailFunc update text without rebuilding the row.
TitleFunc, DetailFunc func() string
TitleStyle, DetailStyle core.Style
// Below follows the title and detail in their text column.
Below core.Node
// TitleMaxLines limits the title; zero leaves it unlimited.
TitleMaxLines int
// MinHeight overrides the row's minimum height in points; zero keeps its default.
MinHeight core.Points
// Role overrides the row's role. core.RoleRadio uses base.Radio behavior in a base.RadioGroup, with Checked supplying the controlled state.
Role core.Role
Checked func() bool
Value func() string
Control core.Node
OnPress func()
Disabled func() bool
Variant FormRowVariant
// Label names a pressable row for assistive technology, Title by default.
Label string
// LabelFunc binds an explicit accessible name; an empty name uses Title.
LabelFunc func() string
TestID string
}
FormRow is a row of a FormSection: Leading or an Icon on a tile, Title over Detail, then Value in the muted color and the Control. With OnPress it is a button; core.RoleRadio gives it base.Radio's controlled selection and keyboard behavior within a base.RadioGroup.
type FormRowVariant ¶
type FormRowVariant uint8
FormRowVariant is a FormRow's look.
const ( // FormRowDefault is a setting: the title in the text's color, and a // chevron at the end when it can be pressed. FormRowDefault FormRowVariant = iota // FormRowAccent is an action: the title in the accent. FormRowAccent // FormRowDanger is a destructive action, or what went wrong: the // title in the danger color. FormRowDanger )
type FormSection ¶
type FormSection struct {
// TitleFunc and FooterFunc update the optional text around the card.
Children []core.Node
TestID string
Style core.Style
// CardStyle styles the rows' surface. CardStyleFunc merges over it and follows the signals it reads.
CardStyle core.Style
CardStyleFunc func() core.Style
// DividerInset overrides a row's hairline inset when it returns true. Zero is full width; false keeps the title alignment or 12-point default. It receives the actual row for each child of a core.Each.
DividerInset func(row core.Node) (inset core.Points, override bool)
}
FormSection is related rows on a rounded card, divided by hairlines from the start of the titles above them, as an inset grouped list of iOS Settings: Title above the card and Footer below it, in the muted color. Its rows are FormRow and FormField, or the app's own nodes, which pad themselves; a core.Each among them gives each of its rows a hairline of its own.
type HoldToConfirm ¶
type HoldToConfirm struct {
Text string
ConfirmedText string
Icon func() *core.SVG
Variant HoldVariant
Duration time.Duration
Confirmed func() bool
OnConfirm func()
Hint string
Disabled func() bool
TestID string
}
HoldToConfirm is a button for what a stray press must not trigger: held down for Duration, 1.2 s when 0, a fill sweeps across it from the leading edge, and once it is full OnConfirm runs, assistive technology hears ConfirmedText, and Text and Icon (lucide.Trash when empty) give way to ConfirmedText and a check. Letting go early rewinds the fill. The keyboard and assistive technology, which cannot hold, start it with a press and cancel it with another or by moving the focus away.
Confirmed is the app's: true shows the done state, and setting it back to false resets the button. Hint is what assistive technology reads after the label, such as "Hold to confirm". Prefer an AlertDialog when people need to read the consequences first.
type HoldVariant ¶
type HoldVariant uint8
HoldVariant is a HoldToConfirm's look: the color it fills with.
const ( // HoldAccent fills with the accent. HoldAccent HoldVariant = iota // HoldDanger tints the face and fills with the danger color, for an // action that cannot be undone. HoldDanger // HoldNeutral fills with the text's color. HoldNeutral )
type HoverCard ¶
type HoverCard struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// OpenDelay and CloseDelay are base.HoverCard's.
OpenDelay, CloseDelay time.Duration
Placement core.Placement
Align core.Align
Trigger core.Node
Children []core.Node
TestID string
// Style merges over the surface's.
Style core.Style
}
HoverCard previews what Trigger points at on a surface beside it: after the pointer rests or the focus stays on a desktop, as a press on a touch screen. Trigger keeps its own role, presses and look.
type IconButton ¶
type IconButton struct {
Icon func() *core.SVG
Label string
LabelFunc func() string
// Tooltip, when set, says the tooltip in place of the label, and follows it; one that returns "" shows none.
Tooltip func() string
Variant IconButtonVariant
// Size is 28 for IconButtonGhost and 32 for a circle when 0.
Size core.Points
// IconSize is the glyph's, 60% of Size for IconButtonGhost and 45% for
// a circle when 0, and Tint its color, the look's when nil.
IconSize core.Points
Tint func() core.Color
// Fill colors the face of IconButtonFilled; the theme's inset color when nil.
Fill func() core.Color
Selected func() bool
Disabled func() bool
OnPress func()
TestID string
}
IconButton is a button of an icon alone, Size points across, faded while Disabled. Icon follows what it reads, and LabelFunc replaces Label, what assistive technology reads. The label is also the tooltip that shows as the pointer rests on it, unless Tooltip says otherwise.
type IconButtonVariant ¶
type IconButtonVariant uint8
IconButtonVariant is an IconButton's look.
const ( // IconButtonGhost is a square with no fill at rest, as a toolbar's: a // fill under the pointer, held down and while Selected. It is the // default. IconButtonGhost IconButtonVariant = iota // IconButtonPrimary is a circle filled with the accent, for the main // action. IconButtonPrimary // IconButtonRaised is a circle on a raised toolbar face. IconButtonRaised // IconButtonFilled is a flat filled circle without a rim or shadow. IconButtonFilled )
type Image ¶
type Image struct {
Source core.ImageSource
Label string
// ResizeMode fits the picture into the well: Cover when 0.
ResizeMode core.ResizeMode
AspectRatio float32
Placeholder core.Node
OnLoad func(pixels core.Size)
OnError func(err error)
// TestID names the picture, which tests report loads on.
TestID string
// Style merges over the well's.
Style core.Style
}
Image is a picture in a rounded well that shows Placeholder while it loads and if it fails: a faint picture icon when nil. It keeps AspectRatio, else the one Source declares, else 3:2, unless its style sizes both sides. With a Label it is an image to assistive technology; without one, decoration.
type ImageCompare ¶
type ImageCompare struct {
Before, After core.Node
Position func() float32
OnChange func(position float32)
// Vertical puts Before on top, the divider across.
Vertical bool
BeforeLabel, AfterLabel string
Label string
// AspectRatio is the frame's width over its height: 3:2 when 0.
AspectRatio float32
TestID string
Style core.Style
}
ImageCompare lays Before over After in a rounded frame and shows it up to a white divider and knob: Position is the share of the frame, from 0 to 100, Before covers, 50 when nil. A press moves the divider there and a drag moves it along; screen readers step it as a slider. Both sides are laid out at the frame's size, so their content lines up. BeforeLabel and AfterLabel caption the sides.
type Input ¶
Input is the platform's text field with base.Input's fields, styled as a text box 28 pt tall with 13 pt text, or Multiline growing from three lines: its rim darker under the pointer and the accent while focused. Its Style and then its StyleFunc merge over that look, so the focus and hover rims stay while neither sets BorderColor or Hover. Its Padding replaces ui's 10 points a side, and core.Zero takes it away.
type Link ¶
type Link struct {
Text string
Href string
OpenWith base.LinkOpenWith
Disabled func() bool
// OnOpen hears it open its Href, before OnPress.
OnOpen func(href string)
OnPress func()
// Label is what assistive technology reads, Text when empty.
Label string
TestID string
// Style styles the link, including its text color; unset Color takes the accent.
Style core.Style
}
Link is text in the accent that goes somewhere when pressed, underlined under the pointer: base.Link's opening, by the system or by OnOpen.
type List ¶
type List struct {
Count func() int
// Key, Row, Selection, OnSelectionChange, OnActivate, TapSelects, RowLabel and Columns are base.List's.
Key func(i int) any
Row func(cx *core.Scope, row core.ListRow) core.Node
Selection *Selection
OnSelectionChange func(s *Selection)
OnActivate func(i int)
TapSelects bool
RowLabel func(i int) string
Columns int
// EstimatedSize is a row's expected height, a row's height when 0.
EstimatedSize core.Points
Gap core.Points
Header core.Node
// Empty shows while Count is 0.
Empty core.Node
// OnLoadMore runs as the end of the rows comes near, for the next page.
OnLoadMore func()
// Label names the list for assistive technology.
Label string
Ref *core.Ref
TestID string
Style core.Style
// ListStyle merges over the scrolled list of rows', whose padding is the content's: give padding here, so the scroll bar keeps to the list's edge. ListStyleFunc merges over that whenever what it reads changes, without remounting the list.
ListStyle core.Style
ListStyleFunc func() core.Style
// RowStyle merges over each row's, and RowStyleFunc, read as the row's
// colors are, over that.
RowStyle core.Style
RowStyleFunc func() core.Style
}
List is base.List in ui's look: rounded rows, the chosen ones on a faint fill of the text's color as a Sidebar's and the keyboard's cursor ringed. Give it a height, or let it fill what the app sizes.
type Menu ¶
type Menu struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// Trigger is the trigger's look and content; its OnPress and Disabled
// go unused.
Trigger Button
// Face, when set, draws the trigger in place of Trigger's look and
// content, for one that follows the app's state.
Face core.Node
// Presentation is base's: a popup at the trigger by default, or a
// sheet, which ui chooses on no device of its own.
Presentation base.Presentation
Placement core.Placement
Align core.Align
Children []core.Node
// MaxHeight, when set, scrolls the items past that height, as they
// scroll past the room beside the trigger.
MaxHeight core.Points
Label string
LabelFunc func() string
TestID string
}
Menu opens its items from a trigger, which Trigger's look and content draw.
type MenuItem ¶
type MenuItem struct {
Text string
TextFunc func() string
Icon func() *core.SVG
// Shortcut is the keys that choose it, such as "mod+c", shown at its
// end in a popup as the platform writes them.
Shortcut string
// Leading goes before its text, after its check and icon, and Trailing
// at its end, where a button's presses stay its own.
Leading core.Node
Trailing core.Node
Variant MenuItemVariant
Checked func() bool
Disabled func() bool
OnSelect func()
NoCloseOnSelect bool
TestID string
}
MenuItem is a choice of a menu. Checked, when set, keeps a check before its text while it returns true, for an option of the menu.
type MenuItemVariant ¶
type MenuItemVariant uint8
MenuItemVariant is a MenuItem's look.
const ( // MenuItemDefault is in the text's color. MenuItemDefault MenuItemVariant = iota // MenuItemDanger is in the danger color, for a destructive choice. MenuItemDanger )
type Meter ¶
type Meter struct {
Value func() float64
Variant MeterVariant
Marker float64
}
Meter is a horizontal meter of Value, from 0 to 1, in its Variant, with a Marker at a limit when it is above 0.
type MeterVariant ¶
type MeterVariant uint8
MeterVariant is a Meter's look: the color it fills with.
const ( // MeterNeutral fills with the muted text's color. It is the default. MeterNeutral MeterVariant = iota // MeterAccent fills with the accent. MeterAccent // MeterInfo fills with the info color. MeterInfo // MeterWarn fills with the warning color. MeterWarn // MeterDanger fills with the danger color. MeterDanger // MeterUp fills with the color of a rise. MeterUp // MeterDown fills with the color of a fall. MeterDown )
type NavHeader ¶
type NavHeader struct {
// TitleFunc replaces Title as the graph changes.
// Scroll is the page's scroll view, ScrollFunc when it changes: under iOS's and Android's system headers it blurs progressively toward the top.
// Symbols has iOS's system header show its own buttons for what takes presses in Trailing, one each in order, as the back button is drawn.
}
NavHeader is the bar at the top of a page: a back button named BackLabel while OnBack is set, the title, and the app's views at either end. On iOS and Android NavPage gives the title and the views to the system's header, whose own back button pops the page, so OnBack and BackLabel go unused there.
type NumberInput ¶
type NumberInput struct {
// Ref is the field's; LabelledBy and Invalid are a core.Input's.
Ref *core.Ref
LabelledBy []*core.Ref
Invalid func() bool
Value func() float64
OnChange func(value float64)
// Min and Max are the range, when Max is above Min.
Min, Max float64
// Step is what the buttons, the keys and the scrub change the value
// by, and what it is rounded to from Min; 1 when 0.
Step float64
// Format writes the value, with as many decimals as Step has when nil; Parse reads it back, strconv.ParseFloat's when nil. Changes to signals Format reads refresh the shown value outside editing.
Format func(value float64) string
Parse func(text string) (float64, bool)
// Leading is the scrub handle's icon, or LeadingText its text, such
// as "W"; without either the field has no handle. Its test ID is the
// field's with "-scrub".
Leading func() *core.SVG
LeadingText string
// HideSteppers leaves the buttons out.
HideSteppers bool
// IncrementLabel and DecrementLabel name the buttons for assistive
// technology.
IncrementLabel, DecrementLabel string
Disabled func() bool
// Label names the field for assistive technology.
Label string
// LabelFunc binds a changing Label.
LabelFunc func() string
TestID string
Style core.Style
}
NumberInput is base.NumberInput in ui's look, with buttons stacked at its end on desktops, a minus and a plus on touch screens. What is typed is read as the field is left or Return pressed, and kept to the range and the step; text that is no number gives the value back. A drag across its Leading handle scrubs it.
type Option ¶
type Option[T comparable] struct { Value T Label string LabelFunc func() string Group string Icon func() *core.SVG Disabled func() bool Content core.Node Leading core.Node Trailing core.Node TestID string }
Option is one choice of Tabs, a Select or a Combobox. Label names it. In Tabs, Icon leads the label, Disabled turns it off, and Content shows in place of both, inheriting the tab's text style, with Label still naming the tab for assistive technology. In a Select, Leading goes before the label, in its menu's row and in the field while chosen, and Trailing at the end of its row, where a button's presses stay its own. In a Select or a Combobox, adjacent options of one non-empty Group show under a header of it, which cannot be chosen or focused; Tabs ignore it.
type OtpInput ¶
type OtpInput struct {
Length int
// Value makes the code controlled; DefaultValue starts its own.
Value func() string
DefaultValue string
Masked bool
Disabled func() bool
// Groups is how many groups the cells split into.
Groups int
// Size is the default width and height of each cell in points: 36 on desktops and TVs, 44 on touch devices when zero.
Size core.Points
// CellWidth and CellHeight override Size independently.
CellWidth, CellHeight core.Points
// TextStyle sets the cell's typography over TypeBody.
TextStyle core.Style
// CornerRadius defaults to RadiusControl when zero.
CornerRadius core.Points
// CaretHeight defaults to the cell text's line height less two points, with a one-point minimum.
CaretHeight core.Points
OnChange, OnComplete func(value string)
// Label is what assistive technology says for the field.
Label string
// LabelFunc binds a changing Label.
LabelFunc func() string
Ref *base.OtpInputRef
TestID string
Style core.Style
}
OtpInput is a one-time code in bordered cells, the one that takes the next digit ringed in the accent: base.OtpInput's one native field over them, with the system's code autofill.
type Pagination ¶
type Pagination struct {
Page func() int
TotalPages func() int
VisiblePages int
Compact func() bool
Disabled func() bool
OnChange func(page int)
// Label names it for assistive technology, PreviousLabel and NextLabel
// its chevrons.
Label, PreviousLabel, NextLabel string
Children []core.Node
TestID string
Style core.Style
}
Pagination is the pages of a set in a row of buttons, the current one in the accent, with chevrons for Previous and Next: base.Pagination's first, last and neighbouring pages around ellipses. Compact keeps the chevrons and Children, a pager for a narrow screen.
type Palette ¶
type Palette struct {
Background, Surface, Inset, Raised, Field, FieldBorder, Border, Line core.Color
Text, Muted, Faint, Accent, AccentFill, OnAccent, Light, OnLight core.Color
Track, Knob, Hover, Pressed, Code, Info, Warn, Danger, Up, Down core.Color
// Selection is selected text and rows; AccentHover and AccentPressed
// are the accent's fill under the pointer and held down.
Selection, AccentHover, AccentPressed core.Color
}
Palette is ui's colors at one moment, for code that reads many at once, such as a Draw.
type PlainShell ¶
type PlainShell struct {
Title string
Leading []core.Node
Actions []core.Node
Content []core.Node
BehindHeader bool
TestID string
}
PlainShell is a window of the app's content under a header: the app's Leading content, its Title where Leading is nil, and its Actions at the end. Content starts below the header, or under it with BehindHeader, keeping its controls clear with ShellHeaderHeight. The header leaves a window material showing through, and is on the page's background where none shows, as the content is.
type Popover ¶
type Popover struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
// Trigger is the trigger's look and content; its OnPress and Disabled
// go unused.
Trigger Button
Placement core.Placement
Align core.Align
Children []core.Node
// Label names the trigger, Trigger's label when empty.
Label string
LabelFunc func() string
TestID string
// Style merges over the surface's.
Style core.Style
}
Popover shows its children on a surface beside its trigger, which Trigger's look and content draw. Pressing the trigger opens and closes it; pressing outside or Escape closes it.
type Press ¶
type Press struct {
OnPress, OnLongPress func()
Disabled func() bool
// Scale is how far it shrinks (default 0.97).
Scale float64
// StyleFunc merges over Style, as a View's does.
Style core.Style
StyleFunc func() core.Style
// Role is a button's by default.
Role core.Role
// LabelFunc replaces Label, as a View's does.
Label string
LabelFunc func() string
// Tooltip shows above it once the pointer rests on it, as a View's.
Tooltip core.Node
Selected func() bool
HitSlop core.Points
TestID string
Children []core.Node
}
Press is a pressable that sinks a little under the finger and springs back; the spring runs on the platform, only press in and out reach the engine.
type Progress ¶
type Progress struct {
Value func() float32
Indeterminate func() bool
Axis base.Axis
Inverted bool
// Label names the task for assistive technology.
Label string
LabelFunc func() string
TestID string
Style core.Style
}
Progress is a bar of how far a task is, Value from 0 to 100, or with Indeterminate one under way, a segment sweeping across it. Axis and Inverted are base.Progress's: a vertical bar fills from the bottom, or inverted from the top, and takes its height from Style.
type ProgressRing ¶
type ProgressRing struct {
Value func() float32
Indeterminate func() bool
Size core.Points
// LineWidth is the track's and arc's width. When 0, it is a tenth of Size and at most 3 pt.
LineWidth core.Points
// StartAngle is where the arc starts, in degrees clockwise from twelve o'clock.
StartAngle float32
// CounterClockwise runs the arc, and an indeterminate ring's turn, counterclockwise.
CounterClockwise bool
// Tint colors the arc, the accent when nil, and the track under it, a quarter as opaque, where the theme's line would not show, such as on an accent fill.
Tint func() core.Color
// Label names the task for assistive technology.
Label string
// LabelFunc binds a changing Label.
LabelFunc func() string
TestID string
Style core.Style
}
ProgressRing is Progress as a ring: the accent, or Tint, runs clockwise from twelve o'clock over a track, or from StartAngle and counterclockwise as they say, or, Indeterminate, a quarter of it turns once every 1.4 s, still under reduced motion. Value is from 0 to 100, as Progress's. Size is its diameter, 32 pt when 0; LineWidth is the track and arc width, a tenth of the diameter and 3 pt at most when 0.
type Radio ¶
type Radio struct {
// Ref and LabelledBy are the control view's, as a core.View's.
Ref *core.Ref
LabelledBy []*core.Ref
Invalid func() bool
Checked func() bool
Disabled func() bool
// OnChange receives true when the unchecked radio is pressed: check it
// and uncheck the others.
OnChange func(checked bool)
Text string
Children []core.Node
Label string
Hint string
TestID string
Style core.Style
}
Radio is one option of a RadioGroup, with Text or the app's Children beside its ring.
type RadioGroup ¶
type RadioGroup struct {
Horizontal bool
Children []core.Node
// Label names the choice for assistive technology.
Label string
TestID string
Style core.Style
}
RadioGroup holds the Radios of one choice, stacked or in a row.
type Rating ¶
type Rating struct {
Value func() int
OnChange func(value int)
Max int
// Readonly shows the score and takes nothing.
Readonly bool
Disabled func() bool
// ValueText is what assistive technology reads as the value, such as
// "3 stars", the number when nil.
ValueText func(value int) string
Label string
TestID string
Style core.Style
}
Rating is a score from 0 to Max, 5 when 0, in stars filled in the warning color. A press on a star gives that score, or 0 when it is the score already, and on desktops the pointer previews the score under it. Assistive technology reads one adjustable element, and it is a Tab stop the arrow keys adjust.
type ResizablePanelGroup ¶
type ResizablePanelGroup base.ResizablePanelGroup
ResizablePanelGroup is base.ResizablePanelGroup with ui's handles: a hairline, with a thumb on phones.
type ResizeHandle ¶
type ResizeHandle base.ResizeHandle
ResizeHandle is base.ResizeHandle with ui's line.
type ScrollView ¶
type ScrollView struct {
Horizontal bool
Children []core.Node
TopBar []core.Node
BottomBar []core.Node
// TopBarLabel and BottomBarLabel name the bars for assistive
// technology.
TopBarLabel, BottomBarLabel string
// EdgeColor is what the content scrolls over: the page's background
// when nil.
EdgeColor func() core.Color
OnScroll func(core.ScrollEvent)
Ref *core.Ref
TestID string
// Style merges over the frame's; ContentStyle over the content's,
// such as its padding and gap.
Style core.Style
ContentStyle core.Style
}
ScrollView scrolls its Children (a column, or a row when Horizontal) and fades them into EdgeColor at each edge more of them lies past, so the reader sees there is more. TopBar and BottomBar float the app's controls over a vertical view's edges on a capsule of glass, and the content starts and ends clear of them. The app sizes it, as a core.Scroll.
type Scrollbar ¶
type Scrollbar struct {
Scroll func() *core.Ref
Horizontal bool
Mode func() base.ScrollbarMode
Label string
TestID string
Style core.Style
}
Scrollbar is a bar of ui's look for a scroll view or list it names, which the app places over the target's edge. The app turns the target's own indicator off with HideIndicator.
type Select ¶
type Select[T comparable] struct { // Ref is the field's; LabelledBy and Invalid are a core.View's. Ref *core.Ref LabelledBy []*core.Ref Invalid func() bool Options []Option[T] // OptionsFunc, when set, returns the options in place of Options and updates the open list in place when the values it reads change, keeping the field's value and focus. A Value no longer offered shows Placeholder; OnChange is not called for it. OptionsFunc func() []Option[T] Value func() T OnChange func(value T) Placeholder string // Searchable shows a field above the rows that filters them by label, // with SearchPlaceholder in it and Empty while none matches. Searchable bool SearchPlaceholder string // SearchPlaceholderFunc and EmptyFunc bind the search and no-results text. SearchPlaceholderFunc func() string Empty string EmptyFunc func() string // OnClear, when set, shows a button in the field while an option is // chosen, which asks to choose none. OnClear func() Disabled func() bool // Presentation is base's: a popup at the field by default, or a // sheet, which ui chooses on no device of its own. Presentation base.Presentation // Label names the field for assistive technology. An empty label uses Placeholder. Label string LabelFunc func() string // TestID names the field; each option adds "-" and its index. TestID string // Style merges over the field's, 200 pt wide: its height, padding and // type reach the field, as an Input's do, so a smaller one lines up // with a SizeSmall Button. Style core.Style }
Select picks one of Options from a field that opens them as a list: over it on desktops, the chosen row on the field, where the keys move through them and letters jump, and as a sheet on touch screens. The field shows the chosen option's label, or Placeholder while Value matches none, and the list marks it with its row's selected face. The rows are made as they scroll in, so a list may be long. Options' Icon and Content go unused.
type Settings ¶
type Settings struct {
Categories []SettingsCategory
Category, Query *core.Signal[string]
Narrow func() bool
Title, SearchLabel string
SearchPlaceholder string
ResultsTitle, EmptyText string
OnClose func()
CloseLabel string
HideSearch, HideSidebar bool
HideHeading bool
// HeaderActions end the shown page's title; SectionActions the heading
// of a section of the sidebar, given its title.
HeaderActions func(cx *core.Scope) core.Node
SectionActions func(cx *core.Scope, section string) core.Node
TestID string
}
Settings shows Categories. Category and Query are the app's state, its own where nil: an empty or unknown category shows the first, and choosing one clears the query. Narrow, the host's say from the width it gives, swaps the sidebar for a row of the categories above the page and stacks each row's control below its text.
The texts are the app's: Title heads the sidebar and narrow pages, SearchLabel and SearchPlaceholder name the search field, ResultsTitle heads the results and EmptyText says there are none. OnClose, when set, adds a close button named CloseLabel. HideSearch drops the search field; HideSidebar the navigation, showing every category on one page; HideHeading the page's heading, for a host whose header says it.
type SettingsCategory ¶
type SettingsCategory struct {
ID, Title, Section, Description string
Icon func() *core.SVG
Groups []SettingsGroup
// Placeholder, set on a category with no page, stands for it in the
// sidebar: a note that it is empty, not a destination.
Placeholder core.Node
}
SettingsCategory is a destination of Settings' sidebar. IDs are nonempty, unique and stable across languages; consecutive categories of a Section are listed under its title.
type SettingsDialog ¶
type SettingsDialog struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
OnClose func()
Content func(narrow func() bool) core.Node
// Inset is Dialog's.
Inset core.Points
// Label names the dialog for assistive technology.
Label string
TestID string
}
SettingsDialog is Settings in a Dialog, hosted so: the surface holds nothing else, and Content builds the Settings, told when the width it is given is narrow.
type SettingsGroup ¶
type SettingsGroup struct {
ID, Title string
Items []SettingsItem
Actions []core.Node
}
SettingsGroup is related rows under an optional Title, with Actions at the end of its heading. Actions are not searched.
type SettingsItem ¶
type SettingsItem struct {
ID, Title, Description string
Keywords []string
Leading, Control core.Node
Stacked bool
Content core.Node
}
SettingsItem is a row: Title and Description with an optional Leading before them and the Control after, or below them when Stacked (wide controls). Content, when set, replaces the row with the app's own; Title, Description and Keywords are what search matches either way.
type SettingsResult ¶
type SettingsResult struct{ Category, Group, Item int }
SettingsResult is an item by its indices in the categories searched.
func SearchSettings ¶
func SearchSettings(categories []SettingsCategory, query string) []SettingsResult
SearchSettings returns the items, in order, whose category, group, title, description and keywords hold every whitespace-separated term of query, in any case: every item for an empty query.
type Sheet ¶
type Sheet struct {
Open func() bool
OnClose func()
// CloseOnSwipe lets a downward drag ask to close the sheet.
CloseOnSwipe bool
// Label names the sheet for screen readers; LabelFunc follows the signals it reads.
Label string
LabelFunc func() string
TestID string
// Style merges over the sheet's surface style. A CornerRadius without CornerRadii rounds every corner in place of the default rounded top.
Style core.Style
// StyleFunc merges over Style and follows the signals it reads.
StyleFunc func() core.Style
Children []core.Node
}
Sheet is a panel at the bottom over a dimmed backdrop while Open (base.Sheet in ui's look); a press on the backdrop, Escape or the back button calls OnClose.
type ShellTab ¶
type ShellTab struct {
Text string
TextFunc func() string
// Icon draws the tab's SVG, in the system tab bar on iOS and Android too wherever SystemIcon names no SF Symbol or drawable there.
Icon func() *core.SVG
// SystemIcon is the platform's name for the tab's icon on iOS and Android, as mobile.TabBarItem's Icon.
SystemIcon string
// Badge is the mark at the tab's icon corner, or beside a text-only tab's label, on the system and drawn bars. The zero value clears it.
Badge func() mobile.TabBadge
// Content is the section, such as a base.Nav's stack of pages. It is
// built when the tab is first selected and kept while others show.
Content func(cx *core.Scope) core.Node
TestID string
}
ShellTab is a top-level section of a TabShell.
type Sidebar ¶
type Sidebar struct {
Sections []SidebarSection
// SectionsFunc replaces Sections with ones that change: the items are
// built anew as it does, keeping the scroll position, the keys and the
// sections' own open state.
SectionsFunc func() []SidebarSection
Selected func() string
OnSelect func(id string)
TestID string
}
Sidebar is grouped navigation: the sections' items, the Selected one on a faint fill of the text's color, icons in the accent. It scrolls and leaves its background to the shell.
It is one stop of Tab, as a macOS source list is: while it has the keyboard focus, the selected item is ringed. While it has the focus, or after a press in it until the focus goes elsewhere, Up and Down select the item before and after, Home and End the first and the last, scrolled into view, passing over collapsed sections' items. A collapsible section's title is a stop of its own.
type SidebarButton ¶
type SidebarButton struct {
Text string
Icon func() *core.SVG
// Shortcut is the keys that press it, such as "mod+k", shown at its
// end but on touch screens. The app binds them.
Shortcut string
Variant SidebarButtonVariant
// Selected fills it as a Sidebar's selected item while it returns
// true.
Selected func() bool
OnPress func()
TestID string
}
SidebarButton is a row in a sidebar's place, above or beside a Sidebar's items: an Icon and Text, with the Shortcut's keys at its end. It is a stop of Tab of its own.
type SidebarButtonVariant ¶
type SidebarButtonVariant uint8
SidebarButtonVariant is a SidebarButton's look.
const ( // SidebarButtonPlain is a Sidebar item's: no fill but while Selected. // It is the default. SidebarButtonPlain SidebarButtonVariant = iota // SidebarButtonField is a search field's: always a quiet fill, deeper // while the pointer is over it, its text muted, for what opens a search. SidebarButtonField )
type SidebarItem ¶
type SidebarItem struct {
// ID is what Selected and OnSelect name the item by.
ID string
// Text labels it, shown after Icon unless Content replaces both.
Text string
Icon func() *core.SVG
Content core.Node
// Expanded marks an item disclosing nested items, which the app lists
// after it while it returns true.
Expanded func() bool
// Menu is its context menu's items.
Menu []core.Node
TestID string
}
SidebarItem is a destination of a Sidebar.
type SidebarSection ¶
type SidebarSection struct {
Title string
Items []SidebarItem
// Trailing ends the title, such as a count of the items; a collapsible
// title's arrow takes its place while the pointer or the focus is on
// it. Actions end the title's row, after the title. Note follows the
// items, for a section that has none yet.
Trailing core.Node
Actions core.Node
Note core.Node
// Collapsible makes a titled section's title a button that folds its
// items and Note away; Actions stay. Open makes that the app's, set
// from OnOpenChange, with its own state otherwise, open unless
// DefaultClosed.
Collapsible bool
Open func() bool
OnOpenChange func(open bool)
DefaultClosed bool
TestID string
}
SidebarSection is a group of a Sidebar's items under an optional title.
type SidebarShell ¶
type SidebarShell struct {
Variant SidebarShellVariant
ChromeStyle func() core.Style
Backdrop []core.Node
Sidebar []core.Node
SidebarActions []core.Node
Header []core.Node
Actions []core.Node
Content []core.Node
Open func() bool
OnOpenChange func(open bool)
// ToggleLabel names the toggle, which shows while OnOpenChange is set.
ToggleLabel string
// Width is the sidebar's width, DefaultWidth (240 points when 0)
// where it is nil or 0. The user drags it between MinWidth (160 when
// 0) and MaxWidth (none when 0) on the handle named ResizeLabel.
Width func() core.Points
OnWidthChange func(width core.Points)
DefaultWidth core.Points
MinWidth, MaxWidth core.Points
ResizeLabel string
Fixed bool
// Right is a panel at the content's end under RightHeader, and
// RightOpen whether it shows, with a toggle ending the content's
// header, named RightToggleLabel, while OnRightOpenChange is set. The
// content slides over it as over the sidebar, and draws its line, a
// handle of its own named RightResizeLabel, on its edge; RightWidth,
// RightDefaultWidth (280 when 0), RightMinWidth (200 when 0) and
// RightMaxWidth (none when 0) work as the sidebar's do.
Right, RightHeader []core.Node
RightOpen func() bool
OnRightOpenChange func(open bool)
RightToggleLabel, RightResizeLabel string
RightWidth func() core.Points
OnRightWidthChange func(width core.Points)
RightDefaultWidth core.Points
RightMinWidth, RightMaxWidth core.Points
TestID string
}
SidebarShell is a window of a sidebar beside the content, each under a header: the sidebar's toggle stays after the window controls, the app's SidebarActions end the sidebar's header, and its Header and Actions are the content's. Hiding the sidebar slides the content over it, the sidebar keeping its width, and the content's header with it until it meets the toggle, where it stays; its edge is a handle the user drags to resize it and double-clicks to restore DefaultWidth. SidebarFooter is a bar at the sidebar's bottom, with no line above it.
Fixed keeps the sidebar at its width, its edge a line with no handle.
Open and Width are the app's, set from OnOpenChange and OnWidthChange. The sidebar and its header are the chrome (Chrome), the content and its header on the page's background, and the right panel on that background at 80%. Variant chooses how the content shows on the chrome, and ChromeStyle, when set, paints the chrome in place of Chrome, such as with a gradient; it is a StyleFunc. Backdrop is drawn over the chrome, filling the window behind the sidebar and the content, such as a texture; it takes no presses.
type SidebarShellVariant ¶
type SidebarShellVariant uint8
SidebarShellVariant is how a SidebarShell shows its content.
const ( // SidebarShellPlain puts the content on the page's background from // the sidebar to the window's edges. It is the default. SidebarShellPlain SidebarShellVariant = iota // SidebarShellInset floats the content as a rounded card on the page's // background at 90%, the window keeping a margin of 5 points around // the sidebar and the card, and between them, while the sidebar // shows; the card's edge and shadow lift it off the chrome there, in // place of the sidebar's line. The margin, the edge and the shadow go // as the sidebar hides, the window controls and the toggle moving with // it as it slides. SidebarShellInset )
type Size ¶
type Size uint8
Size is a control's size. Its zero value is the standard size. The measures below are desktops' and TVs'; a Button is taller on touch devices (Size.heightFor).
type Skeleton ¶
Skeleton is a placeholder for text still loading: Lines bars (3 when 0, at most 6) as wide as it is, after a round avatar's with Avatar. Screen readers read it as one element named Label, such as "Loading".
type SkeletonBlock ¶
SkeletonBlock is one pulsing shape of a placeholder, for content of the app's own shape: a rounded bar, or with Round a circle. Index staggers its pulse after the blocks before it.
type SkeletonContent ¶
type SkeletonContent struct {
Loading func() bool
Placeholder Skeleton
Children []core.Node
TestID string
Style core.Style
}
SkeletonContent shows Placeholder while Loading and then the app's Children, which fade in.
type Slider ¶
type Slider struct {
// Axis and Inverted are base.Slider's: a vertical slider has min at
// the bottom, or inverted at the top, and takes its height from Style.
Axis base.Axis
Inverted bool
// ThumbRef and StartThumbRef are the end and start thumbs' refs.
ThumbRef, StartThumbRef *core.Ref
LabelledBy []*core.Ref
Invalid func() bool
Value func() float64
OnChange func(value float64)
// High and OnHighChange make it a range, Value its low end.
High func() float64
OnHighChange func(value float64)
// Min and Max are the range, 0 to 100 when Max is not above Min.
Min, Max float64
Step float64
// MinFunc, MaxFunc and StepFunc follow changing bounds and steps in place, taking precedence over Min, Max and Step. Explicit bounds may be equal, for a range whose maximum is not known yet.
MinFunc, MaxFunc, StepFunc func() float64
Disabled func() bool
// Label names it for assistive technology; a range's knobs add
// LowLabel and HighLabel after it, such as "minimum" and "maximum".
Label string
LabelFunc func() string
LowLabel, HighLabel string
LowLabelFunc, HighLabelFunc func() string
// ValueText is what assistive technology reads as a value, the
// number when nil.
ValueText func(value float64) string
// TestID names the slider; its knobs add "-thumb", or "-low" and
// "-high" in a range.
TestID string
Style core.Style
}
Slider is base.Slider in ui's look: a white capsule knob on a thin track that stays inside its ends, or with High two that pick a range from Value up to High. Step above 0 snaps the values to steps from Min and marks them under the track, up to 60 of them; at 0 the keys move a hundredth of the range.
type Spinner ¶
type Spinner struct {
Variant SpinnerVariant
Size core.Points
// LineWidth is the ring's track and arc width. When 0, ProgressRing's default is used. It has no effect on SpinnerSpokes.
LineWidth core.Points
// Tint colors it, as ProgressRing's: the ring the accent when nil, the spokes the muted text.
Tint func() core.Color
Label string
// LabelFunc binds a changing Label.
LabelFunc func() string
TestID string
Style core.Style
}
Spinner is work of unknown length. Label names it for assistive technology; Size is its diameter, 32 pt when 0. Under reduced motion it stands still.
type SpinnerVariant ¶
type SpinnerVariant uint8
SpinnerVariant is a Spinner's look.
const ( // SpinnerRing is an indeterminate ProgressRing. It is the default. SpinnerRing SpinnerVariant = iota // SpinnerSpokes is twelve fading spokes that step around in the muted text's color, or Tint. SpinnerSpokes )
type StepStatus ¶
type StepStatus uint8
StepStatus is where a step of a Stepper stands.
const ( StepUpcoming StepStatus = iota StepCurrent StepComplete // StepFailed is a step with an Error. StepFailed )
type Stepper ¶
type Stepper struct {
Steps []StepperStep
Current func() int
Vertical bool
CurrentDescription bool
Compact bool
OnSelect func(step int)
Label string
CompleteLabel string
StatusText func(StepStatus) string
TestID string
}
Stepper is a stepper, where a person is in a flow of steps, for onboarding, checkout and setup: completed steps show a check, the current one a ring around its number and failed ones an alert, and the track between them fills up to the current step, one connector after another across a jump. Current is the step in progress, len(Steps) once every one is done; out-of-range values clamp. The app owns the steps, the flow and the content beside it.
Steps run in a row, or down a column with Vertical. CurrentDescription shows only the current step's description, and Compact the markers alone, the current step's label under a row of them (CompleteLabel once all are done). With OnSelect, completed steps are buttons that return to them. Label names the group for assistive technology, and StatusText, when set, the status read after each step's label, such as "completed".
type StepperStep ¶
StepperStep is one step of a Stepper: a Label with a short Description under it. Error marks it failed: its marker turns into an alert and the message replaces the description.
type Submenu ¶
type Submenu struct {
}
Submenu is an item that opens more: beside it in a popup, in place of the menu's items on a sheet, under a row of Back, the app's label for returning.
type SuggestList ¶
type SuggestList struct {
Suggest *core.Suggest
Items func(query string) []base.SuggestItem
// Leading draws what goes before row index's label, such as an icon; nothing when nil.
Leading func(item base.SuggestItem, index int) core.Node
Placement core.Placement
// OnOpen and OnClose hear the rows show and go, for the field's Expanded.
OnOpen, OnClose func()
// Label names the rows' list for assistive technology, apart from the field.
Label string
TestID string
}
SuggestList is base.SuggestList in a menu's panel at the caret: its rows are a dropdown's, each a row's label over its detail, and the row the keys or the pointer are on is lit. Placement is the caret's side it goes on, below it by default.
type Switch ¶
type Switch struct {
// Ref and LabelledBy are the control view's, as a core.View's.
Ref *core.Ref
LabelledBy []*core.Ref
Invalid func() bool
Disabled func() bool
Checked func() bool
OnChange func(bool)
Label string
LabelFunc func() string
Size Size
Variant SwitchVariant
TestID string
}
Switch is an on and off switch in ui's look: base.Switch, the knob sliding across and the track changing color on the platform. Label is what assistive technology reads.
type SwitchLook ¶
SwitchLook is ui's switch as the styles of base.Switch's parts: a track that turns to the accent and a capsule knob that slides across, both on the platform.
func NewSwitchLook ¶
func NewSwitchLook(cx *core.Scope, on func() bool, size Size) SwitchLook
NewSwitchLook makes a switch's look: 40 × 20, 30 × 16 small and 48 × 24 large. on is the value the app owns; the knob follows it.
type SwitchVariant ¶
type SwitchVariant uint8
SwitchVariant is a Switch's look.
const ( // SwitchDefault is ui's own look. It is the default. SwitchDefault SwitchVariant = iota // SwitchSystem is the platform's own switch where it has one: macOS's NSSwitch, iOS's UISwitch and Android's Material 3 switch (core.SystemSwitch), sized as the system's; elsewhere, a watch included, it is ui's look. SwitchSystem )
type TabShell ¶
type TabShell struct {
Tabs []ShellTab
Selected func() int
OnChange func(index int)
// Edge places the tab bar along the bottom (the default), the leading
// or trailing edge (drawn vertically), or lets the system choose via
// core.Env.VerticalBarEdge (mobile.TabBarAutomatic). EdgeFunc binds it
// reactively.
Edge mobile.TabBarEdge
EdgeFunc func() mobile.TabBarEdge
// BarHidden hides the system or drawn bar while it reports true, and restores the section's safe area and TabBarInset.
BarHidden func() bool
// Label names the bar for assistive technology.
Label string
LabelFunc func() string
TestID string
}
TabShell is an app's top-level sections beside a drawn tab bar, which keeps clear of its edge's safe area, or the system's where every tab has a SystemIcon or an Icon, on any edge on iOS and on the bottom edge on Android. On the bottom edge iOS's floats over the sections, which keep what they must show clear of it with TabBarInset. Every other bar takes room of its own, and the safe area of the sections on the bar's edge (core.Insets, core.EnvSafeArea) is 0 while it shows. Set Edge (or EdgeFunc) to mobile.TabBarLeading or mobile.TabBarTrailing to draw the bar vertically along that edge, or mobile.TabBarAutomatic to follow core.Env.VerticalBarEdge. The Selected tab's content fills the rest; Selected is the app's, set from OnChange. The bar hides while the software keyboard shows, so content padded by core.EnvKeyboard meets the keyboard without an offset. It keeps this form at every window width.
type Tabs ¶
type Tabs[T comparable] struct { Variant TabsVariant Options []Option[T] // OptionsFunc, when set, returns the options in place of Options and updates tabs in place when the values it reads change, keeping the selected tab and focus where their values remain offered. OptionsFunc func() []Option[T] Value func() T // OnChange receives the value of a pressed tab other than the selected // one. OnChange func(T) // Equal fills the width with tabs of one width, instead of each // fitting its content. Equal bool Size Size // IndicatorColor colors an underline indicator. The accent is used when nil. IndicatorColor func() core.Color // IndicatorFit chooses whether an underline indicator follows the tab or its content. IndicatorFit TabsIndicatorFit // Label names the list for assistive technology. Label string LabelFunc func() string TestID string // TabStyle merges over each tab's style; its Selected merges over the selected tab's. TabStyle core.Style // IndicatorStyle merges over the indicator's style, after its position and size. IndicatorStyle core.Style Style core.Style }
Tabs picks one of Options: a tab list whose content the app shows beside it, or a segmented control. One indicator marks the selected tab and slides to the next, resizing to it.
type TabsIndicatorFit ¶
type TabsIndicatorFit uint8
TabsIndicatorFit says what an underline indicator follows.
const ( // TabsIndicatorTab fits the indicator to the selected tab, inset by six points. TabsIndicatorTab TabsIndicatorFit = iota // TabsIndicatorContent fits the indicator to the selected tab's content. TabsIndicatorContent )
type TabsVariant ¶
type TabsVariant uint8
TabsVariant is a tab list's look.
const ( // TabsSegmented sets the selected tab on a raised thumb in a recessed // capsule: the default. TabsSegmented TabsVariant = iota // TabsUnderline marks the selected tab with an accent underline. TabsUnderline )
type TagInput ¶
type TagInput struct {
Tags func() []string
OnChange func(tags []string)
// Accept, when set, keeps out the tags it rejects, which stay typed.
Accept func(tag string) bool
Placeholder string
Disabled func() bool
// RemoveLabel names a tag's remove button for assistive technology,
// such as "Remove design".
RemoveLabel func(tag string) string
// Label names the field for assistive technology.
Label string
TestID string
Style core.Style
}
TagInput is a field of bordered chips that edits a list of tags: each with a remove button, then the text being typed, which Return, a comma or leaving the field adds as a tag, keeping the focus in the field on Return to type the next. Backspace in the empty field removes the last tag. Tags are trimmed, and empty ones and repeats dropped.
type TextView ¶
TextView is textview.TextView in ui's type and colors: its headings, quotes and alerts, lists, code, tables and links. The app's StyleOf merges over ui's styles, and its Styles over both, as they do in base. Code is colored by the app's Highlighter, such as highlight.New's. With RenderMath, a display formula's block keeps its background but not the code type, and its scroll takes the padding, so the scroll bar runs along the block's edge as a code block's does.
type TimeField ¶
type TimeField struct {
Value func() base.TimeOfDay
DefaultValue base.TimeOfDay
Precision base.TimePrecision
HourCycle base.HourCycle
Disabled func() bool
OnChange func(value base.TimeOfDay)
// Label names it for assistive technology.
Label string
TestID string
// Style merges over the field's.
Style core.Style
}
TimeField is a time of day in a field 28 pt tall, edited a segment at a time: digits, the arrows, and a press on a segment.
type Tints ¶
type Tints struct {
// contains filtered or unexported fields
}
Tints are translucent tints of the tones where a scope is, for fills behind text, read as ColorsOf's are.
type ToastContent ¶
type ToastContent struct {
ID string
Type ToastType
Title string
Description string
Leading core.Node
// Trailing is content after Action and before the optional close button.
Trailing core.Node
Action string
OnAction func()
// OnPress makes the toast surface a button and dismisses it after the callback. Action, Trailing and close-button children keep their presses.
OnPress func()
// NoClose omits this toast's close button. Swipe, Escape and its timeout still dismiss it.
NoClose bool
OnClose func()
Duration time.Duration
// Style and StyleFunc style this toast's surface over the stack's style.
// StyleFunc follows the signals it reads and merges over Style.
Style core.Style
StyleFunc func() core.Style
// contains filtered or unexported fields
}
ToastContent is a toast: a Title, a quieter Description and, with Action, a button that runs OnAction and closes it. Leading replaces the Type's status icon, as with an image or a spinner. Duration is how long it stays, 5 s when 0 and until it is dismissed when negative. OnClose runs once it has gone, whatever closed it. A toast with the ID of one shown replaces it.
type ToastPlacement ¶
type ToastPlacement uint8
ToastPlacement is the edge and side of the window toasts stack at; the newest is nearest the edge. The zero value is the top center.
const ( ToastTop ToastPlacement = iota ToastTopStart ToastTopEnd ToastBottom ToastBottomStart ToastBottomEnd // ToastStart and ToastEnd are the middle of the window's sides. ToastStart ToastEnd )
type ToastSwipe ¶
type ToastSwipe uint8
ToastSwipe is the way toasts are swiped away. The zero value is toward the nearest edge of the window.
const ( ToastSwipeEdge ToastSwipe = iota ToastSwipeLeft ToastSwipeRight ToastSwipeUp ToastSwipeDown // ToastSwipeOff keeps them from being swiped. ToastSwipeOff )
type ToastType ¶
type ToastType uint8
ToastType picks a toast's colored status icon; ToastPlain shows none.
type Toaster ¶
type Toaster struct {
Limit int
// contains filtered or unexported fields
}
Toaster keeps the app's toasts: the app makes one near its root with NewToaster, shows and dismisses toasts through it from anywhere, and places a Toasts of it once over its content. NSGo's ToastManager keeps their lifecycle; a toast's timeout pauses while the stack is open under the pointer or a finger. Limit is how many show at once, 3 when 0, older ones waiting behind them.
func (*Toaster) Show ¶
func (t *Toaster) Show(c ToastContent) string
Show shows c and returns its ID, made up when c has none.
type Toasts ¶
type Toasts struct {
Toaster *Toaster
Placement ToastPlacement
Reverse bool
Swipe ToastSwipe
Inset core.Points
CloseLabel string
// Style and StyleFunc style every toast's surface. StyleFunc merges
// over Style, and each ToastContent's styles merge over both.
Style core.Style
StyleFunc func() core.Style
// NoClose omits the close button from every toast in the stack, whatever its ToastContent.NoClose.
NoClose bool
TestID string
}
Toasts is ui's toasts, a Toaster's, over the window inside the safe area: glass cards up to 360 points wide, the newest in front and older ones tucked behind it, fanning out under the pointer or a finger. Reverse puts the newest farthest from the edge, as a list growing away from it. Swiping one away, Swipe's way, or Escape closes it. Inset adds room at the placement's edge, as for a shell's header. CloseLabel names each toast's close button for assistive technology.
type ToggleButton ¶
type ToggleButton struct {
Text string
Icon func() *core.SVG
Label string
On func() bool
OnChange func(on bool)
Disabled func() bool
TestID string
}
ToggleButton is a toggle button, 28 pt tall: a quiet bordered face while off, filled with the accent while On, Text with an optional leading Icon or the Icon alone. A press asks OnChange for the other state; assistive technology hears a toggle button, and in a ToggleGroup or a Toolbar it joins their stop of the keyboard focus. Label is what it reads, Text when empty.
type ToggleGroup ¶
type ToggleGroup struct {
Disabled func() bool
Children []core.Node
Label string
TestID string
Style core.Style
}
ToggleGroup is a row of ToggleButtons, one Tab stop whose arrows move between them: the app keeps which are on, any number or exactly one.
type Toolbar ¶
type Toolbar struct {
Axis base.Axis
Disabled func() bool
Children []core.Node
Label string
TestID string
Style core.Style
}
Toolbar is a bar of controls, on a quiet inset panel: base.Toolbar's one Tab stop whose arrows move between its IconButtons, ToggleButtons and Links.
type ToolbarGroup ¶
ToolbarGroup is a run of related items in a Toolbar, read as one unit.
type ToolbarSeparator ¶
type ToolbarSeparator struct {
TestID string
}
ToolbarSeparator is a hairline between runs of a Toolbar's items.
type Tooltip ¶
type Tooltip struct {
Open func() bool
OnOpenChange func(open bool, reason base.Reason)
Text string
// TextFunc, when set, says the tip in place of Text and follows it.
TextFunc func() string
Trigger core.Node
// Placement is above the trigger when 0.
Placement core.Placement
TestID string
// Style is the trigger's box, within its parent's layout.
Style core.Style
}
Tooltip shows Text by its trigger as the pointer rests on it, on desktops, or while the app opens it.
type Tree ¶
type Tree struct {
// Roots returns the top items' keys, comparable values such as IDs.
Roots func() []any
// Children returns an item's children, none for a leaf.
Children func(key any) []any
Expanded func(key any) bool
OnExpand func(key any, expanded bool)
// Row builds an item's content after its chevron; read it as
// signals, since a cell shows other items as it scrolls.
Row func(cx *core.Scope, item TreeItem) core.Node
Selection *Selection
OnActivate func(key any)
// RowLabel is what assistive technology reads for an item, its text
// when nil.
RowLabel func(key any) string
// ToggleLabel names the chevron for assistive technology, such as
// "Expand".
ToggleLabel string
EstimatedSize core.Points
Empty core.Node
Label string
Ref *core.Ref
TestID string
Style core.Style
RowStyle core.Style
// RowStyleFunc is List's.
RowStyleFunc func() core.Style
}
Tree is base.Tree in ui's look: the app's nested items in rows indented by depth, each branch with a chevron that expands it, as a double press does. It keeps no state: the app says which keys are expanded and sets them from OnExpand, and only the children of what is expanded are read. A press only selects, the rows a multiple Selection holds by Shift and Mod as in a List, which assistive technology hears for the cursor's row alone.
Source Files
¶
- accordion.go
- alertdialog.go
- avatar.go
- avatargroup.go
- badge.go
- breadcrumbs.go
- button.go
- calendar.go
- carousel.go
- cell.go
- checkbox.go
- collapsible.go
- colorpicker.go
- combobox.go
- command.go
- commanddialog.go
- contextmenu.go
- datepicker.go
- dialog.go
- doc.go
- dockarea.go
- emojipicker.go
- field.go
- formfield.go
- formrow.go
- formsection.go
- holdtoconfirm.go
- hovercard.go
- hstack.go
- iconbutton.go
- image.go
- imagecompare.go
- input.go
- link.go
- list.go
- menu.go
- meter.go
- navheader.go
- navpage.go
- numberinput.go
- option.go
- otpinput.go
- pagination.go
- pickerfield.go
- plainshell.go
- popover.go
- press.go
- progress.go
- progressring.go
- radio.go
- rating.go
- resizable.go
- resizehandle.go
- scrollbar.go
- scrollview.go
- select.go
- selection.go
- settings.go
- sheet.go
- shell.go
- sidebar.go
- sidebarbutton.go
- sidebarshell.go
- size.go
- skeleton.go
- slider.go
- spacer.go
- spinner.go
- stepper.go
- style.go
- submenu.go
- suggestlist.go
- switch.go
- tabs.go
- tabshell.go
- taginput.go
- textprops.go
- textview.go
- theme.go
- timefield.go
- toast.go
- togglebutton.go
- togglegroup.go
- toolbar.go
- tooltip.go
- tree.go
- warmdusk.go
- wrap.go
Directories
¶
| Path | Synopsis |
|---|---|
|
locales
Package locales says ui/chat's own messages in the language the app shows.
|
Package locales says ui/chat's own messages in the language the app shows. |
|
Package commitgraph is base/commitgraph's styled form: a repository's commits as a virtualized list beside their revision graph, in the look of Onegit's All Commits page.
|
Package commitgraph is base/commitgraph's styled form: a repository's commits as a virtualized list beside their revision graph, in the look of Onegit's All Commits page. |
|
Package diff is base/diff's DiffView in ui's colors.
|
Package diff is base/diff's DiffView in ui's colors. |
|
Package editor is base/editor's Editor in ui's colors.
|
Package editor is base/editor's Editor in ui's colors. |
|
Package filepicker is a modal file and folder picker, or a browser for copying paths, over a file system the app lists, possibly on another machine: places and disks in a sidebar, the browsed folder's entries in an icon or list view, and the folder's address, shown as breadcrumbs and typed into on request.
|
Package filepicker is a modal file and folder picker, or a browser for copying paths, over a file system the app lists, possibly on another machine: places and disks in a sidebar, the browsed folder's entries in an icon or list view, and the folder's address, shown as breadcrumbs and typed into on request. |
|
Package flow is base/flow's styled form: a directed diagram in ui's look, its lines in the muted text's color, the hovered and selected node's in the accent, and Card, a node's default face.
|
Package flow is base/flow's styled form: a directed diagram in ui's look, its lines in the muted text's color, the hovered and selected node's in the accent, and Card, a node's default face. |
|
Package richeditor is base/richeditor's View in ui's colors.
|
Package richeditor is base/richeditor's View in ui's colors. |