Documentation
¶
Index ¶
- Constants
- Variables
- func Announce(text string, p access.Politeness)
- func AvatarInitials(name string) string
- func CurrencySymbol() (symbol string, after bool)
- func FormatBytes(n uint64) string
- func FormatCurrency(amount float64) string
- func FormatDate(t time.Time) string
- func FormatMonthYear(t time.Time) string
- func FormatNumber(v float64, decimals int) string
- func FormatRelative(t, now time.Time) string
- func FormatTime(t time.Time) string
- func InvalidateQueries(ctx *Context, match func(key string) bool)
- func ParseDate(text string) (time.Time, bool)
- func ParseNumber(text string) (float64, bool)
- func RegisterDefaultBindings(bs ...Binding)
- func SetQueryData[T any](ctx *Context, key string, value T)
- func SetThemeStyle[T any](t *Theme, v T)
- func SortBy[T any, K cmp.Ordered](key func(T) K) func(a, b T) int
- func SortByText[T any](key func(T) string) func(a, b T) int
- func StyleLayer[S any](ctx *Context, s S, name string) S
- func ThemeStyle[T any](t *Theme) (T, bool)
- type AccordionElement
- func (a *AccordionElement) GridSpan(cols, rows int) *AccordionElement
- func (a *AccordionElement) Grow(f float32) *AccordionElement
- func (a *AccordionElement) Key(k string) *AccordionElement
- func (a *AccordionElement) MaxWidth(l Length) *AccordionElement
- func (a *AccordionElement) MinWidth(l Length) *AccordionElement
- func (a *AccordionElement) SingleOpen() *AccordionElement
- func (a *AccordionElement) Width(l Length) *AccordionElement
- type Action
- type AlertDialogElement
- func (a *AlertDialogElement) Action(b *ButtonElement) *AlertDialogElement
- func (a *AlertDialogElement) Body(e Element) *AlertDialogElement
- func (a *AlertDialogElement) Cancel(label string, fn func()) *AlertDialogElement
- func (a *AlertDialogElement) Confirm(label string, fn func()) *AlertDialogElement
- func (a *AlertDialogElement) ConfirmLoading(on bool) *AlertDialogElement
- func (a *AlertDialogElement) Icon(ic *icons.Icon) *AlertDialogElement
- func (a *AlertDialogElement) Intent(i AlertDialogIntent) *AlertDialogElement
- func (a *AlertDialogElement) Key(k string) *AlertDialogElement
- func (a *AlertDialogElement) MaxWidth(l Length) *AlertDialogElement
- func (a *AlertDialogElement) MinWidth(l Length) *AlertDialogElement
- func (a *AlertDialogElement) Styles(st AlertDialogStyle) *AlertDialogElement
- func (a *AlertDialogElement) Width(l Length) *AlertDialogElement
- type AlertDialogIntent
- type AlertDialogStyle
- type AlertElement
- func (a *AlertElement) Action(el Element) *AlertElement
- func (a *AlertElement) Danger() *AlertElement
- func (a *AlertElement) Description(s string) *AlertElement
- func (a *AlertElement) GridSpan(cols, rows int) *AlertElement
- func (a *AlertElement) Grow(f float32) *AlertElement
- func (a *AlertElement) Icon(ic *icons.Icon) *AlertElement
- func (a *AlertElement) Info() *AlertElement
- func (a *AlertElement) Key(k string) *AlertElement
- func (a *AlertElement) MaxWidth(l Length) *AlertElement
- func (a *AlertElement) MinWidth(l Length) *AlertElement
- func (a *AlertElement) OnClose(fn func()) *AlertElement
- func (a *AlertElement) Styles(st AlertStyle) *AlertElement
- func (a *AlertElement) Success() *AlertElement
- func (a *AlertElement) Tooltip(s string) *AlertElement
- func (a *AlertElement) Variant(v AlertVariant) *AlertElement
- func (a *AlertElement) Warning() *AlertElement
- func (a *AlertElement) Width(l Length) *AlertElement
- type AlertStyle
- type AlertVariant
- type AlertVariants
- type Alignment
- type AnimateElement
- type Animation
- type AvatarElement
- func (a *AvatarElement) AccessHidden() *AvatarElement
- func (a *AvatarElement) Image(src *ImageSource) *AvatarElement
- func (a *AvatarElement) Key(k string) *AvatarElement
- func (a *AvatarElement) Size(px float32) *AvatarElement
- func (a *AvatarElement) Styles(st AvatarStyle) *AvatarElement
- func (a *AvatarElement) Tooltip(s string) *AvatarElement
- type AvatarStyle
- type BadgeElement
- func (b *BadgeElement) GridSpan(cols, rows int) *BadgeElement
- func (b *BadgeElement) Grow(f float32) *BadgeElement
- func (b *BadgeElement) Key(k string) *BadgeElement
- func (b *BadgeElement) Max(n int) *BadgeElement
- func (b *BadgeElement) MaxWidth(l Length) *BadgeElement
- func (b *BadgeElement) MinWidth(l Length) *BadgeElement
- func (b *BadgeElement) Noun(s string) *BadgeElement
- func (b *BadgeElement) StatusDot() *BadgeElement
- func (b *BadgeElement) Styles(st BadgeStyle) *BadgeElement
- func (b *BadgeElement) Tooltip(s string) *BadgeElement
- func (b *BadgeElement) Variant(v BadgeVariant) *BadgeElement
- func (b *BadgeElement) Width(l Length) *BadgeElement
- type BadgeStyle
- type BadgeVariant
- type BadgeVariants
- type Binding
- type BreadcrumbsElement
- func (b *BreadcrumbsElement) GridSpan(cols, rows int) *BreadcrumbsElement
- func (b *BreadcrumbsElement) Key(k string) *BreadcrumbsElement
- func (b *BreadcrumbsElement) Label(name string) *BreadcrumbsElement
- func (b *BreadcrumbsElement) MaxItems(n int) *BreadcrumbsElement
- func (b *BreadcrumbsElement) MaxWidth(l Length) *BreadcrumbsElement
- func (b *BreadcrumbsElement) MinWidth(l Length) *BreadcrumbsElement
- func (b *BreadcrumbsElement) Styles(s BreadcrumbsStyle) *BreadcrumbsElement
- func (b *BreadcrumbsElement) Tooltip(s string) *BreadcrumbsElement
- func (b *BreadcrumbsElement) Width(l Length) *BreadcrumbsElement
- type BreadcrumbsStyle
- type ButtonElement
- func (b *ButtonElement) AccessChecked(on bool) *ButtonElement
- func (b *ButtonElement) Danger() *ButtonElement
- func (b *ButtonElement) Disabled(d bool) *ButtonElement
- func (b *ButtonElement) FocusHandle(h *FocusHandle) *ButtonElement
- func (b *ButtonElement) Ghost() *ButtonElement
- func (b *ButtonElement) GridSpan(cols, rows int) *ButtonElement
- func (b *ButtonElement) Grow(f float32) *ButtonElement
- func (b *ButtonElement) Height(l Length) *ButtonElement
- func (b *ButtonElement) Icon(ic *icons.Icon) *ButtonElement
- func (b *ButtonElement) IconEnd(ic *icons.Icon) *ButtonElement
- func (b *ButtonElement) Key(k string) *ButtonElement
- func (b *ButtonElement) Label(s string) *ButtonElement
- func (b *ButtonElement) Large() *ButtonElement
- func (b *ButtonElement) Loading(on bool) *ButtonElement
- func (b *ButtonElement) MaxHeight(l Length) *ButtonElement
- func (b *ButtonElement) MaxWidth(l Length) *ButtonElement
- func (b *ButtonElement) MinHeight(l Length) *ButtonElement
- func (b *ButtonElement) MinWidth(l Length) *ButtonElement
- func (b *ButtonElement) OnClick(fn func()) *ButtonElement
- func (b *ButtonElement) Primary() *ButtonElement
- func (b *ButtonElement) Secondary() *ButtonElement
- func (b *ButtonElement) Small() *ButtonElement
- func (b *ButtonElement) Style(s Style) *ButtonElement
- func (b *ButtonElement) Styles(st ButtonStyle) *ButtonElement
- func (b *ButtonElement) Tooltip(s string) *ButtonElement
- func (b *ButtonElement) Variant(v ButtonVariant) *ButtonElement
- func (b *ButtonElement) Width(l Length) *ButtonElement
- type ButtonStyle
- type ButtonVariant
- type ButtonVariants
- type CalendarElement
- func (c *CalendarElement) DisableDays(fn func(day time.Time) bool) *CalendarElement
- func (c *CalendarElement) Disabled(on bool) *CalendarElement
- func (c *CalendarElement) FirstDay(day time.Weekday) *CalendarElement
- func (c *CalendarElement) FocusHandle(h *FocusHandle) *CalendarElement
- func (c *CalendarElement) GridSpan(cols, rows int) *CalendarElement
- func (c *CalendarElement) Grow(f float32) *CalendarElement
- func (c *CalendarElement) Height(l Length) *CalendarElement
- func (c *CalendarElement) Key(k string) *CalendarElement
- func (c *CalendarElement) Label(name string) *CalendarElement
- func (c *CalendarElement) LabelledBy(keys ...string) *CalendarElement
- func (c *CalendarElement) Max(day time.Time) *CalendarElement
- func (c *CalendarElement) MaxHeight(l Length) *CalendarElement
- func (c *CalendarElement) MaxWidth(l Length) *CalendarElement
- func (c *CalendarElement) Min(day time.Time) *CalendarElement
- func (c *CalendarElement) MinHeight(l Length) *CalendarElement
- func (c *CalendarElement) MinWidth(l Length) *CalendarElement
- func (c *CalendarElement) OnChange(fn func(time.Time)) *CalendarElement
- func (c *CalendarElement) Styles(st CalendarStyle) *CalendarElement
- func (c *CalendarElement) Tooltip(s string) *CalendarElement
- func (c *CalendarElement) Width(l Length) *CalendarElement
- type CalendarRangeElement
- func (c *CalendarRangeElement) DisableDays(fn func(day time.Time) bool) *CalendarRangeElement
- func (c *CalendarRangeElement) Disabled(on bool) *CalendarRangeElement
- func (c *CalendarRangeElement) FirstDay(day time.Weekday) *CalendarRangeElement
- func (c *CalendarRangeElement) FocusHandle(h *FocusHandle) *CalendarRangeElement
- func (c *CalendarRangeElement) GridSpan(cols, rows int) *CalendarRangeElement
- func (c *CalendarRangeElement) Grow(f float32) *CalendarRangeElement
- func (c *CalendarRangeElement) Height(l Length) *CalendarRangeElement
- func (c *CalendarRangeElement) Key(k string) *CalendarRangeElement
- func (c *CalendarRangeElement) Label(name string) *CalendarRangeElement
- func (c *CalendarRangeElement) LabelledBy(keys ...string) *CalendarRangeElement
- func (c *CalendarRangeElement) Max(day time.Time) *CalendarRangeElement
- func (c *CalendarRangeElement) MaxHeight(l Length) *CalendarRangeElement
- func (c *CalendarRangeElement) MaxWidth(l Length) *CalendarRangeElement
- func (c *CalendarRangeElement) Min(day time.Time) *CalendarRangeElement
- func (c *CalendarRangeElement) MinHeight(l Length) *CalendarRangeElement
- func (c *CalendarRangeElement) MinWidth(l Length) *CalendarRangeElement
- func (c *CalendarRangeElement) OnChange(fn func(start, end time.Time)) *CalendarRangeElement
- func (c *CalendarRangeElement) Styles(st CalendarStyle) *CalendarRangeElement
- func (c *CalendarRangeElement) Tooltip(s string) *CalendarRangeElement
- func (c *CalendarRangeElement) Width(l Length) *CalendarRangeElement
- type CalendarStyle
- type CardElement
- func (c *CardElement) Align(a Alignment) *CardElement
- func (c *CardElement) Child(e Element) *CardElement
- func (c *CardElement) Children(es ...Element) *CardElement
- func (c *CardElement) Gap(px float32) *CardElement
- func (c *CardElement) GridSpan(cols, rows int) *CardElement
- func (c *CardElement) Grow(f float32) *CardElement
- func (c *CardElement) Key(k string) *CardElement
- func (c *CardElement) Label(s string) *CardElement
- func (c *CardElement) MaxWidth(l Length) *CardElement
- func (c *CardElement) MinWidth(l Length) *CardElement
- func (c *CardElement) OnClick(fn func()) *CardElement
- func (c *CardElement) Outlined() *CardElement
- func (c *CardElement) Padding(px float32) *CardElement
- func (c *CardElement) Row() *CardElement
- func (c *CardElement) Styles(st CardStyle) *CardElement
- func (c *CardElement) Tooltip(s string) *CardElement
- func (c *CardElement) Variant(v CardVariant) *CardElement
- func (c *CardElement) Width(l Length) *CardElement
- type CardStyle
- type CardVariant
- type CardVariants
- type CarouselElement
- func (c *CarouselElement) AutoPlay(d time.Duration) *CarouselElement
- func (c *CarouselElement) Disabled(on bool) *CarouselElement
- func (c *CarouselElement) FocusHandle(h *FocusHandle) *CarouselElement
- func (c *CarouselElement) GridSpan(cols, rows int) *CarouselElement
- func (c *CarouselElement) Grow(f float32) *CarouselElement
- func (c *CarouselElement) Height(l Length) *CarouselElement
- func (c *CarouselElement) Key(k string) *CarouselElement
- func (c *CarouselElement) Label(name string) *CarouselElement
- func (c *CarouselElement) Loop() *CarouselElement
- func (c *CarouselElement) MaxHeight(l Length) *CarouselElement
- func (c *CarouselElement) MaxWidth(l Length) *CarouselElement
- func (c *CarouselElement) MinHeight(l Length) *CarouselElement
- func (c *CarouselElement) MinWidth(l Length) *CarouselElement
- func (c *CarouselElement) OnChange(fn func(int)) *CarouselElement
- func (c *CarouselElement) Styles(st CarouselStyle) *CarouselElement
- func (c *CarouselElement) Tooltip(s string) *CarouselElement
- func (c *CarouselElement) Width(l Length) *CarouselElement
- type CarouselStyle
- type CellKey
- type CheckState
- type CheckboxElement
- func (c *CheckboxElement) Disabled(d bool) *CheckboxElement
- func (c *CheckboxElement) FocusHandle(h *FocusHandle) *CheckboxElement
- func (c *CheckboxElement) GridSpan(cols, rows int) *CheckboxElement
- func (c *CheckboxElement) Grow(f float32) *CheckboxElement
- func (c *CheckboxElement) Height(l Length) *CheckboxElement
- func (c *CheckboxElement) Key(k string) *CheckboxElement
- func (c *CheckboxElement) MaxHeight(l Length) *CheckboxElement
- func (c *CheckboxElement) MaxWidth(l Length) *CheckboxElement
- func (c *CheckboxElement) MinHeight(l Length) *CheckboxElement
- func (c *CheckboxElement) MinWidth(l Length) *CheckboxElement
- func (c *CheckboxElement) OnChange(fn func(checked bool)) *CheckboxElement
- func (c *CheckboxElement) Styles(st CheckboxStyle) *CheckboxElement
- func (c *CheckboxElement) Tooltip(s string) *CheckboxElement
- func (c *CheckboxElement) Validate(rules ...Validator[bool]) *CheckboxElement
- func (c *CheckboxElement) Width(l Length) *CheckboxElement
- type CheckboxStyle
- type ClearSet
- type CodeEditorColors
- type CollapsibleElement
- func (c *CollapsibleElement) Disabled(d bool) *CollapsibleElement
- func (c *CollapsibleElement) GridSpan(cols, rows int) *CollapsibleElement
- func (c *CollapsibleElement) Grow(f float32) *CollapsibleElement
- func (c *CollapsibleElement) KeepMounted() *CollapsibleElement
- func (c *CollapsibleElement) Key(k string) *CollapsibleElement
- func (c *CollapsibleElement) MaxWidth(l Length) *CollapsibleElement
- func (c *CollapsibleElement) MinWidth(l Length) *CollapsibleElement
- func (c *CollapsibleElement) OnChange(fn func(open bool)) *CollapsibleElement
- func (c *CollapsibleElement) RenderHeader(fn func(title string, state PartState) Element) *CollapsibleElement
- func (c *CollapsibleElement) Styles(st CollapsibleStyle) *CollapsibleElement
- func (c *CollapsibleElement) Width(l Length) *CollapsibleElement
- type CollapsibleStyle
- type Color
- type ColorPickerElement
- func (c *ColorPickerElement) Alpha() *ColorPickerElement
- func (c *ColorPickerElement) Disabled(on bool) *ColorPickerElement
- func (c *ColorPickerElement) FocusHandle(h *FocusHandle) *ColorPickerElement
- func (c *ColorPickerElement) GridSpan(cols, rows int) *ColorPickerElement
- func (c *ColorPickerElement) Grow(f float32) *ColorPickerElement
- func (c *ColorPickerElement) Key(k string) *ColorPickerElement
- func (c *ColorPickerElement) Label(name string) *ColorPickerElement
- func (c *ColorPickerElement) LabelledBy(keys ...string) *ColorPickerElement
- func (c *ColorPickerElement) Large() *ColorPickerElement
- func (c *ColorPickerElement) MaxWidth(l Length) *ColorPickerElement
- func (c *ColorPickerElement) MinWidth(l Length) *ColorPickerElement
- func (c *ColorPickerElement) OnChange(fn func(Color)) *ColorPickerElement
- func (c *ColorPickerElement) Small() *ColorPickerElement
- func (c *ColorPickerElement) Styles(st ColorPickerStyle) *ColorPickerElement
- func (c *ColorPickerElement) Swatches(colors ...Color) *ColorPickerElement
- func (c *ColorPickerElement) Tooltip(s string) *ColorPickerElement
- func (c *ColorPickerElement) Width(l Length) *ColorPickerElement
- type ColorPickerStyle
- type ColorStop
- type ColumnPin
- type ColumnState
- type ComboboxElement
- func (c *ComboboxElement[T]) AllowFree(on bool) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Debounce(d time.Duration) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Disabled(d bool) *ComboboxElement[T]
- func (c *ComboboxElement[T]) EmptyText(s string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) ErrorText(s string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) FocusHandle(h *FocusHandle) *ComboboxElement[T]
- func (c *ComboboxElement[T]) GridSpan(cols, rows int) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Grow(f float32) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Height(l Length) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Icon(ic *icons.Icon) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Key(k string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Label(name string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) LabelledBy(keys ...string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Large() *ComboboxElement[T]
- func (c *ComboboxElement[T]) MaxHeight(l Length) *ComboboxElement[T]
- func (c *ComboboxElement[T]) MaxVisible(n int) *ComboboxElement[T]
- func (c *ComboboxElement[T]) MaxWidth(l Length) *ComboboxElement[T]
- func (c *ComboboxElement[T]) MinChars(n int) *ComboboxElement[T]
- func (c *ComboboxElement[T]) MinHeight(l Length) *ComboboxElement[T]
- func (c *ComboboxElement[T]) MinWidth(l Length) *ComboboxElement[T]
- func (c *ComboboxElement[T]) OnChange(fn func(string)) *ComboboxElement[T]
- func (c *ComboboxElement[T]) OnPick(fn func(T)) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Placeholder(s string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) RenderOption(fn func(opt Option[T], state PartState) Element) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Small() *ComboboxElement[T]
- func (c *ComboboxElement[T]) Styles(st ComboboxStyle) *ComboboxElement[T]
- func (c *ComboboxElement[T]) SuggestAsync(fn func(ctx context.Context, query string) ([]Option[T], error)) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Tooltip(s string) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Validate(rules ...Validator[string]) *ComboboxElement[T]
- func (c *ComboboxElement[T]) Width(l Length) *ComboboxElement[T]
- type ComboboxStyle
- type Command
- type CommandError
- type CommandPaletteElement
- func (p *CommandPaletteElement) Commands(fn func() []*Action) *CommandPaletteElement
- func (p *CommandPaletteElement) Items(fn func(query string) []PaletteItem) *CommandPaletteElement
- func (p *CommandPaletteElement) ItemsOnly() *CommandPaletteElement
- func (p *CommandPaletteElement) Key(k string) *CommandPaletteElement
- func (p *CommandPaletteElement) MaxRows(n int) *CommandPaletteElement
- func (p *CommandPaletteElement) Placeholder(s string) *CommandPaletteElement
- func (p *CommandPaletteElement) Styles(st CommandPaletteStyle) *CommandPaletteElement
- type CommandPaletteStyle
- type ComponentElement
- type Composite
- type Composition
- type Computed
- type Context
- func (c *Context) After(d time.Duration, fn func()) (cancel func())
- func (c *Context) AppTheme() *Theme
- func (c *Context) AvailableActions() []*Action
- func (c *Context) Clipboard() (string, bool)
- func (c *Context) ClipboardHasImage() bool
- func (c *Context) ClipboardImage() (image.Image, bool)
- func (c *Context) CommitComposition()
- func (c *Context) DismissToast(id string)
- func (c *Context) Dispatch(a *Action) bool
- func (c *Context) FocusedHandle() *FocusHandle
- func (c *Context) HighContrast() bool
- func (c *Context) Invalidate()
- func (c *Context) KeyboardFocus() bool
- func (c *Context) KeysFor(a *Action) string
- func (c *Context) OnDispose(fn func())
- func (c *Context) OpenURL(url string) error
- func (c *Context) Post(fn func())
- func (c *Context) ReducedMotion() bool
- func (c *Context) SetClipboard(s string)
- func (c *Context) SetClipboardImage(img image.Image)
- func (c *Context) SetTheme(t *Theme)
- func (c *Context) SetZoom(z float32)
- func (c *Context) Strings() *Strings
- func (c *Context) SystemDark() bool
- func (c *Context) TextScale() int
- func (c *Context) Theme() *Theme
- func (c *Context) Toast(v ToastVariant, text string) *Toast
- func (c *Context) ToastWithID(id string, v ToastVariant, text string) *Toast
- func (c *Context) Window() Window
- func (c *Context) WindowSize() (w, h float32)
- func (c *Context) Zoom() float32
- type CopyButtonElement
- func (c *CopyButtonElement) Copied(s string) *CopyButtonElement
- func (c *CopyButtonElement) Danger() *CopyButtonElement
- func (c *CopyButtonElement) Disabled(d bool) *CopyButtonElement
- func (c *CopyButtonElement) Ghost() *CopyButtonElement
- func (c *CopyButtonElement) Height(l Length) *CopyButtonElement
- func (c *CopyButtonElement) Key(k string) *CopyButtonElement
- func (c *CopyButtonElement) Label(s string) *CopyButtonElement
- func (c *CopyButtonElement) Large() *CopyButtonElement
- func (c *CopyButtonElement) OnCopy(fn func(string)) *CopyButtonElement
- func (c *CopyButtonElement) Primary() *CopyButtonElement
- func (c *CopyButtonElement) Secondary() *CopyButtonElement
- func (c *CopyButtonElement) Small() *CopyButtonElement
- func (c *CopyButtonElement) Style(s Style) *CopyButtonElement
- func (c *CopyButtonElement) Styles(st ButtonStyle) *CopyButtonElement
- func (c *CopyButtonElement) Toast(on bool) *CopyButtonElement
- func (c *CopyButtonElement) Tooltip(s string) *CopyButtonElement
- func (c *CopyButtonElement) Value(fn func() string) *CopyButtonElement
- func (c *CopyButtonElement) Variant(v ButtonVariant) *CopyButtonElement
- func (c *CopyButtonElement) Width(l Length) *CopyButtonElement
- type Corners
- type Crumb
- type Cursor
- type DataColumn
- type DataGridDensity
- type DataGridElement
- func (g *DataGridElement[T]) CellSelection(mode SelectionMode, cells *Signal[[]CellKey]) *DataGridElement[T]
- func (g *DataGridElement[T]) Children(fn func(row T) []T) *DataGridElement[T]
- func (g *DataGridElement[T]) ColumnOrder(keys *Signal[[]string]) *DataGridElement[T]
- func (g *DataGridElement[T]) ColumnWidths(ws *Signal[map[string]float32]) *DataGridElement[T]
- func (g *DataGridElement[T]) ContextMenu(build func(row T, column string) []MenuItem) *DataGridElement[T]
- func (g *DataGridElement[T]) Density(d DataGridDensity) *DataGridElement[T]
- func (g *DataGridElement[T]) Empty(el Element) *DataGridElement[T]
- func (g *DataGridElement[T]) Expanded(keys *Signal[[]string]) *DataGridElement[T]
- func (g *DataGridElement[T]) FocusHandle(h *FocusHandle) *DataGridElement[T]
- func (g *DataGridElement[T]) GridSpan(cols, rows int) *DataGridElement[T]
- func (g *DataGridElement[T]) Grow(f float32) *DataGridElement[T]
- func (g *DataGridElement[T]) Handle(h *DataGridHandle) *DataGridElement[T]
- func (g *DataGridElement[T]) HeaderContextMenu(build func(column string) []MenuItem) *DataGridElement[T]
- func (g *DataGridElement[T]) Height(l Length) *DataGridElement[T]
- func (g *DataGridElement[T]) Key(k string) *DataGridElement[T]
- func (g *DataGridElement[T]) Label(name string) *DataGridElement[T]
- func (g *DataGridElement[T]) LoadMore(hasMore bool, fn func()) *DataGridElement[T]
- func (g *DataGridElement[T]) Loading(on bool) *DataGridElement[T]
- func (g *DataGridElement[T]) LoadingMore(on bool) *DataGridElement[T]
- func (g *DataGridElement[T]) MaxHeight(l Length) *DataGridElement[T]
- func (g *DataGridElement[T]) MaxWidth(l Length) *DataGridElement[T]
- func (g *DataGridElement[T]) MinHeight(l Length) *DataGridElement[T]
- func (g *DataGridElement[T]) MinWidth(l Length) *DataGridElement[T]
- func (g *DataGridElement[T]) Movable() *DataGridElement[T]
- func (g *DataGridElement[T]) OnActivate(fn func(row T)) *DataGridElement[T]
- func (g *DataGridElement[T]) OnCollapse(fn func(key string)) *DataGridElement[T]
- func (g *DataGridElement[T]) OnColumnsChange(fn func(ColumnState)) *DataGridElement[T]
- func (g *DataGridElement[T]) OnExpand(fn func(key string)) *DataGridElement[T]
- func (g *DataGridElement[T]) Selection(mode SelectionMode, keys *Signal[[]string]) *DataGridElement[T]
- func (g *DataGridElement[T]) Sort(s *Signal[SortState]) *DataGridElement[T]
- func (g *DataGridElement[T]) SortChildrenOnly() *DataGridElement[T]
- func (g *DataGridElement[T]) Striped() *DataGridElement[T]
- func (g *DataGridElement[T]) Style(s Style) *DataGridElement[T]
- func (g *DataGridElement[T]) Styles(st DataGridStyle) *DataGridElement[T]
- func (g *DataGridElement[T]) Width(l Length) *DataGridElement[T]
- type DataGridHandle
- type DataGridStyle
- type DatePickerElement
- func (d *DatePickerElement) DisableDays(fn func(day time.Time) bool) *DatePickerElement
- func (d *DatePickerElement) Disabled(on bool) *DatePickerElement
- func (d *DatePickerElement) FirstDay(day time.Weekday) *DatePickerElement
- func (d *DatePickerElement) FocusHandle(h *FocusHandle) *DatePickerElement
- func (d *DatePickerElement) GridSpan(cols, rows int) *DatePickerElement
- func (d *DatePickerElement) Grow(f float32) *DatePickerElement
- func (d *DatePickerElement) Height(l Length) *DatePickerElement
- func (d *DatePickerElement) Key(k string) *DatePickerElement
- func (d *DatePickerElement) Label(name string) *DatePickerElement
- func (d *DatePickerElement) LabelledBy(keys ...string) *DatePickerElement
- func (d *DatePickerElement) Large() *DatePickerElement
- func (d *DatePickerElement) Max(day time.Time) *DatePickerElement
- func (d *DatePickerElement) MaxHeight(l Length) *DatePickerElement
- func (d *DatePickerElement) MaxWidth(l Length) *DatePickerElement
- func (d *DatePickerElement) Min(day time.Time) *DatePickerElement
- func (d *DatePickerElement) MinHeight(l Length) *DatePickerElement
- func (d *DatePickerElement) MinWidth(l Length) *DatePickerElement
- func (d *DatePickerElement) OnChange(fn func(time.Time)) *DatePickerElement
- func (d *DatePickerElement) Placeholder(s string) *DatePickerElement
- func (d *DatePickerElement) Small() *DatePickerElement
- func (d *DatePickerElement) Styles(st DatePickerStyle) *DatePickerElement
- func (d *DatePickerElement) Tooltip(s string) *DatePickerElement
- func (d *DatePickerElement) Validate(rules ...Validator[time.Time]) *DatePickerElement
- func (d *DatePickerElement) Width(l Length) *DatePickerElement
- type DatePickerStyle
- type DateRange
- type DateRangePickerElement
- func (d *DateRangePickerElement) DisableDays(fn func(day time.Time) bool) *DateRangePickerElement
- func (d *DateRangePickerElement) Disabled(on bool) *DateRangePickerElement
- func (d *DateRangePickerElement) FirstDay(day time.Weekday) *DateRangePickerElement
- func (d *DateRangePickerElement) FocusHandle(h *FocusHandle) *DateRangePickerElement
- func (d *DateRangePickerElement) GridSpan(cols, rows int) *DateRangePickerElement
- func (d *DateRangePickerElement) Grow(f float32) *DateRangePickerElement
- func (d *DateRangePickerElement) Height(l Length) *DateRangePickerElement
- func (d *DateRangePickerElement) Key(k string) *DateRangePickerElement
- func (d *DateRangePickerElement) Label(name string) *DateRangePickerElement
- func (d *DateRangePickerElement) LabelledBy(keys ...string) *DateRangePickerElement
- func (d *DateRangePickerElement) Large() *DateRangePickerElement
- func (d *DateRangePickerElement) Max(day time.Time) *DateRangePickerElement
- func (d *DateRangePickerElement) MaxHeight(l Length) *DateRangePickerElement
- func (d *DateRangePickerElement) MaxWidth(l Length) *DateRangePickerElement
- func (d *DateRangePickerElement) Min(day time.Time) *DateRangePickerElement
- func (d *DateRangePickerElement) MinHeight(l Length) *DateRangePickerElement
- func (d *DateRangePickerElement) MinWidth(l Length) *DateRangePickerElement
- func (d *DateRangePickerElement) OnChange(fn func(start, end time.Time)) *DateRangePickerElement
- func (d *DateRangePickerElement) Placeholder(s string) *DateRangePickerElement
- func (d *DateRangePickerElement) Small() *DateRangePickerElement
- func (d *DateRangePickerElement) Styles(st DateRangePickerStyle) *DateRangePickerElement
- func (d *DateRangePickerElement) Tooltip(s string) *DateRangePickerElement
- func (d *DateRangePickerElement) Validate(rules ...Validator[DateRange]) *DateRangePickerElement
- func (d *DateRangePickerElement) Width(l Length) *DateRangePickerElement
- type DateRangePickerStyle
- type DescriptionListElement
- func (l *DescriptionListElement) Bordered() *DescriptionListElement
- func (l *DescriptionListElement) Columns(n int) *DescriptionListElement
- func (l *DescriptionListElement) GridSpan(cols, rows int) *DescriptionListElement
- func (l *DescriptionListElement) Grow(f float32) *DescriptionListElement
- func (l *DescriptionListElement) Item(term string, value Element) *DescriptionListElement
- func (l *DescriptionListElement) ItemText(term, value string) *DescriptionListElement
- func (l *DescriptionListElement) Key(k string) *DescriptionListElement
- func (l *DescriptionListElement) MaxWidth(w Length) *DescriptionListElement
- func (l *DescriptionListElement) MinWidth(w Length) *DescriptionListElement
- func (l *DescriptionListElement) Styles(st DescriptionListStyle) *DescriptionListElement
- func (l *DescriptionListElement) Tooltip(s string) *DescriptionListElement
- func (l *DescriptionListElement) Vertical() *DescriptionListElement
- func (l *DescriptionListElement) Width(w Length) *DescriptionListElement
- type DescriptionListStyle
- type Direction
- type DivElement
- func (d *DivElement) Absolute() *DivElement
- func (d *DivElement) AccessCell(row, col int) *DivElement
- func (d *DivElement) AccessChecked(on bool) *DivElement
- func (d *DivElement) AccessExpanded(open bool) *DivElement
- func (d *DivElement) AccessGrid(rows, cols int) *DivElement
- func (d *DivElement) AccessHidden() *DivElement
- func (d *DivElement) AccessLevel(level int) *DivElement
- func (d *DivElement) AccessPosition(pos, size int) *DivElement
- func (d *DivElement) AccessSelected(on bool) *DivElement
- func (d *DivElement) Align(a Alignment) *DivElement
- func (d *DivElement) AlignSelf(a Alignment) *DivElement
- func (d *DivElement) AutoFocus() *DivElement
- func (d *DivElement) Background(c Color) *DivElement
- func (d *DivElement) BackgroundGradient(g Gradient) *DivElement
- func (d *DivElement) Badged(b *BadgeElement) *DivElement
- func (d *DivElement) Basis(l Length) *DivElement
- func (d *DivElement) Border(width float32, c Color) *DivElement
- func (d *DivElement) BorderEdges(e Edges, c Color) *DivElement
- func (d *DivElement) Bottom(px float32) *DivElement
- func (d *DivElement) CapturePointer() *DivElement
- func (d *DivElement) Center() *DivElement
- func (d *DivElement) Child(e Element) *DivElement
- func (d *DivElement) Children(es ...Element) *DivElement
- func (d *DivElement) ClipContent() *DivElement
- func (d *DivElement) Column() *DivElement
- func (d *DivElement) ContextMenu(build func() []MenuItem) *DivElement
- func (d *DivElement) Cursor(c Cursor) *DivElement
- func (d *DivElement) DescribedBy(keys ...string) *DivElement
- func (d *DivElement) Description(s string) *DivElement
- func (d *DivElement) Display(on bool) *DivElement
- func (d *DivElement) Dragging(s Style) *DivElement
- func (d *DivElement) Enter(m Motion, a Animation) *DivElement
- func (d *DivElement) Exit(m Motion, a Animation) *DivElement
- func (d *DivElement) Flex() *DivElement
- func (d *DivElement) FocusHandle(h *FocusHandle) *DivElement
- func (d *DivElement) FocusVisible(s Style) *DivElement
- func (d *DivElement) FocusWithin(s Style) *DivElement
- func (d *DivElement) Focusable() *DivElement
- func (d *DivElement) Focused(s Style) *DivElement
- func (d *DivElement) FontSize(px float32) *DivElement
- func (d *DivElement) FontWeight(w FontWeight) *DivElement
- func (d *DivElement) Gap(px float32) *DivElement
- func (d *DivElement) Grid(columns ...Length) *DivElement
- func (d *DivElement) GridRows(rows ...Length) *DivElement
- func (d *DivElement) GridSpan(cols, rows int) *DivElement
- func (d *DivElement) Grow(f float32) *DivElement
- func (d *DivElement) Heading(level int) *DivElement
- func (d *DivElement) Height(l Length) *DivElement
- func (d *DivElement) Hover(s Style) *DivElement
- func (d *DivElement) IME(m IME) *DivElement
- func (d *DivElement) Inset(px float32) *DivElement
- func (d *DivElement) Justify(a Alignment) *DivElement
- func (d *DivElement) KeepFocus() *DivElement
- func (d *DivElement) Key(k string) *DivElement
- func (d *DivElement) KeyContext(spec string) *DivElement
- func (d *DivElement) Keyf(format string, args ...any) *DivElement
- func (d *DivElement) Label(s string) *DivElement
- func (d *DivElement) LabelledBy(keys ...string) *DivElement
- func (d *DivElement) Left(px float32) *DivElement
- func (d *DivElement) Margin(px float32) *DivElement
- func (d *DivElement) MarginBottom(px float32) *DivElement
- func (d *DivElement) MarginLeft(px float32) *DivElement
- func (d *DivElement) MarginRight(px float32) *DivElement
- func (d *DivElement) MarginTop(px float32) *DivElement
- func (d *DivElement) MarginX(px float32) *DivElement
- func (d *DivElement) MarginY(px float32) *DivElement
- func (d *DivElement) MaxHeight(l Length) *DivElement
- func (d *DivElement) MaxWidth(l Length) *DivElement
- func (d *DivElement) MinHeight(l Length) *DivElement
- func (d *DivElement) MinWidth(l Length) *DivElement
- func (d *DivElement) Offset(x, y float32) *DivElement
- func (d *DivElement) OnAction(a *Action, fn func()) *DivElement
- func (d *DivElement) OnBlur(fn func()) *DivElement
- func (d *DivElement) OnClick(fn func()) *DivElement
- func (d *DivElement) OnClickOutside(fn func()) *DivElement
- func (d *DivElement) OnDoubleClick(fn func()) *DivElement
- func (d *DivElement) OnDrag(s *DragSpec) *DivElement
- func (d *DivElement) OnDrop(t DropTarget) *DivElement
- func (d *DivElement) OnFocus(fn func()) *DivElement
- func (d *DivElement) OnGridColumns(fn func(n int)) *DivElement
- func (d *DivElement) OnKeyDown(fn func(*KeyEvent)) *DivElement
- func (d *DivElement) OnKeyUp(fn func(*KeyEvent)) *DivElement
- func (d *DivElement) OnMouseDown(fn func(*MouseEvent)) *DivElement
- func (d *DivElement) OnMouseEnter(fn func()) *DivElement
- func (d *DivElement) OnMouseLeave(fn func()) *DivElement
- func (d *DivElement) OnMouseMove(fn func(*MouseEvent)) *DivElement
- func (d *DivElement) OnMouseUp(fn func(*MouseEvent)) *DivElement
- func (d *DivElement) OnPinch(fn func(*PinchEvent)) *DivElement
- func (d *DivElement) OnScroll(fn func(*ScrollEvent)) *DivElement
- func (d *DivElement) OnTextInput(fn func(string)) *DivElement
- func (d *DivElement) Opacity(o float32) *DivElement
- func (d *DivElement) Overlay(p Placement) *DivElement
- func (d *DivElement) OverlayGap(px float32) *DivElement
- func (d *DivElement) Padding(px float32) *DivElement
- func (d *DivElement) PaddingBottom(px float32) *DivElement
- func (d *DivElement) PaddingEdges(e Edges) *DivElement
- func (d *DivElement) PaddingLeft(px float32) *DivElement
- func (d *DivElement) PaddingRight(px float32) *DivElement
- func (d *DivElement) PaddingTop(px float32) *DivElement
- func (d *DivElement) PaddingX(px float32) *DivElement
- func (d *DivElement) PaddingY(px float32) *DivElement
- func (d *DivElement) Play(key any, frames []Keyframe, a Animation) *DivElement
- func (d *DivElement) Pressed(s Style) *DivElement
- func (d *DivElement) Radius(r float32) *DivElement
- func (d *DivElement) RadiusCorners(c Corners) *DivElement
- func (d *DivElement) Right(px float32) *DivElement
- func (d *DivElement) Role(r access.Role) *DivElement
- func (d *DivElement) Row() *DivElement
- func (d *DivElement) Scale(s float32) *DivElement
- func (d *DivElement) ScrollX() *DivElement
- func (d *DivElement) ScrollY() *DivElement
- func (d *DivElement) SelectionContainer() *DivElement
- func (d *DivElement) Shadow(s Shadow) *DivElement
- func (d *DivElement) Shrink(f float32) *DivElement
- func (d *DivElement) Size(w, h Length) *DivElement
- func (d *DivElement) Spring(s Spring) *DivElement
- func (d *DivElement) Style(s Style) *DivElement
- func (d *DivElement) TabIndex(i int) *DivElement
- func (d *DivElement) TabStop(on bool) *DivElement
- func (d *DivElement) TextAccess(t TextAccess) *DivElement
- func (d *DivElement) TextColor(c Color) *DivElement
- func (d *DivElement) Tooltip(s string) *DivElement
- func (d *DivElement) Top(px float32) *DivElement
- func (d *DivElement) Transition(t time.Duration) *DivElement
- func (d *DivElement) When(cond bool, fn func(d *DivElement)) *DivElement
- func (d *DivElement) Width(l Length) *DivElement
- func (d *DivElement) WindowArea(a WindowArea) *DivElement
- func (d *DivElement) Wrap() *DivElement
- func (d *DivElement) ZIndex(z int) *DivElement
- type DockElement
- func (d *DockElement) Floating(open func(DockWindow) Window) *DockElement
- func (d *DockElement) GridSpan(cols, rows int) *DockElement
- func (d *DockElement) Grow(f float32) *DockElement
- func (d *DockElement) Height(l Length) *DockElement
- func (d *DockElement) Key(k string) *DockElement
- func (d *DockElement) MaxHeight(l Length) *DockElement
- func (d *DockElement) MaxWidth(l Length) *DockElement
- func (d *DockElement) MinHeight(l Length) *DockElement
- func (d *DockElement) MinWidth(l Length) *DockElement
- func (d *DockElement) OnChange(fn func(DockLayout)) *DockElement
- func (d *DockElement) Styles(s DockStyle) *DockElement
- func (d *DockElement) Width(l Length) *DockElement
- type DockFloat
- type DockHome
- type DockLayout
- func (l DockLayout) Clone() DockLayout
- func (l DockLayout) Close(id string) DockLayout
- func (l DockLayout) Dock(id string) DockLayout
- func (l DockLayout) Float(id string, x, y, w, h int) DockLayout
- func (l DockLayout) Focus(id string) DockLayout
- func (l DockLayout) Has(id string) bool
- func (l DockLayout) Move(id, target string, zone DockZone) DockLayout
- func (l DockLayout) MoveSide(id string, side DockZone) DockLayout
- func (l DockLayout) Show(id string) DockLayout
- type DockNode
- type DockPanel
- type DockStyle
- type DockWindow
- type DockZone
- type DragEnd
- type DragSpec
- type DrawerElement
- func (d *DrawerElement) CloseButton(show bool) *DrawerElement
- func (d *DrawerElement) CloseOnClickOutside() *DrawerElement
- func (d *DrawerElement) Default(b *ButtonElement) *DrawerElement
- func (d *DrawerElement) Footer(buttons ...Element) *DrawerElement
- func (d *DrawerElement) Height(l Length) *DrawerElement
- func (d *DrawerElement) InitialFocus(h *FocusHandle) *DrawerElement
- func (d *DrawerElement) Key(k string) *DrawerElement
- func (d *DrawerElement) MaxHeight(l Length) *DrawerElement
- func (d *DrawerElement) MaxWidth(l Length) *DrawerElement
- func (d *DrawerElement) MinHeight(l Length) *DrawerElement
- func (d *DrawerElement) MinWidth(l Length) *DrawerElement
- func (d *DrawerElement) NonModal() *DrawerElement
- func (d *DrawerElement) OnClose(fn func()) *DrawerElement
- func (d *DrawerElement) Side(s DrawerSide) *DrawerElement
- func (d *DrawerElement) Styles(st DrawerStyle) *DrawerElement
- func (d *DrawerElement) Width(l Length) *DrawerElement
- type DrawerSide
- type DrawerStyle
- type DrawnStyle
- type DropEvent
- type DropSpec
- type DropTarget
- type DropdownMenuElement
- type Edges
- type Element
- type EmptyElement
- func (e *EmptyElement) Action(el Element) *EmptyElement
- func (e *EmptyElement) Description(s string) *EmptyElement
- func (e *EmptyElement) GridSpan(cols, rows int) *EmptyElement
- func (e *EmptyElement) Grow(f float32) *EmptyElement
- func (e *EmptyElement) Icon(ic *icons.Icon) *EmptyElement
- func (e *EmptyElement) Key(k string) *EmptyElement
- func (e *EmptyElement) MaxWidth(l Length) *EmptyElement
- func (e *EmptyElement) MinWidth(l Length) *EmptyElement
- func (e *EmptyElement) Styles(st EmptyStyle) *EmptyElement
- func (e *EmptyElement) Width(l Length) *EmptyElement
- type EmptyStyle
- type FieldElement
- func (f *FieldElement) Check(fn func() error) *FieldElement
- func (f *FieldElement) Description(s string) *FieldElement
- func (f *FieldElement) Error(msg string) *FieldElement
- func (f *FieldElement) Focus(h *FocusHandle) *FieldElement
- func (f *FieldElement) Grow(g float32) *FieldElement
- func (f *FieldElement) Inline() *FieldElement
- func (f *FieldElement) Key(k string) *FieldElement
- func (f *FieldElement) MaxWidth(l Length) *FieldElement
- func (f *FieldElement) MinWidth(l Length) *FieldElement
- func (f *FieldElement) Required() *FieldElement
- func (f *FieldElement) Styles(st FormFieldStyle) *FieldElement
- func (f *FieldElement) Width(l Length) *FieldElement
- type FieldStyle
- type Files
- type FocusHandle
- type FontWeight
- type Form
- func (f *Form) Field(key, label string, control Element) *FieldElement
- func (f *Form) OnSubmit(fn func() error) *Form
- func (f *Form) OnSubmitAsync(fn func() <-chan error) *Form
- func (f *Form) Reset()
- func (f *Form) Submit()
- func (f *Form) Submitting() bool
- func (f *Form) Summary() *FormSummaryElement
- type FormFieldStyle
- type FormStyle
- type FormSummaryElement
- type FrameStats
- type GesturePhase
- type Gradient
- type GradientPaint
- type GroupBoxElement
- func (g *GroupBoxElement) Child(e Element) *GroupBoxElement
- func (g *GroupBoxElement) Children(es ...Element) *GroupBoxElement
- func (g *GroupBoxElement) Description(s string) *GroupBoxElement
- func (g *GroupBoxElement) Fill() *GroupBoxElement
- func (g *GroupBoxElement) GridSpan(cols, rows int) *GroupBoxElement
- func (g *GroupBoxElement) Grow(f float32) *GroupBoxElement
- func (g *GroupBoxElement) Key(k string) *GroupBoxElement
- func (g *GroupBoxElement) MaxWidth(l Length) *GroupBoxElement
- func (g *GroupBoxElement) MinWidth(l Length) *GroupBoxElement
- func (g *GroupBoxElement) Styles(st GroupBoxStyle) *GroupBoxElement
- func (g *GroupBoxElement) Tooltip(s string) *GroupBoxElement
- func (g *GroupBoxElement) Width(l Length) *GroupBoxElement
- type GroupBoxStyle
- type Highlight
- type HoverCardElement
- func (h *HoverCardElement) CloseDelay(d time.Duration) *HoverCardElement
- func (h *HoverCardElement) Key(k string) *HoverCardElement
- func (h *HoverCardElement) OpenDelay(d time.Duration) *HoverCardElement
- func (h *HoverCardElement) Placement(pl Placement) *HoverCardElement
- func (h *HoverCardElement) Styles(st HoverCardStyle) *HoverCardElement
- type HoverCardStyle
- type IME
- type IconElement
- type ImageElement
- func (i *ImageElement) Alt(s string) *ImageElement
- func (i *ImageElement) Fit(f ImageFit) *ImageElement
- func (i *ImageElement) Key(k string) *ImageElement
- func (i *ImageElement) Opacity(o float32) *ImageElement
- func (i *ImageElement) Radius(r float32) *ImageElement
- func (i *ImageElement) Size(w, h Length) *ImageElement
- func (i *ImageElement) Style(s Style) *ImageElement
- type ImageFit
- type ImageSource
- type InputFormat
- type KbdElement
- func (k *KbdElement) GridSpan(cols, rows int) *KbdElement
- func (k *KbdElement) Grow(f float32) *KbdElement
- func (k *KbdElement) Key(key string) *KbdElement
- func (k *KbdElement) MaxWidth(l Length) *KbdElement
- func (k *KbdElement) MinWidth(l Length) *KbdElement
- func (k *KbdElement) Styles(st KbdStyle) *KbdElement
- func (k *KbdElement) Tooltip(s string) *KbdElement
- func (k *KbdElement) Width(l Length) *KbdElement
- type KbdStyle
- type KeyEvent
- type Keyframe
- type Length
- type LineCap
- type LineJoin
- type ListBoxElement
- func (l *ListBoxElement[T]) ContextMenu(build func(item T) []MenuItem) *ListBoxElement[T]
- func (l *ListBoxElement[T]) GridSpan(cols, rows int) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Grow(f float32) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Height(v Length) *ListBoxElement[T]
- func (l *ListBoxElement[T]) ItemName(name func(item T) string) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Key(k string) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Label(name string) *ListBoxElement[T]
- func (l *ListBoxElement[T]) MaxHeight(v Length) *ListBoxElement[T]
- func (l *ListBoxElement[T]) MaxWidth(v Length) *ListBoxElement[T]
- func (l *ListBoxElement[T]) MinHeight(v Length) *ListBoxElement[T]
- func (l *ListBoxElement[T]) MinWidth(v Length) *ListBoxElement[T]
- func (l *ListBoxElement[T]) OnActivate(fn func(item T)) *ListBoxElement[T]
- func (l *ListBoxElement[T]) OnChange(fn func(keys []string)) *ListBoxElement[T]
- func (l *ListBoxElement[T]) SelectedKey(key *Signal[string]) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Selection(mode SelectionMode) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Style(s Style) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Styles(st ListBoxStyle) *ListBoxElement[T]
- func (l *ListBoxElement[T]) Width(v Length) *ListBoxElement[T]
- type ListBoxStyle
- type ListElement
- func (l *ListElement) Bottom() *ListElement
- func (l *ListElement) GridSpan(cols, rows int) *ListElement
- func (l *ListElement) Grow(f float32) *ListElement
- func (l *ListElement) Handle(h *ListHandle) *ListElement
- func (l *ListElement) Height(v Length) *ListElement
- func (l *ListElement) Key(k string) *ListElement
- func (l *ListElement) Label(name string) *ListElement
- func (l *ListElement) MaxHeight(v Length) *ListElement
- func (l *ListElement) MaxWidth(v Length) *ListElement
- func (l *ListElement) MinHeight(v Length) *ListElement
- func (l *ListElement) MinWidth(v Length) *ListElement
- func (l *ListElement) OnAtEnd(fn func(atEnd bool)) *ListElement
- func (l *ListElement) SelectionContainer() *ListElement
- func (l *ListElement) Style(s Style) *ListElement
- func (l *ListElement) Width(v Length) *ListElement
- type ListHandle
- type MenuBarElement
- type MenuBarStyle
- type MenuCheck
- type MenuItem
- type MenuKind
- type MenuStyle
- type ModalElement
- func (m *ModalElement) CloseButton(show bool) *ModalElement
- func (m *ModalElement) CloseOnBackdrop() *ModalElement
- func (m *ModalElement) CloseOnClickOutside() *ModalElement
- func (m *ModalElement) Default(b *ButtonElement) *ModalElement
- func (m *ModalElement) Footer(buttons ...Element) *ModalElement
- func (m *ModalElement) InitialFocus(h *FocusHandle) *ModalElement
- func (m *ModalElement) Key(k string) *ModalElement
- func (m *ModalElement) MaxWidth(l Length) *ModalElement
- func (m *ModalElement) MinWidth(l Length) *ModalElement
- func (m *ModalElement) NonModal() *ModalElement
- func (m *ModalElement) OnClose(fn func()) *ModalElement
- func (m *ModalElement) Styles(st ModalStyle) *ModalElement
- func (m *ModalElement) Width(l Length) *ModalElement
- type ModalStyle
- type Motion
- type MotionTokens
- type MouseEvent
- type NopWindow
- func (NopWindow) Close()
- func (NopWindow) Closed() bool
- func (NopWindow) Focus()
- func (NopWindow) Focused() bool
- func (NopWindow) Fullscreen() bool
- func (NopWindow) Hide()
- func (NopWindow) Maximized() bool
- func (NopWindow) MessageBox(dialog.MessageOptions, func(dialog.Button))
- func (NopWindow) Minimize()
- func (NopWindow) OpenFiles(dialog.FileOptions, func(dialog.FileResult))
- func (NopWindow) PickFolder(dialog.FileOptions, func(dialog.FileResult))
- func (NopWindow) Position() (x, y int)
- func (NopWindow) RequestClose()
- func (NopWindow) SaveFile(dialog.FileOptions, func(dialog.FileResult))
- func (NopWindow) SetFullscreen(on bool)
- func (NopWindow) SetPosition(x, y int)
- func (NopWindow) SetSize(width, height int)
- func (NopWindow) SetTaskbarBadge(image.Image, string)
- func (NopWindow) SetTaskbarProgress(TaskbarProgress)
- func (NopWindow) SetTitle(string)
- func (NopWindow) Show()
- func (NopWindow) Size() (width, height int)
- func (NopWindow) ToggleMaximize()
- func (NopWindow) Visible() bool
- type NumberInputElement
- func (n *NumberInputElement[T]) Align(a Alignment) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Disabled(d bool) *NumberInputElement[T]
- func (n *NumberInputElement[T]) FocusHandle(h *FocusHandle) *NumberInputElement[T]
- func (n *NumberInputElement[T]) GridSpan(cols, rows int) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Grow(f float32) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Height(l Length) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Key(k string) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Label(s string) *NumberInputElement[T]
- func (n *NumberInputElement[T]) LabelledBy(keys ...string) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Large() *NumberInputElement[T]
- func (n *NumberInputElement[T]) MaxWidth(l Length) *NumberInputElement[T]
- func (n *NumberInputElement[T]) MinWidth(l Length) *NumberInputElement[T]
- func (n *NumberInputElement[T]) OnChange(fn func(T)) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Precision(d int) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Small() *NumberInputElement[T]
- func (n *NumberInputElement[T]) SpinButtons(p SpinPlacement) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Styles(st NumberInputStyle) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Tooltip(s string) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Validate(rules ...Validator[T]) *NumberInputElement[T]
- func (n *NumberInputElement[T]) Width(l Length) *NumberInputElement[T]
- type NumberInputStyle
- type NumberOptions
- type OTPInputElement
- func (o *OTPInputElement) Alphanumeric() *OTPInputElement
- func (o *OTPInputElement) Disabled(d bool) *OTPInputElement
- func (o *OTPInputElement) FocusHandle(h *FocusHandle) *OTPInputElement
- func (o *OTPInputElement) GridSpan(cols, rows int) *OTPInputElement
- func (o *OTPInputElement) Groups(sizes ...int) *OTPInputElement
- func (o *OTPInputElement) Grow(f float32) *OTPInputElement
- func (o *OTPInputElement) Key(k string) *OTPInputElement
- func (o *OTPInputElement) LabelledBy(keys ...string) *OTPInputElement
- func (o *OTPInputElement) Masked() *OTPInputElement
- func (o *OTPInputElement) MaxWidth(l Length) *OTPInputElement
- func (o *OTPInputElement) MinWidth(l Length) *OTPInputElement
- func (o *OTPInputElement) OnChange(fn func(string)) *OTPInputElement
- func (o *OTPInputElement) OnComplete(fn func(code string)) *OTPInputElement
- func (o *OTPInputElement) Styles(st OTPInputStyle) *OTPInputElement
- func (o *OTPInputElement) Tooltip(s string) *OTPInputElement
- func (o *OTPInputElement) Validate(rules ...Validator[string]) *OTPInputElement
- func (o *OTPInputElement) Width(l Length) *OTPInputElement
- type OTPInputStyle
- type Option
- type Overflow
- type PaginationElement
- func (p *PaginationElement) Compact() *PaginationElement
- func (p *PaginationElement) GridSpan(cols, rows int) *PaginationElement
- func (p *PaginationElement) Key(k string) *PaginationElement
- func (p *PaginationElement) Label(name string) *PaginationElement
- func (p *PaginationElement) MaxWidth(l Length) *PaginationElement
- func (p *PaginationElement) MinWidth(l Length) *PaginationElement
- func (p *PaginationElement) OnChange(fn func(page int)) *PaginationElement
- func (p *PaginationElement) Siblings(n int) *PaginationElement
- func (p *PaginationElement) Styles(s PaginationStyle) *PaginationElement
- func (p *PaginationElement) Tooltip(s string) *PaginationElement
- func (p *PaginationElement) Width(l Length) *PaginationElement
- type PaginationStyle
- type Paint
- type Painter
- func (p *Painter) Alpha(a float32)
- func (p *Painter) CaretVisible(activity time.Time) bool
- func (p *Painter) Clip(path *Path)
- func (p *Painter) Fill(path *Path, paint Paint)
- func (p *Painter) FillRect(x, y, w, h float32, paint Paint)
- func (p *Painter) FontName(st TextFormat) string
- func (p *Painter) MeasureText(s string, st TextFormat) (w, h float32)
- func (p *Painter) Now() time.Time
- func (p *Painter) Restore()
- func (p *Painter) Rotate(angle float32)
- func (p *Painter) Save()
- func (p *Painter) Scale(sx, sy float32)
- func (p *Painter) Stroke(path *Path, s StrokeStyle)
- func (p *Painter) Text(x, y float32, s string, st TextFormat)
- func (p *Painter) TextColor() Color
- func (p *Painter) Translate(x, y float32)
- type PaletteItem
- type PaneElement
- func (p *PaneElement) Collapsed(v *Signal[bool]) *PaneElement
- func (p *PaneElement) Collapsible() *PaneElement
- func (p *PaneElement) Key(k string) *PaneElement
- func (p *PaneElement) Label(name string) *PaneElement
- func (p *PaneElement) Max(l Length) *PaneElement
- func (p *PaneElement) Min(l Length) *PaneElement
- func (p *PaneElement) Size(l Length) *PaneElement
- func (p *PaneElement) SizeSignal(v *Signal[Length]) *PaneElement
- type PartState
- type Path
- func (p *Path) Arc(cx, cy, r, start, end float32) *Path
- func (p *Path) ArcTo(rx, ry, rotation float32, large, sweep bool, x, y float32) *Path
- func (p *Path) Circle(cx, cy, r float32) *Path
- func (p *Path) Close() *Path
- func (p *Path) CubicTo(c1x, c1y, c2x, c2y, x, y float32) *Path
- func (p *Path) Ellipse(cx, cy, rx, ry float32) *Path
- func (p *Path) EvenOdd() *Path
- func (p *Path) LineTo(x, y float32) *Path
- func (p *Path) MoveTo(x, y float32) *Path
- func (p *Path) QuadTo(cx, cy, x, y float32) *Path
- func (p *Path) Rect(x, y, w, h float32) *Path
- func (p *Path) RoundRect(x, y, w, h, r float32) *Path
- type PinchEvent
- type Placement
- type PopoverElement
- func (p *PopoverElement) Key(k string) *PopoverElement
- func (p *PopoverElement) Label(name string) *PopoverElement
- func (p *PopoverElement) OnChange(fn func(open bool)) *PopoverElement
- func (p *PopoverElement) Placement(pl Placement) *PopoverElement
- func (p *PopoverElement) Styles(st PopoverStyle) *PopoverElement
- type PopoverStyle
- type ProgressBarElement
- func (p *ProgressBarElement) Color(c Color) *ProgressBarElement
- func (p *ProgressBarElement) Format(fn func(float64) string) *ProgressBarElement
- func (p *ProgressBarElement) GridSpan(cols, rows int) *ProgressBarElement
- func (p *ProgressBarElement) Grow(f float32) *ProgressBarElement
- func (p *ProgressBarElement) HideValue() *ProgressBarElement
- func (p *ProgressBarElement) Indeterminate() *ProgressBarElement
- func (p *ProgressBarElement) Key(k string) *ProgressBarElement
- func (p *ProgressBarElement) Label(name string) *ProgressBarElement
- func (p *ProgressBarElement) Max(hi float64) *ProgressBarElement
- func (p *ProgressBarElement) MaxWidth(l Length) *ProgressBarElement
- func (p *ProgressBarElement) Min(lo float64) *ProgressBarElement
- func (p *ProgressBarElement) MinWidth(l Length) *ProgressBarElement
- func (p *ProgressBarElement) Styles(st ProgressBarStyle) *ProgressBarElement
- func (p *ProgressBarElement) Width(l Length) *ProgressBarElement
- type ProgressBarStyle
- type ProgressRingElement
- type ProgressRingStyle
- type QueryOption
- type QueryResult
- type RadioGroupElement
- func (r *RadioGroupElement[T]) Disabled(d bool) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) FocusHandle(h *FocusHandle) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) GridSpan(cols, rows int) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Grow(f float32) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Height(l Length) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Key(k string) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Label(s string) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) LabelledBy(keys ...string) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) MaxWidth(l Length) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) MinWidth(l Length) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) OnChange(fn func(T)) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Styles(st RadioGroupStyle) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Tooltip(s string) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Validate(rules ...Validator[T]) *RadioGroupElement[T]
- func (r *RadioGroupElement[T]) Width(l Length) *RadioGroupElement[T]
- type RadioGroupStyle
- type RangeSliderElement
- func (s *RangeSliderElement) Disabled(d bool) *RangeSliderElement
- func (s *RangeSliderElement) FocusHandle(h *FocusHandle) *RangeSliderElement
- func (s *RangeSliderElement) Format(fn func(float64) string) *RangeSliderElement
- func (s *RangeSliderElement) GridSpan(cols, rows int) *RangeSliderElement
- func (s *RangeSliderElement) Grow(f float32) *RangeSliderElement
- func (s *RangeSliderElement) Key(k string) *RangeSliderElement
- func (s *RangeSliderElement) Label(name string) *RangeSliderElement
- func (s *RangeSliderElement) LabelledBy(keys ...string) *RangeSliderElement
- func (s *RangeSliderElement) MaxWidth(l Length) *RangeSliderElement
- func (s *RangeSliderElement) MinGap(gap float64) *RangeSliderElement
- func (s *RangeSliderElement) MinWidth(l Length) *RangeSliderElement
- func (s *RangeSliderElement) OnChange(fn func(low, high float64)) *RangeSliderElement
- func (s *RangeSliderElement) Styles(st RangeSliderStyle) *RangeSliderElement
- func (s *RangeSliderElement) Tooltip(text string) *RangeSliderElement
- func (s *RangeSliderElement) Width(l Length) *RangeSliderElement
- type RangeSliderStyle
- type RatingElement
- func (r *RatingElement) Disabled(d bool) *RatingElement
- func (r *RatingElement) FocusHandle(h *FocusHandle) *RatingElement
- func (r *RatingElement) GridSpan(cols, rows int) *RatingElement
- func (r *RatingElement) Grow(f float32) *RatingElement
- func (r *RatingElement) Key(k string) *RatingElement
- func (r *RatingElement) Max(n int) *RatingElement
- func (r *RatingElement) MaxWidth(l Length) *RatingElement
- func (r *RatingElement) MinWidth(l Length) *RatingElement
- func (r *RatingElement) OnChange(fn func(int)) *RatingElement
- func (r *RatingElement) ReadOnly() *RatingElement
- func (r *RatingElement) Styles(st RatingStyle) *RatingElement
- func (r *RatingElement) Tooltip(s string) *RatingElement
- func (r *RatingElement) Validate(rules ...Validator[int]) *RatingElement
- func (r *RatingElement) Width(l Length) *RatingElement
- type RatingStyle
- type Rect
- type RelativeUnit
- type Renderer
- type Runtime
- func (rt *Runtime) AccessBridge() *access.Bridge
- func (rt *Runtime) AccessTree() *access.Tree
- func (rt *Runtime) AddBindings(bs ...Binding)
- func (rt *Runtime) AppTheme() *Theme
- func (rt *Runtime) AvailableActions() []*Action
- func (rt *Runtime) ClickKey(key string) error
- func (rt *Runtime) ContentWidth() float32
- func (rt *Runtime) Dispatch(a *Action) bool
- func (rt *Runtime) DropFiles(x, y float32, paths []string)
- func (rt *Runtime) Dump(w io.Writer, maxDepth int)
- func (rt *Runtime) Fetching() bool
- func (rt *Runtime) Find(key string) (Rect, bool)
- func (rt *Runtime) FocusedHandle() *FocusHandle
- func (rt *Runtime) Frame(now time.Time)
- func (rt *Runtime) FrameRequested() bool
- func (rt *Runtime) HighContrast() bool
- func (rt *Runtime) HostLayerShown() bool
- func (rt *Runtime) KeyDown(k input.Key, mods input.Modifiers, repeat bool)
- func (rt *Runtime) KeyUp(k input.Key, mods input.Modifiers)
- func (rt *Runtime) KeysFor(a *Action) string
- func (rt *Runtime) NeedsFrame() bool
- func (rt *Runtime) Pinch(x, y float32, phase GesturePhase, scale, panX, panY float32, inertia bool, ...)
- func (rt *Runtime) PointerDown(x, y float32, b input.MouseButton, clicks int, mods input.Modifiers)
- func (rt *Runtime) PointerMove(x, y float32, mods input.Modifiers)
- func (rt *Runtime) PointerUp(x, y float32, b input.MouseButton, mods input.Modifiers)
- func (rt *Runtime) Post(fn func())
- func (rt *Runtime) Press(k input.Key, mods input.Modifiers)
- func (rt *Runtime) ReducedMotion() bool
- func (rt *Runtime) ResetZoom()
- func (rt *Runtime) Scroll(x, y, dx, dy float32, precise bool, mods input.Modifiers)
- func (rt *Runtime) ScrollIntoView(id access.ID) bool
- func (rt *Runtime) SetAccessWarnings(on bool)
- func (rt *Runtime) SetBindings(layer string, bs []Binding)
- func (rt *Runtime) SetDefaultTitleBar(on bool, title string)
- func (rt *Runtime) SetHostLayer(fn func(ctx *Context) Element)
- func (rt *Runtime) SetStrings(s *Strings)
- func (rt *Runtime) SetSystemSettings(s SystemSettings)
- func (rt *Runtime) SetTheme(t *Theme)
- func (rt *Runtime) SetThemes(light, dark *Theme)
- func (rt *Runtime) SetViewport(w, h, scale float32)
- func (rt *Runtime) SetWarnFunc(fn func(string))
- func (rt *Runtime) SetWindow(w Window)
- func (rt *Runtime) SetZoom(z float32)
- func (rt *Runtime) SetZoomShortcuts(on bool)
- func (rt *Runtime) Settled() bool
- func (rt *Runtime) Stats() FrameStats
- func (rt *Runtime) StyleOf(key string) (DrawnStyle, bool)
- func (rt *Runtime) SystemSettings() SystemSettings
- func (rt *Runtime) TextInput(s string)
- func (rt *Runtime) TextScale() int
- func (rt *Runtime) Theme() *Theme
- func (rt *Runtime) Type(text string)
- func (rt *Runtime) Zoom() float32
- func (rt *Runtime) ZoomIn()
- func (rt *Runtime) ZoomOut()
- type SVGElement
- func (e *SVGElement) Alt(s string) *SVGElement
- func (e *SVGElement) Color(c Color) *SVGElement
- func (e *SVGElement) Fit(f ImageFit) *SVGElement
- func (e *SVGElement) Key(k string) *SVGElement
- func (e *SVGElement) Opacity(o float32) *SVGElement
- func (e *SVGElement) Radius(r float32) *SVGElement
- func (e *SVGElement) Size(w, h Length) *SVGElement
- func (e *SVGElement) Style(s Style) *SVGElement
- type SVGSource
- type ScrollEvent
- type Segment
- func (g Segment) Background(c Color) Segment
- func (g Segment) Bold() Segment
- func (g Segment) Color(c Color) Segment
- func (g Segment) Hover(h Highlight) Segment
- func (g Segment) Italic() Segment
- func (g Segment) Mono() Segment
- func (g Segment) OnClick(fn func()) Segment
- func (g Segment) Strikethrough() Segment
- func (g Segment) Style(h Highlight) Segment
- func (g Segment) Underline() Segment
- type SelectElement
- func (s *SelectElement[T]) Disabled(d bool) *SelectElement[T]
- func (s *SelectElement[T]) FocusHandle(h *FocusHandle) *SelectElement[T]
- func (s *SelectElement[T]) GridSpan(cols, rows int) *SelectElement[T]
- func (s *SelectElement[T]) Grow(f float32) *SelectElement[T]
- func (s *SelectElement[T]) Height(l Length) *SelectElement[T]
- func (s *SelectElement[T]) Key(k string) *SelectElement[T]
- func (s *SelectElement[T]) Label(name string) *SelectElement[T]
- func (s *SelectElement[T]) LabelledBy(keys ...string) *SelectElement[T]
- func (s *SelectElement[T]) Large() *SelectElement[T]
- func (s *SelectElement[T]) MaxHeight(l Length) *SelectElement[T]
- func (s *SelectElement[T]) MaxWidth(l Length) *SelectElement[T]
- func (s *SelectElement[T]) MinHeight(l Length) *SelectElement[T]
- func (s *SelectElement[T]) MinWidth(l Length) *SelectElement[T]
- func (s *SelectElement[T]) OnChange(fn func(T)) *SelectElement[T]
- func (s *SelectElement[T]) Placeholder(text string) *SelectElement[T]
- func (s *SelectElement[T]) RenderOption(fn func(opt Option[T], state PartState) Element) *SelectElement[T]
- func (s *SelectElement[T]) RenderValue(fn func(opt Option[T], state PartState) Element) *SelectElement[T]
- func (s *SelectElement[T]) Small() *SelectElement[T]
- func (s *SelectElement[T]) Styles(st SelectStyle) *SelectElement[T]
- func (s *SelectElement[T]) Tooltip(text string) *SelectElement[T]
- func (s *SelectElement[T]) Validate(rules ...Validator[T]) *SelectElement[T]
- func (s *SelectElement[T]) Width(l Length) *SelectElement[T]
- type SelectStyle
- type SelectionMode
- type Shadow
- type SidebarElement
- func (s *SidebarElement) Collapsed(c *Signal[bool]) *SidebarElement
- func (s *SidebarElement) Footer(el Element) *SidebarElement
- func (s *SidebarElement) GridSpan(cols, rows int) *SidebarElement
- func (s *SidebarElement) Header(el Element) *SidebarElement
- func (s *SidebarElement) Key(k string) *SidebarElement
- func (s *SidebarElement) Label(name string) *SidebarElement
- func (s *SidebarElement) MaxWidth(l Length) *SidebarElement
- func (s *SidebarElement) MinWidth(l Length) *SidebarElement
- func (s *SidebarElement) NoIndicator() *SidebarElement
- func (s *SidebarElement) OnChange(fn func(key string)) *SidebarElement
- func (s *SidebarElement) Styles(st SidebarStyle) *SidebarElement
- func (s *SidebarElement) Toggle() *SidebarElement
- func (s *SidebarElement) Tooltip(text string) *SidebarElement
- func (s *SidebarElement) Width(l Length) *SidebarElement
- type SidebarItem
- type SidebarStyle
- type Signal
- type SkeletonElement
- func (s *SkeletonElement) Circle(diameter float32) *SkeletonElement
- func (s *SkeletonElement) GridSpan(cols, rows int) *SkeletonElement
- func (s *SkeletonElement) Grow(f float32) *SkeletonElement
- func (s *SkeletonElement) Height(l Length) *SkeletonElement
- func (s *SkeletonElement) Key(k string) *SkeletonElement
- func (s *SkeletonElement) Lines(n int) *SkeletonElement
- func (s *SkeletonElement) MaxWidth(l Length) *SkeletonElement
- func (s *SkeletonElement) Styles(st SkeletonStyle) *SkeletonElement
- func (s *SkeletonElement) Width(l Length) *SkeletonElement
- type SkeletonStyle
- type SliderElement
- func (s *SliderElement) Disabled(d bool) *SliderElement
- func (s *SliderElement) FocusHandle(h *FocusHandle) *SliderElement
- func (s *SliderElement) Format(fn func(float64) string) *SliderElement
- func (s *SliderElement) GridSpan(cols, rows int) *SliderElement
- func (s *SliderElement) Grow(f float32) *SliderElement
- func (s *SliderElement) Key(k string) *SliderElement
- func (s *SliderElement) Label(name string) *SliderElement
- func (s *SliderElement) LabelledBy(keys ...string) *SliderElement
- func (s *SliderElement) MaxWidth(l Length) *SliderElement
- func (s *SliderElement) MinWidth(l Length) *SliderElement
- func (s *SliderElement) OnChange(fn func(float64)) *SliderElement
- func (s *SliderElement) Styles(st SliderStyle) *SliderElement
- func (s *SliderElement) Tooltip(text string) *SliderElement
- func (s *SliderElement) Width(l Length) *SliderElement
- type SliderStyle
- type SortState
- type SpinPlacement
- type SplitButtonElement
- func (b *SplitButtonElement) Danger() *SplitButtonElement
- func (b *SplitButtonElement) Disabled(d bool) *SplitButtonElement
- func (b *SplitButtonElement) FocusHandle(h *FocusHandle) *SplitButtonElement
- func (b *SplitButtonElement) Ghost() *SplitButtonElement
- func (b *SplitButtonElement) GridSpan(cols, rows int) *SplitButtonElement
- func (b *SplitButtonElement) Grow(f float32) *SplitButtonElement
- func (b *SplitButtonElement) Icon(ic *icons.Icon) *SplitButtonElement
- func (b *SplitButtonElement) Key(k string) *SplitButtonElement
- func (b *SplitButtonElement) Large() *SplitButtonElement
- func (b *SplitButtonElement) Loading(on bool) *SplitButtonElement
- func (b *SplitButtonElement) MaxWidth(l Length) *SplitButtonElement
- func (b *SplitButtonElement) MinWidth(l Length) *SplitButtonElement
- func (b *SplitButtonElement) Primary() *SplitButtonElement
- func (b *SplitButtonElement) Secondary() *SplitButtonElement
- func (b *SplitButtonElement) Small() *SplitButtonElement
- func (b *SplitButtonElement) Styles(st SplitButtonStyle) *SplitButtonElement
- func (b *SplitButtonElement) Tooltip(s string) *SplitButtonElement
- func (b *SplitButtonElement) Variant(v ButtonVariant) *SplitButtonElement
- func (b *SplitButtonElement) Width(l Length) *SplitButtonElement
- type SplitButtonStyle
- type SplitElement
- func (s *SplitElement) GridSpan(cols, rows int) *SplitElement
- func (s *SplitElement) Grip(g SplitGrip) *SplitElement
- func (s *SplitElement) Grow(f float32) *SplitElement
- func (s *SplitElement) Height(l Length) *SplitElement
- func (s *SplitElement) Key(k string) *SplitElement
- func (s *SplitElement) Label(name string) *SplitElement
- func (s *SplitElement) MaxHeight(l Length) *SplitElement
- func (s *SplitElement) MaxWidth(l Length) *SplitElement
- func (s *SplitElement) MinHeight(l Length) *SplitElement
- func (s *SplitElement) MinWidth(l Length) *SplitElement
- func (s *SplitElement) OnChange(fn func()) *SplitElement
- func (s *SplitElement) Orientation(o SplitOrientation) *SplitElement
- func (s *SplitElement) Styles(st SplitStyle) *SplitElement
- func (s *SplitElement) Width(l Length) *SplitElement
- type SplitGrip
- type SplitOrientation
- type SplitStyle
- type Spring
- type StatusBarElement
- func (s *StatusBarElement) End(els ...Element) *StatusBarElement
- func (s *StatusBarElement) GridSpan(cols, rows int) *StatusBarElement
- func (s *StatusBarElement) Grow(f float32) *StatusBarElement
- func (s *StatusBarElement) Key(k string) *StatusBarElement
- func (s *StatusBarElement) Label(name string) *StatusBarElement
- func (s *StatusBarElement) MaxWidth(l Length) *StatusBarElement
- func (s *StatusBarElement) MinWidth(l Length) *StatusBarElement
- func (s *StatusBarElement) Start(els ...Element) *StatusBarElement
- func (s *StatusBarElement) Styles(st StatusBarStyle) *StatusBarElement
- func (s *StatusBarElement) Width(l Length) *StatusBarElement
- type StatusBarStyle
- type Step
- type StepperElement
- func (s *StepperElement) Compact() *StepperElement
- func (s *StepperElement) Disabled(d bool) *StepperElement
- func (s *StepperElement) FocusHandle(h *FocusHandle) *StepperElement
- func (s *StepperElement) GridSpan(cols, rows int) *StepperElement
- func (s *StepperElement) Grow(f float32) *StepperElement
- func (s *StepperElement) Height(l Length) *StepperElement
- func (s *StepperElement) Key(k string) *StepperElement
- func (s *StepperElement) Label(name string) *StepperElement
- func (s *StepperElement) MaxWidth(l Length) *StepperElement
- func (s *StepperElement) MinWidth(l Length) *StepperElement
- func (s *StepperElement) OnSelect(fn func(i int)) *StepperElement
- func (s *StepperElement) Styles(st StepperStyle) *StepperElement
- func (s *StepperElement) Tooltip(text string) *StepperElement
- func (s *StepperElement) Vertical() *StepperElement
- func (s *StepperElement) Width(l Length) *StepperElement
- type StepperStyle
- type Strings
- type StrokeStyle
- type Style
- type SwitchElement
- func (s *SwitchElement) Disabled(d bool) *SwitchElement
- func (s *SwitchElement) FocusHandle(h *FocusHandle) *SwitchElement
- func (s *SwitchElement) GridSpan(cols, rows int) *SwitchElement
- func (s *SwitchElement) Grow(f float32) *SwitchElement
- func (s *SwitchElement) Key(k string) *SwitchElement
- func (s *SwitchElement) MaxWidth(l Length) *SwitchElement
- func (s *SwitchElement) MinWidth(l Length) *SwitchElement
- func (s *SwitchElement) OnChange(fn func(bool)) *SwitchElement
- func (s *SwitchElement) ShowLabel() *SwitchElement
- func (s *SwitchElement) Styles(st SwitchStyle) *SwitchElement
- func (s *SwitchElement) Tooltip(text string) *SwitchElement
- func (s *SwitchElement) Width(l Length) *SwitchElement
- type SwitchStyle
- type SyntaxStyle
- type SystemColors
- type SystemSettings
- type Tab
- type TabsElement
- func (t *TabsElement[T]) FocusHandle(h *FocusHandle) *TabsElement[T]
- func (t *TabsElement[T]) KeepMounted() *TabsElement[T]
- func (t *TabsElement[T]) Key(k string) *TabsElement[T]
- func (t *TabsElement[T]) Label(name string) *TabsElement[T]
- func (t *TabsElement[T]) MaxWidth(l Length) *TabsElement[T]
- func (t *TabsElement[T]) MinWidth(l Length) *TabsElement[T]
- func (t *TabsElement[T]) OnChange(fn func(T)) *TabsElement[T]
- func (t *TabsElement[T]) OnClose(fn func(T)) *TabsElement[T]
- func (t *TabsElement[T]) OnReorder(fn func(order []T)) *TabsElement[T]
- func (t *TabsElement[T]) OnReselect(fn func(T)) *TabsElement[T]
- func (t *TabsElement[T]) OverflowMenu() *TabsElement[T]
- func (t *TabsElement[T]) Prefix(e Element) *TabsElement[T]
- func (t *TabsElement[T]) RenderTab(fn func(tab Tab[T], state PartState) Element) *TabsElement[T]
- func (t *TabsElement[T]) Reorderable() *TabsElement[T]
- func (t *TabsElement[T]) ScrollButtons(on bool) *TabsElement[T]
- func (t *TabsElement[T]) Styles(s TabsStyle) *TabsElement[T]
- func (t *TabsElement[T]) Suffix(e Element) *TabsElement[T]
- func (t *TabsElement[T]) TabMaxWidth(l Length) *TabsElement[T]
- func (t *TabsElement[T]) Variant(v TabsVariant) *TabsElement[T]
- func (t *TabsElement[T]) Width(l Length) *TabsElement[T]
- type TabsStyle
- type TabsVariant
- type TagElement
- func (g *TagElement) Color(c Color) *TagElement
- func (g *TagElement) GridSpan(cols, rows int) *TagElement
- func (g *TagElement) Grow(f float32) *TagElement
- func (g *TagElement) Icon(ic *icons.Icon) *TagElement
- func (g *TagElement) Key(k string) *TagElement
- func (g *TagElement) MaxWidth(l Length) *TagElement
- func (g *TagElement) MinWidth(l Length) *TagElement
- func (g *TagElement) OnRemove(fn func()) *TagElement
- func (g *TagElement) Styles(st TagStyle) *TagElement
- func (g *TagElement) Tooltip(s string) *TagElement
- func (g *TagElement) Width(l Length) *TagElement
- type TagStyle
- type TaskbarProgress
- type TaskbarState
- type TextAccess
- type TextAreaElement
- func (ta *TextAreaElement) AutoFocus() *TextAreaElement
- func (ta *TextAreaElement) Borderless() *TextAreaElement
- func (ta *TextAreaElement) DescribedBy(keys ...string) *TextAreaElement
- func (ta *TextAreaElement) Disabled(d bool) *TextAreaElement
- func (ta *TextAreaElement) FocusHandle(h *FocusHandle) *TextAreaElement
- func (ta *TextAreaElement) GridSpan(cols, rows int) *TextAreaElement
- func (ta *TextAreaElement) Grow(f float32) *TextAreaElement
- func (ta *TextAreaElement) Height(l Length) *TextAreaElement
- func (ta *TextAreaElement) Key(k string) *TextAreaElement
- func (ta *TextAreaElement) Label(s string) *TextAreaElement
- func (ta *TextAreaElement) LabelledBy(keys ...string) *TextAreaElement
- func (ta *TextAreaElement) Leading(el Element) *TextAreaElement
- func (ta *TextAreaElement) MaxHeight(l Length) *TextAreaElement
- func (ta *TextAreaElement) MaxWidth(l Length) *TextAreaElement
- func (ta *TextAreaElement) MinHeight(l Length) *TextAreaElement
- func (ta *TextAreaElement) MinRows(n int) *TextAreaElement
- func (ta *TextAreaElement) MinWidth(l Length) *TextAreaElement
- func (ta *TextAreaElement) OnChange(fn func(string)) *TextAreaElement
- func (ta *TextAreaElement) OnKeyDown(fn func(*KeyEvent)) *TextAreaElement
- func (ta *TextAreaElement) OnPasteImage(fn func(image.Image)) *TextAreaElement
- func (ta *TextAreaElement) Placeholder(s string) *TextAreaElement
- func (ta *TextAreaElement) ReadOnly(on bool) *TextAreaElement
- func (ta *TextAreaElement) Style(s Style) *TextAreaElement
- func (ta *TextAreaElement) Styles(s FieldStyle) *TextAreaElement
- func (ta *TextAreaElement) Tooltip(s string) *TextAreaElement
- func (ta *TextAreaElement) Trailing(el Element) *TextAreaElement
- func (ta *TextAreaElement) Validate(rules ...Validator[string]) *TextAreaElement
- func (ta *TextAreaElement) Width(l Length) *TextAreaElement
- type TextElement
- func (t *TextElement) Align(a Alignment) *TextElement
- func (t *TextElement) Basis(l Length) *TextElement
- func (t *TextElement) Bold() *TextElement
- func (t *TextElement) Font(family string) *TextElement
- func (t *TextElement) FontSize(px float32) *TextElement
- func (t *TextElement) FontWeight(w FontWeight) *TextElement
- func (t *TextElement) GridSpan(cols, rows int) *TextElement
- func (t *TextElement) Grow(f float32) *TextElement
- func (t *TextElement) Highlight(start, end int, h Highlight) *TextElement
- func (t *TextElement) HighlightMatches(query string, h Highlight) *TextElement
- func (t *TextElement) Italic() *TextElement
- func (t *TextElement) Key(k string) *TextElement
- func (t *TextElement) LineHeight(m float32) *TextElement
- func (t *TextElement) Margin(px float32) *TextElement
- func (t *TextElement) MarginBottom(px float32) *TextElement
- func (t *TextElement) MarginLeft(px float32) *TextElement
- func (t *TextElement) MarginRight(px float32) *TextElement
- func (t *TextElement) MarginTop(px float32) *TextElement
- func (t *TextElement) MarginX(px float32) *TextElement
- func (t *TextElement) MarginY(px float32) *TextElement
- func (t *TextElement) MaxLines(n int) *TextElement
- func (t *TextElement) MaxWidth(l Length) *TextElement
- func (t *TextElement) Medium() *TextElement
- func (t *TextElement) MinWidth(l Length) *TextElement
- func (t *TextElement) Mono() *TextElement
- func (t *TextElement) NoWrap() *TextElement
- func (t *TextElement) Selectable() *TextElement
- func (t *TextElement) Semibold() *TextElement
- func (t *TextElement) Shrink(f float32) *TextElement
- func (t *TextElement) Style(s Style) *TextElement
- func (t *TextElement) TextColor(c Color) *TextElement
- func (t *TextElement) Truncate() *TextElement
- func (t *TextElement) Weight(w FontWeight) *TextElementdeprecated
- func (t *TextElement) Width(l Length) *TextElement
- type TextFormat
- type TextInputElement
- func (ti *TextInputElement) Accept(fn func(next string) bool) *TextInputElement
- func (ti *TextInputElement) AutoFocus() *TextInputElement
- func (ti *TextInputElement) Borderless() *TextInputElement
- func (ti *TextInputElement) Clearable() *TextInputElement
- func (ti *TextInputElement) DescribedBy(keys ...string) *TextInputElement
- func (ti *TextInputElement) Disabled(d bool) *TextInputElement
- func (ti *TextInputElement) FocusHandle(h *FocusHandle) *TextInputElement
- func (ti *TextInputElement) Format(f InputFormat) *TextInputElement
- func (ti *TextInputElement) GridSpan(cols, rows int) *TextInputElement
- func (ti *TextInputElement) Grow(f float32) *TextInputElement
- func (ti *TextInputElement) Height(l Length) *TextInputElement
- func (ti *TextInputElement) Icon(ic *icons.Icon) *TextInputElement
- func (ti *TextInputElement) Key(k string) *TextInputElement
- func (ti *TextInputElement) Label(s string) *TextInputElement
- func (ti *TextInputElement) LabelledBy(keys ...string) *TextInputElement
- func (ti *TextInputElement) Large() *TextInputElement
- func (ti *TextInputElement) Leading(el Element) *TextInputElement
- func (ti *TextInputElement) Masked() *TextInputElement
- func (ti *TextInputElement) MaxHeight(l Length) *TextInputElement
- func (ti *TextInputElement) MaxWidth(l Length) *TextInputElement
- func (ti *TextInputElement) MinHeight(l Length) *TextInputElement
- func (ti *TextInputElement) MinWidth(l Length) *TextInputElement
- func (ti *TextInputElement) OnChange(fn func(string)) *TextInputElement
- func (ti *TextInputElement) OnKeyDown(fn func(*KeyEvent)) *TextInputElement
- func (ti *TextInputElement) OnPasteImage(fn func(image.Image)) *TextInputElement
- func (ti *TextInputElement) OnSubmit(fn func(string)) *TextInputElement
- func (ti *TextInputElement) Placeholder(s string) *TextInputElement
- func (ti *TextInputElement) ReadOnly(on bool) *TextInputElement
- func (ti *TextInputElement) Revealable() *TextInputElement
- func (ti *TextInputElement) Small() *TextInputElement
- func (ti *TextInputElement) Style(s Style) *TextInputElement
- func (ti *TextInputElement) Styles(s FieldStyle) *TextInputElement
- func (ti *TextInputElement) Tooltip(s string) *TextInputElement
- func (ti *TextInputElement) Trailing(el Element) *TextInputElement
- func (ti *TextInputElement) Validate(rules ...Validator[string]) *TextInputElement
- func (ti *TextInputElement) Width(l Length) *TextInputElement
- type Theme
- type ThemeInfo
- type TimePickerElement
- func (p *TimePickerElement) Disabled(on bool) *TimePickerElement
- func (p *TimePickerElement) FocusHandle(h *FocusHandle) *TimePickerElement
- func (p *TimePickerElement) GridSpan(cols, rows int) *TimePickerElement
- func (p *TimePickerElement) Grow(f float32) *TimePickerElement
- func (p *TimePickerElement) Height(l Length) *TimePickerElement
- func (p *TimePickerElement) Key(k string) *TimePickerElement
- func (p *TimePickerElement) Label(name string) *TimePickerElement
- func (p *TimePickerElement) LabelledBy(keys ...string) *TimePickerElement
- func (p *TimePickerElement) Large() *TimePickerElement
- func (p *TimePickerElement) Max(t time.Time) *TimePickerElement
- func (p *TimePickerElement) MaxHeight(l Length) *TimePickerElement
- func (p *TimePickerElement) MaxWidth(l Length) *TimePickerElement
- func (p *TimePickerElement) Min(t time.Time) *TimePickerElement
- func (p *TimePickerElement) MinHeight(l Length) *TimePickerElement
- func (p *TimePickerElement) MinWidth(l Length) *TimePickerElement
- func (p *TimePickerElement) MinuteStep(minutes int) *TimePickerElement
- func (p *TimePickerElement) OnChange(fn func(time.Time)) *TimePickerElement
- func (p *TimePickerElement) Placeholder(s string) *TimePickerElement
- func (p *TimePickerElement) Small() *TimePickerElement
- func (p *TimePickerElement) Styles(st TimePickerStyle) *TimePickerElement
- func (p *TimePickerElement) Tooltip(s string) *TimePickerElement
- func (p *TimePickerElement) Validate(rules ...Validator[time.Time]) *TimePickerElement
- func (p *TimePickerElement) Width(l Length) *TimePickerElement
- type TimePickerStyle
- type Timeline
- type TitleBarElement
- func (t *TitleBarElement) Buttons(show bool) *TitleBarElement
- func (t *TitleBarElement) Center(e Element) *TitleBarElement
- func (t *TitleBarElement) Child(e Element) *TitleBarElement
- func (t *TitleBarElement) Height(l Length) *TitleBarElement
- func (t *TitleBarElement) Key(k string) *TitleBarElement
- func (t *TitleBarElement) Style(s Style) *TitleBarElement
- func (t *TitleBarElement) Styles(st TitleBarStyle) *TitleBarElement
- func (t *TitleBarElement) Trailing(els ...Element) *TitleBarElement
- func (t *TitleBarElement) Width(l Length) *TitleBarElement
- type TitleBarStyle
- type Toast
- type ToastPlacement
- type ToastStyle
- type ToastVariant
- type ToastVariants
- type ToasterElement
- type ToggleElement
- func (b *ToggleElement) Disabled(d bool) *ToggleElement
- func (b *ToggleElement) FocusHandle(h *FocusHandle) *ToggleElement
- func (b *ToggleElement) Ghost() *ToggleElement
- func (b *ToggleElement) GridSpan(cols, rows int) *ToggleElement
- func (b *ToggleElement) Grow(f float32) *ToggleElement
- func (b *ToggleElement) Height(l Length) *ToggleElement
- func (b *ToggleElement) Icon(ic *icons.Icon) *ToggleElement
- func (b *ToggleElement) IconOnly() *ToggleElement
- func (b *ToggleElement) Key(k string) *ToggleElement
- func (b *ToggleElement) Large() *ToggleElement
- func (b *ToggleElement) MaxHeight(l Length) *ToggleElement
- func (b *ToggleElement) MaxWidth(l Length) *ToggleElement
- func (b *ToggleElement) MinHeight(l Length) *ToggleElement
- func (b *ToggleElement) MinWidth(l Length) *ToggleElement
- func (b *ToggleElement) OnChange(fn func(bool)) *ToggleElement
- func (b *ToggleElement) Secondary() *ToggleElement
- func (b *ToggleElement) Small() *ToggleElement
- func (b *ToggleElement) Styles(st ToggleStyle) *ToggleElement
- func (b *ToggleElement) Tooltip(s string) *ToggleElement
- func (b *ToggleElement) Width(l Length) *ToggleElement
- type ToggleGroupElement
- func (g *ToggleGroupElement[T]) Disabled(d bool) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) FocusHandle(h *FocusHandle) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) GridSpan(cols, rows int) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Grow(f float32) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) IconOnly() *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Key(k string) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Label(s string) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) LabelledBy(keys ...string) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Large() *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) MaxWidth(l Length) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) MinWidth(l Length) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) OnChange(fn func(T)) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Small() *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Styles(st ToggleGroupStyle) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Tooltip(s string) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Validate(rules ...Validator[T]) *ToggleGroupElement[T]
- func (g *ToggleGroupElement[T]) Width(l Length) *ToggleGroupElement[T]
- type ToggleGroupStyle
- type ToggleStyle
- type ToolbarElement
- func (b *ToolbarElement) Child(e Element) *ToolbarElement
- func (b *ToolbarElement) Children(es ...Element) *ToolbarElement
- func (b *ToolbarElement) GridSpan(cols, rows int) *ToolbarElement
- func (b *ToolbarElement) Grow(f float32) *ToolbarElement
- func (b *ToolbarElement) Key(k string) *ToolbarElement
- func (b *ToolbarElement) MaxWidth(l Length) *ToolbarElement
- func (b *ToolbarElement) MinWidth(l Length) *ToolbarElement
- func (b *ToolbarElement) Styles(st ToolbarStyle) *ToolbarElement
- func (b *ToolbarElement) Width(l Length) *ToolbarElement
- type ToolbarStyle
- type TooltipStyle
- type TopMenu
- type TreeElement
- func (tv *TreeElement) ContextMenu(build func(key string) []MenuItem) *TreeElement
- func (tv *TreeElement) Expanded(keys *Signal[[]string]) *TreeElement
- func (tv *TreeElement) FocusHandle(h *FocusHandle) *TreeElement
- func (tv *TreeElement) GridSpan(cols, rows int) *TreeElement
- func (tv *TreeElement) Grow(f float32) *TreeElement
- func (tv *TreeElement) Handle(h *TreeHandle) *TreeElement
- func (tv *TreeElement) Height(l Length) *TreeElement
- func (tv *TreeElement) Key(k string) *TreeElement
- func (tv *TreeElement) Label(name string) *TreeElement
- func (tv *TreeElement) MaxHeight(l Length) *TreeElement
- func (tv *TreeElement) MaxWidth(l Length) *TreeElement
- func (tv *TreeElement) MinHeight(l Length) *TreeElement
- func (tv *TreeElement) MinWidth(l Length) *TreeElement
- func (tv *TreeElement) OnChange(fn func(key string)) *TreeElement
- func (tv *TreeElement) OnCollapse(fn func(key string)) *TreeElement
- func (tv *TreeElement) OnExpand(fn func(key string)) *TreeElement
- func (tv *TreeElement) RenderLabel(fn func(node TreeNode, state PartState) Element) *TreeElement
- func (tv *TreeElement) RenderRow(fn func(node TreeNode, state PartState) Element) *TreeElement
- func (tv *TreeElement) RenderTrailing(fn func(node TreeNode, state PartState) Element) *TreeElement
- func (tv *TreeElement) Style(s Style) *TreeElement
- func (tv *TreeElement) Styles(st TreeStyle) *TreeElement
- func (tv *TreeElement) Width(l Length) *TreeElement
- type TreeHandle
- type TreeNode
- type TreeStyle
- type UniformListElement
- func (l *UniformListElement) GridSpan(cols, rows int) *UniformListElement
- func (l *UniformListElement) Grow(f float32) *UniformListElement
- func (l *UniformListElement) Handle(h *ListHandle) *UniformListElement
- func (l *UniformListElement) Height(v Length) *UniformListElement
- func (l *UniformListElement) Key(k string) *UniformListElement
- func (l *UniformListElement) Label(name string) *UniformListElement
- func (l *UniformListElement) MaxHeight(v Length) *UniformListElement
- func (l *UniformListElement) MaxWidth(v Length) *UniformListElement
- func (l *UniformListElement) MinHeight(v Length) *UniformListElement
- func (l *UniformListElement) MinWidth(v Length) *UniformListElement
- func (l *UniformListElement) SelectionContainer() *UniformListElement
- func (l *UniformListElement) Style(s Style) *UniformListElement
- func (l *UniformListElement) Width(v Length) *UniformListElement
- type Validator
- type Window
- type WindowArea
Constants ¶
const ( RingSmall float32 = 16 RingMedium float32 = 24 RingLarge float32 = 40 )
Sizes of a ProgressRing, for ProgressRingElement.Size.
const ( // FontLight is the weight 300. FontLight = text.Light // FontRegular is the weight 400, the normal weight. FontRegular = text.Regular // FontMedium is the weight 500. FontMedium = text.Medium // FontSemibold is the weight 600. FontSemibold = text.Semibold // FontBold is the weight 700. FontBold = text.Bold )
const ( // CursorDefault is the arrow cursor. CursorDefault = input.CursorDefault // CursorPointer is the hand cursor, for a link or a button. CursorPointer = input.CursorPointer // CursorText is the I-beam cursor, for text. CursorText = input.CursorText // CursorNotAllowed is the cursor for an action that cannot be done. CursorNotAllowed = input.CursorNotAllowed )
const DefaultTitleBarHeight = 34
DefaultTitleBarHeight is the height of the title bar that SetDefaultTitleBar draws, in logical pixels.
Variables ¶
var ( ShadowSm = Shadow{Y: 1, Blur: 3, Color: Color{0, 0, 0, 0.18}} ShadowMd = Shadow{Y: 4, Blur: 12, Color: Color{0, 0, 0, 0.22}} ShadowLg = Shadow{Y: 12, Blur: 32, Color: Color{0, 0, 0, 0.30}} )
Ready-made shadows that read well on both light and dark backgrounds.
var Auto = layout.Auto
Auto sizes from content (or stretches, depending on alignment).
var Full = layout.Percent(100)
Full is Percent(100).
var NoAction = NewAction("no-action", "No action").Hide()
NoAction disables keys: BindIn("Editor", "ctrl+a", ui.NoAction) makes Ctrl+A do nothing in fields. Bindings ranked below it for the same keys are skipped, and the key goes on to OnKeyDown and text input.
var Transparent = Color{}
Transparent is fully transparent black.
var ZoomLevels = []float32{0.5, 0.67, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3}
ZoomLevels are the steps used by ZoomIn, ZoomOut and the shortcuts.
Functions ¶
func Announce ¶
func Announce(text string, p access.Politeness)
Announce queues text for an assistive technology to speak, for a status message that has no focused element to carry it, such as "Saved". It is safe from any goroutine. Without an assistive technology it has no effect beyond the bounded queue.
func AvatarInitials ¶ added in v0.4.0
AvatarInitials returns the initials that Avatar shows for name: the first letter of its first word and of its last word, uppercased, or one letter for a name of one word. A name with no words has no initials, and "" is returned.
func CurrencySymbol ¶ added in v0.6.0
CurrencySymbol returns the symbol of the currency of the user's region settings, such as "$" or "€", and reports whether it goes after the amount, as in 5,00 €.
func FormatBytes ¶ added in v0.5.0
FormatBytes returns the size n in bytes as Windows Explorer and Task Manager show it: in 1024-based units, with three significant digits, such as "512 bytes", "1.00 KB", "12.3 MB", "123 MB" and "1.23 GB". A size of 1000 units or more is shown in the next unit, as Windows does, so 1024000 is "0.97 MB", and the digits are cut, not rounded, so 1048575 is "0.99 MB". The sizes go up to PB. The decimal point is the user's locale's, and the words are in the language of the system (see SystemStrings). Unlike Windows, one byte is "1 byte".
func FormatCurrency ¶ added in v0.6.0
FormatCurrency returns amount as an amount of money in the currency of the user's region settings, as Windows formats it: rounded to the currency's digits, with its decimal point and group separator, and its symbol and its sign where the settings put them, such as $1,234.56 and -$5.00 in en-US, 1.234,56 € and -5,00 € in de-DE, or ($5.00) where the settings show negative amounts in parentheses. An amount that rounds to zero has no sign. A NaN is the empty string. Elsewhere than on Windows the currency is the US dollar.
func FormatDate ¶
FormatDate returns t as a short date in the user's locale.
func FormatMonthYear ¶
FormatMonthYear returns the month and year of t in the user's locale, such as October 2026.
func FormatNumber ¶ added in v0.5.0
FormatNumber returns v rounded to decimals places, with the group separators, the decimal point and the minus sign of the user's locale, such as 12,345.68 in en-US or 12.345,68 in de-DE. A negative decimals is 0. A value that rounds to zero is shown without a minus sign. A NaN is the empty string, and an infinity is "∞" or "-∞".
func FormatRelative ¶ added in v0.4.0
FormatRelative returns how far t is from now in the user's language, such as "3 days ago" for a time in the past and "in 3 days" for one in the future. A zero time is empty. A time within a minute of now is "now"; the day before and the day after today are "yesterday" and "tomorrow". Days are counted by calendar day, and a week starts at 7 days, a month at 30 days and a year at 365 days. The text is in the language of the system (see SystemStrings). A TimeAgo element uses the Strings of its window instead.
func FormatTime ¶
FormatTime returns the time of day of t, to the minute, in the user's locale's clock.
func InvalidateQueries ¶ added in v0.4.0
InvalidateQueries marks each key that match reports as stale. A key with an enabled user is fetched again at once, and a fetch in flight for it is canceled. The others are fetched when a component next uses them. It runs on the UI thread.
func ParseDate ¶ added in v0.6.0
ParseDate returns the day that text holds, at local midnight, and whether it is a date: a short date in the user's locale, read as a date picker reads typed text (the numbers in the locale's order, with any punctuation between them; a year of two digits in this century or the one before; no year meaning this year), or an ISO 8601 date such as 2026-10-13, which files from other programs often hold. It is the counterpart of FormatDate. Month names are not read.
func ParseNumber ¶ added in v0.6.0
ParseNumber returns the number that text holds, written in the user's locale, and whether it is one: with the locale's decimal point and group separators (or those of amounts of money), and a leading minus or plus. It is the counterpart of FormatNumber, and reads what FormatCurrency writes too: a currency symbol before or after the number is dropped, and parentheses or a trailing minus make it negative, as some programs write amounts. So "1,234.5" is 1234.5 in en-US and "1.234,5" is 1234.5 in de-DE, and "($5.00)" is -5.
func RegisterDefaultBindings ¶
func RegisterDefaultBindings(bs ...Binding)
RegisterDefaultBindings adds bs to the bindings that every runtime starts with (see DefaultBindings). It is for packages that define widgets outside ui, such as codeedit, so that their keys work without the app binding them: call it from the package's init. An app's own bindings still win at the same depth, so the app can bind other keys or turn a key off with Unbind.
func SetQueryData ¶ added in v0.4.0
SetQueryData writes the data of key, as if a fetch had returned it, and so the data is fresh from now (see QueryStaleTime). It is how an optimistic update shows a change before the server confirms it. A fetch in flight is not canceled, so its result, when it arrives, replaces the value. It runs on the UI thread.
func SetThemeStyle ¶ added in v0.2.0
SetThemeStyle stores v on the theme t, under the type T. It is how a theme holds the style of a widget that the Theme struct cannot name, such as charts.Style or codeedit.Style, or the style type of a third-party widget: the widget reads it with ThemeStyle, and merges it over its built-in defaults and under the Styles of an instance. Storing again under the same type replaces the value.
The value belongs to the theme t, not to the app: a window that switches between a light and a dark theme needs it set on both. Set it before the theme is given to a window or to SetTheme, as with the other fields of a theme. To change it while the theme is in use, set it on a Clone and pass the clone to SetTheme. Copies made with Clone, with a struct copy, or by HighContrastTheme keep the values set before the copy, and a later SetThemeStyle on one does not change the other.
func SortBy ¶
SortBy returns the Compare of a DataColumn that orders the rows by key, with cmp.Compare. The sort is reversed by SortState.Desc, so there is no SortByDesc.
ui.DataColumn[Run]{Header: "Cost", Text: ..., Compare: ui.SortBy(func(r Run) float32 { return r.Cost })}
func SortByText ¶
SortByText returns the Compare of a DataColumn that orders the rows by the text key, without regard to case: "api" sorts with "Billing". Text with the same lowercase form is ordered by its case, so the order is total. The text is compared by its Unicode lowercase form, not by a locale's collation.
func StyleLayer ¶
StyleLayer returns s with the name of the layer recorded on each style that s holds: s itself when it is a Style, or each Style field of a struct, such as a widget's part styles. When no inspector is attached to the window of ctx, s is returned unchanged.
A widget that builds a part's style from layers calls StyleLayer on each layer, before it merges the layer, so that the inspector can name the layer each value came from. The names the inspector shows are "built-in default" (the widget's own default), "theme" (the theme's style for the part) and "instance Styles" (the Styles of the element); a widget may name another layer, such as "high contrast". The merged style keeps the names, so the inspector reports the layer of every field. A style that is already merged from named layers keeps its names.
func ThemeStyle ¶ added in v0.2.0
ThemeStyle returns the value that SetThemeStyle stored on the theme t under the type T, and true. It returns the zero value and false when none is stored, or when t is nil. A widget calls it while it renders, with ctx.Theme(); the theme is not changed then (see SetThemeStyle), so the read needs no lock.
Under high contrast ctx.Theme() is the high contrast theme, which keeps the values of the app's theme. A widget should treat them as it treats the Styles of an instance there: keep their sizes and spacing, and take its colors from the system colors, as the built-in widgets do.
Types ¶
type AccordionElement ¶
type AccordionElement struct {
// contains filtered or unexported fields
}
AccordionElement is a group of collapsible sections. By default each section opens and closes on its own. SingleOpen makes opening one section close the others, as Microsoft's expander guidance describes for groups of expanders (https://learn.microsoft.com/en-us/windows/apps/develop/ui/controls/expander), and leaves the choice to the app: the default is independent sections.
The group draws no part of its own. Its sections are Collapsibles, styled by Theme.Collapsible and by the Styles of each section.
func Accordion ¶
func Accordion(sections ...*CollapsibleElement) *AccordionElement
Accordion creates a group of sections, shown in order.
func (*AccordionElement) GridSpan ¶
func (a *AccordionElement) GridSpan(cols, rows int) *AccordionElement
GridSpan sets how many columns and rows the accordion covers in its parent's grid.
func (*AccordionElement) Grow ¶
func (a *AccordionElement) Grow(f float32) *AccordionElement
Grow makes the accordion take a share of the free space on its parent's main axis.
func (*AccordionElement) Key ¶
func (a *AccordionElement) Key(k string) *AccordionElement
Key gives the group a stable identity among its siblings.
func (*AccordionElement) MaxWidth ¶
func (a *AccordionElement) MaxWidth(l Length) *AccordionElement
MaxWidth sets the largest width of the accordion.
func (*AccordionElement) MinWidth ¶
func (a *AccordionElement) MinWidth(l Length) *AccordionElement
MinWidth sets the smallest width of the accordion.
func (*AccordionElement) SingleOpen ¶
func (a *AccordionElement) SingleOpen() *AccordionElement
SingleOpen makes opening a section close the others. A section that is closed stays closed, so the group can be closed entirely.
func (*AccordionElement) Width ¶
func (a *AccordionElement) Width(l Length) *AccordionElement
The sizing methods give the group's outer box a width, as for a Collapsible.
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action is a named command that key bindings, menus and the command palette can run.
func EditorActions ¶
func EditorActions() []*Action
EditorActions lists the actions of text fields, in the order of the editor table. Keymap files may name them. The actions package has each of them as a variable.
func NewAction ¶
NewAction creates an action. name identifies it (for example "notes.new"), label is the text a menu or command palette shows (for example "New note").
func Unbind ¶
Unbind returns an action that removes a's bindings for the same keys ranked below it: BindIn("Editor", "ctrl+z", ui.Unbind(actions.Undo)). Other bindings for those keys still apply.
type AlertDialogElement ¶ added in v0.4.0
type AlertDialogElement struct {
// contains filtered or unexported fields
}
AlertDialogElement is a modal dialog that asks the user to respond to a message, such as "Delete 3 files?", with a confirm button and, if it has one, a cancel button. It is a Modal with a fixed layout: an icon and the title, the message and an optional Body, and the buttons at the end of the footer, the app's Actions first, then Cancel, then the confirm button. Build it only while it is open, last in the window's root element, as a Modal is, and remove it in the confirm and cancel functions:
ui.If(asking.Get(), ui.AlertDialog("Delete 3 files?", "They cannot be restored.").
Intent(ui.AlertDialogDestructive).
Confirm("Delete", deleteFiles).
Cancel("", func() { asking.Set(false) }))
Focus moves into it when it opens, to the confirm button, or to Cancel for AlertDialogDestructive, and returns when it closes; Tab stays inside it. Escape runs Cancel, or the confirm function when there is no Cancel. A press on the backdrop does nothing: the dialog waits for an answer. Enter presses the focused button; elsewhere in the dialog it confirms, except for AlertDialogDestructive, whose confirm button has to be pressed.
Assistive technology hears an alert dialog (RoleAlertDialog) named by the title and described by the message.
func AlertDialog ¶ added in v0.4.0
func AlertDialog(title, message string) *AlertDialogElement
AlertDialog creates an alert dialog with a title and a message. Add its buttons with Confirm, Cancel and Action. Without Confirm it has an OK button that runs nothing.
func (*AlertDialogElement) Action ¶ added in v0.4.0
func (a *AlertDialogElement) Action(b *ButtonElement) *AlertDialogElement
Action adds a button of the app's, such as "Save as…", before Cancel. Calling it again adds another, after the earlier ones.
func (*AlertDialogElement) Body ¶ added in v0.4.0
func (a *AlertDialogElement) Body(e Element) *AlertDialogElement
Body adds e under the message, such as a check box "Don't ask again".
func (*AlertDialogElement) Cancel ¶ added in v0.4.0
func (a *AlertDialogElement) Cancel(label string, fn func()) *AlertDialogElement
Cancel adds a cancel button, Secondary, before the confirm button, with its label and the function it runs. An empty label is Strings.Cancel. Escape runs it too.
func (*AlertDialogElement) Confirm ¶ added in v0.4.0
func (a *AlertDialogElement) Confirm(label string, fn func()) *AlertDialogElement
Confirm sets the label of the confirm button and the function it runs. An empty label is Strings.OK.
func (*AlertDialogElement) ConfirmLoading ¶ added in v0.4.0
func (a *AlertDialogElement) ConfirmLoading(on bool) *AlertDialogElement
ConfirmLoading shows the confirm button as loading (see ButtonElement.Loading) while the work it started runs: it does nothing and keeps the focus. Escape does not confirm meanwhile.
func (*AlertDialogElement) Icon ¶ added in v0.4.0
func (a *AlertDialogElement) Icon(ic *icons.Icon) *AlertDialogElement
Icon replaces the intent's icon with ic; nil hides the icon.
func (*AlertDialogElement) Intent ¶ added in v0.4.0
func (a *AlertDialogElement) Intent(i AlertDialogIntent) *AlertDialogElement
Intent sets what the dialog asks (see AlertDialogIntent), AlertDialogInfo by default.
func (*AlertDialogElement) Key ¶ added in v0.4.0
func (a *AlertDialogElement) Key(k string) *AlertDialogElement
Key identifies the dialog among its siblings (see DivElement.Key). It also scopes the key of its message.
func (*AlertDialogElement) MaxWidth ¶ added in v0.4.0
func (a *AlertDialogElement) MaxWidth(l Length) *AlertDialogElement
MaxWidth sets the largest width of the dialog.
func (*AlertDialogElement) MinWidth ¶ added in v0.4.0
func (a *AlertDialogElement) MinWidth(l Length) *AlertDialogElement
MinWidth sets the smallest width of the dialog.
func (*AlertDialogElement) Styles ¶ added in v0.4.0
func (a *AlertDialogElement) Styles(st AlertDialogStyle) *AlertDialogElement
Styles sets the look of the parts of the dialog, for this instance only. Set fields win over the theme's AlertDialog and the defaults; see AlertDialogStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*AlertDialogElement) Width ¶ added in v0.4.0
func (a *AlertDialogElement) Width(l Length) *AlertDialogElement
The sizing methods give the panel a width, 420 px by default, as a Modal's. A percentage is of the window's width. See Sizing in docs/styling.md.
type AlertDialogIntent ¶ added in v0.4.0
type AlertDialogIntent uint8
AlertDialogIntent is what an alert dialog asks: it picks the dialog's icon, the look of its confirm button and where the focus goes when it opens.
const ( // AlertDialogInfo is a message to acknowledge, with the Info icon and, as a // rule, the confirm button alone ("OK"). It is the default. AlertDialogInfo AlertDialogIntent = iota // AlertDialogConfirm asks the user to confirm an action, with the Info icon in // the accent color. AlertDialogConfirm // AlertDialogWarning asks about an action that needs care, with the Alert icon // in the warning colors. AlertDialogWarning // AlertDialogDestructive asks about an action that deletes or cannot be undone, // with the Alert icon in the danger colors and a Danger confirm button. The // focus starts on Cancel, and Enter in the dialog confirms only from the // confirm button. AlertDialogDestructive )
type AlertDialogStyle ¶ added in v0.4.0
type AlertDialogStyle struct {
Scrim Style // the dimmed backdrop behind the dialog
Panel Style // the dialog
Header Style // the row of the icon and the title
Icon Style // the icon, before the title
Title Style // the title
Message Style // the message, under the title
Body Style // the area of the message and the Body element
}
AlertDialogStyle is the look of each part of an alert dialog. A part's style merges over the built-in defaults of its intent, then over the theme's AlertDialog, then over the Styles of the instance; see docs/styling.md. Scrim, Panel, Body and Footer are a modal's parts. Header is the row of the icon and the title, Icon the icon, Title the title, Message the message, and Body the area under the header that holds the message and the Body element.
type AlertElement ¶ added in v0.3.0
type AlertElement struct {
// contains filtered or unexported fields
}
AlertElement is a message box in the flow of the page, such as a note above a form or the result of an action: an icon, a title, an optional description and action, and an optional close button. It is a group named by its title, with the description as its description.
An alert is not a live region: it is not announced when it appears. An app that shows one after an action the user should hear about announces it too, with Announce.
func Alert ¶ added in v0.3.0
func Alert(title string) *AlertElement
Alert creates an info alert titled title. An alert fills the width of its container by default.
func (*AlertElement) Action ¶ added in v0.3.0
func (a *AlertElement) Action(el Element) *AlertElement
Action adds el under the description, such as a button that fixes what the alert reports.
func (*AlertElement) Danger ¶ added in v0.3.0
func (a *AlertElement) Danger() *AlertElement
Danger sets the AlertDanger variant.
func (*AlertElement) Description ¶ added in v0.3.0
func (a *AlertElement) Description(s string) *AlertElement
Description sets the text under the title.
func (*AlertElement) GridSpan ¶ added in v0.3.0
func (a *AlertElement) GridSpan(cols, rows int) *AlertElement
GridSpan sets how many columns and rows the alert covers in its parent's grid.
func (*AlertElement) Grow ¶ added in v0.3.0
func (a *AlertElement) Grow(f float32) *AlertElement
Grow makes the alert take a share of the free space on its parent's main axis.
func (*AlertElement) Icon ¶ added in v0.3.0
func (a *AlertElement) Icon(ic *icons.Icon) *AlertElement
Icon replaces the variant's icon. Icon(nil) shows no icon.
func (*AlertElement) Info ¶ added in v0.3.0
func (a *AlertElement) Info() *AlertElement
Info sets the AlertInfo variant, the default.
func (*AlertElement) Key ¶ added in v0.3.0
func (a *AlertElement) Key(k string) *AlertElement
Key identifies the alert among its siblings (see DivElement.Key).
func (*AlertElement) MaxWidth ¶ added in v0.3.0
func (a *AlertElement) MaxWidth(l Length) *AlertElement
MaxWidth sets the largest width of the alert.
func (*AlertElement) MinWidth ¶ added in v0.3.0
func (a *AlertElement) MinWidth(l Length) *AlertElement
MinWidth sets the smallest width of the alert.
func (*AlertElement) OnClose ¶ added in v0.3.0
func (a *AlertElement) OnClose(fn func()) *AlertElement
OnClose adds a close button at the end of the alert, which calls fn when it is pressed with the mouse, or with Enter or Space. The button is named with the Close text of the window's Strings. fn removes the alert, by changing the state it is built from.
func (*AlertElement) Styles ¶ added in v0.3.0
func (a *AlertElement) Styles(st AlertStyle) *AlertElement
Styles sets the look of the parts of the alert, for this instance only. Set fields win over the theme's Alert and Alerts and the defaults; see AlertStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*AlertElement) Success ¶ added in v0.3.0
func (a *AlertElement) Success() *AlertElement
Success sets the AlertSuccess variant.
func (*AlertElement) Tooltip ¶ added in v0.3.0
func (a *AlertElement) Tooltip(s string) *AlertElement
Tooltip shows s below the alert after the pointer rests on it. Assistive technology reads it as the alert's description, when it has none.
func (*AlertElement) Variant ¶ added in v0.3.0
func (a *AlertElement) Variant(v AlertVariant) *AlertElement
Variant sets the kind: AlertInfo, AlertSuccess, AlertWarning or AlertDanger.
func (*AlertElement) Warning ¶ added in v0.3.0
func (a *AlertElement) Warning() *AlertElement
Warning sets the AlertWarning variant.
func (*AlertElement) Width ¶ added in v0.3.0
func (a *AlertElement) Width(l Length) *AlertElement
The sizing methods give the alert's outer box a size. See Sizing in docs/styling.md.
type AlertStyle ¶ added in v0.3.0
type AlertStyle struct {
Alert Style // the box: its shape, fill and border
Icon Style // the icon, in the color of its variant
Title Style // the title
Description Style // the text under the title
Close Style // the box around the close button
}
AlertStyle is the look of each part of an alert. A part's style merges over the built-in defaults of its variant, then over the theme's Alert, then over the theme's Alerts for that variant, then over the Styles of the instance; see docs/styling.md. Alert is the box, Icon the icon of its variant (its TextColor is the icon's color), Title and Description the two texts, and Close the box around the close button, which an alert has only when it has OnClose. A variant's colors are in its defaults, so an override of Alert or Icon sets the color for the variants it applies to.
type AlertVariant ¶ added in v0.3.0
type AlertVariant uint8
AlertVariant is the kind of an alert. It sets the icon and the color.
const ( // AlertInfo is an alert for information. It is the default. AlertInfo AlertVariant = iota // AlertSuccess is an alert for a completed action or a good state. AlertSuccess // AlertWarning is an alert for a situation that needs attention. AlertWarning // AlertDanger is an alert for an error or a dangerous state. AlertDanger )
type AlertVariants ¶ added in v0.3.0
type AlertVariants struct {
// Info, Success, Warning and Danger are the styles of the alert variants, and each merges over Alert.
Info, Success, Warning, Danger AlertStyle
}
AlertVariants holds the style of each variant of an alert, for the theme's Alerts. It merges over Theme.Alert, which applies to every variant.
type Alignment ¶
type Alignment uint8
Alignment is used for Align (cross axis), Justify (main axis) and text alignment. The zero value means unset.
const ( // Start aligns to the start edge of the axis. Start Alignment = iota + 1 // Center aligns to the middle of the axis. Center // End aligns to the end edge of the axis. End // Stretch fills the cross axis (Align only). It is the default for Align. Stretch // SpaceBetween, SpaceAround and SpaceEvenly apply to Justify only. SpaceBetween // SpaceAround spreads the children with equal space around each one. It applies to Justify only. SpaceAround // SpaceEvenly spreads the children with equal space between and around them. It applies to Justify only. SpaceEvenly // Baseline lines up the first lines of text of a row's children, so text of // two sizes sits on one line (Align and AlignSelf in a row only). A child with // no text sits with its bottom edge on the line. In a column or a grid it is // Start. Baseline )
type AnimateElement ¶
type AnimateElement struct {
// contains filtered or unexported fields
}
AnimateElement is the element made by Animate. It is an expander: it realizes the element fn returns for the current progress.
func Animate ¶
func Animate(key string, a Animation, fn func(t float32) Element) *AnimateElement
Animate re-renders fn every frame with eased progress t (0..1) until the animation ends (or forever with Repeat), so any property can be animated. It restarts when key changes. Layout properties (Width, Padding...) cost a re-layout each frame; Opacity/Offset/Scale are cheaper but fine here too.
ui.Animate("bar", ui.Animation{Duration: 600 * time.Millisecond, Easing: ease.OutCubic},
func(t float32) ui.Element {
return ui.Div().Width(ui.Percent(100 * t)).Height(ui.Px(6)).Background(accent)
})
func AnimateTimeline ¶ added in v0.4.0
func AnimateTimeline(key string, t Timeline, fn func(p []float32) Element) *AnimateElement
AnimateTimeline re-renders fn every frame with the progress of each step of t, as Animate does with one: p[i] is the eased progress (0..1) of the i-th Animation that t was built from, in the order they were given. It restarts when key changes, and stops asking for frames when t ends, after rendering fn once more with every step at 1; a repeating timeline loops.
tl := ui.Sequence(
ui.Animation{Duration: 200 * time.Millisecond},
ui.Animation{Duration: 300 * time.Millisecond, Easing: ease.Spring(0.3)},
)
ui.AnimateTimeline("intro", tl, func(p []float32) ui.Element {
return ui.Div().Opacity(p[0]).Width(ui.Px(100 + 100*p[1]))
})
type Animation ¶
type Animation struct {
// Duration is how long the animation runs.
Duration time.Duration
// Easing maps the linear progress of the animation to its eased progress, such as ease.OutCubic.
Easing func(t float32) float32
Repeat bool // Animate and Play: loop forever
// Delay is how long the animation waits before it starts. Meanwhile it
// shows its first frame (an entrance its Motion, keyframes their first
// stop) and asks for no frames: the window is woken when it is due. A
// delayed entrance is invisible when its Motion fades, but it can be hit.
Delay time.Duration
// Stagger, on an Enter, delays the elements that enter together, in one
// render, under one parent with the same Stagger: each starts Stagger after
// the one before it, in the order they were built, up to 16 Staggers. An
// element that enters later, as a row appended to a list, enters at once.
Stagger time.Duration
// OnDone runs once when the animation ends by itself: Delay plus Duration
// after it started, whether or not it is drawn then. It runs on the UI
// thread at the next frame, never while rendering. It does not run for an
// animation that is restarted (its key changed) or removed first, nor for
// a repeating one. An Exit's runs when the element has finished exiting,
// or at the next frame when it is removed without its exit (off screen, or
// with reduced motion). In a Timeline a step's OnDone runs when the step
// ends. With reduced motion it runs at the next frame.
OnDone func()
}
Animation configures timed motion. Easing maps progress 0..1; nil means ease-out (cubic). Use the functions in github.com/tyler-builds/jamb/ease or your own.
type AvatarElement ¶
type AvatarElement struct {
// contains filtered or unexported fields
}
AvatarElement is a circle that stands for a person: the initials of the name in a fill that the name picks, or an image cropped to the circle. It is an image named by the name, unless AccessHidden does.
func Avatar ¶
func Avatar(name string) *AvatarElement
Avatar creates an avatar of name, a circle of 32 logical pixels with the initials of the name (see Size). An empty name is named with the Avatar text of the window's Strings for assistive technology.
func (*AvatarElement) AccessHidden ¶
func (a *AvatarElement) AccessHidden() *AvatarElement
AccessHidden leaves the avatar out of the accessibility tree. Use it for an avatar that stands beside the name of the person it shows, since the name is read already.
func (*AvatarElement) Image ¶
func (a *AvatarElement) Image(src *ImageSource) *AvatarElement
Image shows src in the circle, cropped to it, in place of the initials.
func (*AvatarElement) Key ¶
func (a *AvatarElement) Key(k string) *AvatarElement
Key identifies the avatar among its siblings (see DivElement.Key).
func (*AvatarElement) Size ¶
func (a *AvatarElement) Size(px float32) *AvatarElement
Size sets the diameter, in logical pixels: 32 by default. The diameter and the initials grow with the Text size, as the text in a control does.
func (*AvatarElement) Styles ¶
func (a *AvatarElement) Styles(st AvatarStyle) *AvatarElement
Styles sets the look of the parts of the avatar, for this instance only. Set fields win over the theme's Avatar and the defaults; see AvatarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*AvatarElement) Tooltip ¶ added in v0.2.0
func (a *AvatarElement) Tooltip(s string) *AvatarElement
Tooltip shows s below the avatar after the pointer rests on it, such as the name of the person in full. Assistive technology reads it as the avatar's description, unless it is the avatar's name.
type AvatarStyle ¶
type AvatarStyle struct {
Avatar Style // the circle: its fill and border
Initials Style // the initials in the circle
}
AvatarStyle is the look of each part of an avatar. A part's style merges over the built-in defaults, then over the theme's Avatar, then over the Styles of the instance; see docs/styling.md. Avatar is the circle: its border, and its fill, which the name picks unless the style sets one. Initials is the text in the circle, drawn when the avatar has no image.
type BadgeElement ¶
type BadgeElement struct {
// contains filtered or unexported fields
}
BadgeElement is a small label: a count, a word such as "New", or a dot. A badge is drawn as a pill in its variant's color. High contrast draws it outlined, so the variant is also told by the text.
func Badge ¶
func Badge(count int) *BadgeElement
Badge creates a badge showing count. A count above the maximum (99 by default; see Max) shows as "99+". A count of zero shows nothing, so a badge can stay in place while its count is empty.
func BadgeDot ¶
func BadgeDot() *BadgeElement
BadgeDot creates a badge that is only a dot, for a thing that is new or changed without a count.
func BadgeText ¶
func BadgeText(text string) *BadgeElement
BadgeText creates a badge with a word in it, such as "New" or "Beta".
func (*BadgeElement) GridSpan ¶
func (b *BadgeElement) GridSpan(cols, rows int) *BadgeElement
GridSpan sets how many columns and rows the badge covers in its parent's grid.
func (*BadgeElement) Grow ¶
func (b *BadgeElement) Grow(f float32) *BadgeElement
Grow makes the badge take a share of the free space on its parent's main axis.
func (*BadgeElement) Key ¶
func (b *BadgeElement) Key(k string) *BadgeElement
Key identifies the badge among its siblings (see DivElement.Key).
func (*BadgeElement) Max ¶
func (b *BadgeElement) Max(n int) *BadgeElement
Max sets the count above which the badge shows "n+", such as "99+".
func (*BadgeElement) MaxWidth ¶
func (b *BadgeElement) MaxWidth(l Length) *BadgeElement
MaxWidth sets the largest width of the badge.
func (*BadgeElement) MinWidth ¶
func (b *BadgeElement) MinWidth(l Length) *BadgeElement
MinWidth sets the smallest width of the badge.
func (*BadgeElement) Noun ¶
func (b *BadgeElement) Noun(s string) *BadgeElement
Noun is the word that follows the count when the badge names its owner, as "items" makes a badge of 6 read "6 items". It is not drawn.
func (*BadgeElement) StatusDot ¶
func (b *BadgeElement) StatusDot() *BadgeElement
StatusDot puts a dot in front of the text, in the text color, as a status chip does. The dot is hidden from assistive technology: the text is what is read.
func (*BadgeElement) Styles ¶
func (b *BadgeElement) Styles(st BadgeStyle) *BadgeElement
Styles sets the look of the parts of the badge, for this instance only. Set fields win over the theme's Badge and Badges and the defaults; see BadgeStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*BadgeElement) Tooltip ¶ added in v0.6.0
func (b *BadgeElement) Tooltip(s string) *BadgeElement
Tooltip shows s in a small floating label below the badge after the pointer has rested on it for half a second, such as who verified a "Verified" badge. A badge that stands alone also gets s as its accessible description, so assistive technology reads it after the badge's text. An empty string means none.
func (*BadgeElement) Variant ¶
func (b *BadgeElement) Variant(v BadgeVariant) *BadgeElement
Variant sets the color: BadgeNeutral, BadgeAccent, BadgeSuccess, BadgeWarning or BadgeDanger.
func (*BadgeElement) Width ¶
func (b *BadgeElement) Width(l Length) *BadgeElement
The sizing methods give the badge's outer box a size. A badge is as wide as its text by default; see Sizing in docs/styling.md.
type BadgeStyle ¶
type BadgeStyle struct {
Badge Style // the pill: its shape, fill and border
Label Style // the text of the badge
Dot Style // the dot, before the text or alone
}
BadgeStyle is the look of each part of a badge. A part's style merges over the built-in defaults of its variant, then over the theme's Badge, then over the theme's Badges for that variant, then over the Styles of the instance; see docs/styling.md. Badge is the pill, Label its text and Dot the dot: the dot that a badge with StatusDot() shows before its text, or a badge that is only a dot (BadgeDot). A variant's colors are in its defaults, so an override of Badge or Dot sets the color for the variants it applies to.
type BadgeVariant ¶
type BadgeVariant uint8
BadgeVariant is the color of a badge.
const ( // BadgeNeutral is the default look, for text that needs no emphasis. BadgeNeutral BadgeVariant = iota // BadgeAccent is the accent look, for a count or a label that needs emphasis. BadgeAccent // BadgeSuccess is the look of a success or a good state. BadgeSuccess // BadgeWarning is the look of a warning. BadgeWarning // BadgeDanger is the look of an error or a dangerous state. BadgeDanger )
type BadgeVariants ¶
type BadgeVariants struct {
// Neutral, Accent, Success, Warning and Danger are the styles of the badge variants, and each merges over Badge.
Neutral, Accent, Success, Warning, Danger BadgeStyle
}
BadgeVariants holds the style of each variant of a badge, for the theme's Badges. It merges over Theme.Badge, which applies to every variant.
type Binding ¶
type Binding struct {
// contains filtered or unexported fields
}
Binding maps keys to an action. Create one with Bind or BindIn and pass it to Runtime.AddBindings or app.Window.Bindings.
func Bind ¶
Bind maps keys to a: the binding applies everywhere, after any contextual binding (BindIn) that matches, as the dispatch order in docs/input.md says. keys is strokes separated by spaces, each stroke modifiers and one key joined by "+", for example "ctrl+shift+p", "alt+up", "ctrl+k ctrl+t" or "f2". Modifiers are ctrl, shift, alt and super; keys are a-z, 0-9, f1-f12, enter, escape (or esc), backspace, delete, tab, space, left, right, up, down, home, end, pageup, pagedown, insert, and the punctuation keys = - / \ [ ] ; ' , . `. Bind panics on a malformed keys string.
The punctuation keys name the physical key as the US layout prints it, so "ctrl+shift+[" is the key that is [ on the US layout. With Shift held that key types {, and the binding still matches, since it is the same key position with Shift held.
func BindIn ¶
BindIn is Bind limited by a context expression, matched against the KeyContexts on the focus path. Expressions are GPUI's: a context name ("Editor"), key == value and key != value, ! (not), && and ||, > (a descendant: "Palette > Editor"), and parentheses. A binding whose expression matches at a deeper context runs before one that matches at a shallower context; global bindings run last. At the same depth, the binding added later runs first. So a binding for a field's own keys in a palette is BindIn("Palette > Editor", "up", ...), which beats the field's binding for Up. BindIn panics on a malformed expression.
func DefaultBindings ¶
func DefaultBindings() []Binding
DefaultBindings are the key bindings every runtime starts with: the keys of text fields, then the bindings registered with RegisterDefaultBindings. NewRuntime adds them first, so an app's binding at the same depth wins. In a palette, for example, BindIn("Palette > Editor", "up", ...) beats the field's own Up.
func ParseBinding ¶
ParseBinding is Bind and BindIn returning an error instead of panicking, for keys and expressions that come from outside the program, such as a keymap file. expr is a BindIn expression, or "" for a global binding. The error says what is wrong, without the call that produced it.
type BreadcrumbsElement ¶
type BreadcrumbsElement struct {
// contains filtered or unexported fields
}
BreadcrumbsElement is a trail of locations, from the outermost to the current one. A location with an OnClick is a link: it takes keyboard focus in the Tab order, and Enter and Space choose it, as a click does. The trail is a group named by its Label, and the current location is selected in it, so assistive technology reports which location is current. The separators are decorative and are hidden from assistive technology.
func Breadcrumbs ¶
func Breadcrumbs(items ...Crumb) *BreadcrumbsElement
Breadcrumbs creates a trail over items, shown left to right, with the last item as the current location.
func (*BreadcrumbsElement) GridSpan ¶
func (b *BreadcrumbsElement) GridSpan(cols, rows int) *BreadcrumbsElement
GridSpan sets how many columns and rows the breadcrumbs covers in its parent's grid.
func (*BreadcrumbsElement) Key ¶
func (b *BreadcrumbsElement) Key(k string) *BreadcrumbsElement
Key gives the trail a stable identity. With a key, its locations and its menu keep their identity too, so their focus survives a render.
func (*BreadcrumbsElement) Label ¶
func (b *BreadcrumbsElement) Label(name string) *BreadcrumbsElement
Label names the trail for assistive technology, such as "Folder path". It defaults to the Breadcrumb text of the window's Strings.
func (*BreadcrumbsElement) MaxItems ¶
func (b *BreadcrumbsElement) MaxItems(n int) *BreadcrumbsElement
MaxItems collapses a trail longer than n locations: the first location and the last n-1 are shown, with a "..." button between them. The button opens a menu of the hidden locations, and a hidden location is chosen in that menu. A value below 2 counts as 2. Zero, the default, shows every location.
func (*BreadcrumbsElement) MaxWidth ¶
func (b *BreadcrumbsElement) MaxWidth(l Length) *BreadcrumbsElement
MaxWidth sets the largest width of the breadcrumbs.
func (*BreadcrumbsElement) MinWidth ¶
func (b *BreadcrumbsElement) MinWidth(l Length) *BreadcrumbsElement
MinWidth sets the smallest width of the breadcrumbs.
func (*BreadcrumbsElement) Styles ¶
func (b *BreadcrumbsElement) Styles(s BreadcrumbsStyle) *BreadcrumbsElement
Styles sets the look of the parts of the trail, for this instance only. Set fields win over the theme's Breadcrumbs and the defaults; see BreadcrumbsStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*BreadcrumbsElement) Tooltip ¶ added in v0.2.0
func (b *BreadcrumbsElement) Tooltip(s string) *BreadcrumbsElement
Tooltip shows s below the trail after the pointer rests on it. Assistive technology reads it as the trail's description, unless it has another.
func (*BreadcrumbsElement) Width ¶
func (b *BreadcrumbsElement) Width(l Length) *BreadcrumbsElement
The sizing methods give the trail's outer box a size. A trail is as wide as its locations by default; see Sizing in docs/styling.md.
type BreadcrumbsStyle ¶
type BreadcrumbsStyle struct {
Bar Style // the row that holds the trail
Item Style // each location that can be chosen, and each plain location before the last
ItemHover Style // a location that can be chosen, while the pointer is over it
Current Style // the last location, the current one
Separator Style // the chevron between two locations
Overflow Style // the box around the "..." button of the hidden locations
}
BreadcrumbsStyle is the look of each part of a breadcrumb trail. A part's style merges over the built-in defaults, then over the theme's Breadcrumbs, then over the Styles of the instance; see docs/styling.md. Bar is the row that holds the trail, Item each location that can be chosen, and ItemHover the one the pointer is over. Current is the last location, Separator the chevron between two locations, and Overflow the box around the "..." button that lists the hidden locations (see MaxItems).
type ButtonElement ¶
type ButtonElement struct {
// contains filtered or unexported fields
}
ButtonElement is a themed, clickable button.
func Button ¶
func Button(label string) *ButtonElement
Button creates a button with a text label. The default variant is Primary.
func IconButton ¶
func IconButton(ic *icons.Icon) *ButtonElement
IconButton creates a square, label-less Ghost button.
func (*ButtonElement) AccessChecked ¶
func (b *ButtonElement) AccessChecked(on bool) *ButtonElement
AccessChecked makes the button a toggle button, such as a pin that is on or off. Assistive technology reports its state, and the button's click handler changes it. Give an icon-only toggle a Label that names what it toggles.
func (*ButtonElement) Danger ¶
func (b *ButtonElement) Danger() *ButtonElement
Danger sets the button's look to ButtonDanger.
func (*ButtonElement) Disabled ¶
func (b *ButtonElement) Disabled(d bool) *ButtonElement
Disabled sets whether the button is disabled, so that it cannot be pressed.
func (*ButtonElement) FocusHandle ¶
func (b *ButtonElement) FocusHandle(h *FocusHandle) *ButtonElement
FocusHandle lets code focus the button (see NewFocusHandle). A modal's Default button keeps the handle it was given.
func (*ButtonElement) Ghost ¶
func (b *ButtonElement) Ghost() *ButtonElement
Ghost sets the button's look to ButtonGhost.
func (*ButtonElement) GridSpan ¶
func (b *ButtonElement) GridSpan(cols, rows int) *ButtonElement
GridSpan sets how many columns and rows the button covers in its parent's grid.
func (*ButtonElement) Grow ¶
func (b *ButtonElement) Grow(f float32) *ButtonElement
Grow makes the button take a share of the free space on its parent's main axis.
func (*ButtonElement) Height ¶
func (b *ButtonElement) Height(l Length) *ButtonElement
Height sets the height of the button.
func (*ButtonElement) Icon ¶
func (b *ButtonElement) Icon(ic *icons.Icon) *ButtonElement
Icon sets an icon drawn before the button's label.
func (*ButtonElement) IconEnd ¶ added in v0.6.0
func (b *ButtonElement) IconEnd(ic *icons.Icon) *ButtonElement
IconEnd sets an icon drawn after the button's label, as in "See all →". It replaces an icon set with Icon. A loading button's ring takes its place.
func (*ButtonElement) Key ¶
func (b *ButtonElement) Key(k string) *ButtonElement
Key identifies the button among its siblings (see DivElement.Key).
func (*ButtonElement) Label ¶
func (b *ButtonElement) Label(s string) *ButtonElement
Label names the button for assistive technology. A button with text needs no label, since its text is its name; an icon-only button does.
func (*ButtonElement) Large ¶
func (b *ButtonElement) Large() *ButtonElement
Large makes the button larger: 40 px high with 16 px text, for prominent or touch-friendly actions. Small and Large replace each other.
func (*ButtonElement) Loading ¶ added in v0.4.0
func (b *ButtonElement) Loading(on bool) *ButtonElement
Loading shows a busy ring and makes the button inert: clicks, Enter, Space, UIA Invoke and a modal's Default do nothing. It keeps focus, its Tab stop and its width: the ring takes the icon's place, or sits over the label, which is hidden. Assistive technology hears the same name, with the status Strings.Loading and access.StateBusy (aria-busy through UI Automation's AriaProperties); announce the wait if it needs to be heard (see Announce). A uitest Click on it fails the test. Disabled(true) wins over Loading.
func (*ButtonElement) MaxHeight ¶
func (b *ButtonElement) MaxHeight(l Length) *ButtonElement
MaxHeight sets the largest height of the button.
func (*ButtonElement) MaxWidth ¶
func (b *ButtonElement) MaxWidth(l Length) *ButtonElement
MaxWidth sets the largest width of the button.
func (*ButtonElement) MinHeight ¶
func (b *ButtonElement) MinHeight(l Length) *ButtonElement
MinHeight sets the smallest height of the button.
func (*ButtonElement) MinWidth ¶
func (b *ButtonElement) MinWidth(l Length) *ButtonElement
MinWidth sets the smallest width of the button.
func (*ButtonElement) OnClick ¶
func (b *ButtonElement) OnClick(fn func()) *ButtonElement
OnClick sets the function that runs when the button is clicked.
func (*ButtonElement) Primary ¶
func (b *ButtonElement) Primary() *ButtonElement
Primary sets the button's look to ButtonPrimary.
func (*ButtonElement) Secondary ¶
func (b *ButtonElement) Secondary() *ButtonElement
Secondary sets the button's look to ButtonSecondary.
func (*ButtonElement) Small ¶
func (b *ButtonElement) Small() *ButtonElement
Small makes the button use the small control size.
func (*ButtonElement) Style ¶
func (b *ButtonElement) Style(s Style) *ButtonElement
Style sets the look of the button's Root part, for this instance only. It is the same as Styles(ButtonStyle{Root: s}); calling it again merges.
func (*ButtonElement) Styles ¶
func (b *ButtonElement) Styles(st ButtonStyle) *ButtonElement
Styles sets the look of the parts of the button, for this instance only. Set fields win over the theme's Button and Buttons and the defaults of the variant; see ButtonStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ButtonElement) Tooltip ¶
func (b *ButtonElement) Tooltip(s string) *ButtonElement
Tooltip shows s below the button after the pointer rests on it.
func (*ButtonElement) Variant ¶
func (b *ButtonElement) Variant(v ButtonVariant) *ButtonElement
Variant sets the button's look (see ButtonVariant).
func (*ButtonElement) Width ¶
func (b *ButtonElement) Width(l Length) *ButtonElement
The sizing methods give the button's outer box a size. A button is as wide as its label by default, and Width(Full) fills its container (see Sizing in docs/styling.md).
type ButtonStyle ¶
type ButtonStyle struct {
Root Style // the button: its size, shape, fill, border, font and text color
RootHover Style // the button while the pointer is over it, if enabled
RootPressed Style // the button while it is pressed
RootDisabled Style // the button when it is disabled
RootLoading Style // the button while it is loading
RootFocusVisible Style // the button while it has keyboard focus
Label Style // the text of the label
Icon Style // the icon
}
ButtonStyle is the look of each part of a button. A part's style merges over the built-in defaults of its variant, then over the theme's Button, then over the theme's Buttons for that variant, then over the Styles of the instance; see docs/styling.md. The states are parts of their own: RootHover while the pointer is over an enabled button, RootPressed while it is pressed, RootDisabled when it is disabled, RootLoading while it is loading (see ButtonElement.Loading), and RootFocusVisible while it has keyboard focus (its focus ring is added to the shadows of Root).
type ButtonVariant ¶
type ButtonVariant uint8
ButtonVariant selects a button's look.
const ( // ButtonPrimary is the look for the main action of a form or a dialog. ButtonPrimary ButtonVariant = iota // ButtonSecondary is the default look, for an action that is not the main one. ButtonSecondary // ButtonGhost is a button with no fill or border, for an action of low emphasis. ButtonGhost // ButtonDanger is the look for an action that deletes or cannot be undone. ButtonDanger )
type ButtonVariants ¶
type ButtonVariants struct {
// Primary is the style of a ButtonPrimary button.
Primary ButtonStyle
// Secondary is the style of a ButtonSecondary button.
Secondary ButtonStyle
// Ghost is the style of a ButtonGhost button.
Ghost ButtonStyle
// Danger is the style of a ButtonDanger button.
Danger ButtonStyle
}
ButtonVariants holds the style of each variant of a button, for the theme's Buttons. It merges over Theme.Button, which applies to every variant.
type CalendarElement ¶ added in v0.3.0
type CalendarElement struct {
// contains filtered or unexported fields
}
CalendarElement is a month of days on the page, for choosing a day, bound to a time.Time signal: the month grid of a DatePicker's calendar, without the field and the popup. Its day is the chosen day and its time of day is kept, as a DatePicker keeps it; a zero time is no date.
The calendar is a Tab stop. Its keys are those of a DatePicker's calendar (see docs/widgets-selection.md, Date and time): the arrows move by a day and a week, Home and End to the ends of the week, Page Up and Page Down by a month, with Shift by a year, and Enter or Space choose the day the keys have reached. Escape and Tab are left to the page. A click chooses a day, and the buttons of the header move by a month or a year. A day that is not between Min and Max, or that DisableDays rules out, cannot be chosen: it is disabled.
func Calendar ¶ added in v0.3.0
func Calendar(value *Signal[time.Time]) *CalendarElement
Calendar creates a calendar that reads and writes value. It shows the month of the chosen day, or of today when there is none. The week starts on the first day of the user's locale.
func (*CalendarElement) DisableDays ¶ added in v0.3.0
func (c *CalendarElement) DisableDays(fn func(day time.Time) bool) *CalendarElement
DisableDays rules out the days for which fn returns true, such as weekends. fn is called with each day at local midnight. A disabled day is drawn dimmed, is marked unavailable to assistive technology, and cannot be chosen.
func (*CalendarElement) Disabled ¶ added in v0.3.0
func (c *CalendarElement) Disabled(on bool) *CalendarElement
Disabled shows the calendar dimmed, with its day, and does not let it change.
func (*CalendarElement) FirstDay ¶ added in v0.3.0
func (c *CalendarElement) FirstDay(day time.Weekday) *CalendarElement
FirstDay sets the first day of the week. The default is the first day of the week of the user's locale.
func (*CalendarElement) FocusHandle ¶ added in v0.3.0
func (c *CalendarElement) FocusHandle(h *FocusHandle) *CalendarElement
FocusHandle lets code focus the calendar (see NewFocusHandle).
func (*CalendarElement) GridSpan ¶ added in v0.3.0
func (c *CalendarElement) GridSpan(cols, rows int) *CalendarElement
GridSpan sets how many columns and rows the calendar covers in its parent's grid.
func (*CalendarElement) Grow ¶ added in v0.3.0
func (c *CalendarElement) Grow(f float32) *CalendarElement
Grow makes the calendar take a share of the free space on its parent's main axis.
func (*CalendarElement) Height ¶ added in v0.3.0
func (c *CalendarElement) Height(l Length) *CalendarElement
Height sets the height of the calendar.
func (*CalendarElement) Key ¶ added in v0.3.0
func (c *CalendarElement) Key(k string) *CalendarElement
Key identifies the calendar among its siblings (see DivElement.Key).
func (*CalendarElement) Label ¶ added in v0.3.0
func (c *CalendarElement) Label(name string) *CalendarElement
Label names the calendar for assistive technology, such as "Due date". Without a label it is named by Strings.DateField.
func (*CalendarElement) LabelledBy ¶ added in v0.3.0
func (c *CalendarElement) LabelledBy(keys ...string) *CalendarElement
LabelledBy names the calendar by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*CalendarElement) Max ¶ added in v0.3.0
func (c *CalendarElement) Max(day time.Time) *CalendarElement
Max sets the latest day that can be chosen. Its time of day is ignored; a zero time means there is no latest day.
func (*CalendarElement) MaxHeight ¶ added in v0.3.0
func (c *CalendarElement) MaxHeight(l Length) *CalendarElement
MaxHeight sets the largest height of the calendar.
func (*CalendarElement) MaxWidth ¶ added in v0.3.0
func (c *CalendarElement) MaxWidth(l Length) *CalendarElement
MaxWidth sets the largest width of the calendar.
func (*CalendarElement) Min ¶ added in v0.3.0
func (c *CalendarElement) Min(day time.Time) *CalendarElement
Min sets the earliest day that can be chosen. Its time of day is ignored; a zero time means there is no earliest day.
func (*CalendarElement) MinHeight ¶ added in v0.3.0
func (c *CalendarElement) MinHeight(l Length) *CalendarElement
MinHeight sets the smallest height of the calendar.
func (*CalendarElement) MinWidth ¶ added in v0.3.0
func (c *CalendarElement) MinWidth(l Length) *CalendarElement
MinWidth sets the smallest width of the calendar.
func (*CalendarElement) OnChange ¶ added in v0.3.0
func (c *CalendarElement) OnChange(fn func(time.Time)) *CalendarElement
OnChange runs fn with the new value after the user chooses a day. The signal is set first. It does not run when the value is set from outside.
func (*CalendarElement) Styles ¶ added in v0.3.0
func (c *CalendarElement) Styles(st CalendarStyle) *CalendarElement
Styles sets the look of the parts of the calendar, for this instance only. Set fields win over the theme's Calendar and the defaults; see CalendarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*CalendarElement) Tooltip ¶ added in v0.3.0
func (c *CalendarElement) Tooltip(s string) *CalendarElement
Tooltip shows s below the calendar after the pointer rests on it. Assistive technology reads it as the calendar's description, unless it has another.
func (*CalendarElement) Width ¶ added in v0.3.0
func (c *CalendarElement) Width(l Length) *CalendarElement
The sizing methods give the calendar's panel a size. A calendar is as wide and as high as its days by default; see Sizing in docs/styling.md.
type CalendarRangeElement ¶ added in v0.3.0
type CalendarRangeElement struct {
// contains filtered or unexported fields
}
CalendarRangeElement is a month of days on the page, for choosing a range of days, bound to two time.Time signals: the start and the end, each at local midnight; a zero start is no range. It is the month grid of a DateRangePicker's calendar, without the field and the popup.
A range is chosen in two steps, as in a DateRangePicker: the first day chosen is the start, and the second is the end. If the end is before the start, the two are swapped. The signals change only when the end is chosen. While the end is being chosen, the days from the start to the day under the pointer, or under the keys, are shaded as the range would be, and Escape, or focus leaving the calendar, drops the start. The keys are those of a Calendar. A day that Min and Max, or DisableDays, rule out cannot be chosen as either end; a range may span such days.
func CalendarRange ¶ added in v0.3.0
func CalendarRange(from, to *Signal[time.Time]) *CalendarRangeElement
CalendarRange creates a calendar that reads and writes the start and the end of a range of days, from and to. It shows the month of the start, or of today when there is none.
func (*CalendarRangeElement) DisableDays ¶ added in v0.3.0
func (c *CalendarRangeElement) DisableDays(fn func(day time.Time) bool) *CalendarRangeElement
DisableDays rules out the days for which fn returns true, such as weekends. fn is called with each day at local midnight. A disabled day is drawn dimmed, is marked unavailable to assistive technology, and cannot be chosen as an end of the range.
func (*CalendarRangeElement) Disabled ¶ added in v0.3.0
func (c *CalendarRangeElement) Disabled(on bool) *CalendarRangeElement
Disabled shows the calendar dimmed, with its range, and does not let it change.
func (*CalendarRangeElement) FirstDay ¶ added in v0.3.0
func (c *CalendarRangeElement) FirstDay(day time.Weekday) *CalendarRangeElement
FirstDay sets the first day of the week. The default is the first day of the week of the user's locale.
func (*CalendarRangeElement) FocusHandle ¶ added in v0.3.0
func (c *CalendarRangeElement) FocusHandle(h *FocusHandle) *CalendarRangeElement
FocusHandle lets code focus the calendar (see NewFocusHandle).
func (*CalendarRangeElement) GridSpan ¶ added in v0.3.0
func (c *CalendarRangeElement) GridSpan(cols, rows int) *CalendarRangeElement
GridSpan sets how many columns and rows the calendar covers in its parent's grid.
func (*CalendarRangeElement) Grow ¶ added in v0.3.0
func (c *CalendarRangeElement) Grow(f float32) *CalendarRangeElement
Grow makes the calendar take a share of the free space on its parent's main axis.
func (*CalendarRangeElement) Height ¶ added in v0.3.0
func (c *CalendarRangeElement) Height(l Length) *CalendarRangeElement
Height sets the height of the calendar.
func (*CalendarRangeElement) Key ¶ added in v0.3.0
func (c *CalendarRangeElement) Key(k string) *CalendarRangeElement
Key identifies the calendar among its siblings (see DivElement.Key).
func (*CalendarRangeElement) Label ¶ added in v0.3.0
func (c *CalendarRangeElement) Label(name string) *CalendarRangeElement
Label names the calendar for assistive technology, such as "Trip dates". Without a label it is named by Strings.DateRangeField.
func (*CalendarRangeElement) LabelledBy ¶ added in v0.3.0
func (c *CalendarRangeElement) LabelledBy(keys ...string) *CalendarRangeElement
LabelledBy names the calendar by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*CalendarRangeElement) Max ¶ added in v0.3.0
func (c *CalendarRangeElement) Max(day time.Time) *CalendarRangeElement
Max sets the latest day that can be chosen. Its time of day is ignored; a zero time means there is no latest day.
func (*CalendarRangeElement) MaxHeight ¶ added in v0.3.0
func (c *CalendarRangeElement) MaxHeight(l Length) *CalendarRangeElement
MaxHeight sets the largest height of the calendar.
func (*CalendarRangeElement) MaxWidth ¶ added in v0.3.0
func (c *CalendarRangeElement) MaxWidth(l Length) *CalendarRangeElement
MaxWidth sets the largest width of the calendar.
func (*CalendarRangeElement) Min ¶ added in v0.3.0
func (c *CalendarRangeElement) Min(day time.Time) *CalendarRangeElement
Min sets the earliest day that can be chosen. Its time of day is ignored; a zero time means there is no earliest day.
func (*CalendarRangeElement) MinHeight ¶ added in v0.3.0
func (c *CalendarRangeElement) MinHeight(l Length) *CalendarRangeElement
MinHeight sets the smallest height of the calendar.
func (*CalendarRangeElement) MinWidth ¶ added in v0.3.0
func (c *CalendarRangeElement) MinWidth(l Length) *CalendarRangeElement
MinWidth sets the smallest width of the calendar.
func (*CalendarRangeElement) OnChange ¶ added in v0.3.0
func (c *CalendarRangeElement) OnChange(fn func(start, end time.Time)) *CalendarRangeElement
OnChange runs fn with the new start and end after the user chooses the end of a range. The signals are set first. It does not run when the range is set from outside.
func (*CalendarRangeElement) Styles ¶ added in v0.3.0
func (c *CalendarRangeElement) Styles(st CalendarStyle) *CalendarRangeElement
Styles sets the look of the parts of the calendar, for this instance only. Set fields win over the theme's Calendar and the defaults; see CalendarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*CalendarRangeElement) Tooltip ¶ added in v0.3.0
func (c *CalendarRangeElement) Tooltip(s string) *CalendarRangeElement
Tooltip shows s below the calendar after the pointer rests on it. Assistive technology reads it as the calendar's description, unless it has another.
func (*CalendarRangeElement) Width ¶ added in v0.3.0
func (c *CalendarRangeElement) Width(l Length) *CalendarRangeElement
The sizing methods give the calendar's panel a size. A calendar is as wide and as high as its days by default; see Sizing in docs/styling.md.
type CalendarStyle ¶ added in v0.3.0
type CalendarStyle struct {
// Root is the panel of the month.
Root Style
// RootDisabled is the panel when the calendar is disabled.
RootDisabled Style
// Header is the row with the month and the year.
Header Style
NavButton Style
// WeekdayLabel is the name of each day of the week.
WeekdayLabel Style
// Day is each day of the calendar.
Day Style
// DayHover is a day under the pointer.
DayHover Style
// DaySelected is the day that is chosen, or a day at either end of a range.
DaySelected Style
// DayInRange is a day between the ends of a range.
DayInRange Style
// DayToday is today.
DayToday Style
// DayDisabled is a day that cannot be chosen.
DayDisabled Style
// DayOutsideMonth is a day of the adjacent months.
DayOutsideMonth Style
// DayFocusVisible is the day that has keyboard focus.
DayFocusVisible Style
}
CalendarStyle is the look of each part of a Calendar and of a CalendarRange, a month of days on the page. A part's style merges over the built-in defaults, then over the theme's Calendar, then over the Styles of the instance; see docs/styling.md.
The parts are those of a DatePicker's calendar, with the same names and the same defaults: Root is the panel of the month (a DatePicker's Popup, without the shadow), Header the row with the month and the year, NavButton each of its navigation buttons, WeekdayLabel the name of each day of the week, and Day each day. The states of a day are DayHover, DaySelected (the chosen day, or an end of a range), DayInRange (a day between the ends, drawn as a band; a CalendarRange only), DayToday, DayDisabled (see Min, Max and DisableDays), DayOutsideMonth and DayFocusVisible, the day the keys have reached while the calendar has keyboard focus. RootDisabled is the panel of a calendar that is Disabled. Under high contrast the chosen day is drawn in the system Highlight colors, and today and the focused day by their borders, so that no state is shown by color alone.
type CardElement ¶ added in v0.6.0
type CardElement struct {
// contains filtered or unexported fields
}
CardElement is a surface that holds related content, such as one item of a grid of results. It lays its children out in a column by default (see Row, Gap and Padding). With OnClick the whole card is one control: it is a button to assistive technology, named by Label or by its text, takes keyboard focus, runs fn on Enter and Space, and shows hover and pressed states. Put no other control inside a clickable card, since a control inside a control cannot be reached on its own.
func Card ¶ added in v0.6.0
func Card() *CardElement
Card creates a filled card. A card is as wide as its container's column, or as its content in a row, as a Div is.
func (*CardElement) Align ¶ added in v0.6.0
func (c *CardElement) Align(a Alignment) *CardElement
Align sets how the children line up across the card's main axis.
func (*CardElement) Child ¶ added in v0.6.0
func (c *CardElement) Child(e Element) *CardElement
Child appends a child.
func (*CardElement) Children ¶ added in v0.6.0
func (c *CardElement) Children(es ...Element) *CardElement
Children appends several children.
func (*CardElement) Gap ¶ added in v0.6.0
func (c *CardElement) Gap(px float32) *CardElement
Gap sets the space between the children, 8 by default. Gap(0) removes it.
func (*CardElement) GridSpan ¶ added in v0.6.0
func (c *CardElement) GridSpan(cols, rows int) *CardElement
GridSpan sets how many columns and rows the card covers in its parent's grid.
func (*CardElement) Grow ¶ added in v0.6.0
func (c *CardElement) Grow(f float32) *CardElement
Grow makes the card take a share of the free space on its parent's main axis.
func (*CardElement) Key ¶ added in v0.6.0
func (c *CardElement) Key(k string) *CardElement
Key identifies the card among its siblings (see DivElement.Key).
func (*CardElement) Label ¶ added in v0.6.0
func (c *CardElement) Label(s string) *CardElement
Label names a clickable card for assistive technology, in place of the text it holds, such as "Firefox, web browser" for a card that shows more.
func (*CardElement) MaxWidth ¶ added in v0.6.0
func (c *CardElement) MaxWidth(l Length) *CardElement
MaxWidth sets the largest width of the card.
func (*CardElement) MinWidth ¶ added in v0.6.0
func (c *CardElement) MinWidth(l Length) *CardElement
MinWidth sets the smallest width of the card.
func (*CardElement) OnClick ¶ added in v0.6.0
func (c *CardElement) OnClick(fn func()) *CardElement
OnClick makes the whole card a button that runs fn (see CardElement).
func (*CardElement) Outlined ¶ added in v0.6.0
func (c *CardElement) Outlined() *CardElement
Outlined sets the look to CardOutlined.
func (*CardElement) Padding ¶ added in v0.6.0
func (c *CardElement) Padding(px float32) *CardElement
Padding sets the space inside the card on every side, 16 by default. Padding(0) removes it, as for a card that shows an image edge to edge.
func (*CardElement) Row ¶ added in v0.6.0
func (c *CardElement) Row() *CardElement
Row lays the children out in a row instead of a column.
func (*CardElement) Styles ¶ added in v0.6.0
func (c *CardElement) Styles(st CardStyle) *CardElement
Styles sets the look of the parts of the card, for this instance only. Set fields win over the theme's Card and Cards and the defaults; see CardStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*CardElement) Tooltip ¶ added in v0.6.0
func (c *CardElement) Tooltip(s string) *CardElement
Tooltip shows s below the card after the pointer rests on it. Assistive technology reads it as the card's description.
func (*CardElement) Variant ¶ added in v0.6.0
func (c *CardElement) Variant(v CardVariant) *CardElement
Variant sets the look: CardFilled (the default) or CardOutlined.
func (*CardElement) Width ¶ added in v0.6.0
func (c *CardElement) Width(l Length) *CardElement
The sizing methods give the card's outer box a size. See Sizing in docs/styling.md.
type CardStyle ¶ added in v0.6.0
type CardStyle struct {
Card Style // the card: its shape, fill, border and padding
CardHover Style // a clickable card the pointer is over
CardPressed Style // a clickable card while it is pressed
CardFocusVisible Style // a clickable card that has keyboard focus
}
CardStyle is the look of each part of a card. A part's style merges over the built-in defaults, then over the theme's Card, then over the theme's Cards for the card's variant, then over the Styles of the instance; see docs/styling.md. Card is the card itself; the states apply only to a card with OnClick: CardHover while the pointer is over it, CardPressed while it is pressed, and CardFocusVisible while it has keyboard focus.
type CardVariant ¶ added in v0.6.0
type CardVariant uint8
CardVariant is the look of a card: CardFilled, a raised surface with no border, or CardOutlined, a border with no fill.
const ( CardFilled CardVariant = iota // the Surface color, no border (the default) CardOutlined // a border in the Border color, no fill )
type CardVariants ¶ added in v0.6.0
type CardVariants struct {
// Filled and Outlined are the styles of the variants, and each merges over Card.
Filled, Outlined CardStyle
}
CardVariants is the look of each card variant, in Theme.Cards.
type CarouselElement ¶ added in v0.3.0
type CarouselElement struct {
// contains filtered or unexported fields
}
CarouselElement shows slides one at a time, bound to the index of the slide shown, from 0. Under the slides are a previous and a next button and a row of dots, one for each slide, that go to that slide. Without Loop the buttons are disabled at the first and the last slide; with it they wrap around. Left and Right go to the previous and the next slide while focus is on the buttons or the dots. A slide comes in with a short slide and fade, which reduced motion turns off.
Only the slide shown is built, as only a tab's selected panel is: a slide that keeps state of its own keeps it in signals outside the carousel.
For assistive technology the carousel is a group named by its label and described as a carousel (Strings.Carousel), as the WAI-ARIA carousel pattern describes. The slide shown is a group named by its position, such as "Slide 2 of 5" (Strings.SlideOf), and the other slides are not in the tree. Each dot is a button named "Go to slide 3" (Strings.GoToSlide), in a group of the dots in which the current one is selected. When the user changes the slide, its position is announced politely; AutoPlay changes it without an announcement.
With AutoPlay the controls start with a button that stops and starts it, as WCAG's Pause, Stop, Hide asks: a button named "Pause slides" while the slides move and "Play slides" while they are stopped (Strings.PauseSlides and Strings.PlaySlides). Its name says what it does, so it reports no pressed state as well, as the WAI-ARIA carousel pattern asks. It is the first of the controls in the Tab order, where that pattern places its rotation control.
func Carousel ¶ added in v0.3.0
func Carousel(index *Signal[int], slides ...Element) *CarouselElement
Carousel creates a carousel of slides that reads and writes index, the slide shown, from 0. An index out of range shows the nearest slide.
func (*CarouselElement) AutoPlay ¶ added in v0.3.0
func (c *CarouselElement) AutoPlay(d time.Duration) *CarouselElement
AutoPlay moves to the next slide every d, on the window's clock (see Context.After), and adds a button that stops and starts it. It waits while the pointer is over the carousel or focus is inside it, and stops at the last slide unless the carousel loops. While the user asks for reduced motion it starts stopped, and the button shows Play, so that the user can still start it. It does not run while the carousel is disabled.
func (*CarouselElement) Disabled ¶ added in v0.3.0
func (c *CarouselElement) Disabled(on bool) *CarouselElement
Disabled shows the carousel dimmed, with its slide, and does not let the slide change.
func (*CarouselElement) FocusHandle ¶ added in v0.3.0
func (c *CarouselElement) FocusHandle(h *FocusHandle) *CarouselElement
FocusHandle lets code focus the carousel: its focus goes to the dot of the slide shown (see NewFocusHandle).
func (*CarouselElement) GridSpan ¶ added in v0.3.0
func (c *CarouselElement) GridSpan(cols, rows int) *CarouselElement
GridSpan sets how many columns and rows the carousel covers in its parent's grid.
func (*CarouselElement) Grow ¶ added in v0.3.0
func (c *CarouselElement) Grow(f float32) *CarouselElement
Grow makes the carousel take a share of the free space on its parent's main axis.
func (*CarouselElement) Height ¶ added in v0.3.0
func (c *CarouselElement) Height(l Length) *CarouselElement
Height sets the height of the carousel.
func (*CarouselElement) Key ¶ added in v0.3.0
func (c *CarouselElement) Key(k string) *CarouselElement
Key identifies the carousel among its siblings (see DivElement.Key).
func (*CarouselElement) Label ¶ added in v0.3.0
func (c *CarouselElement) Label(name string) *CarouselElement
Label names the carousel for assistive technology, such as "Featured products". Without a label it is named by Strings.Carousel.
func (*CarouselElement) Loop ¶ added in v0.3.0
func (c *CarouselElement) Loop() *CarouselElement
Loop makes the previous and the next button, the keys and AutoPlay wrap around: after the last slide comes the first.
func (*CarouselElement) MaxHeight ¶ added in v0.3.0
func (c *CarouselElement) MaxHeight(l Length) *CarouselElement
MaxHeight sets the largest height of the carousel.
func (*CarouselElement) MaxWidth ¶ added in v0.3.0
func (c *CarouselElement) MaxWidth(l Length) *CarouselElement
MaxWidth sets the largest width of the carousel.
func (*CarouselElement) MinHeight ¶ added in v0.3.0
func (c *CarouselElement) MinHeight(l Length) *CarouselElement
MinHeight sets the smallest height of the carousel.
func (*CarouselElement) MinWidth ¶ added in v0.3.0
func (c *CarouselElement) MinWidth(l Length) *CarouselElement
MinWidth sets the smallest width of the carousel.
func (*CarouselElement) OnChange ¶ added in v0.3.0
func (c *CarouselElement) OnChange(fn func(int)) *CarouselElement
OnChange runs fn with the new index after the carousel changes the slide: by the buttons, the dots, the keys or AutoPlay. The signal is set first. It does not run when the index is set from outside.
func (*CarouselElement) Styles ¶ added in v0.3.0
func (c *CarouselElement) Styles(st CarouselStyle) *CarouselElement
Styles sets the look of the parts of the carousel, for this instance only. Set fields win over the theme's Carousel and the defaults; see CarouselStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*CarouselElement) Tooltip ¶ added in v0.3.0
func (c *CarouselElement) Tooltip(s string) *CarouselElement
Tooltip shows s below the carousel after the pointer rests on it. Assistive technology reads it as the carousel's description, in place of Strings.Carousel.
func (*CarouselElement) Width ¶ added in v0.3.0
func (c *CarouselElement) Width(l Length) *CarouselElement
The sizing methods give the carousel a size. A carousel fills the width of a column, and is as high as its slide and its controls by default; with a Height, the viewport takes the room the controls leave. See Sizing in docs/styling.md.
type CarouselStyle ¶ added in v0.3.0
type CarouselStyle struct {
Root Style // the carousel: a column of the viewport and the controls
RootDisabled Style // the carousel when it is disabled
Viewport Style // the box that shows the current slide, and clips it
Slide Style // the box around the slide shown
Controls Style // the row of the buttons and the dots
PlayPause Style // the box around the button that stops and starts AutoPlay
Dots Style // the row of dots
Dot Style // each dot: a button that goes to its slide
DotCurrent Style // the dot of the slide shown
DotHover Style // a dot under the pointer
DotFocusVisible Style // the dot that has keyboard focus
DotDisabled Style // each dot when the carousel is disabled
}
CarouselStyle is the look of each part of a carousel. A part's style merges over the built-in defaults, then over the theme's Carousel, then over the Styles of the instance; see docs/styling.md. Root is the whole carousel, a column of the viewport and the controls. Viewport is the box that shows the current slide and clips it while it comes in, and Slide the box around the slide. Controls is the row under the viewport, NavButton the box around each of the previous and next buttons, PlayPause the box around the button that stops and starts AutoPlay (all three are IconButtons, styled by the theme's Button), and Dots the row of dots. Each Dot is a button that goes to its slide: DotCurrent is the dot of the slide shown, drawn wider so that it is not told by its color alone, DotHover a dot under the pointer, DotFocusVisible a dot with keyboard focus, and DotDisabled and RootDisabled the dots and the carousel when it is disabled.
type CellKey ¶ added in v0.4.0
type CellKey struct {
// Row is the key of the cell's row.
Row string
// Column is the key of the cell's column.
Column string
}
CellKey names a cell of a DataGrid: the key of its row and the key of its column.
type CheckState ¶
type CheckState uint8
CheckState is the state of a check box. CheckMixed is the indeterminate state: some of the items a box stands for are checked and some are not, as in a "select all" box.
const ( // CheckOff is an unchecked box. CheckOff CheckState = iota // CheckOn is a checked box. CheckOn // CheckMixed is a box with a dash, for a mixed state. CheckMixed )
type CheckboxElement ¶
type CheckboxElement struct {
// contains filtered or unexported fields
}
CheckboxElement is a check box with a text label. Space, a click on the box or on its label, changes it. Enter does not change it: it goes on to the modal's default button or the form, as on Windows.
func Checkbox ¶
func Checkbox(label string, checked *Signal[bool]) *CheckboxElement
Checkbox creates a check box that is on while checked is true.
func CheckboxTri ¶
func CheckboxTri(label string, state *Signal[CheckState]) *CheckboxElement
CheckboxTri creates a check box that shows state, including CheckMixed. It is the parent of a group of items that are only some of them checked. Read the state with Peek, to know whether the group is all, some or none.
func (*CheckboxElement) Disabled ¶
func (c *CheckboxElement) Disabled(d bool) *CheckboxElement
Disabled shows the box but does not let it change.
func (*CheckboxElement) FocusHandle ¶
func (c *CheckboxElement) FocusHandle(h *FocusHandle) *CheckboxElement
FocusHandle lets code focus the check box (see NewFocusHandle). A Field that wraps the check box gives it its own handle, which takes precedence.
func (*CheckboxElement) GridSpan ¶
func (c *CheckboxElement) GridSpan(cols, rows int) *CheckboxElement
GridSpan sets how many columns and rows the checkbox covers in its parent's grid.
func (*CheckboxElement) Grow ¶
func (c *CheckboxElement) Grow(f float32) *CheckboxElement
Grow makes the checkbox take a share of the free space on its parent's main axis.
func (*CheckboxElement) Height ¶
func (c *CheckboxElement) Height(l Length) *CheckboxElement
Height sets the height of the checkbox.
func (*CheckboxElement) Key ¶
func (c *CheckboxElement) Key(k string) *CheckboxElement
Key identifies the checkbox among its siblings (see DivElement.Key).
func (*CheckboxElement) MaxHeight ¶
func (c *CheckboxElement) MaxHeight(l Length) *CheckboxElement
MaxHeight sets the largest height of the checkbox.
func (*CheckboxElement) MaxWidth ¶
func (c *CheckboxElement) MaxWidth(l Length) *CheckboxElement
MaxWidth sets the largest width of the checkbox.
func (*CheckboxElement) MinHeight ¶
func (c *CheckboxElement) MinHeight(l Length) *CheckboxElement
MinHeight sets the smallest height of the checkbox.
func (*CheckboxElement) MinWidth ¶
func (c *CheckboxElement) MinWidth(l Length) *CheckboxElement
MinWidth sets the smallest width of the checkbox.
func (*CheckboxElement) OnChange ¶
func (c *CheckboxElement) OnChange(fn func(checked bool)) *CheckboxElement
OnChange runs fn with the box's new state after the user checks or clears it, by a click, the Space key or assistive technology. The signal is set first. A click on a CheckboxTri sets it on or off, never mixed, so fn gets true for on.
func (*CheckboxElement) Styles ¶
func (c *CheckboxElement) Styles(st CheckboxStyle) *CheckboxElement
Styles sets the look of the parts of the check box, for this instance only. Set fields win over the theme's Checkbox and the defaults; see CheckboxStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*CheckboxElement) Tooltip ¶
func (c *CheckboxElement) Tooltip(s string) *CheckboxElement
Tooltip shows s below the check box after the pointer rests on it. Assistive technology reads it as the check box's description, unless it has another.
func (*CheckboxElement) Validate ¶
func (c *CheckboxElement) Validate(rules ...Validator[bool]) *CheckboxElement
Validate sets the validators of the checked value. Required[bool] makes the box "must accept": it is an error while the box is off (see Field). A mixed or tri-state box (CheckboxTri) has no validators.
func (*CheckboxElement) Width ¶
func (c *CheckboxElement) Width(l Length) *CheckboxElement
The sizing methods give the check box's control, its box and label, a size. It is as wide as its label by default; see Sizing in docs/styling.md.
type CheckboxStyle ¶
type CheckboxStyle struct {
Control Style // the row: the focus element, with the box and the label
ControlFocusVisible Style // the row while it has keyboard focus
ControlDisabled Style // the row when it is disabled
Box Style // the box: its size, shape, border and fill
BoxHover Style // the box while the pointer is over it, if enabled
BoxChecked Style // the box when it is on
BoxMixed Style // the box when it is mixed
BoxDisabled Style // the box when it is disabled
BoxInvalid Style // the box when the check's value is not valid (see Field)
Mark Style // the check mark of an on box
Dash Style // the line of a mixed box
Label Style // the text beside the box
LabelDisabled Style // the text when the box is disabled
}
CheckboxStyle is the look of each part of a check box. A part's style merges over the built-in defaults, then over the theme's Checkbox, then over the Styles of the instance; see docs/styling.md. Control is the row that takes focus and holds the box and the label. The box is drawn in the state of the check: BoxChecked for an on box, BoxMixed for a mixed one, and BoxDisabled when the box cannot change. Mark is the check mark of an on box and Dash the line of a mixed one; the mark's color is its TextColor. The states are parts of their own: BoxHover while the pointer is over an enabled box, ControlFocusVisible while the control has keyboard focus, and ControlDisabled and LabelDisabled when the box cannot change.
type ClearSet ¶
type ClearSet uint16
ClearSet names the fields that a style removes with its Clear field. Each constant clears the fields listed beside it, before the rest of the style is applied, so a clear and a value for the same field give the value.
const ( ClearBackground ClearSet = 1 << iota // Background and Gradient: no fill ClearTextColor // TextColor: text and icons inherit the color above ClearBorder // BorderWidth, BorderEdges and BorderColor: no border ClearRadius // Radius and Corners: square corners ClearShadows // Shadows: no shadow, and no focus ring of this style ClearPadding // Padding: no padding ClearMargin // Margin: no margin ClearGap // Gap: no space between children )
type CodeEditorColors ¶
type CodeEditorColors struct {
// Background is the background of the editor.
Background Color
// Foreground is the color of the text that has no syntax color.
Foreground Color
// ActiveLine is the background of the line that holds the caret.
ActiveLine Color
// LineNumber is the color of the line numbers.
LineNumber Color
// ActiveLineNumber is the color of the line number of the caret's line.
ActiveLineNumber Color
// Selection is the background of the selected text.
Selection Color
}
CodeEditorColors are the colors of a code editor, as the predefined themes set them from their editor colors. Selection is translucent, so it is drawn over the text.
type CollapsibleElement ¶
type CollapsibleElement struct {
// contains filtered or unexported fields
}
CollapsibleElement is a section with a header row, which opens and closes the content under it. The header is a button: Space and Enter open and close it, as a click does, and its chevron points right when closed and down when open. The content is not built while the section is closed.
The header's accessible name is the title. The header carries the Expanded state, so assistive technology can open and close it; the content is a group named by the header. Microsoft's guidance is that an expander's header is what a user activates and that its content is the region it shows (https://learn.microsoft.com/en-us/windows/apps/develop/ui/controls/expander).
func Collapsible ¶
func Collapsible(title string, open *Signal[bool], content Element) *CollapsibleElement
Collapsible creates a section titled title, whose content shows while open is true. The content is shown below the header when the section is open.
func (*CollapsibleElement) Disabled ¶
func (c *CollapsibleElement) Disabled(d bool) *CollapsibleElement
Disabled shows the section but does not let it open or close.
func (*CollapsibleElement) GridSpan ¶
func (c *CollapsibleElement) GridSpan(cols, rows int) *CollapsibleElement
GridSpan sets how many columns and rows the collapsible covers in its parent's grid.
func (*CollapsibleElement) Grow ¶
func (c *CollapsibleElement) Grow(f float32) *CollapsibleElement
Grow makes the collapsible take a share of the free space on its parent's main axis.
func (*CollapsibleElement) KeepMounted ¶
func (c *CollapsibleElement) KeepMounted() *CollapsibleElement
KeepMounted keeps the content once the section has been opened. The content is built the first time the section opens, as it is by default, and then stays in the tree while the section is closed, hidden with Display. Its state survives closing and opening the section. Without KeepMounted the content is discarded when the section closes.
func (*CollapsibleElement) Key ¶
func (c *CollapsibleElement) Key(k string) *CollapsibleElement
Key gives the section a stable identity. It also names the header, which the content is labelled by, so give two sections with the same title different keys.
func (*CollapsibleElement) MaxWidth ¶
func (c *CollapsibleElement) MaxWidth(l Length) *CollapsibleElement
MaxWidth sets the largest width of the collapsible.
func (*CollapsibleElement) MinWidth ¶
func (c *CollapsibleElement) MinWidth(l Length) *CollapsibleElement
MinWidth sets the smallest width of the collapsible.
func (*CollapsibleElement) OnChange ¶
func (c *CollapsibleElement) OnChange(fn func(open bool)) *CollapsibleElement
OnChange runs fn with the new state after the user opens or closes the section. The signal is set first.
func (*CollapsibleElement) RenderHeader ¶
func (c *CollapsibleElement) RenderHeader(fn func(title string, state PartState) Element) *CollapsibleElement
RenderHeader replaces the title in the header with what fn returns. The chevron stays, so the open state is still shown, and the header keeps its behavior, focus and accessible name, which is still the title. fn is called again when the header's pointer or focus state changes, with the state in the PartState (Selected means the section is open). The content is hidden from assistive technology.
ui.Collapsible("Sync", open, body).RenderHeader(func(title string, s ui.PartState) ui.Element {
return ui.Div().Row().Gap(8).Child(ui.Text(title)).Child(ui.Badge(3))
})
func (*CollapsibleElement) Styles ¶
func (c *CollapsibleElement) Styles(st CollapsibleStyle) *CollapsibleElement
Styles sets the look of the parts of the section, for this instance only. Set fields win over the theme's Collapsible and the defaults; see CollapsibleStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*CollapsibleElement) Width ¶
func (c *CollapsibleElement) Width(l Length) *CollapsibleElement
The sizing methods give the section's outer box a width. A section fills its container by default; see Sizing in docs/styling.md.
type CollapsibleStyle ¶
type CollapsibleStyle struct {
Section Style // the frame around the header and the content
Header Style // the header row, which opens and closes the section
HeaderHover Style // the header while the pointer is over an enabled one
HeaderOpen Style // the header while the section is open
HeaderFocusVisible Style // the header while it has keyboard focus
HeaderDisabled Style // the header when the section is disabled
Chevron Style // the arrow at the start of the header
Content Style // the area under the header, while the section is open
}
CollapsibleStyle is the look of each part of a collapsible section. A part's style merges over the built-in defaults, then over the theme's Collapsible, then over the Styles of the instance; see docs/styling.md. Section is the frame around the header and the content. Header is the row that opens and closes the section, Chevron its arrow, and Content the area under it. The states are parts of their own: HeaderOpen while the section is open, HeaderHover while the pointer is over an enabled header, HeaderFocusVisible while the header has keyboard focus, and HeaderDisabled when the section cannot be opened or closed.
type Color ¶
type Color struct {
// R is the red channel, from 0 to 1.
R float32
// G is the green channel, from 0 to 1.
G float32
// B is the blue channel, from 0 to 1.
B float32
// A is the alpha channel, from 0 (transparent) to 1 (opaque).
A float32
}
Color is a straight-alpha sRGB color with components in [0,1]. The zero value is transparent and, inside a Style, means "unset". R, G, B and A are the red, green, blue and alpha channels, from 0 to 1.
func AvatarColor ¶ added in v0.4.0
AvatarColor returns the fill that Avatar uses for name. A hash of the name picks it from a fixed palette, so a name keeps its color from one render to the next, and an app can use the same color for the same person elsewhere.
func Hex ¶
Hex parses "#rgb", "#rrggbb" or "#rrggbbaa" (the '#' is optional). It panics with an explanation on malformed input, because colors are almost always literals and a typo should fail loudly at startup.
type ColorPickerElement ¶
type ColorPickerElement struct {
// contains filtered or unexported fields
}
ColorPickerElement is a button that shows a color and opens a panel to change it. The panel holds a saturation and brightness area, a hue slider, an opacity slider when Alpha is set, a hex text field and the preset swatches of Swatches. It opens and closes as a Popover does: a click, Enter or Space on the trigger toggles it, and Escape or a click outside closes it, with focus back on the trigger. The area takes focus when the panel opens. Its arrow keys move the saturation (Left and Right) and the brightness (Up and Down) by 1 percent, and by 10 percent with Shift; the arrows and Page Up and Page Down move the hue.
The value is a Color. Its hue, saturation and value are kept while the user changes them, so a grey color keeps the hue the user chose. A value set from outside is read again as its hue, saturation and value.
func ColorPicker ¶
func ColorPicker(value *Signal[Color]) *ColorPickerElement
ColorPicker creates a color picker that reads and writes value. The trigger shows the color and its hex text, such as "#3B82F6".
func (*ColorPickerElement) Alpha ¶
func (c *ColorPickerElement) Alpha() *ColorPickerElement
Alpha adds an opacity slider to the panel, and makes the hex text eight digits long, #RRGGBBAA. Without it the alpha of the color is kept as it is.
func (*ColorPickerElement) Disabled ¶ added in v0.2.0
func (c *ColorPickerElement) Disabled(on bool) *ColorPickerElement
Disabled shows the trigger, with its color, and does not let the panel open.
func (*ColorPickerElement) FocusHandle ¶ added in v0.2.0
func (c *ColorPickerElement) FocusHandle(h *FocusHandle) *ColorPickerElement
FocusHandle lets code focus the trigger (see NewFocusHandle).
func (*ColorPickerElement) GridSpan ¶
func (c *ColorPickerElement) GridSpan(cols, rows int) *ColorPickerElement
GridSpan sets how many columns and rows the color picker covers in its parent's grid.
func (*ColorPickerElement) Grow ¶
func (c *ColorPickerElement) Grow(f float32) *ColorPickerElement
Grow makes the color picker take a share of the free space on its parent's main axis.
func (*ColorPickerElement) Key ¶
func (c *ColorPickerElement) Key(k string) *ColorPickerElement
Key identifies the color picker among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*ColorPickerElement) Label ¶
func (c *ColorPickerElement) Label(name string) *ColorPickerElement
Label names the trigger for assistive technology. It defaults to "Color".
func (*ColorPickerElement) LabelledBy ¶ added in v0.2.0
func (c *ColorPickerElement) LabelledBy(keys ...string) *ColorPickerElement
LabelledBy names the trigger by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*ColorPickerElement) Large ¶
func (c *ColorPickerElement) Large() *ColorPickerElement
Large makes the trigger larger: 40 px high with 16 px text, like a large text field. Small and Large replace each other.
func (*ColorPickerElement) MaxWidth ¶
func (c *ColorPickerElement) MaxWidth(l Length) *ColorPickerElement
MaxWidth sets the largest width of the color picker.
func (*ColorPickerElement) MinWidth ¶
func (c *ColorPickerElement) MinWidth(l Length) *ColorPickerElement
MinWidth sets the smallest width of the color picker.
func (*ColorPickerElement) OnChange ¶
func (c *ColorPickerElement) OnChange(fn func(Color)) *ColorPickerElement
OnChange runs fn with the new color when the user changes it. It does not run when the value is set from outside. The signal is set first.
func (*ColorPickerElement) Small ¶
func (c *ColorPickerElement) Small() *ColorPickerElement
Small makes the trigger compact: 28 px high with smaller text, like a small text field. Small and Large replace each other.
func (*ColorPickerElement) Styles ¶
func (c *ColorPickerElement) Styles(st ColorPickerStyle) *ColorPickerElement
Styles sets the look of the parts of the color picker, for this instance only. Set fields win over the theme's ColorPicker and the defaults; see ColorPickerStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ColorPickerElement) Swatches ¶
func (c *ColorPickerElement) Swatches(colors ...Color) *ColorPickerElement
Swatches sets the preset colors of the panel. Each is a button named by its hex value, and choosing one sets the value to it.
func (*ColorPickerElement) Tooltip ¶ added in v0.2.0
func (c *ColorPickerElement) Tooltip(s string) *ColorPickerElement
Tooltip shows s below the trigger after the pointer rests on it. Assistive technology reads it as the trigger's description, after the hex text.
func (*ColorPickerElement) Width ¶
func (c *ColorPickerElement) Width(l Length) *ColorPickerElement
The sizing methods give the trigger's outer box a size, as they do for the other widgets. See Sizing in docs/styling.md.
type ColorPickerStyle ¶
type ColorPickerStyle struct {
Trigger Style // the button that shows the color
TriggerHover Style // the trigger while the pointer is over it
TriggerFocusVisible Style // the trigger while it has keyboard focus
TriggerDisabled Style // the trigger of a disabled picker
Swatch Style // the box in the trigger, drawn in the color
Popup Style // the panel
Area Style // the saturation and brightness area
AreaFocusVisible Style // the area while it has keyboard focus
Thumb Style // the knob at the color in the area
Slider SliderStyle // the hue and opacity sliders
Preset Style // each preset swatch
PresetFocusVisible Style // a preset swatch while it has keyboard focus
}
ColorPickerStyle is the look of each part of a color picker. A part's style merges over the built-in defaults, then over the theme's ColorPicker, then over the Styles of the instance; see docs/styling.md.
Trigger is the button that shows the color: a frame like a text field's, with TriggerHover while the pointer is over it and TriggerFocusVisible while it has keyboard focus. Swatch is the box in the trigger that is drawn in the color; the color is its content, so only its other fields apply. Popup is the panel, Area the saturation and brightness area and AreaFocusVisible the area while it has focus. TriggerDisabled is the trigger of a disabled picker. Thumb is the knob at the color in the area: a fixed circle, drawn in the color with its border and shadow. Slider is the hue and opacity sliders, whose parts are those of a Slider (see SliderStyle). Preset is each swatch of Swatches, and PresetFocusVisible a swatch while it has keyboard focus.
type ColorStop ¶
type ColorStop struct {
// At is the position of the stop, from 0 to 1 along the gradient.
At float32
// Color is the color at the stop.
Color Color
}
ColorStop is a color at At (0 to 1) along a gradient.
type ColumnPin ¶ added in v0.4.0
type ColumnPin uint8
ColumnPin keeps a column of a DataGrid in view as the columns scroll sideways: PinStart keeps it at the start of the grid and PinEnd at the end. The pinned columns are shown before and after the others, in their order.
type ColumnState ¶ added in v0.4.0
type ColumnState struct {
// Order is the keys of the columns, in the order they are shown.
Order []string
// Widths is the width of each column the user has resized, by key.
Widths map[string]float32
}
ColumnState is the layout of the columns of a DataGrid that the user can change: the keys of the columns in the order they are shown, and the widths the user has set, by key, in logical pixels at the Text size setting 100 percent. Save it to restore the columns with ColumnOrder and ColumnWidths.
type ComboboxElement ¶
type ComboboxElement[T comparable] struct { // contains filtered or unexported fields }
ComboboxElement is an editable text field with a list of suggestions below it. As the user types, the suggestions for the text are found and the list opens; the highlighted suggestion is the one the keys have reached, and focus stays in the text (see docs/widgets-selection.md, Combobox). The text is the signal the field reads and writes.
The suggestions come from a function of the query (see Combobox), or from a function that runs in the background (see SuggestAsync), whose results are discarded when a newer query has started.
func Combobox ¶
func Combobox[T comparable](text *Signal[string], suggest func(query string) []Option[T]) *ComboboxElement[T]
Combobox creates an editable text field that reads and writes text, with the suggestions that suggest returns for the text the user has typed. suggest runs on the UI thread at each change of the text, unless Debounce or SuggestAsync says otherwise. A nil suggest is allowed with SuggestAsync.
Free text is allowed by default. AllowFree(false) makes the field choose only from its suggestions (see AllowFree).
func (*ComboboxElement[T]) AllowFree ¶
func (c *ComboboxElement[T]) AllowFree(on bool) *ComboboxElement[T]
AllowFree sets whether the text may be something other than a suggestion. With free text (the default), the text is kept as the user leaves it, and OnPick runs only when a suggestion is chosen. With AllowFree(false), the field chooses only from its suggestions: when it loses focus, a text that is not the label of the option last chosen (or of a suggestion that matches it exactly, ignoring case) is reverted to that option's label, or cleared when no option was chosen. The reverted text is what a Validate rule and a Form see, so Required makes an unchosen field an error.
func (*ComboboxElement[T]) Debounce ¶
func (c *ComboboxElement[T]) Debounce(d time.Duration) *ComboboxElement[T]
Debounce waits for the user to stop typing for d before it asks for suggestions, for a suggest function that is expensive. Zero (the default) asks at once. Keys that need the suggestions ask at once too.
func (*ComboboxElement[T]) Disabled ¶
func (c *ComboboxElement[T]) Disabled(d bool) *ComboboxElement[T]
Disabled shows the field, with its text, and does not let it change.
func (*ComboboxElement[T]) EmptyText ¶
func (c *ComboboxElement[T]) EmptyText(s string) *ComboboxElement[T]
EmptyText sets the text of the slot shown when there are no suggestions, such as "No matching projects". The default is "No results".
func (*ComboboxElement[T]) ErrorText ¶
func (c *ComboboxElement[T]) ErrorText(s string) *ComboboxElement[T]
ErrorText sets the text of the row shown when an async suggest function fails, such as "Could not reach the server". The default is "Couldn't load suggestions". The text is announced politely. The field stays usable: its text is free, and editing it asks again.
func (*ComboboxElement[T]) FocusHandle ¶
func (c *ComboboxElement[T]) FocusHandle(h *FocusHandle) *ComboboxElement[T]
FocusHandle lets code focus the text (see NewFocusHandle).
func (*ComboboxElement[T]) GridSpan ¶
func (c *ComboboxElement[T]) GridSpan(cols, rows int) *ComboboxElement[T]
GridSpan sets how many columns and rows the combobox covers in its parent's grid.
func (*ComboboxElement[T]) Grow ¶
func (c *ComboboxElement[T]) Grow(f float32) *ComboboxElement[T]
Grow makes the combobox take a share of the free space on its parent's main axis.
func (*ComboboxElement[T]) Height ¶
func (c *ComboboxElement[T]) Height(l Length) *ComboboxElement[T]
Height sets the height of the combobox.
func (*ComboboxElement[T]) Icon ¶
func (c *ComboboxElement[T]) Icon(ic *icons.Icon) *ComboboxElement[T]
Icon puts ic at the start of the field, as TextInput.Icon does.
func (*ComboboxElement[T]) Key ¶
func (c *ComboboxElement[T]) Key(k string) *ComboboxElement[T]
Key identifies the combobox among its siblings (see DivElement.Key).
func (*ComboboxElement[T]) Label ¶
func (c *ComboboxElement[T]) Label(name string) *ComboboxElement[T]
Label names the field for assistive technology, such as "City". The placeholder is not used as the name.
func (*ComboboxElement[T]) LabelledBy ¶
func (c *ComboboxElement[T]) LabelledBy(keys ...string) *ComboboxElement[T]
LabelledBy names the field by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*ComboboxElement[T]) Large ¶
func (c *ComboboxElement[T]) Large() *ComboboxElement[T]
Large makes the field larger: 40 px high with 16 px text, like Button.Large and TextInput.Large, for touch-friendly or prominent forms. Small and Large replace each other.
func (*ComboboxElement[T]) MaxHeight ¶
func (c *ComboboxElement[T]) MaxHeight(l Length) *ComboboxElement[T]
MaxHeight sets the largest height of the combobox.
func (*ComboboxElement[T]) MaxVisible ¶
func (c *ComboboxElement[T]) MaxVisible(n int) *ComboboxElement[T]
MaxVisible sets how many rows the list shows at once (8 by default): the list is at most that many rows high and scrolls to the rest. Every suggestion is in the list and in the accessibility tree; the rows are not virtualized, so a suggest function should still narrow its results to a few dozen. The keys scroll the highlighted row into view.
func (*ComboboxElement[T]) MaxWidth ¶
func (c *ComboboxElement[T]) MaxWidth(l Length) *ComboboxElement[T]
MaxWidth sets the largest width of the combobox.
func (*ComboboxElement[T]) MinChars ¶
func (c *ComboboxElement[T]) MinChars(n int) *ComboboxElement[T]
MinChars is the number of characters the text needs before the field suggests anything. The list is closed until then. The default is 0.
func (*ComboboxElement[T]) MinHeight ¶
func (c *ComboboxElement[T]) MinHeight(l Length) *ComboboxElement[T]
MinHeight sets the smallest height of the combobox.
func (*ComboboxElement[T]) MinWidth ¶
func (c *ComboboxElement[T]) MinWidth(l Length) *ComboboxElement[T]
MinWidth sets the smallest width of the combobox.
func (*ComboboxElement[T]) OnChange ¶
func (c *ComboboxElement[T]) OnChange(fn func(string)) *ComboboxElement[T]
OnChange runs fn with the text after each change the user makes to it, as TextInput's OnChange does. It does not run for a suggestion that is chosen, which sets the text.
func (*ComboboxElement[T]) OnPick ¶
func (c *ComboboxElement[T]) OnPick(fn func(T)) *ComboboxElement[T]
OnPick runs fn with the value of the suggestion that the user chose, by a click or by Enter. The text is set to the suggestion's label first.
func (*ComboboxElement[T]) Placeholder ¶
func (c *ComboboxElement[T]) Placeholder(s string) *ComboboxElement[T]
Placeholder is the text shown while the field is empty.
func (*ComboboxElement[T]) RenderOption ¶
func (c *ComboboxElement[T]) RenderOption(fn func(opt Option[T], state PartState) Element) *ComboboxElement[T]
RenderOption replaces the label of each suggestion with what fn returns, as Select.RenderOption does. The state's Focused means the suggestion is highlighted. The content is hidden from assistive technology, which reads the label.
func (*ComboboxElement[T]) Small ¶
func (c *ComboboxElement[T]) Small() *ComboboxElement[T]
Small makes the field compact: 28 px high with smaller text, like Button.Small and TextInput.Small, for toolbars and dense forms.
func (*ComboboxElement[T]) Styles ¶
func (c *ComboboxElement[T]) Styles(st ComboboxStyle) *ComboboxElement[T]
Styles sets the look of the parts of the combobox, for this instance only. Set fields win over the theme's Combobox and the defaults; see ComboboxStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ComboboxElement[T]) SuggestAsync ¶
func (c *ComboboxElement[T]) SuggestAsync(fn func(ctx context.Context, query string) ([]Option[T], error)) *ComboboxElement[T]
SuggestAsync finds the suggestions in the background, instead of with the suggest function of Combobox. fn runs on its own goroutine with a context that is canceled when a newer query starts, and it must return promptly once that happens. Its results are shown only if they are for the latest query; the others are dropped. An error shows the error row (see ErrorText). The list shows a ProgressRing while fn runs.
func (*ComboboxElement[T]) Tooltip ¶
func (c *ComboboxElement[T]) Tooltip(s string) *ComboboxElement[T]
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*ComboboxElement[T]) Validate ¶
func (c *ComboboxElement[T]) Validate(rules ...Validator[string]) *ComboboxElement[T]
Validate sets the validators of the text: the field shows the first error of them once the user has changed the text and left the field, and on submit when it is in a Form (see Field and Validator). An empty text passes MinLength and Pattern, so pair those with Required when the field must be filled in.
func (*ComboboxElement[T]) Width ¶
func (c *ComboboxElement[T]) Width(l Length) *ComboboxElement[T]
The sizing methods give the field a size. The field is textFieldWidth wide at the Text size of 100 percent by default; Width(Full) fills its container. The list is at least as wide as the field. See Sizing in docs/styling.md.
type ComboboxStyle ¶
type ComboboxStyle struct {
// Field is the text frame of the combo box.
Field FieldStyle
// Popup is the panel that holds the list of options.
Popup Style
// Option is the style of each option in the list.
Option Style
// OptionHighlighted is the style of the option that the keyboard or the pointer is on.
OptionHighlighted Style
// OptionDisabled is the style of an option that cannot be chosen.
OptionDisabled Style
// Match is the style of the part of an option that matches the typed text.
Match Style
// Empty is the style of the message shown when no option matches.
Empty Style
// Loading is the style of the message shown while the suggestions load.
Loading Style
// Error is the style of the message shown when the suggestions cannot be loaded.
Error Style
}
ComboboxStyle is the look of each part of a combobox. A part's style merges over the built-in defaults, then over the theme's Combobox, then over the Styles of the instance; see docs/styling.md. Field is the text frame of the editor, a FieldStyle (see TextInput) with the same parts and states. Popup is the open list, Option each suggestion, OptionHighlighted the suggestion that the keys have reached, and OptionDisabled a suggestion that cannot be chosen. Match is the style of the text that matches the query in a suggestion's label (see HighlightMatches); under high contrast it is underlined instead of colored. Empty is the "No results" slot, and Loading the row with the ProgressRing while suggestions are being found. Error is the row that says the suggestions could not be found (see ErrorText), and the message under the field that says what was reverted or cleared (see AllowFree); both have the look of a field's error message.
type Command ¶ added in v0.6.2
type Command struct {
// contains filtered or unexported fields
}
Command is an operation of the app that a coding agent or a script calls with arguments and gets a result from, through the control channel (`jamb ctl run`, see docs/tools.md). Its input and output are Go types, and the channel describes them to the caller with JSON Schemas made from those types.
An action (see NewAction) is what a user runs from a key, a menu or the command palette, on the focused element; it takes nothing and returns nothing. A command is app-wide, takes typed input and returns typed output. The control channel offers both: an agent runs the app's actions as a user would, and its commands where clicking through the UI would be slow or ambiguous.
func CommandNamed ¶ added in v0.6.2
CommandNamed returns the command with the name, or nil.
func Commands ¶ added in v0.6.2
func Commands() []*Command
Commands returns the registered commands, sorted by name.
func NewCommand ¶ added in v0.6.2
NewCommand registers a command. name identifies it, as an action's does (for example "notes.create"); description tells an agent what it does. run is called on the UI thread with the decoded input, and its output is encoded as JSON. In and Out are any types that encoding/json reads and writes: structs with json tags describe best, and a field's `desc` tag becomes its description in the schema. A field without omitempty is required.
type CreateIn struct {
Title string `json:"title" desc:"The note's title"`
Tags []string `json:"tags,omitempty"`
}
var CreateNote = ui.NewCommand("notes.create", "Create a note and select it",
func(in CreateIn) (NoteRef, error) { ... })
Create commands once, as package variables, as actions are. A second command with the same name panics.
func (*Command) Description ¶ added in v0.6.2
Description returns what the command does.
func (*Command) InputSchema ¶ added in v0.6.2
InputSchema returns the JSON Schema (draft 2020-12) of the command's input.
func (*Command) OutputSchema ¶ added in v0.6.2
OutputSchema returns the JSON Schema (draft 2020-12) of the command's output.
type CommandError ¶ added in v0.6.2
type CommandError struct{ Err error }
CommandError is an input that the command could not decode, which RunJSON returns so that a caller can tell it from a failure of the command itself.
func (*CommandError) Error ¶ added in v0.6.2
func (e *CommandError) Error() string
func (*CommandError) Unwrap ¶ added in v0.6.2
func (e *CommandError) Unwrap() error
type CommandPaletteElement ¶ added in v0.3.0
type CommandPaletteElement struct {
// contains filtered or unexported fields
}
CommandPaletteElement is a floating panel that lists commands to run: a search field, and below it the commands whose names match what is typed, each with its key binding. It is open while its signal is true. Place it last in the window's root element, which must fill the window, as a Modal is placed; its panel floats near the top of the window, centered.
open := ui.NewSignal(false)
ui.Div().OnAction(showPalette, func() { open.Set(true) }).
Child(page).
Child(ui.CommandPalette(open))
When it opens it lists the commands available where focus was, and the field takes focus. Up and Down move the highlight, PageUp and PageDown move it a list's height, Enter runs the highlighted command and a click runs the one clicked. The command runs where focus was before the palette opened, so a command that acts on the focused element acts on that element, and focus goes back there. Escape closes the palette and gives focus back too; a click outside closes it and leaves focus where the click put it.
func CommandPalette ¶ added in v0.3.0
func CommandPalette(open *Signal[bool]) *CommandPaletteElement
CommandPalette creates a command palette that is open while open is true. It sets open to false when it closes itself: after it runs a command, on Escape, and on a click outside it.
func (*CommandPaletteElement) Commands ¶ added in v0.3.0
func (p *CommandPaletteElement) Commands(fn func() []*Action) *CommandPaletteElement
Commands sets the function that gives the commands to list. It runs each time the palette opens, before the field takes focus. By default the palette lists the actions available where focus is (see Context.AvailableActions). Hidden actions are left out either way. A command runs where focus was when the palette opened, so one that no element there handles does nothing.
func (*CommandPaletteElement) Items ¶ added in v0.4.0
func (p *CommandPaletteElement) Items(fn func(query string) []PaletteItem) *CommandPaletteElement
Items sets the function that gives the items to list before the matching commands, for the query typed. It runs each time the query changes. The palette keeps the items whose label, detail or keywords contain every word of the query, ignoring case and in any order, so fn may return all its items or filter them itself, which is cheaper for a long list. Every item kept is built as a row, so fn should keep the list short. A query that starts with ">" in an ItemsOnly palette lists only commands, and fn is not called then.
func (*CommandPaletteElement) ItemsOnly ¶ added in v0.4.0
func (p *CommandPaletteElement) ItemsOnly() *CommandPaletteElement
ItemsOnly hides the commands, so the palette is a quick open of the items, as VS Code's Ctrl+P is. Typing ">" first switches to the commands, which are matched against the rest of the query, as VS Code's palette does. Set a Placeholder that names what the palette opens.
func (*CommandPaletteElement) Key ¶ added in v0.3.0
func (p *CommandPaletteElement) Key(k string) *CommandPaletteElement
Key identifies the palette among its siblings (see DivElement.Key).
func (*CommandPaletteElement) MaxRows ¶ added in v0.3.0
func (p *CommandPaletteElement) MaxRows(n int) *CommandPaletteElement
MaxRows sets how many commands the list shows at once (8 by default): the list is at most that many rows high and scrolls to the rest. PageUp and PageDown move the highlight by that many rows.
func (*CommandPaletteElement) Placeholder ¶ added in v0.3.0
func (p *CommandPaletteElement) Placeholder(s string) *CommandPaletteElement
Placeholder sets the text shown while the field is empty. The default is the window's Strings.CommandPalettePlaceholder, "Type a command".
func (*CommandPaletteElement) Styles ¶ added in v0.3.0
func (p *CommandPaletteElement) Styles(st CommandPaletteStyle) *CommandPaletteElement
Styles sets the look of the parts of the palette, for this instance only. Set fields win over the theme's CommandPalette and the defaults; see CommandPaletteStyle and docs/styling.md. Calling Styles again merges with the earlier values.
type CommandPaletteStyle ¶ added in v0.3.0
type CommandPaletteStyle struct {
// Panel is the floating panel that holds the field and the list.
Panel Style
// Input is the box around the search field.
Input Style
// List is the list of commands, which scrolls past MaxRows rows.
List Style
// Item is the style of each command's row.
Item Style
// ItemHighlighted is the style of the row that the keyboard or the pointer is on.
ItemHighlighted Style
// Label is the style of a command's name.
Label Style
// Match is the style of the part of a name that matches the typed text.
Match Style
// Keys is the style of a command's key binding, such as "Ctrl+N".
Keys Style
// Detail is the style of the detail text of a PaletteItem, such as a commit's author.
Detail Style
// Empty is the style of the message shown when nothing matches.
Empty Style
}
CommandPaletteStyle is the look of each part of a command palette. A part's style merges over the built-in defaults, then over the theme's CommandPalette, then over the Styles of the instance; see docs/styling.md. Panel is the floating panel, 520 px wide by default; Input holds the search field; List is the list of commands; Item is each row's style and ItemHighlighted the row that the keys or the pointer are on. Label is a row's name, Match the text of it that matches the query (see HighlightMatches; under high contrast it is underlined instead of colored), and Keys a command's key binding. Detail is the detail text of a PaletteItem. Empty is the message shown when nothing matches.
type ComponentElement ¶
type ComponentElement struct {
// contains filtered or unexported fields
}
ComponentElement is a re-render boundary. Its function runs when the component first appears, when a signal it read changes, or when its parent re-renders. Otherwise its previous output — and the realized, laid-out nodes built from it — are kept as they are.
func Component ¶
func Component(fn func(ctx *Context) Element) *ComponentElement
Component wraps a render function as a re-render boundary:
ui.Component(func(ctx *ui.Context) ui.Element {
return ui.Textf("Count: %d", counter.Get())
})
When counter changes only this function re-runs, only its subtree is rebuilt, and layout is recomputed only where sizes actually changed.
func TimeAgo ¶ added in v0.4.0
func TimeAgo(t time.Time) *ComponentElement
TimeAgo shows how far t is from now, as FormatRelative does, on the window's clock (see Context.After), and renders again as time passes: every minute under an hour, every hour under a day, and daily after that. Its tooltip and accessible description are the full date and time of t. While it is off screen it keeps no timer: it starts again the next time it renders, so a parent that renders it again brings it up to date.
func (*ComponentElement) Key ¶
func (c *ComponentElement) Key(k string) *ComponentElement
Key gives the component a stable identity among its siblings.
type Composite ¶
type Composite struct {
// contains filtered or unexported fields
}
Composite makes a type from another package an element. Embed it in the type, and implement Renderer: the type's Render builds it, as a Component's function does. The element keeps its state, and re-renders when the signals its Render reads change. SetKey gives it an identity among its siblings (see DivElement.Key).
type Gauge struct {
ui.Composite
value float64
}
func (g *Gauge) Render(ctx *ui.Context) ui.Element { return ui.Text(fmt.Sprint(g.value)) }
ui.Div().Child(&Gauge{value: 0.4})
type Composition ¶
type Composition struct {
// Text is the text of the composition.
Text string
// Cursor is the byte offset of the caret in Text.
Cursor int
// ClauseStart and ClauseEnd are the byte range of the clause that is being converted.
ClauseStart, ClauseEnd int
}
Composition is the text an input method is composing: Text, with the input method's caret at byte Cursor in it, and the clause being converted from byte ClauseStart to ClauseEnd. The clause is empty when there is none.
type Computed ¶
type Computed[T any] struct { // contains filtered or unexported fields }
Computed is a value derived from signals: the result of a function that reads them. It remembers the result, and computes it again only when it is read after one of the signals it read has changed. Reading it with Get inside a component's render subscribes the component, as a Signal does, so the component re-renders when the value may have changed.
Create a Computed once, like a signal (a package variable, a field of the app's store, or ui.Local), not in every render: it stays subscribed to the signals it reads.
total := ui.NewComputed(func() int {
sum := 0
for _, item := range cart.Get() {
sum += item.Price
}
return sum
})
ui.Textf("Total: %d", total.Get())
Read a Computed on the UI thread: in a render, an event handler or a function passed to Post. Recording which signals the function reads uses the same process-wide tracker as rendering, so a computation on another goroutine could take a rendering component's reads. Off the UI thread, read the signals themselves.
func NewComputed ¶
NewComputed creates a Computed whose value is fn's result. fn runs the first time the value is read, and again after a signal it read changes; it should only read signals and compute, with no other effects.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is passed to render functions. It gives access to the theme and window and lets components schedule their own re-render.
func (*Context) After ¶ added in v0.3.0
After runs fn on the UI thread once d has passed, at the first frame at or after that time, and wakes the window for it. It returns a function that cancels fn if it has not run yet. Call both on the UI thread, such as in a render or a handler.
The time is the window's clock, the one that animations and tooltips use, so a headless test moves it with uitest's Advance. Use After to debounce work that follows typing:
cancel := func() {}
ui.TextInput(query).OnChange(func(string) {
cancel() // a search that was waiting waits again
cancel = ctx.After(150*time.Millisecond, search)
})
fn still runs if the component goes away first; cancel it in OnDispose when it must not.
func (*Context) AppTheme ¶
AppTheme returns the theme the app set with SetTheme, which under high contrast is not the active theme (see Theme).
func (*Context) AvailableActions ¶
AvailableActions lists the actions on the focus path; see Runtime.AvailableActions.
func (*Context) Clipboard ¶
Clipboard returns the clipboard's plain text, with LF line endings, and false when it holds none. Text fields use the same clipboard. Plain text and images are supported (see ClipboardImage); HTML is not yet. Headless runtimes keep a clipboard of their own.
func (*Context) ClipboardHasImage ¶
ClipboardHasImage reports whether the clipboard holds an image, without reading it, which can take a while for a large one. It is cheap enough to call in a render, such as to enable a Paste image menu item; the result is not reactive, so it is read again on the next render.
func (*Context) ClipboardImage ¶
ClipboardImage returns the image on the clipboard, such as a screenshot or an image copied from a browser, and false when it holds none. Show it with ImageFromImage, or save it with image/png. Copied images keep their transparency when the program that copied them kept it.
func (*Context) CommitComposition ¶
func (c *Context) CommitComposition()
CommitComposition types what an input method is composing in the focused element. An element that handles a click or a key itself calls it before its change, so the composition is typed first (see IME.Commit). It does nothing when nothing is composed.
func (*Context) DismissToast ¶ added in v0.4.0
DismissToast removes the toast with the ID, as its close button does, and moves the focus on if it was in the toast. It does nothing when no such toast is shown.
func (*Context) FocusedHandle ¶
func (c *Context) FocusedHandle() *FocusHandle
FocusedHandle returns a handle to what has keyboard focus now; see Runtime.FocusedHandle.
func (*Context) HighContrast ¶
HighContrast reports whether Windows high contrast is on, and the theme is then the high contrast one (see HighContrastTheme). Use it to pick solid colors for content that does not take its colors from the theme.
func (*Context) Invalidate ¶
func (c *Context) Invalidate()
Invalidate re-renders the current component on the next frame.
func (*Context) KeyboardFocus ¶
KeyboardFocus reports whether the element produced by this render has focus and focus is keyboard-driven, the case in which FocusVisible styles show. Custom elements draw their focus ring with it. The component re-renders when it changes.
func (*Context) KeysFor ¶
KeysFor returns the display text of a's most recent binding; see Runtime.KeysFor.
func (*Context) OnDispose ¶
func (c *Context) OnDispose(fn func())
OnDispose registers fn to run when the component is removed from the tree, such as to close a file or stop a worker it started. Callbacks run in the order they were registered, each once, before the component's children are disposed. The registration lasts as long as the component does, not as long as one render: a call in every render adds a callback in every render. Guard the call so that it happens once, such as with a flag kept in Local.
func (*Context) OpenURL ¶
OpenURL opens url with the system: an http or https URL in the default browser, a mailto URL in the mail app. Other schemes, file paths included, are refused with an error, because opening them could run a program; a URL built from text the app does not control stays safe. A headless runtime opens nothing and returns nil.
func (*Context) Post ¶
func (c *Context) Post(fn func())
Post runs fn on the UI thread at the start of the next frame (see Runtime.Post). It is safe to call from a goroutine that holds the Context, so background work can hand its results back to the window.
func (*Context) ReducedMotion ¶
ReducedMotion reports whether the user asked for less motion. Animations that the app runs itself should then jump to their end (see Animate).
func (*Context) SetClipboard ¶
SetClipboard replaces the clipboard's contents with plain text (see Clipboard).
func (*Context) SetClipboardImage ¶
SetClipboardImage replaces the clipboard's contents with img, which other programs can paste, with its transparency where they support it.
func (*Context) Strings ¶
Strings returns the text the built-in controls show and announce, as set with Runtime.SetStrings or app.Window.Strings. Read it while rendering, and let a closure that runs later use the value it captured.
func (*Context) SystemDark ¶
SystemDark reports whether the system's app mode is dark. A window that follows the system (see app.Window) already uses its dark theme then; use it for content that does not take its colors from the theme.
func (*Context) TextScale ¶
TextScale returns the Text size setting in percent, from 100 to 225. Text sizes are scaled by it already; use it for sizes the app computes itself.
func (*Context) Toast ¶
func (c *Context) Toast(v ToastVariant, text string) *Toast
Toast shows a notification with text in the window's Toaster. It is announced to assistive technology: politely for info and success, assertively for warning and error. It does not take focus, so typing carries on where it was. Without a Toaster in the window it is not shown. Call it from a click or another handler on the UI thread, or from a goroutine through Post.
func (*Context) ToastWithID ¶ added in v0.4.0
func (c *Context) ToastWithID(id string, v ToastVariant, text string) *Toast
ToastWithID shows a toast with the ID, or, when a toast with the ID is already shown, replaces that toast in place: its text, variant, title, action, time and styles are set again from the returned Toast, and it keeps its place in the stack and its focus and hover. An update does not announce the text again when it is the same, and the same kind of toast is announced at most every two seconds. The ID is unique in the window, and it is not shown in the toast. Without an ID (the empty string) it is a new toast, as Toast makes.
func (*Context) Window ¶
Window returns the window the component is shown in. Its Maximized and Focused methods are reactive: the component re-renders when they change. Without an app window (headless tests) the actions do nothing.
func (*Context) WindowSize ¶
WindowSize returns the window size in logical pixels.
type CopyButtonElement ¶ added in v0.4.0
type CopyButtonElement struct {
// contains filtered or unexported fields
}
CopyButtonElement is a button that copies text to the clipboard. It is an icon button by default, with a copy icon that turns into a check after a copy, and it is a text button when it has a Label. Its confirmation shows for 1.5 seconds and is announced to assistive technology politely.
func CopyButton ¶ added in v0.4.0
func CopyButton(text string) *CopyButtonElement
CopyButton creates a button that copies text to the clipboard. It is a Ghost icon button by default: a copy icon, which becomes a check for 1.5 seconds after a copy. Its accessible name is Strings.Copy. Use Value to compute the text at the click, and Label for a text button.
func (*CopyButtonElement) Copied ¶ added in v0.4.0
func (c *CopyButtonElement) Copied(s string) *CopyButtonElement
Copied sets the confirmation text: the label of the button after a copy, and the text announced and shown in a toast. It defaults to Strings.Copied.
func (*CopyButtonElement) Danger ¶ added in v0.4.0
func (c *CopyButtonElement) Danger() *CopyButtonElement
Danger sets the button's look to ButtonDanger.
func (*CopyButtonElement) Disabled ¶ added in v0.4.0
func (c *CopyButtonElement) Disabled(d bool) *CopyButtonElement
Disabled sets whether the button is disabled, so that it cannot copy (see Button.Disabled).
func (*CopyButtonElement) Ghost ¶ added in v0.4.0
func (c *CopyButtonElement) Ghost() *CopyButtonElement
Ghost sets the button's look to ButtonGhost, its default.
func (*CopyButtonElement) Height ¶ added in v0.4.0
func (c *CopyButtonElement) Height(l Length) *CopyButtonElement
Height sets the height of the button (see Button.Height).
func (*CopyButtonElement) Key ¶ added in v0.4.0
func (c *CopyButtonElement) Key(k string) *CopyButtonElement
Key identifies the button among its siblings (see DivElement.Key).
func (*CopyButtonElement) Label ¶ added in v0.4.0
func (c *CopyButtonElement) Label(s string) *CopyButtonElement
Label makes a text button, labeled s. After a copy its label reads the confirmation (see Copied). Without a label the button is an icon button.
func (*CopyButtonElement) Large ¶ added in v0.4.0
func (c *CopyButtonElement) Large() *CopyButtonElement
Large makes the button larger (see Button.Large).
func (*CopyButtonElement) OnCopy ¶ added in v0.4.0
func (c *CopyButtonElement) OnCopy(fn func(string)) *CopyButtonElement
OnCopy sets the function that runs after a copy, with the text copied.
func (*CopyButtonElement) Primary ¶ added in v0.4.0
func (c *CopyButtonElement) Primary() *CopyButtonElement
Primary sets the button's look to ButtonPrimary.
func (*CopyButtonElement) Secondary ¶ added in v0.4.0
func (c *CopyButtonElement) Secondary() *CopyButtonElement
Secondary sets the button's look to ButtonSecondary.
func (*CopyButtonElement) Small ¶ added in v0.4.0
func (c *CopyButtonElement) Small() *CopyButtonElement
Small makes the button use the small control size (see Button.Small).
func (*CopyButtonElement) Style ¶ added in v0.4.0
func (c *CopyButtonElement) Style(s Style) *CopyButtonElement
Style sets the look of the button's Root part, for this instance only (see Button.Style).
func (*CopyButtonElement) Styles ¶ added in v0.4.0
func (c *CopyButtonElement) Styles(st ButtonStyle) *CopyButtonElement
Styles sets the look of the parts of the button, for this instance only (see Button.Styles).
func (*CopyButtonElement) Toast ¶ added in v0.4.0
func (c *CopyButtonElement) Toast(on bool) *CopyButtonElement
Toast sets whether a copy also shows a success toast in the window's Toaster (see Context.Toast). It is off by default: the button's own confirmation is enough for most copies, and the toast is announced in the same way.
func (*CopyButtonElement) Tooltip ¶ added in v0.4.0
func (c *CopyButtonElement) Tooltip(s string) *CopyButtonElement
Tooltip shows s below the button after the pointer rests on it (see Button.Tooltip).
func (*CopyButtonElement) Value ¶ added in v0.4.0
func (c *CopyButtonElement) Value(fn func() string) *CopyButtonElement
Value computes the text to copy at the click, instead of the text given to CopyButton. The function runs on the UI thread.
func (*CopyButtonElement) Variant ¶ added in v0.4.0
func (c *CopyButtonElement) Variant(v ButtonVariant) *CopyButtonElement
Variant sets the button's look (see ButtonVariant). The default is Ghost.
func (*CopyButtonElement) Width ¶ added in v0.4.0
func (c *CopyButtonElement) Width(l Length) *CopyButtonElement
Width sets the width of the button (see Button.Width).
type Corners ¶
type Corners struct {
// TopLeft is the radius of the top left corner, in logical pixels.
TopLeft float32
// TopRight is the radius of the top right corner, in logical pixels.
TopRight float32
// BottomRight is the radius of the bottom right corner, in logical pixels.
BottomRight float32
// BottomLeft is the radius of the bottom left corner, in logical pixels.
BottomLeft float32
}
Corners holds per-corner radii.
type Crumb ¶
type Crumb struct {
// Label is the text of the crumb.
Label string
// Icon is an icon shown before the label.
Icon *icons.Icon
// OnClick runs when the crumb is clicked.
OnClick func()
}
Crumb is one location of a Breadcrumbs: its label, an optional icon and the function that runs when the location is chosen. A location without OnClick is plain text. The last location is the current one, and it is plain text whatever its OnClick is.
type DataColumn ¶
type DataColumn[T any] struct { // Header is the text of the header, which is the column's name for // assistive technology. Header string // Key identifies the column in a SortState and in the widths the user sets. // It is Header when empty, so it must be unique among the columns. Key string // Text is the text of each cell. It is also the cell's accessible name. Text func(row T) string // Cell replaces the text of each cell with what it returns (a render slot). // The content is hidden from assistive technology, so give Text as well. The // content fills the height of its row, so a canvas sized with Full is as tall as // the row. CellStyle sets the look of this column's cells. Cell func(row T) Element // CellStyle is merged over the Cell part for the cells of this column, after the // grid's style, so one column can differ: a graph column clears its padding with // Clear: ClearPadding. Under high contrast it is plain (see plainStyle). CellStyle Style // RenderHeader replaces the text of the header with what it returns, for // sighted users. The state's Selected is set while the column is sorted. RenderHeader func(label string, s PartState) Element // Compare orders two rows as strings.Compare does, for sorting. Nil means the // column cannot be sorted. A sort is stable: rows that compare equal keep // their order. Compare func(a, b T) int // Width is the width of the column in logical pixels. Zero means 120. Width float32 // MinWidth is the narrowest the user can resize the column to, and MaxWidth // the widest (zero means no limit). A zero MinWidth means 40. MinWidth, MaxWidth float32 // Grow is the share of the grid's spare width that the column takes when the // columns are narrower than the grid. Zero means the column keeps its width. Grow float32 // Resizable lets the user resize the column, by the edge of its header and // with Ctrl+Left and Ctrl+Right on its header (see DataGrid). Resizable bool // Movable lets the user move the column, by dragging its header and with // Ctrl+Shift+Left and Ctrl+Shift+Right on its header (see DataGrid and // DataGridElement.ColumnOrder). A column moves among the columns of its Pin. Movable bool // Pin keeps the column at the start or the end of the grid as the other columns // scroll sideways. Zero (PinNone) lets it scroll. Pin ColumnPin // Group names a group of columns, such as "Address" over Street and City. Columns // next to each other with the same Group share one cell, of their width, in a row // above the header; a group that a pin or a move splits is drawn in pieces. It is // the description of each column's header for assistive technology. Group string // Align places the text of the column's cells and header: Start (the zero // value), Center or End. Align Alignment // Interactive lets the content of Cell hold controls, such as buttons. The // content is not hidden from assistive technology. The controls are not Tab // stops: Enter or F2 on the cell moves focus to its first control, Tab and // Shift+Tab move through them, and Escape or F2 returns to the grid (see // DataGrid). Interactive bool // Edit makes the cells editable. It saves value as the row's text, or returns an // error that says why the value is not accepted; the editor then stays open with // the error. The app keeps the data, so it updates its rows in Edit. Edit func(row T, value string) error // Value is the text that an edit starts with, when it differs from Text, such as // the raw number of a formatted one. Nil means Text. Value func(row T) string // Editor replaces the text field of an edit with what it returns, such as a // Select, a NumberInput or a CheckBox. value is the pending value, which starts // as Value (or Text); change sets the pending value; commit saves it through Edit // (and an error keeps the editor open); cancel ends the edit. The grid's keys // and focus work as for the text field (see DataGrid): the editor's controls get // their keys first, and Enter, Tab and a blur save the pending value, Escape // cancels. Give the editor a focusable control, or it cannot take focus. Editor func(row T, value string, change func(string), commit, cancel func()) Element }
DataColumn is one column of a DataGrid. Its cells show the text of each row, or what Cell returns, and its header shows Header. Set Compare to let the user sort by the column, and Resizable to let the user resize it.
type DataGridDensity ¶
type DataGridDensity uint8
DataGridDensity is the height of the rows and the header: a Comfortable row is 36 logical pixels high, a Compact one 26, both at the Text size setting.
const ( // DataGridComfortable is the default row height, with room around the text. DataGridComfortable DataGridDensity = iota // DataGridCompact is a smaller row height, for more rows on the screen. DataGridCompact )
type DataGridElement ¶
type DataGridElement[T any] struct { // contains filtered or unexported fields }
DataGridElement is a table of rows and columns, for business data. Only the rows in view are built, so a grid of 100,000 rows costs what its visible part costs. When the columns are wider than the grid, the rows build only the columns in view as well, with the pinned columns, the focused one and the one being edited; the header is built whole. As for the rows, assistive technology finds by row and column only the cells that are built, and the grid reports all its columns. Create one with DataGrid.
The grid is one Tab stop. Its keys act on the focused cell, and they follow the Windows list and grid conventions and the WAI-ARIA grid pattern (https://www.w3.org/WAI/ARIA/apg/patterns/grid/):
- Left and Right move to the previous and next column. Home and End move to the first and last column of the row; Ctrl+Home and Ctrl+End move to the first and last cell of the grid.
- Down and Up move to the next and previous row. Up from the first row moves to the header, and Down from the header moves to the first row.
- PageDown and PageUp move by a viewport of rows.
- In a single or multiple selection a plain move selects the row it reaches. With Ctrl the focus moves without selecting, as in the Windows list views.
- Shift with Up, Down, PageUp or PageDown extends the selection from the anchor row (multiple selection only).
- Space toggles the focused row (multiple selection), or selects it (single). Shift+Space extends the selection to the row, and Ctrl+A selects every row.
- When the grid selects cells (see CellSelection), the moves select cells in the same way: a plain move selects the cell, Ctrl moves the focus only, and Shift with an arrow, Home, End, PageUp or PageDown extends a rectangle from the anchor cell. Space toggles the focused cell, Shift+Space selects the cells of its row, Ctrl+Space those of its column, and Ctrl+A every cell.
- Enter activates the focused row, and calls OnActivate with it.
- On a header cell, Enter and Space sort by its column (see Sort). On a resizable header cell, Ctrl+Left and Ctrl+Right narrow and widen the column by 8 logical pixels. On a movable header cell (see DataColumn.Movable), Ctrl+Shift+Left and Ctrl+Shift+Right move the column one place, and its new place is announced; on other header cells they resize, as Ctrl does.
- Shift+F10 or the Menu key opens the context menu of the focused cell, or of the header cell (see ContextMenu and HeaderContextMenu). Alt is not used by the grid, so that the host keeps its menu and navigation keys.
- On an interactive cell (see DataColumn.Interactive), Enter or F2 moves focus to its first control. In the cell, Tab and Shift+Tab move through its controls and wrap at the ends, as the WAI-ARIA grid pattern allows; Escape or F2 returns focus to the cell, which is still the grid's one Tab stop. Keys that a control uses (the arrows of a text field, Enter on a button) are its own.
- On an editable cell (see DataColumn.Edit), Enter or F2 starts an edit, and so does typing a printable character, which replaces the text as in a spreadsheet. Enter saves, and Escape cancels. Tab saves and starts an edit of the next editable cell of the row; at the last one the edit ends and focus stays in the grid. Leaving the editor, by a click elsewhere or by focus moving on, saves the edit, as a spreadsheet does; a save that fails keeps the editor open with its error. Only Escape cancels.
A click selects a row (Ctrl toggles it, Shift extends the selection), or a cell when the grid selects cells (Shift selects the rectangle from the anchor), and a double-click activates it, except on an editable cell, where a double-click starts an edit. A click on a control in a cell (see DataColumn.Interactive) focuses and operates the control; it moves the cursor to the cell but does not select or activate the row. A click on a header sorts by its column: ascending, then descending, then not sorted. Dragging the edge of a resizable header resizes its column, and a double-click on the edge fits the column to the rows in view. Dragging a movable header moves its column: a line shows the side of the header under the pointer that it lands on. A column header stays at the top of the rows as they scroll, and the header scrolls with the rows when the columns are wider than the grid. A pinned column (see DataColumn.Pin) stays at the start or the end of the grid as the others scroll under it, and a column that the focus moves to is scrolled clear of the pinned ones. Columns with a Group share a cell in a row above the header; the keys do not reach that row, and assistive technology reads the group as the description of each column's header.
The columns are shown in the order of ColumnOrder, and assistive technology numbers them in that order. The order and the widths the user sets can be kept in signals (ColumnOrder and ColumnWidths), and OnColumnsChange reports each change the user makes to them, so that an app can save and restore them. A DataGridHandle scrolls to a row or a column, and focuses a cell, by their keys. LoadMore asks for more rows as the user nears the end of them, and LoadingMore shows a row at the end while they load.
Sorting orders the rows without changing their keys, and the focus and the selection follow their rows by key, so a sort, a scroll, new rows or a saved edit keep them. Sorting is stable, and it runs on the UI thread: a sort of 100,000 rows takes about 8 ms (see docs/accessibility-design-phases-i-m.md, Phase I). Keys must be unique.
With Children the rows form a tree. The rows given to DataGrid are its top level, and a row with children shows a chevron in the first column, which opens and closes it. On a cell of that column, Right opens a closed row and, on an open row, moves to its first child; Left closes an open row and, on a row that is closed or has no children, moves to its parent. Elsewhere Left and Right move between columns, as above. The * key opens the closed rows among the siblings of the focused row. A row's chevron is hidden from assistive technology: the row reports its level, its place among its siblings and whether it is open. The rows that are shown are counted for assistive technology, and Ctrl+A selects them. A collapse that hides the focused row moves the focus to the row above it that is shown. A collapse that hides a row being edited saves the edit, as a blur does.
An editing row is built only while it is in view, as the other rows are, because the rows of a grid are one window of the list. When the row scrolls out of view its editor is not laid out, but the edit, its text and its focus are kept, and the editor is laid out again when the row comes back (see docs/accessibility-design-phases-i-m.md).
func DataGrid ¶
func DataGrid[T any](rows []T, key func(T) string, cols ...DataColumn[T]) *DataGridElement[T]
DataGrid creates a table of rows, with a column for each of cols. key gives the key of each row, which must be unique and stable: the focus, the selection and the sort follow it.
With no size, the grid takes the height its parent leaves it, and builds the rows that fit in it, as a grid with a Height does.
ui.DataGrid(runs, func(r Run) string { return r.ID },
ui.DataColumn[Run]{Header: "Name", Text: func(r Run) string { return r.Name }, Compare: byName, Grow: 1},
ui.DataColumn[Run]{Header: "Status", Text: func(r Run) string { return r.Status }}).
Selection(ui.SelectionMultiple, picked).Sort(order)
func (*DataGridElement[T]) CellSelection ¶ added in v0.4.0
func (g *DataGridElement[T]) CellSelection(mode SelectionMode, cells *Signal[[]CellKey]) *DataGridElement[T]
CellSelection lets the user select cells rather than rows, and keeps the selected cells in cells: the grid sets it when the selection changes, and a value set in cells selects those cells. A nil cells keeps the selection inside the grid. The cells follow their rows and columns by key, through a sort or a move.
It replaces Selection: the grid selects rows or cells, not both, and the later of the two calls is the one that applies (the development warnings say so). Ctrl+A selects every cell, so with many rows cells holds a key for each cell of each row.
func (*DataGridElement[T]) Children ¶ added in v0.5.0
func (g *DataGridElement[T]) Children(fn func(row T) []T) *DataGridElement[T]
Children makes the rows a tree: the rows given to DataGrid are the top level, and fn returns the children of a row, nil or empty for a row with none. Keys must be unique across the whole tree. A row with children shows a chevron that opens and closes it, and its children are shown under it while it is open (see Expanded). The rows and their children are read on each build of the grid, as a flat grid reads its rows, so a change made in place shows; fn therefore runs for each row on each build, and should be cheap, such as a field read. The grid computes no totals: a group row is an ordinary row that the app builds, with its summed values.
The children of a row are sorted within their level by the sort (see Sort), so a group sorts among the groups and a child among its siblings.
ui.DataGrid(groups, func(g Group) string { return g.Key },
ui.DataColumn[Group]{Header: "Name", Text: func(g Group) string { return g.Name }},
ui.DataColumn[Group]{Header: "Memory", Text: func(g Group) string { return g.Memory }}).
Children(func(g Group) []Group { return g.Members })
func (*DataGridElement[T]) ColumnOrder ¶ added in v0.4.0
func (g *DataGridElement[T]) ColumnOrder(keys *Signal[[]string]) *DataGridElement[T]
ColumnOrder keeps the order of the columns in keys: the grid sets it when the user moves a column, and a value set in keys shows the columns in that order. A key that is not a column's is dropped, and the columns that keys does not name follow in the order they are given, so a saved order survives new columns. A nil keys keeps the order inside the grid.
func (*DataGridElement[T]) ColumnWidths ¶ added in v0.4.0
func (g *DataGridElement[T]) ColumnWidths(ws *Signal[map[string]float32]) *DataGridElement[T]
ColumnWidths keeps the widths the user sets in ws, by column key, in logical pixels at the Text size setting 100 percent: the grid sets it when the user resizes a column, and a value set in ws sizes the columns it names. A nil ws keeps the widths inside the grid.
func (*DataGridElement[T]) ContextMenu ¶ added in v0.4.0
func (g *DataGridElement[T]) ContextMenu(build func(row T, column string) []MenuItem) *DataGridElement[T]
ContextMenu opens a menu on the cells of the grid, built by build with the row and the key of the column. A right-press opens it at the pointer: on a row that is not selected it first moves the focus to the cell and selects the row, and on a selected row it moves the focus and keeps the selection, as in File Explorer. Shift+F10 or the Menu key opens it for the focused cell. An empty result opens nothing.
func (*DataGridElement[T]) Density ¶
func (g *DataGridElement[T]) Density(d DataGridDensity) *DataGridElement[T]
Density sets the height of the rows: DataGridComfortable (the default) or DataGridCompact.
func (*DataGridElement[T]) Empty ¶
func (g *DataGridElement[T]) Empty(el Element) *DataGridElement[T]
Empty sets what the grid shows with no rows, under its header. Without it the grid shows "No rows".
func (*DataGridElement[T]) Expanded ¶ added in v0.5.0
func (g *DataGridElement[T]) Expanded(keys *Signal[[]string]) *DataGridElement[T]
Expanded keeps the keys of the open rows of a tree in keys: the grid sets it when a row is opened or closed, and a value the app sets in keys opens those rows and closes the others. A nil keys keeps the open rows inside the grid. The keys are kept in the order the rows were opened; closing a row keeps the keys of the rows below it, so opening it again shows them open. A DataGridHandle that scrolls to a row opens the rows above it (see ScrollToRow).
func (*DataGridElement[T]) FocusHandle ¶
func (g *DataGridElement[T]) FocusHandle(h *FocusHandle) *DataGridElement[T]
FocusHandle lets code focus the grid (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*DataGridElement[T]) GridSpan ¶
func (g *DataGridElement[T]) GridSpan(cols, rows int) *DataGridElement[T]
GridSpan sets how many columns and rows the data grid covers in its parent's grid.
func (*DataGridElement[T]) Grow ¶
func (g *DataGridElement[T]) Grow(f float32) *DataGridElement[T]
Grow makes the data grid take a share of the free space on its parent's main axis.
func (*DataGridElement[T]) Handle ¶ added in v0.4.0
func (g *DataGridElement[T]) Handle(h *DataGridHandle) *DataGridElement[T]
Handle connects h, so that code can scroll the grid and move its focus.
func (*DataGridElement[T]) HeaderContextMenu ¶ added in v0.4.0
func (g *DataGridElement[T]) HeaderContextMenu(build func(column string) []MenuItem) *DataGridElement[T]
HeaderContextMenu opens a menu on the header cells, built by build with the key of the column: on a right-press on a header cell, and with Shift+F10 or the Menu key while the focus is on the header. An empty result opens nothing.
func (*DataGridElement[T]) Height ¶
func (g *DataGridElement[T]) Height(l Length) *DataGridElement[T]
Height sets the height of the data grid.
func (*DataGridElement[T]) Key ¶
func (g *DataGridElement[T]) Key(k string) *DataGridElement[T]
Key gives the grid a stable identity among its siblings.
func (*DataGridElement[T]) Label ¶
func (g *DataGridElement[T]) Label(name string) *DataGridElement[T]
Label names the grid for assistive technology, such as "Deploy runs".
func (*DataGridElement[T]) LoadMore ¶ added in v0.4.0
func (g *DataGridElement[T]) LoadMore(hasMore bool, fn func()) *DataGridElement[T]
LoadMore asks fn for more rows while hasMore is true: fn runs when the rows near the end come into view, within a viewport of rows of the last one, or when Down, PageDown or Ctrl+End is pressed on the last row. It runs once for each number of rows, so it runs again only after the rows have changed, and it runs after the frame, not while the grid is built. In a tree the rows counted are every row given, children included, so opening or closing a row does not ask again. fn adds the rows to the data, with LoadingMore shown while they load.
func (*DataGridElement[T]) Loading ¶
func (g *DataGridElement[T]) Loading(on bool) *DataGridElement[T]
Loading shows a progress ring over the rows while on is true. The rows stay where they are, so the grid keeps its focus and selection while it loads.
func (*DataGridElement[T]) LoadingMore ¶ added in v0.4.0
func (g *DataGridElement[T]) LoadingMore(on bool) *DataGridElement[T]
LoadingMore shows a row at the end of the grid, with a progress ring and "Loading more rows", while on is true, and announces it when it starts. The row is not one of the grid's rows for assistive technology.
func (*DataGridElement[T]) MaxHeight ¶
func (g *DataGridElement[T]) MaxHeight(l Length) *DataGridElement[T]
MaxHeight sets the largest height of the data grid.
func (*DataGridElement[T]) MaxWidth ¶
func (g *DataGridElement[T]) MaxWidth(l Length) *DataGridElement[T]
MaxWidth sets the largest width of the data grid.
func (*DataGridElement[T]) MinHeight ¶
func (g *DataGridElement[T]) MinHeight(l Length) *DataGridElement[T]
MinHeight sets the smallest height of the data grid.
func (*DataGridElement[T]) MinWidth ¶
func (g *DataGridElement[T]) MinWidth(l Length) *DataGridElement[T]
MinWidth sets the smallest width of the data grid.
func (*DataGridElement[T]) Movable ¶ added in v0.4.0
func (g *DataGridElement[T]) Movable() *DataGridElement[T]
Movable lets the user move every column of the grid, as DataColumn.Movable does for one column.
func (*DataGridElement[T]) OnActivate ¶
func (g *DataGridElement[T]) OnActivate(fn func(row T)) *DataGridElement[T]
OnActivate runs fn with the row that the user activates, by Enter or a double-click.
func (*DataGridElement[T]) OnCollapse ¶ added in v0.5.0
func (g *DataGridElement[T]) OnCollapse(fn func(key string)) *DataGridElement[T]
OnCollapse runs fn with the key of a row after it is closed, from the same sources as OnExpand. It does not run for the keys the app sets in Expanded.
func (*DataGridElement[T]) OnColumnsChange ¶ added in v0.4.0
func (g *DataGridElement[T]) OnColumnsChange(fn func(ColumnState)) *DataGridElement[T]
OnColumnsChange runs fn with the layout of the columns after the user changes it: when a drag of a column's edge ends, at each step of a resize by the keyboard, after an auto-fit, and after a column is moved. It does not run while the edge is dragged, so fn can save the layout.
func (*DataGridElement[T]) OnExpand ¶ added in v0.5.0
func (g *DataGridElement[T]) OnExpand(fn func(key string)) *DataGridElement[T]
OnExpand runs fn with the key of a row after it is opened, by a click on its chevron, a key, the accessibility actions or a DataGridHandle. It does not run for the keys the app sets in Expanded.
func (*DataGridElement[T]) Selection ¶
func (g *DataGridElement[T]) Selection(mode SelectionMode, keys *Signal[[]string]) *DataGridElement[T]
Selection sets how the user selects rows, and keeps the keys of the selected rows in keys: the grid sets it when the selection changes, and a value set in keys selects those rows. A nil keys keeps the selection inside the grid.
func (*DataGridElement[T]) Sort ¶
func (g *DataGridElement[T]) Sort(s *Signal[SortState]) *DataGridElement[T]
Sort keeps the sort in s: the grid sets it when the user sorts, and the rows are ordered by it. A nil s keeps the sort inside the grid. A column sorts only when its Compare is set.
func (*DataGridElement[T]) SortChildrenOnly ¶ added in v0.6.0
func (g *DataGridElement[T]) SortChildrenOnly() *DataGridElement[T]
SortChildrenOnly keeps the top rows of a tree in the order they are given, and sorts only the rows under them, each among its siblings. The top rows are then sections, such as Task Manager's Apps, Background processes and Windows processes, which stay in their place while the rows in them sort. It applies to a grid with Children; a grid without them sorts all its rows, as before.
func (*DataGridElement[T]) Striped ¶
func (g *DataGridElement[T]) Striped() *DataGridElement[T]
Striped draws every other row in the RowAlternate part.
func (*DataGridElement[T]) Style ¶
func (g *DataGridElement[T]) Style(s Style) *DataGridElement[T]
Style is merged into the grid's outer box: size it with Height, Grow or MaxHeight.
func (*DataGridElement[T]) Styles ¶
func (g *DataGridElement[T]) Styles(st DataGridStyle) *DataGridElement[T]
Styles sets the look of the parts of the grid, for this instance only. Set fields win over the theme's DataGrid and the defaults; see DataGridStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*DataGridElement[T]) Width ¶
func (g *DataGridElement[T]) Width(l Length) *DataGridElement[T]
The sizing methods give the grid's outer box a size, over its Style. See Sizing in docs/styling.md.
type DataGridHandle ¶ added in v0.4.0
type DataGridHandle struct {
// contains filtered or unexported fields
}
DataGridHandle scrolls a DataGrid and moves its focus from code, by the keys of the rows and the columns. Create one with NewDataGridHandle and pass it to DataGrid.Handle. A request takes effect when the grid is next built, on the next frame; a key that names no row or column does nothing. Call it on the UI thread.
func NewDataGridHandle ¶ added in v0.4.0
func NewDataGridHandle() *DataGridHandle
NewDataGridHandle creates a handle to pass to DataGrid.Handle.
func (*DataGridHandle) FocusCell ¶ added in v0.4.0
func (h *DataGridHandle) FocusCell(rowKey, colKey string)
FocusCell moves the grid's focused cell to the row with the key rowKey, in the column with the key colKey (the focused column when colKey names none), scrolls it into view and gives the grid keyboard focus. It does not change the selection.
func (*DataGridHandle) ScrollToColumn ¶ added in v0.4.0
func (h *DataGridHandle) ScrollToColumn(key string)
ScrollToColumn scrolls sideways the least amount that shows the column with the key key.
func (*DataGridHandle) ScrollToRow ¶ added in v0.4.0
func (h *DataGridHandle) ScrollToRow(key string)
ScrollToRow scrolls the least amount that shows the row with the key key, in the order the rows are sorted in.
type DataGridStyle ¶
type DataGridStyle struct {
// Grid is the frame of the grid.
Grid Style
// GridFocusVisible is the frame while the grid has keyboard focus.
GridFocusVisible Style
// Header is the header row.
Header Style
// HeaderCell is each cell of the header row.
HeaderCell Style
// HeaderCellHover is a header cell under the pointer.
HeaderCellHover Style
// HeaderCellSorted is the header cell of the column that the grid is sorted by.
HeaderCellSorted Style
// SortIndicator is the mark that shows the sort direction in a header cell.
SortIndicator Style
// ResizeHandle is the handle that resizes a column.
ResizeHandle Style
// Row is each row.
Row Style
// RowHover is a row under the pointer.
RowHover Style
// RowSelected is a selected row.
RowSelected Style
// RowAlternate is every other row, for banding.
RowAlternate Style
// Cell is each cell of a row.
Cell Style
// CellFocused is the cell that has keyboard focus.
CellFocused Style
// Empty is the message shown when the grid has no rows.
Empty Style
// CellEditing is a cell that is being edited.
CellEditing Style
// Editor is the field of the cell editor.
Editor FieldStyle
// EditorMessage is the message of the cell editor, such as an error.
EditorMessage Style
// DropIndicator is the line that shows where a dragged column lands.
DropIndicator Style
// CellPinned is each cell of a pinned column (see DataColumn.Pin).
CellPinned Style
// PinnedEdge is the cell, in the body or the header, at the inner edge of the
// pinned columns, whose border separates them from the columns that scroll.
PinnedEdge Style
// HeaderGroup is the cell of a group of columns, above their header cells (see
// DataColumn.Group).
HeaderGroup Style
// CellSelected is a selected cell, when the grid selects cells (see CellSelection).
CellSelected Style
// TreeIndent is the space of each level above a row, in the first column of a tree
// (see Children).
TreeIndent Style
// TreeChevron is the chevron that opens and closes a row with children, in the first
// column of a tree. A row without children leaves its space empty.
TreeChevron Style
}
DataGridStyle is the look of the parts of a DataGrid. A part's style merges over the built-in defaults, then over the theme's DataGrid, then over the Styles of the instance; see docs/styling.md. Grid is the scroll container of the rows, and the header scrolls with it. Header is the row of header cells, HeaderCell each cell of it, and ResizeHandle the edge a column is resized by. Row is each row, RowAlternate every other row when the grid is Striped, RowHover a row the pointer is over, and RowSelected a selected row. Cell is each cell, and CellFocused the cell that has keyboard focus, in the body or the header. Empty is the message shown with no rows. The states are parts of their own: GridFocusVisible while the grid has keyboard focus, HeaderCellHover over a sortable header, HeaderCellSorted for the column the rows are sorted by, and SortIndicator is the arrow of that column.
An editable cell has two more parts: CellEditing is the cell being edited, Editor is its text field (a FieldStyle; FrameInvalid is its frame while the last save failed), and EditorMessage is the popover under the cell that says why a save failed.
In a tree (see Children) the first column has two parts more: TreeIndent is the space of each level above a row, and TreeChevron is the chevron that opens and closes a row with children, or the space it leaves for a row without.
type DatePickerElement ¶
type DatePickerElement struct {
// contains filtered or unexported fields
}
DatePickerElement is a text field for a day, with a calendar that opens below it. The text is the day in the short date format of the user's locale (see docs/widgets-selection.md, Date and time). The value is a time.Time: its day is the chosen day and its time of day is kept, so one signal can hold a date and a time (see TimePicker); a zero time is no date.
The keys of the calendar follow the WAI-ARIA date picker dialog pattern (see docs/widgets-selection.md, Date and time). Alt+Down and F4 open it from the field, with focus on the chosen day or today; Enter or Space chooses the day and closes it, and Escape or Tab closes it without a change. A day that is not between Min and Max, or that DisableDays rules out, cannot be chosen: it is disabled, and typed text that names it is refused with a message.
func DatePicker ¶
func DatePicker(value *Signal[time.Time]) *DatePickerElement
DatePicker creates a date picker that reads and writes value. The default width is 180 px at the Text size of 100 percent. A zero time is no date, and the field is empty.
func (*DatePickerElement) DisableDays ¶
func (d *DatePickerElement) DisableDays(fn func(day time.Time) bool) *DatePickerElement
DisableDays rules out the days for which fn returns true, such as weekends. fn is called with each day at local midnight. A disabled day is drawn dimmed, is marked unavailable to assistive technology, and cannot be chosen by the calendar or by typing.
func (*DatePickerElement) Disabled ¶
func (d *DatePickerElement) Disabled(on bool) *DatePickerElement
Disabled shows the field, with its date, and does not let it change.
func (*DatePickerElement) FirstDay ¶
func (d *DatePickerElement) FirstDay(day time.Weekday) *DatePickerElement
FirstDay sets the first day of the week in the calendar. The default is the first day of the week of the user's locale.
func (*DatePickerElement) FocusHandle ¶
func (d *DatePickerElement) FocusHandle(h *FocusHandle) *DatePickerElement
FocusHandle lets code focus the date field (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*DatePickerElement) GridSpan ¶
func (d *DatePickerElement) GridSpan(cols, rows int) *DatePickerElement
GridSpan sets how many columns and rows the date picker covers in its parent's grid.
func (*DatePickerElement) Grow ¶
func (d *DatePickerElement) Grow(f float32) *DatePickerElement
Grow makes the date picker take a share of the free space on its parent's main axis.
func (*DatePickerElement) Height ¶
func (d *DatePickerElement) Height(l Length) *DatePickerElement
Height sets the height of the date picker.
func (*DatePickerElement) Key ¶
func (d *DatePickerElement) Key(k string) *DatePickerElement
Key identifies the date picker among its siblings (see DivElement.Key).
func (*DatePickerElement) Label ¶
func (d *DatePickerElement) Label(name string) *DatePickerElement
Label names the field for assistive technology, such as "Due date".
func (*DatePickerElement) LabelledBy ¶
func (d *DatePickerElement) LabelledBy(keys ...string) *DatePickerElement
LabelledBy names the field by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*DatePickerElement) Large ¶
func (d *DatePickerElement) Large() *DatePickerElement
Large makes the field larger: 40 px high with 16 px text, like Button.Large and TextInput.Large, for touch-friendly or prominent forms. Small and Large replace each other.
func (*DatePickerElement) Max ¶
func (d *DatePickerElement) Max(day time.Time) *DatePickerElement
Max sets the latest day that can be chosen. Its time of day is ignored; a zero time means there is no latest day.
func (*DatePickerElement) MaxHeight ¶
func (d *DatePickerElement) MaxHeight(l Length) *DatePickerElement
MaxHeight sets the largest height of the date picker.
func (*DatePickerElement) MaxWidth ¶
func (d *DatePickerElement) MaxWidth(l Length) *DatePickerElement
MaxWidth sets the largest width of the date picker.
func (*DatePickerElement) Min ¶
func (d *DatePickerElement) Min(day time.Time) *DatePickerElement
Min sets the earliest day that can be chosen. Its time of day is ignored; a zero time means there is no earliest day.
func (*DatePickerElement) MinHeight ¶
func (d *DatePickerElement) MinHeight(l Length) *DatePickerElement
MinHeight sets the smallest height of the date picker.
func (*DatePickerElement) MinWidth ¶
func (d *DatePickerElement) MinWidth(l Length) *DatePickerElement
MinWidth sets the smallest width of the date picker.
func (*DatePickerElement) OnChange ¶
func (d *DatePickerElement) OnChange(fn func(time.Time)) *DatePickerElement
OnChange runs fn with the new value after the user chooses a day, or types a date that can be chosen. It does not run when the value is set from outside.
func (*DatePickerElement) Placeholder ¶
func (d *DatePickerElement) Placeholder(s string) *DatePickerElement
Placeholder is the text shown while the field is empty. The default is the hint of the locale's date format, such as "MM/DD/YYYY" for en-US (see datePlaceholder).
func (*DatePickerElement) Small ¶
func (d *DatePickerElement) Small() *DatePickerElement
Small makes the field compact: 28 px high with smaller text, like Button.Small and TextInput.Small, for toolbars and dense forms.
func (*DatePickerElement) Styles ¶
func (d *DatePickerElement) Styles(st DatePickerStyle) *DatePickerElement
Styles sets the look of the parts of the date picker, for this instance only. Set fields win over the theme's DatePicker and the defaults; see DatePickerStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*DatePickerElement) Tooltip ¶
func (d *DatePickerElement) Tooltip(s string) *DatePickerElement
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*DatePickerElement) Validate ¶
func (d *DatePickerElement) Validate(rules ...Validator[time.Time]) *DatePickerElement
Validate sets the validators of the value. A zero time is no date, so Required rejects an empty field (see Field).
func (*DatePickerElement) Width ¶
func (d *DatePickerElement) Width(l Length) *DatePickerElement
The sizing methods give the field a size. The field is datePickerWidth wide at the Text size of 100 percent by default; Width(Full) fills its container. See Sizing in docs/styling.md.
type DatePickerStyle ¶
type DatePickerStyle struct {
// Field is the text frame of the date picker.
Field FieldStyle
// CalendarButton is the button that opens the calendar.
CalendarButton Style
// Message is the message under the field.
Message Style
// Popup is the panel of the calendar.
Popup Style
// Header is the row with the month and the year.
Header Style
NavButton Style
// WeekdayLabel is the name of each day of the week.
WeekdayLabel Style
// Day is each day of the calendar.
Day Style
// DayHover is a day under the pointer.
DayHover Style
// DaySelected is the day that is chosen.
DaySelected Style
// DayToday is today.
DayToday Style
// DayDisabled is a day that cannot be chosen.
DayDisabled Style
// DayOutsideMonth is a day of the adjacent months.
DayOutsideMonth Style
// DayFocusVisible is the day that has keyboard focus.
DayFocusVisible Style
}
DatePickerStyle is the look of each part of a date picker. A part's style merges over the built-in defaults, then over the theme's DatePicker, then over the Styles of the instance; see docs/styling.md.
Field is the text frame, a FieldStyle as TextInput's is, with its states. CalendarButton is the button at the end of the field that opens the calendar, and Message the row that says why the text is not a date that can be chosen (as NumberInput's message). The calendar is the popup: Popup is its panel, Header the row with the month and the year, NavButton each of its navigation buttons (previous and next month, and year), and WeekdayLabel the name of each day of the week. Day is each day; DayHover a day the pointer is over; DaySelected the day in the field; DayToday today; DayDisabled a day that cannot be chosen (see Min, Max and DisableDays); DayOutsideMonth a day of the previous or the next month that fills the grid; and DayFocusVisible the day the keys have reached. Under high contrast the selected day is drawn in the system Highlight colors, and today and the focused day by their borders, so that no state is shown by color alone.
type DateRange ¶ added in v0.2.0
DateRange is a range of days, as the validators of a date range picker see it (see DateRangePickerElement.Validate): its first day and its last, each at local midnight. A zero Start is no range.
type DateRangePickerElement ¶
type DateRangePickerElement struct {
// contains filtered or unexported fields
}
DateRangePickerElement is a text field for a range of days, with a calendar that opens below it. The text is the two days in the short date format of the user's locale, joined by an en dash ("1/3/2026 – 1/9/2026"), and it is the start alone while the end is not chosen. The start and the end are two signals of time.Time, each at local midnight; a zero start is no range.
The calendar chooses a range in two steps: the first day chosen is the start, and the second is the end, which closes the calendar. If the end is before the start, the two are swapped. The signals change only when the end is chosen, so Escape, Tab, and a click outside the calendar keep the range that was there. While the end is being chosen, the days from the start to the day under the pointer, or under the keys, are shaded as the range would be. A day that Min and Max, or DisableDays, rule out cannot be chosen as either end; a range may span such days. Typed text is "date – date" or "date - date", each date in the locale's format, and it is refused with a message when either date cannot be chosen.
The keys of the calendar follow the WAI-ARIA date picker dialog pattern (see docs/widgets-selection.md, Date and time). Alt+Down and F4 open it, from the start of the range, or from today when there is none.
func DateRangePicker ¶
func DateRangePicker(start, end *Signal[time.Time]) *DateRangePickerElement
DateRangePicker creates a date range picker that reads and writes the start and the end of a range. The default width is 280 px at the Text size of 100 percent. A zero start is no range, and the field is empty.
func (*DateRangePickerElement) DisableDays ¶
func (d *DateRangePickerElement) DisableDays(fn func(day time.Time) bool) *DateRangePickerElement
DisableDays rules out the days for which fn returns true, such as weekends. fn is called with each day at local midnight. A disabled day is drawn dimmed, is marked unavailable to assistive technology, and cannot be chosen as an end of the range by the calendar or by typing. A day between the ends may be disabled: the range is shaded across it.
func (*DateRangePickerElement) Disabled ¶
func (d *DateRangePickerElement) Disabled(on bool) *DateRangePickerElement
Disabled shows the field, with its range, and does not let it change.
func (*DateRangePickerElement) FirstDay ¶
func (d *DateRangePickerElement) FirstDay(day time.Weekday) *DateRangePickerElement
FirstDay sets the first day of the week in the calendar. The default is the first day of the week of the user's locale.
func (*DateRangePickerElement) FocusHandle ¶
func (d *DateRangePickerElement) FocusHandle(h *FocusHandle) *DateRangePickerElement
FocusHandle lets code focus the date range field (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*DateRangePickerElement) GridSpan ¶
func (d *DateRangePickerElement) GridSpan(cols, rows int) *DateRangePickerElement
GridSpan sets how many columns and rows the date range picker covers in its parent's grid.
func (*DateRangePickerElement) Grow ¶
func (d *DateRangePickerElement) Grow(f float32) *DateRangePickerElement
Grow makes the date range picker take a share of the free space on its parent's main axis.
func (*DateRangePickerElement) Height ¶
func (d *DateRangePickerElement) Height(l Length) *DateRangePickerElement
Height sets the height of the date range picker.
func (*DateRangePickerElement) Key ¶
func (d *DateRangePickerElement) Key(k string) *DateRangePickerElement
Key identifies the date range picker among its siblings (see DivElement.Key).
func (*DateRangePickerElement) Label ¶
func (d *DateRangePickerElement) Label(name string) *DateRangePickerElement
Label names the field for assistive technology, such as "Trip dates".
func (*DateRangePickerElement) LabelledBy ¶
func (d *DateRangePickerElement) LabelledBy(keys ...string) *DateRangePickerElement
LabelledBy names the field by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*DateRangePickerElement) Large ¶
func (d *DateRangePickerElement) Large() *DateRangePickerElement
Large makes the field larger: 40 px high with 16 px text, like Button.Large and TextInput.Large, for touch-friendly or prominent forms. Small and Large replace each other.
func (*DateRangePickerElement) Max ¶
func (d *DateRangePickerElement) Max(day time.Time) *DateRangePickerElement
Max sets the latest day that can be chosen. Its time of day is ignored; a zero time means there is no latest day.
func (*DateRangePickerElement) MaxHeight ¶
func (d *DateRangePickerElement) MaxHeight(l Length) *DateRangePickerElement
MaxHeight sets the largest height of the date range picker.
func (*DateRangePickerElement) MaxWidth ¶
func (d *DateRangePickerElement) MaxWidth(l Length) *DateRangePickerElement
MaxWidth sets the largest width of the date range picker.
func (*DateRangePickerElement) Min ¶
func (d *DateRangePickerElement) Min(day time.Time) *DateRangePickerElement
Min sets the earliest day that can be chosen. Its time of day is ignored; a zero time means there is no earliest day.
func (*DateRangePickerElement) MinHeight ¶
func (d *DateRangePickerElement) MinHeight(l Length) *DateRangePickerElement
MinHeight sets the smallest height of the date range picker.
func (*DateRangePickerElement) MinWidth ¶
func (d *DateRangePickerElement) MinWidth(l Length) *DateRangePickerElement
MinWidth sets the smallest width of the date range picker.
func (*DateRangePickerElement) OnChange ¶
func (d *DateRangePickerElement) OnChange(fn func(start, end time.Time)) *DateRangePickerElement
OnChange runs fn with the new start and end after the user chooses the end of a range, or types a range that can be chosen. It does not run when the range is set from outside.
func (*DateRangePickerElement) Placeholder ¶
func (d *DateRangePickerElement) Placeholder(s string) *DateRangePickerElement
Placeholder is the text shown while the field is empty. The default is the hint of the locale's date format for both ends, such as "MM/DD/YYYY – MM/DD/YYYY" for en-US.
func (*DateRangePickerElement) Small ¶
func (d *DateRangePickerElement) Small() *DateRangePickerElement
Small makes the field compact: 28 px high with smaller text, like Button.Small and TextInput.Small, for toolbars and dense forms.
func (*DateRangePickerElement) Styles ¶
func (d *DateRangePickerElement) Styles(st DateRangePickerStyle) *DateRangePickerElement
Styles sets the look of the parts of the date range picker, for this instance only. Set fields win over the theme's DateRangePicker and the defaults; see DateRangePickerStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*DateRangePickerElement) Tooltip ¶
func (d *DateRangePickerElement) Tooltip(s string) *DateRangePickerElement
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*DateRangePickerElement) Validate ¶ added in v0.2.0
func (d *DateRangePickerElement) Validate(rules ...Validator[DateRange]) *DateRangePickerElement
Validate sets the validators of the range. A zero DateRange is no range, so Required rejects an empty field (see Field).
func (*DateRangePickerElement) Width ¶
func (d *DateRangePickerElement) Width(l Length) *DateRangePickerElement
The sizing methods give the field a size. The field is dateRangePickerWidth wide at the Text size of 100 percent by default; Width(Full) fills its container. See Sizing in docs/styling.md.
type DateRangePickerStyle ¶
type DateRangePickerStyle struct {
// Field is the text frame of the date range picker.
Field FieldStyle
// CalendarButton is the button that opens the calendar.
CalendarButton Style
// Message is the message under the field.
Message Style
// Popup is the panel of the calendar.
Popup Style
// Header is the row with the month and the year.
Header Style
NavButton Style
// WeekdayLabel is the name of each day of the week.
WeekdayLabel Style
// Day is each day of the calendar.
Day Style
// DayHover is a day under the pointer.
DayHover Style
// DaySelected is a day at either end of the range.
DaySelected Style
// DayInRange is a day between the ends of the range.
DayInRange Style
// DayToday is today.
DayToday Style
// DayDisabled is a day that cannot be chosen.
DayDisabled Style
// DayOutsideMonth is a day of the adjacent months.
DayOutsideMonth Style
// DayFocusVisible is the day that has keyboard focus.
DayFocusVisible Style
}
DateRangePickerStyle is the look of each part of a date range picker. A part's style merges over the built-in defaults, then over the theme's DateRangePicker, then over the Styles of the instance; see docs/styling.md.
The parts are those of a DatePicker, and they are drawn in the same way: Field is the text frame, and CalendarButton, Message, and the parts of the calendar (Popup, Header, NavButton, WeekdayLabel, Day, DayHover, DayToday, DayDisabled, DayOutsideMonth and DayFocusVisible) are as they are there (see DatePickerStyle). DaySelected is the start and the end of the range. DayInRange is each day between them, which is drawn as a band, with a line above and below and square corners, so that the range is not shown by its fill alone. Under high contrast the ends are drawn in the system Highlight colors, and the days between by their lines, in the text color.
type DescriptionListElement ¶ added in v0.3.0
type DescriptionListElement struct {
// contains filtered or unexported fields
}
DescriptionListElement shows terms with their values, such as the details of a record: "Owner" and "Dana Lee", "Status" and a badge. The items are laid out in a grid, row by row, one column by default. Each item is a group named by its term.
func DescriptionList ¶ added in v0.3.0
func DescriptionList() *DescriptionListElement
DescriptionList creates an empty description list; Item and ItemText add its items. A list fills the width of its container by default.
func (*DescriptionListElement) Bordered ¶ added in v0.3.0
func (l *DescriptionListElement) Bordered() *DescriptionListElement
Bordered outlines the list and draws a line between its items, which are padded. The lines between items are the border edges of the items.
func (*DescriptionListElement) Columns ¶ added in v0.3.0
func (l *DescriptionListElement) Columns(n int) *DescriptionListElement
Columns lays the items out in n columns of the same width, row by row. The default is 1; a value below 1 counts as 1.
func (*DescriptionListElement) GridSpan ¶ added in v0.3.0
func (l *DescriptionListElement) GridSpan(cols, rows int) *DescriptionListElement
GridSpan sets how many columns and rows the list covers in its parent's grid.
func (*DescriptionListElement) Grow ¶ added in v0.3.0
func (l *DescriptionListElement) Grow(f float32) *DescriptionListElement
Grow makes the list take a share of the free space on its parent's main axis.
func (*DescriptionListElement) Item ¶ added in v0.3.0
func (l *DescriptionListElement) Item(term string, value Element) *DescriptionListElement
Item adds the term with value, which can be any element, such as a badge or a link.
func (*DescriptionListElement) ItemText ¶ added in v0.3.0
func (l *DescriptionListElement) ItemText(term, value string) *DescriptionListElement
ItemText adds the term with a value that is text.
func (*DescriptionListElement) Key ¶ added in v0.3.0
func (l *DescriptionListElement) Key(k string) *DescriptionListElement
Key identifies the list among its siblings (see DivElement.Key).
func (*DescriptionListElement) MaxWidth ¶ added in v0.3.0
func (l *DescriptionListElement) MaxWidth(w Length) *DescriptionListElement
MaxWidth sets the largest width of the list.
func (*DescriptionListElement) MinWidth ¶ added in v0.3.0
func (l *DescriptionListElement) MinWidth(w Length) *DescriptionListElement
MinWidth sets the smallest width of the list.
func (*DescriptionListElement) Styles ¶ added in v0.3.0
func (l *DescriptionListElement) Styles(st DescriptionListStyle) *DescriptionListElement
Styles sets the look of the parts of the list, for this instance only. Set fields win over the theme's DescriptionList and the defaults; see DescriptionListStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*DescriptionListElement) Tooltip ¶ added in v0.3.0
func (l *DescriptionListElement) Tooltip(s string) *DescriptionListElement
Tooltip shows s below the list after the pointer rests on it.
func (*DescriptionListElement) Vertical ¶ added in v0.3.0
func (l *DescriptionListElement) Vertical() *DescriptionListElement
Vertical puts each term above its value, in place of the default column of terms beside the values.
func (*DescriptionListElement) Width ¶ added in v0.3.0
func (l *DescriptionListElement) Width(w Length) *DescriptionListElement
The sizing methods give the list's outer box a size. See Sizing in docs/styling.md.
type DescriptionListStyle ¶ added in v0.3.0
type DescriptionListStyle struct {
DescriptionList Style // the grid of items: its gap, and its frame when bordered
Item Style // one term with its value
Term Style // the term, such as "Owner"
Value Style // the value of the term
}
DescriptionListStyle is the look of each part of a description list. A part's style merges over the built-in defaults, then over the theme's DescriptionList, then over the Styles of the instance; see docs/styling.md. DescriptionList is the grid of items, and Item one term with its value: the Term and the Value. The defaults depend on the layout (beside or Vertical) and on Bordered.
type DivElement ¶
type DivElement struct {
// contains filtered or unexported fields
}
DivElement is the general-purpose container: a flex box with optional background, border, radius, shadow, clipping, scrolling and event handlers. Create one with Div and configure it with chained methods.
func Canvas ¶
func Canvas(draw func(p *Painter, w, h float32)) *DivElement
Canvas creates an element that draw paints with shapes, as an HTML canvas does: charts, graphs, diagrams and custom widgets. draw receives a Painter and the size of the content box in logical pixels, with 0, 0 at its top-left and y going down.
The drawing is kept between frames. draw runs again when the component that made the canvas renders again, when the canvas's size, the display scale or the zoom changes, or when a caret it drew with Painter.CaretVisible blinks, so read the signals the drawing depends on in the component's render, not only in draw. Shapes are drawn on the CPU, at the display's resolution, and text with the text renderer, over the shapes.
The canvas is a Div: size it with Size (300 x 150 by default), handle the pointer with OnMouseMove and the others (MouseEvent.LocalX and LocalY are in the canvas's coordinates when it has no padding or border), and add children to lay elements over the drawing. Assistive technology sees an image; name it with Label, such as "Sales by month, rising from 12 to 30". The children stay in the accessibility tree, inside the image. Role(access.RoleUnknown) makes the drawing decoration: the canvas has no node, and its children are read as the children of a plain Div are. The default size wins over insets, so a canvas that fills its parent needs Size(Full, Full). The drawing fills the content box, inside any padding, with the canvas's Radius on its corners; to lay text over art that reaches the edges, pad a child Div, not the canvas.
ui.Canvas(func(p *ui.Painter, w, h float32) {
line := ui.NewPath().MoveTo(0, h).LineTo(w/2, 10).LineTo(w, h/2)
p.Stroke(line, ui.StrokeStyle{Width: 2, Color: t.Accent})
}).Size(ui.Full, ui.Px(200)).Label("Visits this week")
func Div ¶
func Div() *DivElement
Div creates an empty container. Children stack vertically (Column) unless Row is called.
func (*DivElement) Absolute ¶
func (d *DivElement) Absolute() *DivElement
Absolute takes the element out of the flow; position it with Top/Right/Bottom/Left.
func (*DivElement) AccessCell ¶ added in v0.3.0
func (d *DivElement) AccessCell(row, col int) *DivElement
AccessCell gives a cell of a table (see AccessGrid) its row and column, both counted from 1. Assistive technology reports them, and finds the cell by them. The cell's name is its text, unless it has a Label.
It applies to an element with the role access.RoleDataItem, a cell of the data, or access.RoleHeaderItem, the header of the column col. The header row is not one of the table's rows, so a header item's row is not reported: pass 0. A data item in row 0 has no position, and a cell of another role reports none; the development warnings report both. AccessCell panics when row is negative or col is less than 1.
func (*DivElement) AccessChecked ¶
func (d *DivElement) AccessChecked(on bool) *DivElement
AccessChecked gives the element an on or off state: whether a check box, switch, radio button, toggle button or checkable menu item is on. Assistive technology reports the state after the name, and the element can be toggled. A check box, switch or radio button needs a state, so the development warnings ask for this call. A radio button is a choice in a group (see AccessSelected), not a toggle.
func (*DivElement) AccessExpanded ¶
func (d *DivElement) AccessExpanded(open bool) *DivElement
AccessExpanded marks the element as one that opens and closes, such as a row with details or a dropdown trigger, and says whether it is open. Assistive technology reports the state and can open or close the element. Opening and closing run the element's click handler, which must toggle the state, when the element is not already in the requested state.
func (*DivElement) AccessGrid ¶ added in v0.3.0
func (d *DivElement) AccessGrid(rows, cols int) *DivElement
AccessGrid gives a table its shape: rows rows and cols columns, which assistive technology reports and moves through by row and column (the Grid and Table patterns of UI Automation). rows counts the rows of data, not the header row, as a DataGrid does: a table with a header and three rows of data has 3 rows. The cells are the elements under it with AccessCell, and its column headers the header items under it.
It applies to an element with the role access.RoleDataGrid or access.RoleCalendar. On another role the shape is not reported, and the development warnings say so. AccessGrid panics when rows or cols is negative.
func (*DivElement) AccessHidden ¶
func (d *DivElement) AccessHidden() *DivElement
AccessHidden leaves the element and its children out of the accessibility tree. It does not change how the element is drawn.
func (*DivElement) AccessLevel ¶ added in v0.3.0
func (d *DivElement) AccessLevel(level int) *DivElement
AccessLevel gives the element its nesting depth, 1 for the top: the depth of an item of a nested list, a tree item or a menu item, which assistive technology reports as "level 2". It applies to the item of any role. AccessLevel panics when level is less than 1.
func (*DivElement) AccessPosition ¶ added in v0.3.0
func (d *DivElement) AccessPosition(pos, size int) *DivElement
AccessPosition places the element in a set of items, such as an item of a list: it is the pos-th of size items, which assistive technology reports as "2 of 5". It applies to the item of any role, most often access.RoleListItem, and also tree items, menu items, tabs and radio buttons. The rows of a UniformList or ListOf get their position from the list, which replaces this one. AccessPosition panics unless 1 <= pos <= size.
func (*DivElement) AccessSelected ¶
func (d *DivElement) AccessSelected(on bool) *DivElement
AccessSelected marks the element as one item of a selection, such as the selected note in a list, and says whether it is chosen. The item must be inside a SelectionContainer. Selecting an item that is not chosen runs its click handler, which must choose it.
func (*DivElement) Align ¶
func (d *DivElement) Align(a Alignment) *DivElement
Align positions children on the cross axis: Start, Center, End, Stretch, or, in a row, Baseline.
func (*DivElement) AlignSelf ¶
func (d *DivElement) AlignSelf(a Alignment) *DivElement
AlignSelf overrides the parent's Align for this element.
func (*DivElement) AutoFocus ¶
func (d *DivElement) AutoFocus() *DivElement
AutoFocus focuses the element when it first appears. It implies Focusable.
func (*DivElement) Background ¶
func (d *DivElement) Background(c Color) *DivElement
Background sets the fill color.
func (*DivElement) BackgroundGradient ¶
func (d *DivElement) BackgroundGradient(g Gradient) *DivElement
BackgroundGradient fills the element with a linear gradient instead of its Background color. It is merged like the other visual fields, so a Hover or Focused style may set one too.
func (*DivElement) Badged ¶
func (d *DivElement) Badged(b *BadgeElement) *DivElement
Badged adds b to the end of d and names it in d's accessible name, so that the row reads as "Projects, 6 items" rather than as the row followed by a separate badge. The badge is then hidden from assistive technology. See the Badge API in docs/widgets-feedback.md.
func (*DivElement) Basis ¶
func (d *DivElement) Basis(l Length) *DivElement
Basis sets the main-axis size the element starts from before growing or shrinking. Basis(ui.Px(0)) with Grow(1) gives equal-width columns.
func (*DivElement) Border ¶
func (d *DivElement) Border(width float32, c Color) *DivElement
Border sets a uniform border.
func (*DivElement) BorderEdges ¶
func (d *DivElement) BorderEdges(e Edges, c Color) *DivElement
BorderEdges sets a border of color c with its own width on each side (top, right, bottom, left); a zero side has none. Each side takes up space like padding, and a rounded element's corners curve from one side into the next. Its color eases with Transition, its widths do not (they are layout).
ui.Div().BorderEdges(ui.Edges{Bottom: 2}, accent) // an underline
func (*DivElement) Bottom ¶
func (d *DivElement) Bottom(px float32) *DivElement
Bottom sets the bottom inset of an Absolute element, in logical pixels (see Top).
func (*DivElement) CapturePointer ¶
func (d *DivElement) CapturePointer() *DivElement
CapturePointer keeps delivering mouse move and up events to the element while a button pressed on it is held, even when the pointer leaves it (drag gestures such as sliders or text selection).
func (*DivElement) Center ¶
func (d *DivElement) Center() *DivElement
Center centers children on both axes.
func (*DivElement) Child ¶
func (d *DivElement) Child(e Element) *DivElement
Child appends one child. nil is ignored.
func (*DivElement) Children ¶
func (d *DivElement) Children(es ...Element) *DivElement
Children appends children. nil entries are ignored.
func (*DivElement) ClipContent ¶
func (d *DivElement) ClipContent() *DivElement
ClipContent hides children that overflow the element.
func (*DivElement) Column ¶
func (d *DivElement) Column() *DivElement
Column lays children out vertically (the default).
func (*DivElement) ContextMenu ¶
func (d *DivElement) ContextMenu(build func() []MenuItem) *DivElement
ContextMenu opens a menu when the element is right-clicked, or when it has focus and Shift+F10 or the Menu key is pressed. The menu opens at the pointer, or below the focused element for the keyboard. build runs when the menu opens; an empty result opens nothing. The menu closes as the menus of a menu bar do.
func (*DivElement) Cursor ¶
func (d *DivElement) Cursor(c Cursor) *DivElement
Cursor sets the mouse cursor shown over the element.
func (*DivElement) DescribedBy ¶
func (d *DivElement) DescribedBy(keys ...string) *DivElement
DescribedBy describes the element by the text of the elements with the given keys, read after its name.
func (*DivElement) Description ¶
func (d *DivElement) Description(s string) *DivElement
Description adds help text, which assistive technology reads after the name.
func (*DivElement) Display ¶
func (d *DivElement) Display(on bool) *DivElement
Display shows the element when on is true. Display(false) hides it as CSS display: none does, but keeps it in the tree: its component instances, Local state, signals, text and selection, scroll positions and list state survive, so Display(true) shows it again as it was. While hidden, the element and its subtree take no space in layout, are not painted, are not hit, are skipped by Tab and cannot take focus, are absent from the accessibility tree, and run no repeating animation or frame. A focused element that becomes hidden hands focus to its nearest focusable ancestor, or to nothing when there is none.
AccessHidden is a different thing: it only leaves the element out of the accessibility tree, and the element is still drawn, laid out and reachable. Use Display for content that should not be seen or reached, and AccessHidden for content that is seen but not announced.
func (*DivElement) Dragging ¶
func (d *DivElement) Dragging(s Style) *DivElement
Dragging merges s on top while this element is the source of a drag. It is the feedback for an element that is dragged in place, such as dimming it.
func (*DivElement) Enter ¶
func (d *DivElement) Enter(m Motion, a Animation) *DivElement
Enter makes the element animate into place when it first appears: it starts with the look of m and moves to its normal look over a. Elements that were already there do not enter again.
ui.Div().Enter(ui.Fade().Slide(0, -6), ui.Animation{Duration: 140 * time.Millisecond})
func (*DivElement) Exit ¶
func (d *DivElement) Exit(m Motion, a Animation) *DivElement
Exit keeps the element drawn while it animates to the look of m over a, after it has been removed from the tree. The exiting element leaves the layout at once, so its siblings move straight away; while it exits it is drawn above its former siblings, and it cannot be hit, focused or found by Find.
func (*DivElement) Flex ¶
func (d *DivElement) Flex() *DivElement
Flex is accepted for readability; every Div is already a flex container.
func (*DivElement) FocusHandle ¶
func (d *DivElement) FocusHandle(h *FocusHandle) *DivElement
FocusHandle attaches h, so the element can be focused from code with h.Focus(). It implies Focusable.
func (*DivElement) FocusVisible ¶
func (d *DivElement) FocusVisible(s Style) *DivElement
FocusVisible merges s on top while the element has focus and focus is keyboard-driven: it arrived by Tab or a key press and no click has happened since. It is the focus ring to use for controls; Focused applies even after a click. It implies Focusable.
func (*DivElement) FocusWithin ¶
func (d *DivElement) FocusWithin(s Style) *DivElement
FocusWithin merges s on top while the element or any descendant has keyboard focus — for example to highlight a field's frame while the text inside it is being edited.
func (*DivElement) Focusable ¶
func (d *DivElement) Focusable() *DivElement
Focusable lets the element take keyboard focus when clicked or tabbed to.
func (*DivElement) Focused ¶
func (d *DivElement) Focused(s Style) *DivElement
Focused merges s on top while the element has keyboard focus. It implies Focusable.
func (*DivElement) FontSize ¶
func (d *DivElement) FontSize(px float32) *DivElement
FontSize sets the inherited font size.
func (*DivElement) FontWeight ¶
func (d *DivElement) FontWeight(w FontWeight) *DivElement
FontWeight sets the inherited font weight.
func (*DivElement) Gap ¶
func (d *DivElement) Gap(px float32) *DivElement
Gap sets the space between children.
func (*DivElement) Grid ¶
func (d *DivElement) Grid(columns ...Length) *DivElement
Grid lays the children out in a grid, in place of a row or column: one cell each, row by row, with a column for each size in columns. A column of Px or Percent takes that width; AutoFill, as the only track, makes as many equal columns as fit; Auto fits its widest item (shrinking towards the narrowest wrap of its text when the grid is too narrow); Fr takes a share of what the others leave. Rows are as tall as their tallest item, unless GridRows sizes them. Gap separates rows and columns. A child covers more cells with GridSpan; one that does not fit in the rest of its row starts the next one. Items fill their cells unless they have a size of their own, and AlignSelf (or Align on the grid) places them in a taller row.
ui.Div().Grid(ui.Auto, ui.Fr(1)).Gap(12).
Child(ui.Text("Name")).Child(ui.TextInput(name)).
Child(ui.Text("Notes")).Child(ui.TextArea(notes))
func (*DivElement) GridRows ¶
func (d *DivElement) GridRows(rows ...Length) *DivElement
GridRows sizes the first rows of a grid, as Grid sizes its columns; rows past them fit their content. Fr rows share the grid's height, when it has one.
func (*DivElement) GridSpan ¶
func (d *DivElement) GridSpan(cols, rows int) *DivElement
GridSpan makes the element cover cols columns and rows rows of the grid it is in (see Grid).
func (*DivElement) Grow ¶
func (d *DivElement) Grow(f float32) *DivElement
Grow makes the element take a share of the free space on its parent's main axis.
func (*DivElement) Heading ¶
func (d *DivElement) Heading(level int) *DivElement
Heading makes the element a heading of the given level, 1 to 6. Its text is its name. Heading panics for any other level.
func (*DivElement) Height ¶
func (d *DivElement) Height(l Length) *DivElement
Height sets the height (border box).
func (*DivElement) Hover ¶
func (d *DivElement) Hover(s Style) *DivElement
Hover merges s on top while the pointer is over the element.
func (*DivElement) IME ¶
func (d *DivElement) IME(m IME) *DivElement
IME makes the focused element take the composition of an input method itself, through the hooks of m (see IME).
func (*DivElement) Inset ¶
func (d *DivElement) Inset(px float32) *DivElement
Inset pins all four sides (Absolute + Top/Right/Bottom/Left).
func (*DivElement) Justify ¶
func (d *DivElement) Justify(a Alignment) *DivElement
Justify distributes children on the main axis: Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly.
func (*DivElement) KeepFocus ¶
func (d *DivElement) KeepFocus() *DivElement
KeepFocus makes a press inside the element leave focus where it is, as the list of a combo box does: the press does not blur the text field that owns the list, so the field keeps its caret and its list stays open while the click picks a row. A focusable element inside it still takes focus when it is pressed. It is the press half of a browser's preventDefault on mousedown; the element's own handlers still run.
func (*DivElement) Key ¶
func (d *DivElement) Key(k string) *DivElement
Key gives the element a stable identity among its siblings, so its state (hover, scroll position, focus, animations) survives reordering.
func (*DivElement) KeyContext ¶
func (d *DivElement) KeyContext(spec string) *DivElement
KeyContext names this element for contextual key bindings (BindIn). spec is whitespace-separated entries, each an identifier ("Editor") or a key=value pair ("mode=full"), as in GPUI. The bindings a context enables apply while focus is on the element or inside it, so a palette can own the arrow keys while its field has focus:
ui.Div().KeyContext("Palette").Child(ui.TextInput(query))
KeyContext panics on a malformed spec, such as "Editor mode=".
func (*DivElement) Keyf ¶
func (d *DivElement) Keyf(format string, args ...any) *DivElement
Keyf is Key with fmt.Sprintf formatting.
func (*DivElement) Label ¶
func (d *DivElement) Label(s string) *DivElement
Label names the element for assistive technology. It wins over the text the element contains, so it is also how an element with no visible text (an icon-only button, for example) gets a name.
func (*DivElement) LabelledBy ¶
func (d *DivElement) LabelledBy(keys ...string) *DivElement
LabelledBy names the element by the text of the elements with the given keys, such as a visible label above a field. The keys are the Key of those elements.
func (*DivElement) Left ¶
func (d *DivElement) Left(px float32) *DivElement
Left sets the left inset of an Absolute element, in logical pixels (see Top).
func (*DivElement) Margin ¶
func (d *DivElement) Margin(px float32) *DivElement
Margin sets margin on all sides.
func (*DivElement) MarginBottom ¶
func (d *DivElement) MarginBottom(px float32) *DivElement
MarginBottom sets the bottom margin.
func (*DivElement) MarginLeft ¶ added in v0.4.0
func (d *DivElement) MarginLeft(px float32) *DivElement
MarginLeft sets the left margin.
func (*DivElement) MarginRight ¶ added in v0.4.0
func (d *DivElement) MarginRight(px float32) *DivElement
MarginRight sets the right margin.
func (*DivElement) MarginTop ¶
func (d *DivElement) MarginTop(px float32) *DivElement
MarginTop sets the top margin.
func (*DivElement) MarginX ¶
func (d *DivElement) MarginX(px float32) *DivElement
MarginX sets left and right margin.
func (*DivElement) MarginY ¶
func (d *DivElement) MarginY(px float32) *DivElement
MarginY sets top and bottom margin.
func (*DivElement) MaxHeight ¶
func (d *DivElement) MaxHeight(l Length) *DivElement
MaxHeight sets the largest height of the element.
func (*DivElement) MaxWidth ¶
func (d *DivElement) MaxWidth(l Length) *DivElement
MaxWidth sets the largest width of the element.
func (*DivElement) MinHeight ¶
func (d *DivElement) MinHeight(l Length) *DivElement
MinHeight sets the smallest height of the element.
func (*DivElement) MinWidth ¶
func (d *DivElement) MinWidth(l Length) *DivElement
MinWidth sets the smallest width of the element.
func (*DivElement) Offset ¶
func (d *DivElement) Offset(x, y float32) *DivElement
Offset moves the element by (x, y) logical pixels after layout. Its place in the layout does not change, so siblings stay put; hit testing and Find follow the element. Combine with Transition to slide it.
func (*DivElement) OnAction ¶
func (d *DivElement) OnAction(a *Action, fn func()) *DivElement
OnAction runs fn when a is dispatched while focus is on this element or inside it: by a key binding, by ctx.Dispatch or by the command palette. The deepest element with a handler for a wins. A later OnAction for the same action replaces the earlier one.
func (*DivElement) OnBlur ¶
func (d *DivElement) OnBlur(fn func()) *DivElement
OnBlur sets the function that runs when the element loses keyboard focus, and makes it focusable.
func (*DivElement) OnClick ¶
func (d *DivElement) OnClick(fn func()) *DivElement
OnClick runs fn when the element is pressed and released with the primary button. The deepest element with a click handler wins; ancestors are not also clicked.
func (*DivElement) OnClickOutside ¶
func (d *DivElement) OnClickOutside(fn func()) *DivElement
OnClickOutside runs fn when any mouse button is pressed outside the element and its descendants, for closing menus and popovers. On an Overlay, presses on its parent (the anchor) count as inside, so the anchor's own OnClick decides what happens instead of closing and then reopening. Escape also runs fn on an Overlay: it closes the topmost open one, one per press.
func (*DivElement) OnDoubleClick ¶
func (d *DivElement) OnDoubleClick(fn func()) *DivElement
OnDoubleClick sets the function that runs on a double-click on the element.
func (*DivElement) OnDrag ¶
func (d *DivElement) OnDrag(s *DragSpec) *DivElement
OnDrag makes the element a drag source. The drag starts once the pointer moves 4 px with the primary button held; a press that does not move is a click, as before.
func (*DivElement) OnDrop ¶
func (d *DivElement) OnDrop(t DropTarget) *DivElement
OnDrop makes the element a drop target. It may be called several times, for payloads of different types; a drop goes to the first target that accepts it on the deepest element.
func (*DivElement) OnFocus ¶
func (d *DivElement) OnFocus(fn func()) *DivElement
OnFocus sets the function that runs when the element gets keyboard focus, and makes it focusable.
func (*DivElement) OnGridColumns ¶ added in v0.6.1
func (d *DivElement) OnGridColumns(fn func(n int)) *DivElement
OnGridColumns calls fn with the number of columns of the element's grid when it is first laid out and each time it changes, as with an AutoFill track whose window is resized. fn may set signals: what it changes is built and laid out again before the frame ends, so it is never shown a frame late. Use it for a strip that shows one row of as many cards as fit:
cols := ui.Local(ctx, "cols", 1) ui.Div().Grid(ui.AutoFill(260)).Gap(16).OnGridColumns(cols.Set). Children(cards(apps[:min(cols.Get(), len(apps))])...)
The count depends only on the grid's width and gap, not on its children, so changing the children in fn does not change it again.
func (*DivElement) OnKeyDown ¶
func (d *DivElement) OnKeyDown(fn func(*KeyEvent)) *DivElement
OnKeyDown receives key presses while this element or a descendant has focus (or, on the root element, when nothing has focus).
func (*DivElement) OnKeyUp ¶
func (d *DivElement) OnKeyUp(fn func(*KeyEvent)) *DivElement
OnKeyUp sets the function that runs when a key is released while the element has focus.
func (*DivElement) OnMouseDown ¶
func (d *DivElement) OnMouseDown(fn func(*MouseEvent)) *DivElement
OnMouseDown sets the function that runs when a mouse button is pressed over the element.
func (*DivElement) OnMouseEnter ¶
func (d *DivElement) OnMouseEnter(fn func()) *DivElement
OnMouseEnter sets the function that runs when the pointer enters the element.
func (*DivElement) OnMouseLeave ¶
func (d *DivElement) OnMouseLeave(fn func()) *DivElement
OnMouseLeave sets the function that runs when the pointer leaves the element.
func (*DivElement) OnMouseMove ¶
func (d *DivElement) OnMouseMove(fn func(*MouseEvent)) *DivElement
OnMouseMove sets the function that runs when the pointer moves over the element.
func (*DivElement) OnMouseUp ¶
func (d *DivElement) OnMouseUp(fn func(*MouseEvent)) *DivElement
OnMouseUp sets the function that runs when a mouse button is released over the element.
func (*DivElement) OnPinch ¶
func (d *DivElement) OnPinch(fn func(*PinchEvent)) *DivElement
OnPinch receives the pinch gestures of a touchpad or touchscreen whose center is over the element (see PinchEvent). A handler that stops the event keeps the window from zooming, as it keeps the window from scrolling for OnScroll.
func (*DivElement) OnScroll ¶
func (d *DivElement) OnScroll(fn func(*ScrollEvent)) *DivElement
OnScroll sets the function that runs when the wheel or the trackpad scrolls over the element.
func (*DivElement) OnTextInput ¶
func (d *DivElement) OnTextInput(fn func(string)) *DivElement
OnTextInput receives typed text while focused. It implies Focusable.
func (*DivElement) Opacity ¶
func (d *DivElement) Opacity(o float32) *DivElement
Opacity fades the element and its children (0..1).
func (*DivElement) Overlay ¶
func (d *DivElement) Overlay(p Placement) *DivElement
Overlay makes the element float: it is positioned next to its parent's border box at placement p (4 px away unless OverlayGap says otherwise), painted after the rest of the window, never clipped by ancestors and hit-tested before everything else. If it does not fit on the requested side it flips to the opposite side when that has more room, then shifts to stay at least 8 px inside the window.
func (*DivElement) OverlayGap ¶
func (d *DivElement) OverlayGap(px float32) *DivElement
OverlayGap sets the distance between an Overlay and its parent.
func (*DivElement) Padding ¶
func (d *DivElement) Padding(px float32) *DivElement
Padding sets padding on all sides.
func (*DivElement) PaddingBottom ¶ added in v0.4.0
func (d *DivElement) PaddingBottom(px float32) *DivElement
PaddingBottom sets the bottom padding.
func (*DivElement) PaddingEdges ¶
func (d *DivElement) PaddingEdges(e Edges) *DivElement
PaddingEdges sets each side's padding. It replaces all four sides: a side the Edges leaves at zero gets no padding, whatever Padding, PaddingX or PaddingY set before it.
func (*DivElement) PaddingLeft ¶ added in v0.4.0
func (d *DivElement) PaddingLeft(px float32) *DivElement
PaddingLeft sets the left padding.
func (*DivElement) PaddingRight ¶ added in v0.4.0
func (d *DivElement) PaddingRight(px float32) *DivElement
PaddingRight sets the right padding.
func (*DivElement) PaddingTop ¶ added in v0.4.0
func (d *DivElement) PaddingTop(px float32) *DivElement
PaddingTop sets the top padding.
func (*DivElement) PaddingX ¶
func (d *DivElement) PaddingX(px float32) *DivElement
PaddingX sets left and right padding.
func (*DivElement) PaddingY ¶
func (d *DivElement) PaddingY(px float32) *DivElement
PaddingY sets top and bottom padding.
func (*DivElement) Play ¶ added in v0.4.0
func (d *DivElement) Play(key any, frames []Keyframe, a Animation) *DivElement
Play runs the element through keyframes over a: at each stop's At it has the look of the stop's Motion, and between stops it moves from one look to the next. A missing stop at 0 or at 1 is the element's normal look, so a single stop at 0.5 rises from and returns to the element as it is. It plays when the element first appears and again whenever key changes; key must be comparable, as a map key is. With Repeat it loops for as long as it is drawn.
ui.Div().Play("pulse", []ui.Keyframe{{At: 0.5, Motion: ui.Grow(1.06).Opacity(0.8)}},
ui.Animation{Duration: 600 * time.Millisecond, Repeat: true})
Like Enter, it is paint-only: it costs no layout, and an element that is not drawn (scrolled or clipped out of view, or hidden by Display) asks for no frames. The progress is time based, so when it is drawn again it shows the progress of that moment.
func (*DivElement) Pressed ¶
func (d *DivElement) Pressed(s Style) *DivElement
Pressed merges s on top while the element is being pressed.
func (*DivElement) Radius ¶
func (d *DivElement) Radius(r float32) *DivElement
Radius rounds all corners.
func (*DivElement) RadiusCorners ¶
func (d *DivElement) RadiusCorners(c Corners) *DivElement
RadiusCorners rounds each corner separately.
func (*DivElement) Right ¶
func (d *DivElement) Right(px float32) *DivElement
Right sets the right inset of an Absolute element, in logical pixels (see Top).
func (*DivElement) Role ¶
func (d *DivElement) Role(r access.Role) *DivElement
Role gives the element an accessibility role, such as access.RoleCheckBox. Built-in widgets set their own roles; use Role for a custom control.
func (*DivElement) Scale ¶
func (d *DivElement) Scale(s float32) *DivElement
Scale draws the element and its children s times their size about the element's center (1 = normal). Hit testing ignores scale, so a scaled element is hit where it is laid out. Overlays inside a scaled element are placed by their unscaled anchor.
func (*DivElement) ScrollX ¶
func (d *DivElement) ScrollX() *DivElement
ScrollX makes content scroll horizontally (and clips it).
func (*DivElement) ScrollY ¶
func (d *DivElement) ScrollY() *DivElement
ScrollY makes content scroll vertically (and clips it).
func (*DivElement) SelectionContainer ¶
func (d *DivElement) SelectionContainer() *DivElement
SelectionContainer marks the element as the group that holds selection items, such as the filter chips or the list of notes. Each item reports the group it belongs to, and the group reports its chosen items.
func (*DivElement) Shadow ¶
func (d *DivElement) Shadow(s Shadow) *DivElement
Shadow adds a drop shadow (call repeatedly to layer shadows).
func (*DivElement) Shrink ¶
func (d *DivElement) Shrink(f float32) *DivElement
Shrink sets how much the element shrinks when space is short (default 1).
func (*DivElement) Size ¶
func (d *DivElement) Size(w, h Length) *DivElement
Size sets width and height.
func (*DivElement) Spring ¶ added in v0.4.0
func (d *DivElement) Spring(s Spring) *DivElement
Spring moves changes of Opacity, Offset and Scale as a damped spring (see Spring), so they can overshoot, and a change that comes mid-flight keeps the velocity of the motion. Colors keep easing as a Transition does, never overshooting: over the Transition when one is set, and over the spring's Duration otherwise.
ui.Div().Spring(ui.Spring{Duration: 300 * time.Millisecond, Bounce: 0.2}).
Hover(ui.Style{Scale: 1.04})
func (*DivElement) Style ¶
func (d *DivElement) Style(s Style) *DivElement
Style merges s into the element's style (set fields win).
func (*DivElement) TabIndex ¶
func (d *DivElement) TabIndex(i int) *DivElement
TabIndex sets where the element sits in the Tab order and implies Focusable. Elements with a positive index come first, in ascending order (ties in tree order); the rest, at index 0, follow in tree order, as in HTML. Shift+Tab walks the order backwards. A negative index keeps the element focusable by click or handle, but Tab skips it.
func (*DivElement) TabStop ¶
func (d *DivElement) TabStop(on bool) *DivElement
TabStop(false) makes Tab skip the element while it stays focusable by click or handle; TabStop(true) puts it back in the Tab order. It does not make an element focusable on its own.
func (*DivElement) TextAccess ¶
func (d *DivElement) TextAccess(t TextAccess) *DivElement
TextAccess gives the element the Text pattern of a text field or text area, for an element that draws its own text (see TextAccess). Its role should be access.RoleTextArea.
func (*DivElement) TextColor ¶
func (d *DivElement) TextColor(c Color) *DivElement
TextColor sets the inherited text and icon color.
func (*DivElement) Tooltip ¶
func (d *DivElement) Tooltip(s string) *DivElement
Tooltip shows s in a small floating label below the element after the pointer has rested on it for half a second. An empty string means none.
func (*DivElement) Top ¶
func (d *DivElement) Top(px float32) *DivElement
Top, Right, Bottom and Left position an Absolute element relative to its parent's padding box.
func (*DivElement) Transition ¶
func (d *DivElement) Transition(t time.Duration) *DivElement
Transition eases changes of color, Opacity, Offset and Scale over the given duration. Paint-only properties ease without a re-layout.
func (*DivElement) When ¶
func (d *DivElement) When(cond bool, fn func(d *DivElement)) *DivElement
When applies fn only if cond is true; handy for conditional styling:
ui.Div().When(selected, func(d *ui.DivElement) { d.Background(accent) })
func (*DivElement) Width ¶
func (d *DivElement) Width(l Length) *DivElement
Width sets the width (border box).
func (*DivElement) WindowArea ¶
func (d *DivElement) WindowArea(a WindowArea) *DivElement
WindowArea marks d as part of the window's title bar. Elements inside an WindowAreaDrag element are dragged with the window too, unless they take input of their own (see WindowAreaAt): a search box or a button in the title bar stays usable. In a window whose title bar the app draws, the platform runs the button areas' actions for the pointer, so an OnClick on such an element runs only for the keyboard and assistive technology, and must do the same thing.
func (*DivElement) Wrap ¶
func (d *DivElement) Wrap() *DivElement
Wrap lets children flow onto additional lines (rows of chips, tag clouds, galleries). Gap spaces the lines as well as the items.
func (*DivElement) ZIndex ¶
func (d *DivElement) ZIndex(z int) *DivElement
ZIndex paints the element above (higher) or below (lower) its siblings.
type DockElement ¶
type DockElement struct {
// contains filtered or unexported fields
}
DockElement is a dock: the panels of a DockLayout, in splits and tab groups that the user rearranges. See Dock.
func Dock ¶
func Dock(layout *Signal[DockLayout], panels map[string]DockPanel) *DockElement
Dock shows the panels of layout, which the app owns, so that the app can save the layout with its settings and load it back. Each panel is named by an ID that the layout holds, and is shown from panels; a panel ID in the layout that panels does not have is dropped when the dock is shown, and a panel of panels that the layout does not hold is hidden until DockLayout.Show shows it.
The dock is split and grouped as its layout says. Each group is a tab strip over its panels, and each divider between groups is a Split. A user moves a panel by dragging its tab over a group, which shows the zone the panel will land in (the center adds it as a tab, a side makes a group beside that one), or over an outer edge of the dock. The tab's menu, opened with the context menu key or Shift+F10, moves a panel to the group on a side, splits a group, floats a panel, or closes it. Ctrl+Shift with an arrow key moves a panel to the group on that side. Ctrl+Tab and Ctrl+Shift+Tab select the next and previous panel of a group, and Ctrl+F6 moves focus to the next group.
OnChange runs after each change the user makes, so the app can save the layout. A divider dragged, or a floating window moved or resized, is saved late: OnChange runs once the layout has been still for half a second, and at the end of a divider drag. A dock fills its container, as Split does; give it a size or a grow factor in a column with other children. See the Docking section of docs/layout.md.
func (*DockElement) Floating ¶
func (d *DockElement) Floating(open func(DockWindow) Window) *DockElement
Floating lets the groups of the layout float in windows of their own. open opens the window of a floating group and returns it; app.OpenDockWindow does so with app.Open, which the ui package cannot import. The dock opens a window for each floating group it does not have one for, and closes the window of a group that docks back. Without Floating, the floating groups of the layout are not shown, and the panel's Float command is disabled.
A tab dragged out of its window and released where no dock takes it floats its panel in a window at the pointer. A tab released over a group of another window of the dock moves there. A floating window shows its group, and the Float and Dock back commands move a panel between windows as well. Set QuitWhenClosed on the main window of the app, so that closing it closes the floating windows too; their positions are recorded as they close, and as the user moves them.
func (*DockElement) GridSpan ¶
func (d *DockElement) GridSpan(cols, rows int) *DockElement
GridSpan sets how many columns and rows the dock covers in its parent's grid.
func (*DockElement) Grow ¶
func (d *DockElement) Grow(f float32) *DockElement
Grow makes the dock take a share of the free space on its parent's main axis.
func (*DockElement) Height ¶
func (d *DockElement) Height(l Length) *DockElement
Height sets the height of the dock.
func (*DockElement) Key ¶
func (d *DockElement) Key(k string) *DockElement
Key gives the dock a stable identity among its siblings. It also scopes the keys of its tabs and panels, so give two docks in one window different keys.
func (*DockElement) MaxHeight ¶
func (d *DockElement) MaxHeight(l Length) *DockElement
MaxHeight sets the largest height of the dock.
func (*DockElement) MaxWidth ¶
func (d *DockElement) MaxWidth(l Length) *DockElement
MaxWidth sets the largest width of the dock.
func (*DockElement) MinHeight ¶
func (d *DockElement) MinHeight(l Length) *DockElement
MinHeight sets the smallest height of the dock.
func (*DockElement) MinWidth ¶
func (d *DockElement) MinWidth(l Length) *DockElement
MinWidth sets the smallest width of the dock.
func (*DockElement) OnChange ¶
func (d *DockElement) OnChange(fn func(DockLayout)) *DockElement
OnChange runs fn with the new layout after the user changes it: a panel moved, a divider moved, a tab selected, a panel floated, docked back or closed, or a floating window closed. The signal is set first. Use it to save the layout.
func (*DockElement) Styles ¶
func (d *DockElement) Styles(s DockStyle) *DockElement
Styles sets the look of the parts of the dock, for this instance only. Set fields win over the theme's Dock and the defaults; see DockStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*DockElement) Width ¶
func (d *DockElement) Width(l Length) *DockElement
The sizing methods give the dock's outer box a size. A dock fills its container by default; see Sizing in docs/styling.md.
type DockFloat ¶
type DockFloat struct {
// ID identifies the floating group.
ID string `json:"id"`
// Group is the tree of splits and tab groups of the floating window.
Group DockNode `json:"group"`
// X is the horizontal position of the window, in logical screen pixels.
X int `json:"x"`
// Y is the vertical position of the window, in logical screen pixels.
Y int `json:"y"`
// Width is the width of the window's content, in logical pixels.
Width int `json:"width"`
// Height is the height of the window's content, in logical pixels.
Height int `json:"height"`
// Home is where the group's first panel was docked before it floated, so that
// docking it back returns it there. Nil docks it along the right edge.
Home *DockHome `json:"home,omitempty"`
}
DockFloat is a tab group that floats in a window of its own. ID names the window. X and Y are the window's position and Width and Height its size, in logical pixels: they are the position it opens at, and they are recorded when the window closes.
type DockHome ¶ added in v0.5.0
type DockHome struct {
Panel string `json:"panel"`
Zone DockZone `json:"zone"`
Index int `json:"index,omitempty"`
}
DockHome is the place a panel was docked at, by a panel beside it: a tab of Panel's group, at Index, when Zone is DockCenter, or a group of its own on the Zone side of Panel's group.
type DockLayout ¶
type DockLayout struct {
// Root is the root of the tree of splits and groups.
Root DockNode `json:"root"`
// Floating lists the groups that float, each in its own window.
Floating []DockFloat `json:"floating,omitempty"`
}
DockLayout is the layout of a Dock: the root node of the tree of splits and groups, and the floating groups. A zero DockLayout is an empty dock.
func (DockLayout) Clone ¶
func (l DockLayout) Clone() DockLayout
Clone returns a copy of l, the layout an app starts from. An app's Reset layout command sets the layout to it.
func (DockLayout) Close ¶
func (l DockLayout) Close(id string) DockLayout
Close returns l without the panel id. A closed panel is shown again with DockLayout.Show.
func (DockLayout) Dock ¶
func (l DockLayout) Dock(id string) DockLayout
Dock returns l with the panel id taken out of its floating group and docked back into the dock where it was before it floated: as a tab of the group it left, or as a group of its own beside the group it was next to (see DockFloat.Home). When that place is gone, because the panel it was next to has gone too, or the panel was not the one that floated the group, it docks as a group along the right edge. A panel that is docked already, or that does not float, leaves the layout as it is.
func (DockLayout) Float ¶
func (l DockLayout) Float(id string, x, y, w, h int) DockLayout
Float returns l with the panel id moved out of its group into a floating group of its own, in a window at x, y of w by h logical pixels. The window's ID is the lowest free one of the form float-1. A panel that already floats alone only has its window's position and size set. A panel that l does not hold leaves the layout as it is.
func (DockLayout) Focus ¶
func (l DockLayout) Focus(id string) DockLayout
Focus returns l with the panel id shown in its group, so that it is the active tab. A panel that l does not hold leaves the layout as it is.
func (DockLayout) Has ¶
func (l DockLayout) Has(id string) bool
Has reports whether the layout holds the panel id, docked or floating.
func (DockLayout) Move ¶
func (l DockLayout) Move(id, target string, zone DockZone) DockLayout
Move returns l with the panel id moved to the zone of the group that holds the panel target. The panel leaves its group, and a group left empty goes. A target of "" names the whole dock: a side zone then puts the panel along that outer edge, and DockCenter does nothing. A target that is the panel itself names the group the panel is in, so a side zone splits that group, with the other panels of it.
A floating group holds one group and has no sides, so a side zone onto a panel that floats does nothing, and a panel dropped at the center of a floating group joins it. A move that cannot happen, such as a panel alone in its group dropped beside it, or a target the layout does not hold, leaves the layout as it is.
func (DockLayout) MoveSide ¶
func (l DockLayout) MoveSide(id string, side DockZone) DockLayout
MoveSide returns l with the panel id moved into the group beside its own, on the side given (DockLeft, DockRight, DockTop or DockBottom), as one of its tabs. When no group lies that way, the layout is unchanged. It is the keyboard move of a panel.
func (DockLayout) Show ¶
func (l DockLayout) Show(id string) DockLayout
Show returns l with the panel id shown. A panel that the layout already holds is made the active tab of its group. Otherwise it joins the first group of the dock, in reading order, as its active tab, or it fills an empty dock.
type DockNode ¶
type DockNode struct {
// Vertical reports whether a split stacks its children from top to bottom.
Vertical bool `json:"vertical,omitempty"`
// Sizes are the share of the space that each child takes.
Sizes []float64 `json:"sizes,omitempty"`
// Children are the nodes of a split.
Children []DockNode `json:"children,omitempty"`
// Panels are the IDs of the panels in a tab group.
Panels []string `json:"panels,omitempty"`
// Active is the ID of the selected panel of a tab group.
Active string `json:"active,omitempty"`
}
DockNode is a node of the tree of a DockLayout. A node with Children is a split: its children sit side by side, or one above the other when Vertical is set, and Sizes holds the share of the split's length that each child takes, one per child. A node without children is a tab group: Panels lists the panels it holds, in tab order, and Active is the one it shows. The sizes need not sum to 1; they are normalized when the layout is used.
type DockPanel ¶
type DockPanel struct {
// Title is the name of the panel, shown on its tab and read by assistive technology.
Title string
// Icon is an icon shown on the panel's tab.
Icon *icons.Icon
// Content builds the content of the panel; see the type comment.
Content func() Element
// Closable lets the user close the panel.
Closable bool
}
DockPanel is one panel of a Dock: its title, which names its tab and its tab panel for assistive technology, its icon, and Content, which builds its content. The content keeps its state wherever the panel goes: to another group, split off, dropped on an edge, floated into a window and docked back, or put back by a layout reset. Its components keep their Local state, signals and OnDispose functions, and its text fields keep their text, undo history and selection, its scroll containers their offsets, and the panel keeps the focus when it had it. OnDispose runs only when the panel closes. A panel that moves to another window runs its Content once more there, with its state kept, so the app need not hold that state in its own signals. Closable adds a Close command to the panel's menu.
type DockStyle ¶
type DockStyle struct {
Group Style // the box of each tab group
Strip Style // the tab strip of a group
Tab Style // each tab
TabHover Style // a tab the pointer is over, if it is not the active one
TabSelected Style // the active tab of a group
TabFocusVisible Style // a tab that has keyboard focus
Indicator Style // the line under the active tab
Panel Style // the box of each panel
Preview Style // the rectangle that shows where a dragged panel lands
}
DockStyle is the look of each part of a dock. A part's style merges over the built-in defaults, then over the theme's Dock, then over the Styles of the instance; see docs/styling.md.
Group is the box of each tab group, and Strip its tab strip. Tab is each tab, with TabHover while the pointer is over a tab that is not the active one, TabSelected on the active tab, and TabFocusVisible while it has keyboard focus. Indicator is the line under the active tab, Panel the box of each panel, and Preview the rectangle that shows where a dragged panel will land. The dividers between the groups are the Theme.Split.
type DockWindow ¶
type DockWindow struct {
// Title is the title of the floating window.
Title string
// X and Y are the position of the window's top-left corner, in logical screen pixels.
X, Y int
// Width and Height are the size of the window's content, in logical pixels.
Width, Height int
// Root builds the content of the window.
Root func(ctx *Context) Element
// OnClose is called when the window is asked to close; it returns false to keep the window open.
OnClose func() bool
// OnGeometry is called as the window is moved or resized, with its position and size.
OnGeometry func(x, y, width, height int)
// OnClosed is called after the window has closed.
OnClosed func()
}
DockWindow describes the window of a floating group, for the opener that Dock.Floating takes. Root renders the group, Title names the window after its active panel, and X, Y, Width and Height place it. OnClose records the window's position and size in the layout as the window closes. OnGeometry is called as the user moves or resizes the window, in logical pixels; the layout takes the new place once the window has been still for a moment. OnClosed docks the group's panels back when the window closes, including when the user closes it, so a panel is never lost with its window. The window's own Root, Title and handlers are passed on to app.Window by app.OpenDockWindow.
type DockZone ¶
type DockZone uint8
DockZone is where a panel lands when it is moved in a Dock. DockCenter adds it to a group as a tab. The four sides give it a group of its own, beside the group it is dropped on (or along an outer edge of the whole dock, when no group is named).
const ( DockCenter DockZone = iota // the panel joins the group as a tab DockLeft // the panel gets a group of its own, to the left DockRight // the panel gets a group of its own, to the right DockTop // the panel gets a group of its own, above DockBottom // the panel gets a group of its own, below )
type DragEnd ¶
type DragEnd struct {
// Dropped is set when a target took the drop.
Dropped bool
// Cancelled is set when the drag was cancelled.
Cancelled bool
// X and Y are the pointer position at the end of the drag, in window coordinates.
X, Y float32
}
DragEnd says how a drag ended, for DragSpec.End. Dropped is set when a target took the payload, and Cancelled when Escape or the window losing focus ended the drag. Otherwise the button was released with no target under the pointer, and X and Y are the pointer's position on the screen in logical pixels, which may lie outside the window. They are zero when the drag was cancelled.
type DragSpec ¶
type DragSpec struct {
// contains filtered or unexported fields
}
DragSpec describes a drag: the payload it carries and what is shown while it runs. Create one with Drag.
func Drag ¶
Drag makes a payload of type T that an element can be dragged with. Drop targets accept it by its Go type, so a Drop[*Note] only receives *Note.
func (*DragSpec) End ¶
End runs fn after the drag ends, with how it ended (see DragEnd). Dropped is true when a target took the payload, and false when the drag was cancelled or released over nothing. Where the drag ended, on the screen, is reported too, so that fn can float a panel where the user let go of it.
type DrawerElement ¶
type DrawerElement struct {
// contains filtered or unexported fields
}
DrawerElement is a panel that slides in from an edge of the window over a dimmed backdrop, with a title, a body and footer buttons: settings, details or filters that need more room than a popover. It is a modal: build it only while it is open, last in the window's root element, as a Modal is.
ui.If(open.Get(), ui.Drawer("Filters", filters).
Side(ui.DrawerRight).Footer(reset, apply).OnClose(close))
Focus moves into it when it opens and returns when it closes, Tab stays inside it, and Escape or a press on the backdrop closes it (see OnClose).
func Drawer ¶
func Drawer(title string, body Element) *DrawerElement
Drawer creates a drawer with a title and a body, at the right edge.
func (*DrawerElement) CloseButton ¶ added in v0.4.0
func (d *DrawerElement) CloseButton(show bool) *DrawerElement
CloseButton shows a close button at the top right of the drawer, when show is set (see Modal.CloseButton).
func (*DrawerElement) CloseOnClickOutside ¶ added in v0.4.0
func (d *DrawerElement) CloseOnClickOutside() *DrawerElement
CloseOnClickOutside makes a press outside the drawer close it (see Modal.CloseOnClickOutside). A modal drawer closes on a press on its backdrop already.
func (*DrawerElement) Default ¶
func (d *DrawerElement) Default(b *ButtonElement) *DrawerElement
Default makes b the default button: Enter runs its OnClick (see Modal.Default).
func (*DrawerElement) Footer ¶
func (d *DrawerElement) Footer(buttons ...Element) *DrawerElement
Footer sets the buttons under the body, at the right, in the order given.
func (*DrawerElement) Height ¶
func (d *DrawerElement) Height(l Length) *DrawerElement
Height sets the height of the drawer.
func (*DrawerElement) InitialFocus ¶
func (d *DrawerElement) InitialFocus(h *FocusHandle) *DrawerElement
InitialFocus sets the element that takes focus when the drawer opens (see Modal.InitialFocus).
func (*DrawerElement) Key ¶
func (d *DrawerElement) Key(k string) *DrawerElement
Key identifies the drawer among its siblings (see DivElement.Key).
func (*DrawerElement) MaxHeight ¶
func (d *DrawerElement) MaxHeight(l Length) *DrawerElement
MaxHeight sets the largest height of the drawer.
func (*DrawerElement) MaxWidth ¶
func (d *DrawerElement) MaxWidth(l Length) *DrawerElement
MaxWidth sets the largest width of the drawer.
func (*DrawerElement) MinHeight ¶
func (d *DrawerElement) MinHeight(l Length) *DrawerElement
MinHeight sets the smallest height of the drawer.
func (*DrawerElement) MinWidth ¶
func (d *DrawerElement) MinWidth(l Length) *DrawerElement
MinWidth sets the smallest width of the drawer.
func (*DrawerElement) NonModal ¶ added in v0.4.0
func (d *DrawerElement) NonModal() *DrawerElement
NonModal makes the drawer non-modal: the window behind it stays usable, with no backdrop and no focus trap (see Modal.NonModal).
func (*DrawerElement) OnClose ¶
func (d *DrawerElement) OnClose(fn func()) *DrawerElement
OnClose sets what runs when the user asks for the drawer to close: Escape, or a press on the backdrop. It should remove the drawer from the app's state.
func (*DrawerElement) Side ¶
func (d *DrawerElement) Side(s DrawerSide) *DrawerElement
Side sets the edge the drawer slides in from, DrawerRight by default.
func (*DrawerElement) Styles ¶
func (d *DrawerElement) Styles(st DrawerStyle) *DrawerElement
Styles sets the look of the parts of the drawer, for this instance only.
func (*DrawerElement) Width ¶
func (d *DrawerElement) Width(l Length) *DrawerElement
The sizing methods size the panel across its side: the width of a left or right drawer (360 px by default) and the height of a top or bottom one (280 px). A percentage is of the window. See Sizing in docs/styling.md.
type DrawerSide ¶
type DrawerSide uint8
DrawerSide is the edge of the window a Drawer slides in from.
const ( DrawerRight DrawerSide = iota // the right edge, the full height of the window (the default) DrawerLeft // the left edge, the full height of the window DrawerTop // the top edge, the full width of the window DrawerBottom // the bottom edge, the full width of the window )
type DrawerStyle ¶
type DrawerStyle = ModalStyle
DrawerStyle is the look of each part of a drawer: the same parts as a modal's (Scrim, Panel, Title, Body and Footer). A part's style merges over the built-in defaults, then over the theme's Drawer, then over the Styles of the instance; see docs/styling.md.
type DrawnStyle ¶ added in v0.2.0
type DrawnStyle struct {
// Painted reports whether the latest paint drew the element. An element
// culled as off screen, or hidden by Display(false), was not, and the other
// fields are then zero.
Painted bool
// Bounds is where the element was drawn, in logical pixels, window
// coordinates, as Find reports it.
Bounds Rect
// Background is the fill. It is transparent when the element has none, and
// the first color of a gradient when Gradient is set.
Background Color
// Gradient reports whether the fill is a gradient. High contrast draws a
// gradient as its first color, and then it is not set.
Gradient bool
// BorderColor and BorderWidth are the border, widths in logical pixels.
// Both are zero when no border is drawn.
BorderColor Color
BorderWidth Edges
// TextColor is the color of the element's text and icons, and the color
// its children inherit; an icon reports its own color.
TextColor Color
// Opacity is the opacity the element was drawn with, its ancestors'
// included, and an entrance motion's too: 1 is opaque.
Opacity float32
// Scale is the element's own scale, drawn about its center, with its
// transition, spring, entrance, exit and keyframes at the point they had
// reached: 1 is none. Its ancestors' scales are not included.
Scale float32
// Ring and RingWidth are a ring drawn around the element: a shadow with a
// spread and no offset or blur, which is how the built-in controls draw
// their focus ring. RingWidth is in logical pixels, and 0 when there is no
// ring.
Ring Color
RingWidth float32
}
DrawnStyle is how the latest paint drew an element: its style with the hover, press, focus and other state styles merged in, and its transitions at the point they had reached. Runtime.StyleOf returns it, for tests and tools that check what is on screen; the ui/uitest package wraps it.
Colors are the element's own, before its opacity is applied; Opacity says how transparent it was drawn.
type DropEvent ¶
type DropEvent struct {
// X and Y are the pointer position, in window coordinates.
X, Y float32
// LocalX and LocalY are the pointer position relative to the target.
LocalX, LocalY float32
// Width and Height are the size of the target.
Width, Height float32
// Mods are the modifier keys held during the drop.
Mods input.Modifiers
}
DropEvent describes a drop, or a pointer position over a target during a drag. Coordinates are logical pixels; X and Y are relative to the window, and LocalX and LocalY relative to the target. Width and Height are the target's size, so a list row can tell which half the pointer is over:
after := e.LocalY > e.Height/2
type DropSpec ¶
type DropSpec[T any] struct { // contains filtered or unexported fields }
DropSpec is a drop target for payloads of type T. Create one with Drop.
func Drop ¶
Drop makes a drop target for payloads of type T (matched with a type assertion, so interface types work too). fn receives the payload when it is dropped on the target.
func (*DropSpec[T]) Accept ¶
Accept decides whether the target takes a payload of type T that is being dragged over it. It is like GPUI's can_drop. Without it, every payload of type T is accepted.
type DropTarget ¶
type DropTarget interface {
// contains filtered or unexported methods
}
DropTarget is a drop target for one payload type. *DropSpec[T] implements it; create one with Drop and attach it with OnDrop.
type DropdownMenuElement ¶
type DropdownMenuElement struct {
// contains filtered or unexported fields
}
DropdownMenuElement is a trigger and the menu it opens. See DropdownMenu.
func DropdownMenu ¶
func DropdownMenu(trigger Element, build func() []MenuItem) *DropdownMenuElement
DropdownMenu wraps trigger so that a click opens a menu below it. Enter, Space or Down opens it too, while trigger or a control in it has focus. build runs when the menu opens; an empty result opens nothing. The wrapper keeps the size of the trigger. The menu closes on a second click, on a press outside it, or with Escape, and focus returns to where it was.
func (*DropdownMenuElement) Key ¶
func (dm *DropdownMenuElement) Key(k string) *DropdownMenuElement
Key identifies the menu among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*DropdownMenuElement) Styles ¶
func (dm *DropdownMenuElement) Styles(st MenuStyle) *DropdownMenuElement
Styles sets the look of the parts of the menu, for this instance only. Set fields win over the theme's Menu and the defaults; see MenuStyle and docs/styling.md. Calling Styles again merges with the earlier values.
type Edges ¶
type Edges struct {
// Top is the inset of the top side, in logical pixels.
Top float32
// Right is the inset of the right side, in logical pixels.
Right float32
// Bottom is the inset of the bottom side, in logical pixels.
Bottom float32
// Left is the inset of the left side, in logical pixels.
Left float32
}
Edges are per-side insets in logical pixels. Inside a Style, a zero side means unset.
type Element ¶
type Element interface {
// contains filtered or unexported methods
}
Element is anything that can appear in the UI tree: *DivElement, *TextElement, *IconElement, *ImageElement, *ButtonElement, *TextInputElement, *ComponentElement, *UniformListElement and *ListElement. A nil Element renders nothing.
func TitleBarButtons ¶
func TitleBarButtons() Element
TitleBarButtons returns the minimize, maximize-or-restore and close buttons of a custom title bar, for its right end. They are 46 logical pixels wide, as Windows 11's are, and take the height of the bar they are in, so in a taller bar they still reach its top and bottom edges and the close button's red meets the window's corner. A bar whose height comes from its content gets 32 px buttons. Their areas are marked, so the native hit testing presses them, shows Snap Layouts over the maximize button, and performs their actions on release. The close button turns red on hover.
func ToolbarSeparator ¶ added in v0.3.0
func ToolbarSeparator() Element
ToolbarSeparator is a thin vertical line between groups of controls in a toolbar. Arrow keys pass over it. Assistive technology sees a separator.
type EmptyElement ¶ added in v0.3.0
type EmptyElement struct {
// contains filtered or unexported fields
}
EmptyElement is what a list, a table or a page shows when it has nothing to show: an icon, a title, an optional description and an optional action, such as a button that clears a filter, centered and muted. It fits the empty slots of the widgets, such as DataGrid.Empty. It is a group named by its title, with the description as its description.
func Empty ¶ added in v0.3.0
func Empty(title string) *EmptyElement
Empty creates an empty state titled title, with an inbox icon. An empty state fills the width of its container by default, and centers its parts in it.
func (*EmptyElement) Action ¶ added in v0.3.0
func (e *EmptyElement) Action(el Element) *EmptyElement
Action adds el under the description, such as a button that clears a filter or creates the first item.
func (*EmptyElement) Description ¶ added in v0.3.0
func (e *EmptyElement) Description(s string) *EmptyElement
Description sets the text under the title, such as what to do next.
func (*EmptyElement) GridSpan ¶ added in v0.3.0
func (e *EmptyElement) GridSpan(cols, rows int) *EmptyElement
GridSpan sets how many columns and rows the empty state covers in its parent's grid.
func (*EmptyElement) Grow ¶ added in v0.3.0
func (e *EmptyElement) Grow(f float32) *EmptyElement
Grow makes the empty state take a share of the free space on its parent's main axis.
func (*EmptyElement) Icon ¶ added in v0.3.0
func (e *EmptyElement) Icon(ic *icons.Icon) *EmptyElement
Icon replaces the inbox icon. Icon(nil) shows no icon.
func (*EmptyElement) Key ¶ added in v0.3.0
func (e *EmptyElement) Key(k string) *EmptyElement
Key identifies the empty state among its siblings (see DivElement.Key).
func (*EmptyElement) MaxWidth ¶ added in v0.3.0
func (e *EmptyElement) MaxWidth(l Length) *EmptyElement
MaxWidth sets the largest width of the empty state.
func (*EmptyElement) MinWidth ¶ added in v0.3.0
func (e *EmptyElement) MinWidth(l Length) *EmptyElement
MinWidth sets the smallest width of the empty state.
func (*EmptyElement) Styles ¶ added in v0.3.0
func (e *EmptyElement) Styles(st EmptyStyle) *EmptyElement
Styles sets the look of the parts of the empty state, for this instance only. Set fields win over the theme's Empty and the defaults; see EmptyStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*EmptyElement) Width ¶ added in v0.3.0
func (e *EmptyElement) Width(l Length) *EmptyElement
The sizing methods give the empty state's outer box a size. See Sizing in docs/styling.md.
type EmptyStyle ¶ added in v0.3.0
type EmptyStyle struct {
Empty Style // the box: its padding and the space between the parts
Icon Style // the icon, in its color
Title Style // the title
Description Style // the text under the title
Action Style // the box around the action
}
EmptyStyle is the look of each part of an empty state. A part's style merges over the built-in defaults, then over the theme's Empty, then over the Styles of the instance; see docs/styling.md. Empty is the box that centers the rest, Icon the icon above the title (its TextColor is the icon's color), Title and Description the two texts, and Action the box around the action, which an empty state has only when it has one.
type FieldElement ¶
type FieldElement struct {
// contains filtered or unexported fields
}
FieldElement is a labelled field: a label above its control, with optional help text, a required marker and the error the field shows. The control is named by the label, described by the help text and the error, and reports whether it is required and whether its value is valid (see docs/accessibility-design-phases-i-m.md, Phase K). Its validators (see Validate) are checked as the user works with the field, and on submit when the field belongs to a Form (see Form and docs/widgets-forms.md, Forms).
func Field ¶
func Field(label string, control Element) *FieldElement
Field creates a field with the label and the control. Add help text with Description, and mark it required with Required.
func (*FieldElement) Check ¶
func (f *FieldElement) Check(fn func() error) *FieldElement
Check sets a check of the whole field, for a group of controls that have no value of their own, such as "at least one channel". It returns the error, or nil. It runs after the control's validators. It reads its signals with Get, so the field re-renders when they change.
func (*FieldElement) Description ¶
func (f *FieldElement) Description(s string) *FieldElement
Description sets the help text under the label. It is read after the name, and it is part of the control's description, with the error.
func (*FieldElement) Error ¶
func (f *FieldElement) Error(msg string) *FieldElement
Error sets an error the app found, such as a name the server rejects. It is shown until the app clears it, and it wins over the control's validators. Like a validator's error, it keeps the form from being submitted.
func (*FieldElement) Focus ¶
func (f *FieldElement) Focus(h *FocusHandle) *FieldElement
Focus sets the element that takes focus when a form with an error is submitted, for a field whose control is a group that the field does not wire (see Check). For a control, the control takes focus, and Focus is not needed.
func (*FieldElement) Grow ¶
func (f *FieldElement) Grow(g float32) *FieldElement
Grow makes the field take a share of the free space on its parent's main axis.
func (*FieldElement) Inline ¶
func (f *FieldElement) Inline() *FieldElement
Inline puts the label beside the control, as in a settings row, instead of above it. The help text and the error stay under the control.
func (*FieldElement) Key ¶
func (f *FieldElement) Key(k string) *FieldElement
Key identifies the field among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*FieldElement) MaxWidth ¶
func (f *FieldElement) MaxWidth(l Length) *FieldElement
MaxWidth sets the largest width of the field.
func (*FieldElement) MinWidth ¶
func (f *FieldElement) MinWidth(l Length) *FieldElement
MinWidth sets the smallest width of the field.
func (*FieldElement) Required ¶
func (f *FieldElement) Required() *FieldElement
Required marks the field as required: an asterisk follows the label, and the control reports IsRequiredForForm to assistive technology.
func (*FieldElement) Styles ¶
func (f *FieldElement) Styles(st FormFieldStyle) *FieldElement
Styles sets the look of the parts of the field, for this instance only. Set fields win over the theme's FormField and the defaults; see FormFieldStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*FieldElement) Width ¶
func (f *FieldElement) Width(l Length) *FieldElement
The sizing methods give the field's outer box a size, so a form can size a labeled field as a unit. A field fills its container by default, as a column does. Its control keeps its own width: a control whose width is Auto or Full fills the field, and a fixed one keeps its size. See Sizing in docs/styling.md.
type FieldStyle ¶
type FieldStyle struct {
Frame Style // the box around the text; not drawn when a field is Borderless
FrameHover Style // the frame while the pointer is over it, if the field is enabled (paint only)
FrameFocusWithin Style // the frame while the focus is inside it (paint only)
FrameDisabled Style // the frame of a disabled field
FrameReadOnly Style // the frame of a read-only field
FrameInvalid Style // the frame of a field whose value is not valid
Text Style // the text inside the frame: TextColor and font
Placeholder Style // the placeholder, while the field is empty
Selection Style // the background of the selected text
Leading Style // the container of the icon and the Leading element, before the text
Trailing Style // the container of the Trailing element, after the text
Button Style // each button of a TextInput in the Trailing part: the clear and reveal buttons
ButtonHover Style // such a button while the pointer is over it (paint only)
}
FieldStyle is the look of the text frame of a text field: TextInput, TextArea and NumberInput. A part's style merges over the built-in defaults, then over the theme's Field, then over the Styles of the instance. A NumberInput also takes its theme's and instance's NumberInput parts; see docs/styling.md.
Frame is the box around the text. Its states are FrameHover, while the pointer is over an editable field, and FrameFocusWithin, while the focus is inside it. FrameDisabled is the frame of a disabled field, FrameReadOnly that of a read-only one (see TextInputElement.ReadOnly), and FrameInvalid that of a field whose value is not valid. Text is the text inside the frame, with its TextColor and font, and Selection is the background of the selected text. Placeholder is the text shown while a TextInput or TextArea is empty. Leading and Trailing are the containers of the content before and after the text: the icon (see Icon) and the element of Leading, and the element of Trailing. A number input has no placeholder, icon or element, so Placeholder, Leading and Trailing do not apply to it. Button is each button that a TextInput puts in its Trailing part (see Clearable and Revealable), and ButtonHover such a button while the pointer is over it; a TextArea has none. The caret is drawn in the text color, and its width and blink follow the system settings.
type Files ¶
type Files []string
Files is the payload of files dropped from the operating system: their paths. Drop[Files] receives them; see Runtime.DropFiles.
type FocusHandle ¶
type FocusHandle struct {
// contains filtered or unexported fields
}
FocusHandle lets code move keyboard focus to an element, for shortcuts like Ctrl+F or focusing a field that was just created:
search := ui.NewFocusHandle() ui.TextInput(query).FocusHandle(search) ... OnKeyDown: search.Focus()
Use it on the UI thread (in event handlers and render functions).
func NewFocusHandle ¶
func NewFocusHandle() *FocusHandle
NewFocusHandle creates a handle; attach it to one element.
func (*FocusHandle) Blur ¶
func (h *FocusHandle) Blur()
Blur removes focus from the element if it has it.
func (*FocusHandle) Focus ¶
func (h *FocusHandle) Focus()
Focus focuses the element on the next frame, after any changes made by the same event have been rebuilt. So a handle attached to a field that the event replaces (for example the title field of a newly created note) focuses the new field, not the old one.
func (*FocusHandle) FocusNow ¶
func (h *FocusHandle) FocusNow() bool
FocusNow focuses the element at once, or clears focus for a "nothing focused" handle, and reports whether it did. If the element is no longer in the tree, or is hidden by Display, it does nothing and reports false: a restore must not wait and later take focus from wherever the user has moved on to. To focus an element that is about to appear, use Focus.
func (*FocusHandle) Focused ¶
func (h *FocusHandle) Focused() bool
Focused reports whether the element has keyboard focus.
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form groups the fields of a form and submits them. Build the form once, with NewForm, and keep it across renders (in a Local, or in the app's state); its fields are made with Field, and its error summary is placed with Summary:
f := ui.NewForm().OnSubmit(func() error { return save() })
ui.Column(
f.Summary(),
f.Field("name", "Name", ui.TextInput(name).Validate(ui.Required[string]())).Required(),
ui.Button("Save").Primary().OnClick(f.Submit),
)
On submit, the form checks every field. If one has an error, focus moves to the first such field, the number of fields that need attention is announced assertively, and the summary lists each error as a link that moves focus to its field. If none has, the submit function runs. It returns an error, which the form shows as its message, or it runs its work in the background (OnSubmitAsync), and Submitting reports while it does.
Enter in a single-line field of the form submits it. A check box, switch or radio button keeps Enter for the modal's default button, as it does outside a form.
func NewForm ¶
func NewForm() *Form
NewForm creates a form with no fields and no submit function. Set one with OnSubmit or OnSubmitAsync.
func (*Form) Field ¶
func (f *Form) Field(key, label string, control Element) *FieldElement
Field makes a field of the form, with the label and the control. The key names the field in the form and in the window's keys, so it must be unique in the form. The field is checked when it is built: a field that is no longer built is dropped by Reset.
func (*Form) OnSubmit ¶
OnSubmit sets the function that runs when the form is valid. It returns nil when the work succeeded, or an error whose text the form shows as its message.
func (*Form) OnSubmitAsync ¶
OnSubmitAsync sets a submit function that takes time. It starts the work and returns a channel that receives the result: nil on success, or an error whose text the form shows. Until the result arrives, Submitting reports true, and Submit does nothing. The work runs on its own goroutine; the form receives the result on the UI thread.
func (*Form) Reset ¶
func (f *Form) Reset()
Reset clears the submitted state and the message of the form, and forgets its fields, which are added again when they are built. Call it when the fields leave the window, such as when the modal that holds them closes.
func (*Form) Submit ¶
func (f *Form) Submit()
Submit checks the form and, when it is valid, runs its submit function. It is the action of a submit button (OnClick(f.Submit)) and of Enter in a field. Submit does nothing while an async submit is running.
func (*Form) Submitting ¶
Submitting reports whether an async submit is running. Read it while building the form, so the submit button can be disabled and show progress.
func (*Form) Summary ¶
func (f *Form) Summary() *FormSummaryElement
Summary returns the error summary of the form (see FormSummaryElement).
type FormFieldStyle ¶
type FormFieldStyle struct {
Root Style // the field: a column, or a row when Inline
Label Style // the label above the control
InlineLabel Style // the label beside the control, when the field is Inline
Required Style // the asterisk after the label; hidden from assistive technology
Description Style // the help text under the label
Error Style // the row with the alert icon and the error text
}
FormFieldStyle is the look of each part of a Field. A part's style merges over the built-in defaults, then over the theme's FormField, then over the Styles of the instance; see docs/styling.md. Root is the field: a column of the label, the help text, the error and the control, or a row when the field is Inline. Label is the label, InlineLabel the label beside the control of an Inline field (merged over Label), Required the asterisk after the label, Description the help text, and Error the message row with the error. The error's icon and text take the Error part's TextColor, as a number input's message does.
type FormStyle ¶
type FormStyle struct {
Summary Style // the box of the summary, above the fields
SummaryTitle Style // the title: the number of fields that need attention
SummaryItem Style // each item: a link to its field, or the form's message
SummaryItemHover Style // an item the pointer is over, if it is a link
SummaryItemFocusVisible Style // an item with keyboard focus
}
FormStyle is the look of each part of a form's error summary. A part's style merges over the built-in defaults, then over the theme's Form, then over the Styles of the instance; see docs/styling.md. Summary is the box, with its title (SummaryTitle) and its items. Each item is a link to its field, or the form's own message. SummaryItem's hover and focus states are SummaryItemHover and SummaryItemFocusVisible.
type FormSummaryElement ¶
type FormSummaryElement struct {
// contains filtered or unexported fields
}
FormSummaryElement is the error summary of a form. It is empty until the form is submitted, and it lists the fields with a message, or the form's own message, while there are any. Place it above the fields.
func (*FormSummaryElement) Styles ¶
func (s *FormSummaryElement) Styles(st FormStyle) *FormSummaryElement
Styles sets the look of the parts of the summary, for this instance only. Set fields win over the theme's Form and the defaults; see FormStyle and docs/styling.md. Calling Styles again merges with the earlier values.
type FrameStats ¶
type FrameStats struct {
Nodes int // live nodes in the tree
Rendered int // components (and composite elements) whose render function ran
NodesBuilt int // nodes created by those renders
Restyled int // nodes restyled in place (hover, press, focus)
NodesLaidOut int // nodes whose children were re-positioned
Measured int // layout measurements that were not served from cache
NodesPainted int // nodes painted (off-screen subtrees are culled and not counted)
// Built reports whether the frame built the tree.
Built bool
// LaidOut reports whether the frame laid out the tree.
LaidOut bool
// Painted reports whether the frame painted the tree.
Painted bool
// BuildTime is the time the frame spent building the tree.
BuildTime time.Duration
// LayoutTime is the time the frame spent laying out the tree.
LayoutTime time.Duration
// PaintTime is the time the frame spent painting.
PaintTime time.Duration
// Quads is the number of quads drawn in the frame.
Quads int
// Glyphs is the number of glyphs drawn in the frame.
Glyphs int
}
FrameStats describes the work done by the last Frame call.
type GesturePhase ¶
type GesturePhase uint8
GesturePhase says where a pinch gesture is (see PinchEvent).
const ( // GestureBegin starts a gesture. It carries no change. GestureBegin GesturePhase = iota // GestureUpdate carries the change since the previous event of the gesture. GestureUpdate // GestureEnd ends a gesture. It carries no change. GestureEnd )
type Gradient ¶
type Gradient struct {
Angle float32 // degrees: 0 points up, 90 right, 180 down (as in CSS)
// From and To are the colors at the start and the end of the gradient.
From, To Color
FromAt, ToAt float32 // stop positions 0..1; both zero means 0 and 1
Oklab bool // interpolate in Oklab (smoother, no muddy middle); default sRGB like GPUI
}
Gradient is a linear gradient background. The zero value is unset. A gradient replaces the element's Background when both are set. Build one with LinearGradient and refine it with Stops and InOklab:
ui.Div().BackgroundGradient(ui.LinearGradient(135, ui.Hex("#6366f1"), ui.Hex("#ec4899")))
Gradient colors do not animate: a Transition does not ease them, so a hover that changes the gradient snaps to the new one.
func LinearGradient ¶
LinearGradient returns a gradient from one color to another at angle degrees (0 points up, 90 right, 180 down). The colors sit at the ends of the gradient line, so the corners of the box get them.
type GradientPaint ¶
type GradientPaint struct {
// contains filtered or unexported fields
}
GradientPaint is a gradient that fills or strokes shapes in a Canvas, in the canvas's coordinates.
func LinearPaint ¶
func LinearPaint(x0, y0, x1, y1 float32, stops ...ColorStop) *GradientPaint
LinearPaint returns a gradient along the line from x0, y0 to x1, y1, with the colors of stops; the end colors continue past the ends.
func RadialPaint ¶
func RadialPaint(cx, cy, r float32, stops ...ColorStop) *GradientPaint
RadialPaint returns a gradient from the center cx, cy (the first stop) to the circle of radius r (the last stop).
func (*GradientPaint) Focus ¶
func (g *GradientPaint) Focus(x, y float32) *GradientPaint
Focus moves the point a radial gradient starts from off its center, as a highlight on a sphere. It does nothing to a linear gradient.
type GroupBoxElement ¶ added in v0.3.0
type GroupBoxElement struct {
// contains filtered or unexported fields
}
GroupBoxElement is a titled section that holds related content, such as the settings of one feature. It is outlined by default; Fill fills it instead. It is a group named by its title, with the description as its description.
func GroupBox ¶ added in v0.3.0
func GroupBox(title string) *GroupBoxElement
GroupBox creates a group box titled title. A group box fills the width of its container by default, and lays its children out in a column.
func (*GroupBoxElement) Child ¶ added in v0.3.0
func (g *GroupBoxElement) Child(e Element) *GroupBoxElement
Child appends a child to the content.
func (*GroupBoxElement) Children ¶ added in v0.3.0
func (g *GroupBoxElement) Children(es ...Element) *GroupBoxElement
Children appends several children to the content.
func (*GroupBoxElement) Description ¶ added in v0.3.0
func (g *GroupBoxElement) Description(s string) *GroupBoxElement
Description sets the text under the title.
func (*GroupBoxElement) Fill ¶ added in v0.3.0
func (g *GroupBoxElement) Fill() *GroupBoxElement
Fill fills the box with a raised surface color, without a border, in place of the default outline.
func (*GroupBoxElement) GridSpan ¶ added in v0.3.0
func (g *GroupBoxElement) GridSpan(cols, rows int) *GroupBoxElement
GridSpan sets how many columns and rows the group box covers in its parent's grid.
func (*GroupBoxElement) Grow ¶ added in v0.3.0
func (g *GroupBoxElement) Grow(f float32) *GroupBoxElement
Grow makes the group box take a share of the free space on its parent's main axis.
func (*GroupBoxElement) Key ¶ added in v0.3.0
func (g *GroupBoxElement) Key(k string) *GroupBoxElement
Key identifies the group box among its siblings (see DivElement.Key).
func (*GroupBoxElement) MaxWidth ¶ added in v0.3.0
func (g *GroupBoxElement) MaxWidth(l Length) *GroupBoxElement
MaxWidth sets the largest width of the group box.
func (*GroupBoxElement) MinWidth ¶ added in v0.3.0
func (g *GroupBoxElement) MinWidth(l Length) *GroupBoxElement
MinWidth sets the smallest width of the group box.
func (*GroupBoxElement) Styles ¶ added in v0.3.0
func (g *GroupBoxElement) Styles(st GroupBoxStyle) *GroupBoxElement
Styles sets the look of the parts of the group box, for this instance only. Set fields win over the theme's GroupBox and the defaults; see GroupBoxStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*GroupBoxElement) Tooltip ¶ added in v0.3.0
func (g *GroupBoxElement) Tooltip(s string) *GroupBoxElement
Tooltip shows s below the group box after the pointer rests on it. Assistive technology reads it as the group's description, when it has none.
func (*GroupBoxElement) Width ¶ added in v0.3.0
func (g *GroupBoxElement) Width(l Length) *GroupBoxElement
The sizing methods give the group box's outer box a size. See Sizing in docs/styling.md.
type GroupBoxStyle ¶ added in v0.3.0
type GroupBoxStyle struct {
GroupBox Style // the frame: its shape, fill and border
Header Style // the area that holds the title and the description
Title Style // the title
Description Style // the text under the title
Content Style // the area that holds the children
}
GroupBoxStyle is the look of each part of a group box. A part's style merges over the built-in defaults, then over the theme's GroupBox, then over the Styles of the instance; see docs/styling.md. GroupBox is the frame, Header the area that holds the Title and the Description, and Content the area under it that holds the children. A group box with neither a title nor a description has no header.
type Highlight ¶
type Highlight struct {
// Color and Background are the text color and the background of the highlighted text.
Color, Background Color
// Weight is the font weight of the text.
Weight FontWeight
// Italic, Underline and Strikethrough turn on that look for the text.
Italic, Underline, Strikethrough bool
Mono bool // monospace family (inline code)
}
Highlight styles a range of text. Zero fields are unset (keep the text's own style).
type HoverCardElement ¶ added in v0.3.0
type HoverCardElement struct {
// contains filtered or unexported fields
}
HoverCardElement is a trigger that shows a floating card of rich content, such as the profile behind a name or the preview behind a link, while the pointer rests on it. The card opens after the pointer has rested on the trigger for the open delay, or after keyboard focus has moved to the trigger for that delay. It stays open while the pointer is over the trigger or the card, and for the close delay after the pointer leaves both, so the pointer can cross the gap between them. It closes at once on Escape, a click outside, or focus leaving the trigger and the card while the pointer is elsewhere.
The card does not take focus. Assistive technology reads it as the description of the trigger while it is open, as it reads a tooltip; content that only a pointer user should see belongs in the card, and anything needed belongs in the page too.
func HoverCard ¶ added in v0.3.0
func HoverCard(trigger Element, content func() Element) *HoverCardElement
HoverCard creates a hover card: resting the pointer on trigger, or focusing it with the keyboard, shows a card with what content returns. content runs while the card is open, like a component's render.
ui.HoverCard(ui.Button("Dana Lee").Ghost().Small(), func() ui.Element {
return profileCard("Dana Lee")
}).Placement(ui.BelowStart)
func (*HoverCardElement) CloseDelay ¶ added in v0.3.0
func (h *HoverCardElement) CloseDelay(d time.Duration) *HoverCardElement
CloseDelay sets how long the card stays open after the pointer leaves the trigger and the card: 300 milliseconds by default. Coming back within it keeps the card.
func (*HoverCardElement) Key ¶ added in v0.3.0
func (h *HoverCardElement) Key(k string) *HoverCardElement
Key identifies the hover card among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*HoverCardElement) OpenDelay ¶ added in v0.3.0
func (h *HoverCardElement) OpenDelay(d time.Duration) *HoverCardElement
OpenDelay sets how long the pointer rests on the trigger, or keyboard focus stays on it, before the card opens: 500 milliseconds by default.
func (*HoverCardElement) Placement ¶ added in v0.3.0
func (h *HoverCardElement) Placement(pl Placement) *HoverCardElement
Placement sets where the card opens next to the trigger, BelowStart by default. It flips to the other side when it does not fit (see Overlay).
func (*HoverCardElement) Styles ¶ added in v0.3.0
func (h *HoverCardElement) Styles(st HoverCardStyle) *HoverCardElement
Styles sets the look of the card, for this instance only. Set fields win over the theme's HoverCard and the defaults. Calling Styles again merges.
type HoverCardStyle ¶ added in v0.3.0
type HoverCardStyle struct {
Panel Style // the floating panel that holds the content
}
HoverCardStyle is the look of a hover card's panel. It merges over the built-in defaults, which are the look of a popover's panel, then over the theme's HoverCard, then over the Styles of the instance; see docs/styling.md.
type IME ¶
type IME struct {
// Update shows the composition where the caret is. It runs with each change of
// the composition, and with an empty Composition when the composition ends without
// a result, so the element stops showing it. The element's text does not change:
// the composition is typed when Commit commits it, and a confirmed result arrives
// through OnTextInput, as typed text, which replaces the composition.
Update func(Composition)
// Commit types the composition as one edit and ends it. The host calls it before
// something else changes the element or its focus: a click, a key the element
// handles (see Context.CommitComposition), or focus moving to another element.
// Without Commit, the composition is dropped.
Commit func()
// Caret reports the caret of the element, in logical pixels from its top left,
// where the input method's candidate window opens. The host calls it when it places
// that window, so it reads what the last paint drew.
Caret func() Rect
}
IME are the input-method hooks of an element that draws its own text, given to DivElement.IME.
type IconElement ¶
type IconElement struct {
// contains filtered or unexported fields
}
IconElement draws a vector icon from the icons package.
func Icon ¶
func Icon(ic *icons.Icon) *IconElement
Icon creates an icon element. Size defaults to 16 and the color is inherited like text.
func (*IconElement) Color ¶
func (i *IconElement) Color(c Color) *IconElement
Color sets the icon color.
func (*IconElement) Key ¶
func (i *IconElement) Key(k string) *IconElement
Key identifies the icon among its siblings (see DivElement.Key).
func (*IconElement) Size ¶
func (i *IconElement) Size(px float32) *IconElement
Size sets the icon's width and height in logical pixels.
func (*IconElement) Style ¶
func (i *IconElement) Style(s Style) *IconElement
Style merges layout fields (margins, alignment...) of s.
type ImageElement ¶
type ImageElement struct {
// contains filtered or unexported fields
}
ImageElement draws an ImageSource.
func Image ¶
func Image(src *ImageSource) *ImageElement
Image creates an image element. Without an explicit size it uses the image's pixel size as logical pixels.
func (*ImageElement) Alt ¶
func (i *ImageElement) Alt(s string) *ImageElement
Alt describes the image for assistive technology, such as "Avatar of Dana Lee", and is read in place of the image. An image without alternative text is reported by the development warnings. Images are always exposed; there is no decorative flag yet, so an image that adds nothing should be left out of the element tree.
func (*ImageElement) Fit ¶
func (i *ImageElement) Fit(f ImageFit) *ImageElement
Fit chooses cover (default), contain or fill.
func (*ImageElement) Key ¶
func (i *ImageElement) Key(k string) *ImageElement
Key identifies the image among its siblings (see DivElement.Key).
func (*ImageElement) Opacity ¶
func (i *ImageElement) Opacity(o float32) *ImageElement
Opacity fades the image.
func (*ImageElement) Radius ¶
func (i *ImageElement) Radius(r float32) *ImageElement
Radius rounds the image corners.
func (*ImageElement) Size ¶
func (i *ImageElement) Size(w, h Length) *ImageElement
Size sets width and height.
func (*ImageElement) Style ¶
func (i *ImageElement) Style(s Style) *ImageElement
Style merges layout fields of s.
type ImageSource ¶
type ImageSource struct {
// contains filtered or unexported fields
}
ImageSource is decoded pixel data ready for the GPU. Create it once (for example at package init) and reuse it.
func ImageFromBytes ¶
func ImageFromBytes(data []byte) (*ImageSource, error)
ImageFromBytes decodes PNG, JPEG, GIF or WebP data. An animated GIF plays, with its frame timing and loop count; it pauses while it is not drawn (off screen, or in a covered or minimized window), and shows its first frame when the user asked for reduced motion. WebP is decoded as a still image.
func ImageFromImage ¶
func ImageFromImage(img image.Image) *ImageSource
ImageFromImage converts any image.Image.
func MustImage ¶
func MustImage(data []byte) *ImageSource
MustImage is ImageFromBytes that panics on error; meant for embedded assets.
func (*ImageSource) Animated ¶
func (s *ImageSource) Animated() bool
Animated reports whether the image is an animated GIF.
func (*ImageSource) Size ¶
func (s *ImageSource) Size() (int, int)
Size returns the image size in pixels.
type InputFormat ¶ added in v0.4.0
type InputFormat struct {
// contains filtered or unexported fields
}
InputFormat is the shape a TextInput shows its text in (see TextInputElement.Format). Make one with TemplateFormat or NumberFormat; the zero InputFormat shows the text as it is.
func NumberFormat ¶ added in v0.4.0
func NumberFormat(o NumberOptions) InputFormat
NumberFormat returns the format of a number, shown with the decimal point, the group separators and the minus sign of the user's locale, such as 1,234.5 in en-US or 1.234,5 in de-DE. The raw value is the number in ASCII digits with "." and a leading "-", such as "-1234.5", which strconv.ParseFloat parses. While the user types, it can be "-", "12." or "007"; leaving the field makes it "", "12" and "7".
func TemplateFormat ¶ added in v0.4.0
func TemplateFormat(spec string) InputFormat
TemplateFormat returns the format of the template spec, in which each character is a slot or a literal:
9 a digit (full-width digits are taken as ASCII) A a letter # a letter or a digit * any character but a control character \x the literal x
and any other character is a literal. "(999) 999-9999" is a phone number of the US. The raw value is the slot characters only, and a literal shows once the slot before it is filled. It panics when spec has no slots.
func (InputFormat) Complete ¶ added in v0.4.0
func (f InputFormat) Complete(msg string) Validator[string]
Complete returns a validator that rejects, with the message msg, a raw value that is not complete for f: a template with a slot not filled, a number that does not parse (such as "-" or "."), or a value that does not fit f. The empty value passes, so pair it with Required when the field must be filled in.
func (InputFormat) Display ¶ added in v0.4.0
func (f InputFormat) Display(raw string) string
Display returns the raw value as the field shows it, such as "(555) 123-4567" for "5551234567", for showing the value outside the field: in a grid cell or a label. A value that does not fit the format is returned as it is.
type KbdElement ¶ added in v0.3.0
type KbdElement struct {
// contains filtered or unexported fields
}
KbdElement shows a keyboard shortcut as key caps, such as Ctrl, Shift and P for "ctrl+shift+p". Each key is a cap of its own, and the strokes of a sequence are spaced apart. The key names are the ones a menu shows for the same keys.
func Kbd ¶ added in v0.3.0
func Kbd(keys string) *KbdElement
Kbd creates a keyboard shortcut from keys, written as for Bind: strokes separated by spaces, each stroke modifiers and one key joined by "+", such as "ctrl+shift+p" or "ctrl+k ctrl+t". Kbd panics on a malformed keys string, as Bind does.
func (*KbdElement) GridSpan ¶ added in v0.3.0
func (k *KbdElement) GridSpan(cols, rows int) *KbdElement
GridSpan sets how many columns and rows the shortcut covers in its parent's grid.
func (*KbdElement) Grow ¶ added in v0.3.0
func (k *KbdElement) Grow(f float32) *KbdElement
Grow makes the shortcut take a share of the free space on its parent's main axis.
func (*KbdElement) Key ¶ added in v0.3.0
func (k *KbdElement) Key(key string) *KbdElement
Key identifies the shortcut among its siblings (see DivElement.Key).
func (*KbdElement) MaxWidth ¶ added in v0.3.0
func (k *KbdElement) MaxWidth(l Length) *KbdElement
MaxWidth sets the largest width of the shortcut.
func (*KbdElement) MinWidth ¶ added in v0.3.0
func (k *KbdElement) MinWidth(l Length) *KbdElement
MinWidth sets the smallest width of the shortcut.
func (*KbdElement) Styles ¶ added in v0.3.0
func (k *KbdElement) Styles(st KbdStyle) *KbdElement
Styles sets the look of the parts of the shortcut, for this instance only. Set fields win over the theme's Kbd and the defaults; see KbdStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*KbdElement) Tooltip ¶ added in v0.3.0
func (k *KbdElement) Tooltip(s string) *KbdElement
Tooltip shows s below the shortcut after the pointer rests on it, such as the command it runs. Assistive technology reads it as the shortcut's description.
func (*KbdElement) Width ¶ added in v0.3.0
func (k *KbdElement) Width(l Length) *KbdElement
The sizing methods give the shortcut's outer box a size. See Sizing in docs/styling.md.
type KbdStyle ¶ added in v0.3.0
type KbdStyle struct {
Kbd Style // the row of key caps; its Gap is the space between strokes
Key Style // one key cap: its shape, fill, border and text
}
KbdStyle is the look of each part of a keyboard shortcut. A part's style merges over the built-in defaults, then over the theme's Kbd, then over the Styles of the instance; see docs/styling.md. Kbd is the row that holds the key caps, and its Gap is the space between the strokes of a sequence such as "Ctrl+K Ctrl+T". Key is one key cap.
type KeyEvent ¶
type KeyEvent struct {
// Key is the key that was pressed or released.
Key input.Key
// Mods are the modifier keys held.
Mods input.Modifiers
// Repeat is true for an automatic repeat of a held key.
Repeat bool
// contains filtered or unexported fields
}
KeyEvent describes a key press or release.
func (*KeyEvent) StopPropagation ¶
func (e *KeyEvent) StopPropagation()
StopPropagation prevents ancestors from receiving the event.
type Keyframe ¶ added in v0.4.0
Keyframe is one stop of keyframed motion (see Play): at progress At, from 0 (the start) to 1 (the end), the element has the look of Motion. Easing shapes the segment that arrives at this stop; nil uses the Animation's easing.
type Length ¶
Length is a size: Px(240), Percent(100) or Auto.
func AutoFill ¶ added in v0.6.0
AutoFill is a grid column track that repeats as many times as fit the grid's width, each column at least minWidth wide and all of them sharing the width equally, as CSS's repeat(auto-fill, minmax(minWidth, 1fr)) does: a grid of cards that gains a column as its window widens. The columns follow the grid's own width, not the window's. It must be the grid's only column track; a grid with no width of its own, such as one a row sizes to its content, has one column.
ui.Div().Grid(ui.AutoFill(280)).Gap(16).Children(cards...)
func Fr ¶
Fr returns a flexible grid track that takes v shares of the space the other tracks leave (see DivElement.Grid). Elsewhere it acts as Auto.
type ListBoxElement ¶ added in v0.4.0
type ListBoxElement[T any] struct { // contains filtered or unexported fields }
ListBoxElement is a list of items that the user selects from, with the keyboard model of a WAI-ARIA listbox (https://www.w3.org/WAI/ARIA/apg/patterns/listbox/). Its items are built only in view, as ListOf builds its rows, so it can hold many of them. Create one with ListBox.
The list is one Tab stop. Tab reaches the selected item, or the first item when none is selected, and the focus then moves with the keys:
- Up and Down move the focus to the previous and next item, without wrapping.
- Home and End move it to the first and last item, and PageUp and PageDown by a page of ten items.
- In a single selection the selection follows the focus. In a multiple one a plain move selects only the item the focus reaches.
- Ctrl with an arrow or a page key moves the focus and keeps the selection.
- Shift with an arrow or a page key, in a multiple selection, selects the items from the anchor to the focus. Shift+Home and Shift+End do the same.
- Space and Enter select the focused item in a single selection, and toggle it in a multiple one, keeping the others. Enter also activates it (OnActivate).
- Ctrl+A selects every item in a multiple selection.
- Typing letters moves the focus to the next item whose name starts with them, when ItemName is set. A pause of a second starts a new search, as in a select.
A click selects the item alone. Ctrl+click toggles an item and Shift+click selects from the anchor to it, in a multiple selection. A double-click activates the item. A right-press on an item that is not selected selects it first, as File Explorer does, and then opens its context menu. Shift+F10 and the Menu key open the menu of the focused item.
The selection is a signal of the keys of the chosen items. The focus, and the anchor of a Shift selection, are the list's own state.
Assistive technology reads the list as a list named by its Label, each item as a list item with its position, and the selected items as selected. An item is named by its ItemName; without one, its own text is its name. The focused item is the one a screen reader follows while the list has focus.
func ListBox ¶ added in v0.4.0
func ListBox[T any](items []T, key func(T) string, selected *Signal[[]string], row func(item T, s PartState) Element) *ListBoxElement[T]
ListBox creates a list of items, whose keys are the values of selected. Each item is drawn by row, which gets the item and its PartState (Selected for a selected item, Focused for the item that has keyboard focus while the list has focus). The selection is single unless Selection says otherwise. A nil selected keeps the selection in the list, or in the signal SelectedKey gives.
ui.ListBox(repos, func(r Repo) string { return r.Path }, selected,
func(r Repo, s ui.PartState) ui.Element { return ui.Text(r.Name) }).
Label("Repositories").ItemName(func(r Repo) string { return r.Name })
func (*ListBoxElement[T]) ContextMenu ¶ added in v0.4.0
func (l *ListBoxElement[T]) ContextMenu(build func(item T) []MenuItem) *ListBoxElement[T]
ContextMenu opens a menu on an item, built by build with the item: on a right-press on the item, and with Shift+F10 or the Menu key for the focused item. An empty result opens nothing.
func (*ListBoxElement[T]) GridSpan ¶ added in v0.4.0
func (l *ListBoxElement[T]) GridSpan(cols, rows int) *ListBoxElement[T]
GridSpan sets how many columns and rows the list box covers in its parent's grid.
func (*ListBoxElement[T]) Grow ¶ added in v0.4.0
func (l *ListBoxElement[T]) Grow(f float32) *ListBoxElement[T]
Grow makes the list box take a share of the free space on its parent's main axis.
func (*ListBoxElement[T]) Height ¶ added in v0.4.0
func (l *ListBoxElement[T]) Height(v Length) *ListBoxElement[T]
Height sets the height of the list box.
func (*ListBoxElement[T]) ItemName ¶ added in v0.4.0
func (l *ListBoxElement[T]) ItemName(name func(item T) string) *ListBoxElement[T]
ItemName names each item for assistive technology and for type-ahead. The item's content is then hidden from assistive technology, so the name is what it reads.
func (*ListBoxElement[T]) Key ¶ added in v0.4.0
func (l *ListBoxElement[T]) Key(k string) *ListBoxElement[T]
Key gives the list box a stable identity among its siblings.
func (*ListBoxElement[T]) Label ¶ added in v0.4.0
func (l *ListBoxElement[T]) Label(name string) *ListBoxElement[T]
Label names the list for assistive technology, such as "Repositories".
func (*ListBoxElement[T]) MaxHeight ¶ added in v0.4.0
func (l *ListBoxElement[T]) MaxHeight(v Length) *ListBoxElement[T]
MaxHeight sets the largest height of the list box.
func (*ListBoxElement[T]) MaxWidth ¶ added in v0.4.0
func (l *ListBoxElement[T]) MaxWidth(v Length) *ListBoxElement[T]
MaxWidth sets the largest width of the list box.
func (*ListBoxElement[T]) MinHeight ¶ added in v0.4.0
func (l *ListBoxElement[T]) MinHeight(v Length) *ListBoxElement[T]
MinHeight sets the smallest height of the list box.
func (*ListBoxElement[T]) MinWidth ¶ added in v0.4.0
func (l *ListBoxElement[T]) MinWidth(v Length) *ListBoxElement[T]
MinWidth sets the smallest width of the list box.
func (*ListBoxElement[T]) OnActivate ¶ added in v0.4.0
func (l *ListBoxElement[T]) OnActivate(fn func(item T)) *ListBoxElement[T]
OnActivate runs fn with an item after the user activates it: with Enter, or by a double-click.
func (*ListBoxElement[T]) OnChange ¶ added in v0.4.0
func (l *ListBoxElement[T]) OnChange(fn func(keys []string)) *ListBoxElement[T]
OnChange runs fn with the keys of the selected items after the user changes the selection, by a click, the keys or a typed letter. The selection signal is set first. It does not run for a change the app makes to the signal.
func (*ListBoxElement[T]) SelectedKey ¶ added in v0.4.0
func (l *ListBoxElement[T]) SelectedKey(key *Signal[string]) *ListBoxElement[T]
SelectedKey keeps a single selection in key, the selected item's key or "" for none, as Tree and Sidebar keep theirs, in place of the keys signal ListBox takes (which may then be nil). It sets the selection to SelectionSingle.
ui.ListBox(repos, func(r Repo) string { return r.Path }, nil, row).SelectedKey(current)
func (*ListBoxElement[T]) Selection ¶ added in v0.4.0
func (l *ListBoxElement[T]) Selection(mode SelectionMode) *ListBoxElement[T]
Selection sets how many items the user can select at once: SelectionSingle (the default), SelectionMultiple, or SelectionNone for a list the user only moves through. See the keys in ListBoxElement.
func (*ListBoxElement[T]) Style ¶ added in v0.4.0
func (l *ListBoxElement[T]) Style(s Style) *ListBoxElement[T]
Style is merged into the outer box of the list box: size it with Height, Grow or MaxHeight. The list fills that box.
func (*ListBoxElement[T]) Styles ¶ added in v0.4.0
func (l *ListBoxElement[T]) Styles(st ListBoxStyle) *ListBoxElement[T]
Styles sets the look of the parts of the list box, for this instance only. Set fields win over the theme's ListBox and the defaults; see ListBoxStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ListBoxElement[T]) Width ¶ added in v0.4.0
func (l *ListBoxElement[T]) Width(v Length) *ListBoxElement[T]
The sizing methods give the list box's outer box a size, over its Style. See Sizing in docs/styling.md.
type ListBoxStyle ¶ added in v0.4.0
type ListBoxStyle struct {
List Style // the scrolling list that holds the items
Item Style // each item
ItemHover Style // an item the pointer is over, if it is not selected
ItemSelected Style // a selected item
ItemFocusVisible Style // the item that has keyboard focus, while the list has focus
}
ListBoxStyle is the look of each part of a list box. A part's style merges over the built-in defaults, then over the theme's ListBox, then over the Styles of the instance; see docs/styling.md. List is the scrolling list that holds the items. The states are parts of their own: ItemHover applies to an item the pointer is over, if it is not selected, ItemSelected to a selected item, and ItemFocusVisible to the item that has keyboard focus while the list has focus. The ring of ItemFocusVisible is drawn over the fill of ItemSelected, so an item that is both shows both.
type ListElement ¶
type ListElement struct {
// contains filtered or unexported fields
}
ListElement is a scrolling list whose rows may differ in height. Create one with ListOf.
func ListOf ¶
func ListOf[T any](items []T, key func(T) string, row func(i int, item T) Element) *ListElement
ListOf creates a scrolling list of items whose rows may differ in height. Only rows near the viewport are built. Each row's height is measured once it is built and remembered by its key; rows not yet seen are estimated from the mean of the measured ones. The scroll position stays on the item at the top of the viewport, so measurements, inserts and removals above it do not make the view jump.
row gets the item and its index in items, as Map's function does, for striping or a position such as "3 of 10".
Each row is rendered as a component of its own. A row that stays in the window is not rendered again when the window moves, and a signal that a row reads re-renders that row alone, not the list. The list is rendered again when its items change or its own state does (a scroll to an item, for one), and then its rows are rendered again, since the row function may read the list's data.
Changes are detected by slice identity: pass a new slice to change the items, as with signals. Changing a slice in place is not detected:
ui.ListOf(notes, func(n *store.Note) string { return n.ID }, func(_ int, n *store.Note) ui.Element {
return noteRow(n)
}).Style(ui.Style{Grow: 1})
func (*ListElement) Bottom ¶
func (l *ListElement) Bottom() *ListElement
Bottom is for chat-like lists. When the rows are shorter than the viewport they sit at its bottom. While the list is at its end, appended items (and rows growing) keep it there.
func (*ListElement) GridSpan ¶
func (l *ListElement) GridSpan(cols, rows int) *ListElement
GridSpan sets how many columns and rows the list covers in its parent's grid.
func (*ListElement) Grow ¶
func (l *ListElement) Grow(f float32) *ListElement
Grow makes the list take a share of the free space on its parent's main axis.
func (*ListElement) Handle ¶
func (l *ListElement) Handle(h *ListHandle) *ListElement
Handle connects h so the list can be scrolled from code.
func (*ListElement) Height ¶
func (l *ListElement) Height(v Length) *ListElement
Height sets the height of the list.
func (*ListElement) Key ¶
func (l *ListElement) Key(k string) *ListElement
Key gives the list a stable identity among its siblings.
func (*ListElement) Label ¶ added in v0.6.0
func (l *ListElement) Label(name string) *ListElement
Label names the list for assistive technology, such as "Alerts", which reads it with the list's role and its number of items.
func (*ListElement) MaxHeight ¶
func (l *ListElement) MaxHeight(v Length) *ListElement
MaxHeight sets the largest height of the list.
func (*ListElement) MaxWidth ¶
func (l *ListElement) MaxWidth(v Length) *ListElement
MaxWidth sets the largest width of the list.
func (*ListElement) MinHeight ¶
func (l *ListElement) MinHeight(v Length) *ListElement
MinHeight sets the smallest height of the list.
func (*ListElement) MinWidth ¶
func (l *ListElement) MinWidth(v Length) *ListElement
MinWidth sets the smallest width of the list.
func (*ListElement) OnAtEnd ¶
func (l *ListElement) OnAtEnd(fn func(atEnd bool)) *ListElement
OnAtEnd calls fn when the list moves to its end or away from it, during the paint that changes it. Read it into a signal to show a control only while the list is away from its end (AtEnd does not notify).
func (*ListElement) SelectionContainer ¶
func (l *ListElement) SelectionContainer() *ListElement
SelectionContainer makes the list the group that holds its rows as selection items, such as the notes in a sidebar. Rows that call AccessSelected are the items.
func (*ListElement) Style ¶
func (l *ListElement) Style(s Style) *ListElement
Style is merged into the scroll container: size it with Height, Grow or MaxHeight.
func (*ListElement) Width ¶
func (l *ListElement) Width(v Length) *ListElement
The sizing methods give the list's outer box a size, over its Style. See Sizing in docs/styling.md.
type ListHandle ¶
type ListHandle struct {
// contains filtered or unexported fields
}
ListHandle scrolls a UniformList or a ListOf from code.
func NewListHandle ¶
func NewListHandle() *ListHandle
NewListHandle creates a handle to pass to UniformList.Handle.
func (*ListHandle) AtEnd ¶
func (h *ListHandle) AtEnd() bool
AtEnd reports whether the list is scrolled to its end, to within a pixel. It is false before the first paint.
func (*ListHandle) ScrollToEnd ¶
func (h *ListHandle) ScrollToEnd()
ScrollToEnd scrolls to the last item. Takes effect on the next frame.
func (*ListHandle) ScrollToItem ¶
func (h *ListHandle) ScrollToItem(i int)
ScrollToItem scrolls the least amount that shows item i completely (nothing if it already is). Takes effect on the next frame.
type MenuBarElement ¶
type MenuBarElement struct {
// contains filtered or unexported fields
}
MenuBarElement is a row of top-level menus. See MenuBar.
func MenuBar ¶
func MenuBar(menus ...TopMenu) *MenuBarElement
MenuBar is a row of top-level menus, such as File and Edit, for a window's top edge (including a custom title bar). A click on a label opens its menu, and while one is open, the pointer over another label opens that one. Pressing and releasing Alt by itself focuses the bar. There, Left and Right move between labels, Down, Enter or Space opens the highlighted menu, and Escape or Tab leaves the bar. Within an open menu, Left and Right move to the neighboring menu. The labels are not in the Tab order. Alt+letter mnemonics are not implemented.
func (*MenuBarElement) Key ¶
func (mb *MenuBarElement) Key(k string) *MenuBarElement
Key identifies the menu bar among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*MenuBarElement) Styles ¶
func (mb *MenuBarElement) Styles(st MenuBarStyle) *MenuBarElement
Styles sets the look of the labels on the bar, for this instance only. Set fields win over the theme's MenuBar and the defaults; see MenuBarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
type MenuBarStyle ¶
type MenuBarStyle struct {
BarItem Style // each label on the bar
BarItemHover Style // a label the pointer is over
BarItemFocusVisible Style // a label that has keyboard focus
BarItemOpen Style // the label of the open menu
}
MenuBarStyle is the look of each part of a menu bar. A part's style merges over the built-in defaults, then over the theme's MenuBar, then over the Styles of the instance; see docs/styling.md. BarItem is each label on the bar. The states are parts of their own: BarItemHover while the pointer is over a label, BarItemFocusVisible while the label has keyboard focus, and BarItemOpen for the label of the open menu. The menus that a bar opens are styled by Theme.Menu, as the menus of any other kind are (see MenuStyle).
type MenuCheck ¶
type MenuCheck uint8
MenuCheck makes an item checkable. MenuCheckBox shows a check mark while Checked is set; MenuCheckRadio shows a dot. Radio items in one menu form a group, and the selected one is the one that is Checked.
type MenuItem ¶
type MenuItem struct {
// Kind is the kind of item: an action, a separator, or a submenu.
Kind MenuKind
Label string // defaults to the Action's label
// Icon is an icon shown before the label.
Icon *icons.Icon
// Action is the action that the item runs, and whose key it shows.
Action *Action
// OnClick runs when the item is chosen.
OnClick func()
Disabled bool // shown, but cannot be chosen
Check MenuCheck // see MenuCheck
Checked bool // the state of a checkable item
}
MenuItem is one entry of a menu. Set Action, which shows the action's shortcut and runs through the normal action dispatch, or OnClick. If both are set, Action runs. A non-empty Submenu opens a menu to the right instead of running.
func MenuSection ¶
MenuSection is a group label, such as "Status". It runs nothing.
type MenuStyle ¶
type MenuStyle struct {
Panel Style // the box of a menu
Item Style // each row
ItemHighlighted Style // the row that has the keyboard position
ItemDisabled Style // a row that cannot be chosen
Separator Style // the rule between groups of rows
SectionLabel Style // a group's label
Shortcut Style // the key binding of an action
Check Style // the slot before a label: its check mark, dot or icon
}
MenuStyle is the look of each part of a menu: a dropdown, a context menu and the menus of a MenuBar. A part's style merges over the built-in defaults, then over the theme's Menu, then over the Styles of the instance (a DropdownMenu has one; a context menu takes the theme's only); see docs/styling.md. Panel is the box of a menu. Item is each row; ItemHighlighted is the row that has the keyboard position, and ItemDisabled a row that cannot be chosen. Separator is the rule between groups, SectionLabel a group's label, Shortcut the text of an action's key binding, Check the slot before a label (its check mark, dot or icon is drawn in its TextColor), and SubmenuChevron the arrow of a submenu.
type ModalElement ¶
type ModalElement struct {
// contains filtered or unexported fields
}
ModalElement is a dialog drawn over the window: a dimmed backdrop, and a panel centered on it with a title, a body and footer buttons. Build it only while it is open, as a dropdown is built only while it is open. Place it last in the window's root element, which must fill the window:
ui.If(open.Get(), ui.Modal("New project", form).
Footer(cancel, create).Default(create).OnClose(close))
Keyboard focus moves into the modal when it opens, and Tab and Shift+Tab cycle through its fields and buttons only. Focus returns to the element that had it when the modal closes. Escape closes the modal, as it closes an overlay, and a press on the backdrop closes it when CloseOnBackdrop is set. Enter runs the default button, except that a focused button is pressed instead, and a multi-line field takes the newline.
func Modal ¶
func Modal(title string, body Element) *ModalElement
Modal creates a dialog with a title and a body. Add its buttons with Footer.
func (*ModalElement) CloseButton ¶ added in v0.4.0
func (m *ModalElement) CloseButton(show bool) *ModalElement
CloseButton shows a close button at the top right of the panel, beside the title, when show is set. Pressing it runs OnClose, and it is built only when there is an OnClose. It is a small icon button labelled with Strings.Close, first in the Tab order; initial focus skips it. A non-modal dialog shows one unless CloseButton(false) is called.
func (*ModalElement) CloseOnBackdrop ¶
func (m *ModalElement) CloseOnBackdrop() *ModalElement
CloseOnBackdrop makes a press on the backdrop, outside the panel, close the modal (see OnClose).
func (*ModalElement) CloseOnClickOutside ¶ added in v0.4.0
func (m *ModalElement) CloseOnClickOutside() *ModalElement
CloseOnClickOutside makes a press outside the panel close the dialog (see OnClose). For a modal it is CloseOnBackdrop. A non-modal dialog closes on a press in the window behind it only when this is called.
func (*ModalElement) Default ¶
func (m *ModalElement) Default(b *ButtonElement) *ModalElement
Default makes b the default button: Enter runs its OnClick, and it takes focus when nothing in the body does (see InitialFocus).
func (*ModalElement) Footer ¶
func (m *ModalElement) Footer(buttons ...Element) *ModalElement
Footer sets the buttons under the body. They sit at the right, in the order given.
func (*ModalElement) InitialFocus ¶
func (m *ModalElement) InitialFocus(h *FocusHandle) *ModalElement
InitialFocus sets the element that takes focus when the modal opens: the one h is attached to. By default that is the first field of the body that Tab reaches, or else the default button.
func (*ModalElement) Key ¶
func (m *ModalElement) Key(k string) *ModalElement
Key identifies the modal among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*ModalElement) MaxWidth ¶
func (m *ModalElement) MaxWidth(l Length) *ModalElement
MaxWidth sets the largest width of the modal.
func (*ModalElement) MinWidth ¶
func (m *ModalElement) MinWidth(l Length) *ModalElement
MinWidth sets the smallest width of the modal.
func (*ModalElement) NonModal ¶ added in v0.4.0
func (m *ModalElement) NonModal() *ModalElement
NonModal makes the dialog non-modal, for a window that stays usable while the dialog is open, such as a find bar or a properties sheet. There is no scrim, so the window behind is not dimmed, and a press on it reaches the window. Focus is not trapped: Tab moves through the whole window, and F6 cycles the dialog with the window's other regions. A non-modal dialog has a close button unless CloseButton(false) is called. Escape closes it while focus is inside it, and Enter runs its default button only then. A press outside it does not close it unless CloseOnClickOutside is called. Several non-modal dialogs can be open, and the one that was last pressed or focused is on top. A modal that opens later covers them, as it covers the window.
func (*ModalElement) OnClose ¶
func (m *ModalElement) OnClose(fn func()) *ModalElement
OnClose sets what runs when the user asks for the modal to close: Escape, or a press on the backdrop when CloseOnBackdrop is set. It should remove the modal from the app's state. Without OnClose, Escape does nothing.
func (*ModalElement) Styles ¶
func (m *ModalElement) Styles(st ModalStyle) *ModalElement
Styles sets the look of the parts of the modal, for this instance only. Set fields win over the theme's Modal and the defaults; see ModalStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ModalElement) Width ¶
func (m *ModalElement) Width(l Length) *ModalElement
The sizing methods give the panel a width. The panel is 420 px wide by default. A percentage is of the window's width, so Width(Percent(90)) leaves a margin on each side. See Sizing in docs/styling.md.
type ModalStyle ¶
type ModalStyle struct {
Scrim Style // the dimmed backdrop behind the dialog
Panel Style // the dialog
Header Style // the row of the title and the close button, at the top of the dialog
Title Style // the title, at the top of the dialog
Close Style // the box around the close button, at the top right
Body Style // the body, under the title
}
ModalStyle is the look of each part of a modal. A part's style merges over the built-in defaults, then over the theme's Modal, then over the Styles of the instance; see docs/styling.md. Scrim is the dimmed backdrop, Panel the dialog on it, Title its title, Body the area of the body and Footer the row of buttons. The panel's width is its Width, 420 px by default. Header is the row of the title and the close button, and Close the box around that button; both are built only when the modal has a close button (see CloseButton).
type Motion ¶
type Motion struct {
// contains filtered or unexported fields
}
Motion is a paint-only state an element enters from or exits to, or passes through in keyframes (see Play): an opacity, an offset and a scale. Build one with Fade, Slide and Grow, and combine them with the methods of the same names and Opacity:
ui.Fade().Slide(0, -6).Grow(0.98)
func Grow ¶
Grow is a Motion that starts or ends scaled by s about the element's center: 0.96 starts a little smaller and grows into place.
type MotionTokens ¶ added in v0.4.0
type MotionTokens struct {
// Hover is how long the colors of the built-in controls ease on hover and
// press: 110 ms by default.
Hover time.Duration
// Enter is how long menus, lists, dialogs, popovers and tooltips take to
// appear. By default menus, lists and dialogs take 140 ms, and popovers,
// hover cards and tooltips 120 ms.
Enter time.Duration
// Exit is how long they take to go: by default 90 ms for menus, lists and
// dialogs, and 80 ms for popovers, hover cards and tooltips.
Exit time.Duration
// Spring, when set, moves the opacity, offset and scale of the built-in
// controls whose colors ease on hover (as a theme's hover style that lifts
// or grows them would change them) as this spring. The zero Spring keeps
// their transitions.
Spring Spring
}
MotionTokens are the timings of the built-in widgets' motion, for a theme to make them faster, slower or springier. A zero field keeps the built-in default. Reduced motion still turns the motion off.
type MouseEvent ¶
type MouseEvent struct {
// X, Y relative to the window; LocalX, LocalY relative to the element
// whose handler is running.
X, Y float32
// LocalX and LocalY are the position relative to the element whose handler is running.
LocalX, LocalY float32
// Width and Height are the size of the element whose handler is running.
Width, Height float32
// Button is the mouse button that changed.
Button input.MouseButton
// Clicks is the number of clicks in the sequence: one for a single click, two for a double-click.
Clicks int
// Mods are the modifier keys held.
Mods input.Modifiers
// contains filtered or unexported fields
}
MouseEvent describes a pointer event. Coordinates are logical pixels.
func (*MouseEvent) StopPropagation ¶
func (e *MouseEvent) StopPropagation()
StopPropagation prevents ancestors from receiving the event.
type NopWindow ¶
type NopWindow struct{}
NopWindow is a Window whose methods do nothing and return zero values; Closed, Focused, Maximized, Fullscreen and Visible report false. A test fake embeds it and overrides the methods that it records or answers, so the fake keeps compiling when Window gains methods.
func (NopWindow) MessageBox ¶
func (NopWindow) MessageBox(dialog.MessageOptions, func(dialog.Button))
MessageBox does nothing, and its done function is not called.
func (NopWindow) OpenFiles ¶
func (NopWindow) OpenFiles(dialog.FileOptions, func(dialog.FileResult))
OpenFiles does nothing, and its done function is not called.
func (NopWindow) PickFolder ¶
func (NopWindow) PickFolder(dialog.FileOptions, func(dialog.FileResult))
PickFolder does nothing, and its done function is not called.
func (NopWindow) SaveFile ¶
func (NopWindow) SaveFile(dialog.FileOptions, func(dialog.FileResult))
SaveFile does nothing, and its done function is not called.
func (NopWindow) SetFullscreen ¶
SetFullscreen does nothing.
func (NopWindow) SetTaskbarBadge ¶
SetTaskbarBadge does nothing.
func (NopWindow) SetTaskbarProgress ¶
func (NopWindow) SetTaskbarProgress(TaskbarProgress)
SetTaskbarProgress does nothing.
type NumberInputElement ¶
NumberInputElement is a text field for a number, bound to an int or float64 signal, from lo to hi in steps of step. The user types a number, or steps it with Up and Down (and with the optional spin buttons).
The text is checked when it is committed, by Enter or by leaving the field:
- a number outside the range is clamped to the nearest bound;
- text that is not a number (or, for an int, not a whole number) is not applied. Enter shows the field as invalid, with a message that gives the range, and keeps the text so it can be corrected. Leaving the field reverts the text to the value that is set.
Assistive technology reports it as a spin box, which holds the text field.
func NumberInput ¶
func NumberInput[T int | float64](value *Signal[T], lo, hi, step T) *NumberInputElement[T]
NumberInput creates a number input that reads and writes value, from lo to hi in steps of step. Its default width is 120 px at the Text size of 100 percent (see Width), it shows the decimals of step, and its value is centered in the field.
func (*NumberInputElement[T]) Align ¶
func (n *NumberInputElement[T]) Align(a Alignment) *NumberInputElement[T]
Align sets where the value sits in the field: Center, the default, or Start and End for the left and the right, such as End for figures that line up in a column. The value keeps to the room between the spin buttons, and its caret and selection follow it.
func (*NumberInputElement[T]) Disabled ¶
func (n *NumberInputElement[T]) Disabled(d bool) *NumberInputElement[T]
Disabled shows the number but does not let it change.
func (*NumberInputElement[T]) FocusHandle ¶
func (n *NumberInputElement[T]) FocusHandle(h *FocusHandle) *NumberInputElement[T]
FocusHandle lets code focus the number's text (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*NumberInputElement[T]) GridSpan ¶
func (n *NumberInputElement[T]) GridSpan(cols, rows int) *NumberInputElement[T]
GridSpan sets how many columns and rows the number input covers in its parent's grid.
func (*NumberInputElement[T]) Grow ¶
func (n *NumberInputElement[T]) Grow(f float32) *NumberInputElement[T]
Grow makes the number input take a share of the free space on its parent's main axis.
func (*NumberInputElement[T]) Height ¶
func (n *NumberInputElement[T]) Height(l Length) *NumberInputElement[T]
Height sets the height of the number input.
func (*NumberInputElement[T]) Key ¶
func (n *NumberInputElement[T]) Key(k string) *NumberInputElement[T]
Key identifies the number input among its siblings (see DivElement.Key).
func (*NumberInputElement[T]) Label ¶
func (n *NumberInputElement[T]) Label(s string) *NumberInputElement[T]
Label names the field for assistive technology, such as "Quiet hours from".
func (*NumberInputElement[T]) LabelledBy ¶
func (n *NumberInputElement[T]) LabelledBy(keys ...string) *NumberInputElement[T]
LabelledBy names the field by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*NumberInputElement[T]) Large ¶
func (n *NumberInputElement[T]) Large() *NumberInputElement[T]
Large makes the field larger: 40 px high with 16 px text, like Button.Large and TextInput.Large, for touch-friendly or prominent forms. Small and Large replace each other.
func (*NumberInputElement[T]) MaxWidth ¶
func (n *NumberInputElement[T]) MaxWidth(l Length) *NumberInputElement[T]
MaxWidth sets the largest width of the number input.
func (*NumberInputElement[T]) MinWidth ¶
func (n *NumberInputElement[T]) MinWidth(l Length) *NumberInputElement[T]
MinWidth sets the smallest width of the number input.
func (*NumberInputElement[T]) OnChange ¶
func (n *NumberInputElement[T]) OnChange(fn func(T)) *NumberInputElement[T]
OnChange runs fn with the new value after the user changes it: by typing and pressing Enter or leaving the field, by the Up and Down keys, by the spin buttons, or by assistive technology. The signal is set first. It does not run when the value stays the same, such as a step past the end of the range.
func (*NumberInputElement[T]) Precision ¶
func (n *NumberInputElement[T]) Precision(d int) *NumberInputElement[T]
Precision sets the number of decimals a float is shown with, so 2 shows 1.50. The default is the number of decimals of the step.
func (*NumberInputElement[T]) Small ¶
func (n *NumberInputElement[T]) Small() *NumberInputElement[T]
Small makes the field compact: 28 px high with smaller text, like Button.Small and TextInput.Small, for toolbars and dense forms.
func (*NumberInputElement[T]) SpinButtons ¶
func (n *NumberInputElement[T]) SpinButtons(p SpinPlacement) *NumberInputElement[T]
SpinButtons adds the buttons that step the value, placed as p says: SpinInline draws a decrease and an increase button after the field, and SpinStacked draws an up arrow above a down arrow at its right, as Windows' up-down control does. Their look is in NumberInputStyle.
func (*NumberInputElement[T]) Styles ¶
func (n *NumberInputElement[T]) Styles(st NumberInputStyle) *NumberInputElement[T]
Styles sets the look of the parts of the number input, for this instance only. Set fields win over the theme's NumberInput and the defaults; see NumberInputStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*NumberInputElement[T]) Tooltip ¶
func (n *NumberInputElement[T]) Tooltip(s string) *NumberInputElement[T]
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*NumberInputElement[T]) Validate ¶
func (n *NumberInputElement[T]) Validate(rules ...Validator[T]) *NumberInputElement[T]
Validate sets the validators of the value, which are checked after the value is set: a Field shows the first error once the user has changed the field and left it, and on submit when it is in a Form (see Field and Validator). A number input does not need Required, since it always holds a number.
func (*NumberInputElement[T]) Width ¶
func (n *NumberInputElement[T]) Width(l Length) *NumberInputElement[T]
The sizing methods give the field's frame a size. The default is numberInputWidth wide at the Text size of 100 percent; Width(Full) fills the container, and the spin buttons stay at the frame's edges. See Sizing in docs/styling.md.
type NumberInputStyle ¶
type NumberInputStyle struct {
FieldStyle
SpinButtons Style // the group of spin buttons
SpinButton Style // each spin button
SpinButtonHover Style // a spin button the pointer is over, if enabled
SpinButtonPressed Style // a spin button being pressed
SpinButtonFocusVisible Style // a spin button that has keyboard focus
SpinButtonDisabled Style // a spin button that cannot step the value any further
Message Style // the row with the icon and the message, while the text is invalid
}
NumberInputStyle is the look of each part of a number input. A part's style merges over the built-in defaults, then over the theme's Field and NumberInput, then over the Styles of the instance; see docs/styling.md.
The text frame is FieldStyle: Frame, with its states FrameHover, FrameFocusWithin, FrameDisabled and FrameInvalid, and the Text and Selection parts. Placeholder, Leading and Trailing are in FieldStyle too, but a number field has no placeholder, icon or element, so they do not apply to it. Message is the row that says why the text is invalid: its icon is drawn in the message's TextColor when it sets one, and in Danger (the text color under high contrast) otherwise, and its text takes the same color. The spin buttons are SpinButtons (the group), SpinButton (each button), and its states SpinButtonHover, SpinButtonPressed, SpinButtonFocusVisible and SpinButtonDisabled.
type NumberOptions ¶ added in v0.4.0
type NumberOptions struct {
Decimals int // the most digits after the decimal point; 0 takes whole numbers only
Signed bool // allow a leading minus
NoGrouping bool // show no group separators
// Currency makes the number an amount of money in the currency of the user's
// region settings: it takes the decimal point, the group separator and the
// grouping of amounts of money, and a zero Decimals is the currency's digits. A
// TextInput with the format shows the currency's symbol before or after the
// number, where the settings put it (see CurrencySymbol).
Currency bool
}
NumberOptions say which numbers a NumberFormat takes.
type OTPInputElement ¶ added in v0.3.0
type OTPInputElement struct {
// contains filtered or unexported fields
}
OTPInputElement is an input for a one-time code, such as a verification code sent by text message: a row of boxes that each take one character, bound to a string signal. It is one control with a caret, not a field per box. Typing fills the box at the caret and moves to the next one, Backspace clears the box before the caret and moves back, and Delete clears the box at the caret. The code has no gaps: the characters after a cleared box move up. Left, Right, Home and End move the caret, and a click on a box moves it there (no further than the first empty box). Ctrl+V, or the Paste action, pastes the clipboard's text from the caret, keeping only the characters the input takes. Its keys are the actions of a text field (see DefaultBindings), so a binding that changes them for fields changes them here too.
It takes digits only, unless it is Alphanumeric. An input method's composition is not shown in the boxes: the text it confirms is typed as typed text is.
Assistive technology sees one text field named by its label, whose value is the code, or a dot for each character when it is Masked, with the password state.
func OTPInput ¶ added in v0.3.0
func OTPInput(label string, value *Signal[string], length int) *OTPInputElement
OTPInput creates an input of length boxes that reads and writes value. label names it for assistive technology; a Field that wraps it names it by the field's label instead. A value longer than length shows its first length characters. OTPInput panics when length is less than 1.
func (*OTPInputElement) Alphanumeric ¶ added in v0.3.0
func (o *OTPInputElement) Alphanumeric() *OTPInputElement
Alphanumeric lets the input take the letters A to Z and a to z as well as the digits 0 to 9. A letter is kept as it is typed.
func (*OTPInputElement) Disabled ¶ added in v0.3.0
func (o *OTPInputElement) Disabled(d bool) *OTPInputElement
Disabled shows the code but takes the input out of use: it can't be focused or changed. Its boxes are the BoxDisabled part.
func (*OTPInputElement) FocusHandle ¶ added in v0.3.0
func (o *OTPInputElement) FocusHandle(h *FocusHandle) *OTPInputElement
FocusHandle lets code focus the input (see NewFocusHandle). A Field that wraps the input gives it its own handle, which takes precedence.
func (*OTPInputElement) GridSpan ¶ added in v0.3.0
func (o *OTPInputElement) GridSpan(cols, rows int) *OTPInputElement
GridSpan sets how many columns and rows the input covers in its parent's grid.
func (*OTPInputElement) Groups ¶ added in v0.3.0
func (o *OTPInputElement) Groups(sizes ...int) *OTPInputElement
Groups splits the boxes into groups of the given sizes, with a wider gap between two groups, such as Groups(3, 3) for a six-character code shown as 123 456. The sizes must add up to the length; Groups panics otherwise, or when a size is less than 1. Without Groups the boxes are one group.
func (*OTPInputElement) Grow ¶ added in v0.3.0
func (o *OTPInputElement) Grow(f float32) *OTPInputElement
Grow makes the input take a share of the free space on its parent's main axis.
func (*OTPInputElement) Key ¶ added in v0.3.0
func (o *OTPInputElement) Key(k string) *OTPInputElement
Key identifies the input among its siblings (see DivElement.Key).
func (*OTPInputElement) LabelledBy ¶ added in v0.3.0
func (o *OTPInputElement) LabelledBy(keys ...string) *OTPInputElement
LabelledBy names the input by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*OTPInputElement) Masked ¶ added in v0.3.0
func (o *OTPInputElement) Masked() *OTPInputElement
Masked draws a dot in place of each character, as a password field does, and reports the input to assistive technology as a password field whose value is a dot for each character.
func (*OTPInputElement) MaxWidth ¶ added in v0.3.0
func (o *OTPInputElement) MaxWidth(l Length) *OTPInputElement
MaxWidth sets the largest width of the input.
func (*OTPInputElement) MinWidth ¶ added in v0.3.0
func (o *OTPInputElement) MinWidth(l Length) *OTPInputElement
MinWidth sets the smallest width of the input.
func (*OTPInputElement) OnChange ¶ added in v0.3.0
func (o *OTPInputElement) OnChange(fn func(string)) *OTPInputElement
OnChange runs fn with the new code after the user changes it, by typing, by deleting, by pasting or by assistive technology. The signal is set first.
func (*OTPInputElement) OnComplete ¶ added in v0.3.0
func (o *OTPInputElement) OnComplete(fn func(code string)) *OTPInputElement
OnComplete runs fn with the code when a change by the user fills every box, after OnChange.
func (*OTPInputElement) Styles ¶ added in v0.3.0
func (o *OTPInputElement) Styles(st OTPInputStyle) *OTPInputElement
Styles sets the look of the parts of the input, for this instance only. Set fields win over the theme's OTPInput and the defaults; see OTPInputStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*OTPInputElement) Tooltip ¶ added in v0.3.0
func (o *OTPInputElement) Tooltip(s string) *OTPInputElement
Tooltip shows s below the input after the pointer rests on it. Assistive technology reads it as the input's description, unless it has another.
func (*OTPInputElement) Validate ¶ added in v0.3.0
func (o *OTPInputElement) Validate(rules ...Validator[string]) *OTPInputElement
Validate sets the validators of the code, which a Field checks as it checks a TextInput's text (see Field and Validator). MinLength with the input's length asks for a complete code, and Required for a code that is not empty.
func (*OTPInputElement) Width ¶ added in v0.3.0
func (o *OTPInputElement) Width(l Length) *OTPInputElement
The sizing methods give the input's row a size. The row is as wide as its boxes by default, and a box is 40 px wide at the Text size of 100 percent. See Sizing in docs/styling.md.
type OTPInputStyle ¶ added in v0.3.0
type OTPInputStyle struct {
Root Style // the row that holds the groups of boxes
Group Style // each group of boxes
Box Style // each box, as it is drawn empty
BoxFilled Style // a box that holds a character, over Box
BoxFocused Style // the box at the caret while the input has focus
BoxDisabled Style // a box of a disabled input
BoxInvalid Style // a box of an input whose value is not valid
Text Style // the character in a box
Dot Style // the dot of a masked box that holds a character
}
OTPInputStyle is the look of each part of a one-time code input. A part's style merges over the built-in defaults, then over the theme's OTPInput, then over the Styles of the instance; see docs/styling.md. Root is the row that holds the boxes, and Group each group of boxes (see Groups). Box is each box, the look of an empty one; BoxFilled is drawn over it for a box that holds a character, and BoxFocused for the box at the caret while the input has focus. BoxDisabled is a box of a disabled input, and BoxInvalid a box of an input whose value a Field shows an error for. Text is the character in a box, and Dot the dot that a Masked input draws in its place.
type Option ¶
type Option[T comparable] struct { // Value is the value that the option sets. Value T // Label is the text of the option. Label string // Disabled makes the option unable to be chosen. Disabled bool // Icon is drawn before the label of a ToggleGroup's option, or in its place // (see ToggleGroupElement.IconOnly). A RadioGroup and a Select show the label alone. Icon *icons.Icon }
Option is one choice of a RadioGroup, a Select or a ToggleGroup: the value it sets, the text it shows, and whether it can be chosen.
type PaginationElement ¶
type PaginationElement struct {
// contains filtered or unexported fields
}
PaginationElement is a row of page buttons, with Previous and Next, that reads and writes a page number. Pages are numbered from 1. The current page is selected and cannot be chosen; the other pages are buttons in the Tab order, and Enter and Space choose them, as a click does. Previous and Next are disabled at the ends. The row is a group named by its Label, and the current page is named "Page n, current page".
func Pagination ¶
func Pagination(page *Signal[int], pages int) *PaginationElement
Pagination creates a page control over pages pages, numbered from 1, that reads and writes page. The page shown is page, held between 1 and pages. One page is shown on each side of the current page; see Siblings.
func (*PaginationElement) Compact ¶
func (p *PaginationElement) Compact() *PaginationElement
Compact shows only Previous, the text "Page 3 of 20" and Next, for a place with no room for the page numbers.
func (*PaginationElement) GridSpan ¶
func (p *PaginationElement) GridSpan(cols, rows int) *PaginationElement
GridSpan sets how many columns and rows the pagination covers in its parent's grid.
func (*PaginationElement) Key ¶
func (p *PaginationElement) Key(k string) *PaginationElement
Key gives the control a stable identity. It also scopes the keys of its pages, so give two controls over the same signal different keys. Without a key the signal's identity scopes them.
func (*PaginationElement) Label ¶
func (p *PaginationElement) Label(name string) *PaginationElement
Label names the control for assistive technology, such as "Search results pages". It defaults to the Pagination text of the window's Strings.
func (*PaginationElement) MaxWidth ¶
func (p *PaginationElement) MaxWidth(l Length) *PaginationElement
MaxWidth sets the largest width of the pagination.
func (*PaginationElement) MinWidth ¶
func (p *PaginationElement) MinWidth(l Length) *PaginationElement
MinWidth sets the smallest width of the pagination.
func (*PaginationElement) OnChange ¶
func (p *PaginationElement) OnChange(fn func(page int)) *PaginationElement
OnChange runs fn with the new page after the user chooses a page, by a click, by Enter or Space, or by Previous and Next. The signal is set first.
func (*PaginationElement) Siblings ¶
func (p *PaginationElement) Siblings(n int) *PaginationElement
Siblings sets how many pages are shown on each side of the current page. The default is 1, and a negative value counts as zero.
func (*PaginationElement) Styles ¶
func (p *PaginationElement) Styles(s PaginationStyle) *PaginationElement
Styles sets the look of the parts of the control, for this instance only. Set fields win over the theme's Pagination and the defaults; see PaginationStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*PaginationElement) Tooltip ¶ added in v0.2.0
func (p *PaginationElement) Tooltip(s string) *PaginationElement
Tooltip shows s below the control after the pointer rests on it. Assistive technology reads it as the control's description, unless it has another.
func (*PaginationElement) Width ¶
func (p *PaginationElement) Width(l Length) *PaginationElement
The sizing methods give the control's outer box a size. The control is as wide as its pages by default; see Sizing in docs/styling.md.
type PaginationStyle ¶
type PaginationStyle struct {
Bar Style // the row that holds the control
Page Style // each page number
PageHover Style // a page the pointer is over, if it can be chosen
PageCurrent Style // the current page, over Page
Ellipsis Style // the "..." where pages are skipped
}
PaginationStyle is the look of each part of a pagination control. A part's style merges over the built-in defaults, then over the theme's Pagination, then over the Styles of the instance; see docs/styling.md. Bar is the row that holds the control, Page each page number and PageHover the one the pointer is over. PageCurrent is the current page: it is drawn over Page, filled, and is not chosen. Nav is the Previous and Next button, which takes PageHover too while it is enabled, and Ellipsis the "..." that stands for pages that are skipped.
type Paint ¶
type Paint interface {
// contains filtered or unexported methods
}
Paint is what fills or strokes a shape: a Color, or a gradient made with LinearPaint or RadialPaint.
type Painter ¶
type Painter struct {
// contains filtered or unexported fields
}
Painter draws the shapes and text of a Canvas. Its methods are only valid while the canvas's draw function runs.
func (*Painter) Alpha ¶
Alpha fades later drawing by a, from 0 to 1, until Restore. It multiplies the alpha already set.
func (*Painter) CaretVisible ¶
CaretVisible reports whether a text caret drawn now is on. The caret blinks from activity, the time of its latest edit or move (see Now): on for half the system's caret blink period, then off. It stays on, and does not blink, when the system's caret blink is off, when the user asks for reduced motion, or after a while without activity. In an inactive window it is off and nothing blinks. A blinking caret schedules the frame of its next change, and the canvas draws again then, so ask only for a caret that is drawn.
func (*Painter) Clip ¶
Clip limits later shapes to the inside of path, until Restore. Text is not clipped.
func (*Painter) FontName ¶
func (p *Painter) FontName(st TextFormat) string
FontName returns the name that the platform knows the font of st by, such as "Consolas" for a Mono text on Windows. It is "" when the font declares no name. The name is for assistive technology and the inspector; drawing does not use it.
func (*Painter) MeasureText ¶
func (p *Painter) MeasureText(s string, st TextFormat) (w, h float32)
MeasureText returns the size of s drawn with st, to place labels.
func (*Painter) Now ¶
Now returns the time of the frame being painted, the clock that CaretVisible blinks on. A canvas that starts a blink on an edit or a click records Now in its next paint.
func (*Painter) Restore ¶
func (p *Painter) Restore()
Restore brings back the transform, clip and alpha that the last Save remembered.
func (*Painter) Rotate ¶
Rotate turns later drawing by angle radians, clockwise, about the origin. Text is placed with the rotation but is not drawn rotated.
func (*Painter) Save ¶
func (p *Painter) Save()
Save remembers the transform, clip and alpha, which Restore brings back.
func (*Painter) Scale ¶
Scale scales later drawing by sx, sy about the origin; stroke widths scale too.
func (*Painter) Stroke ¶
func (p *Painter) Stroke(path *Path, s StrokeStyle)
Stroke draws the outline of path with s.
func (*Painter) Text ¶
func (p *Painter) Text(x, y float32, s string, st TextFormat)
Text draws s at x, y, aligned against it as st says, over the shapes. It is one line; a line break starts another. Its position follows the transform; the text is not scaled or rotated.
type PaletteItem ¶ added in v0.4.0
type PaletteItem struct {
// Key identifies the item in the list. It must be unique among the items, and stable.
Key string
// Label is the name of the item. The query matches it and highlights the match.
Label string
// Detail is short text after the label, such as a commit's short hash and author.
// The query matches it too, but it is not highlighted.
Detail string
// Icon is an icon shown before the label.
Icon *icons.Icon
// Keywords are other words the query matches, which are not shown.
Keywords []string
// Run runs when the item is chosen. The palette has closed by then, and focus is
// back where it was, as for a command.
Run func()
}
PaletteItem is a thing a command palette lists besides its commands, such as a branch, a tag or a commit, that the user opens or runs (see CommandPalette.Items). It is listed and matched as a command is: its Label is its name, and the palette keeps the items whose label, Detail or Keywords contain every word of the query.
type PaneElement ¶
type PaneElement struct {
// contains filtered or unexported fields
}
PaneElement is one pane of a split, made by Pane and given to Split.
func Pane ¶
func Pane(content Element) *PaneElement
Pane makes a pane of a split that shows content. The pane takes a size with Size or SizeSignal, and a pane with neither fills the space that the sized panes leave; see Split.
func (*PaneElement) Collapsed ¶
func (p *PaneElement) Collapsed(v *Signal[bool]) *PaneElement
Collapsed stores in v whether the pane is collapsed, so the app can save the state, and makes the pane collapsible (see Collapsible). A collapsed pane is hidden, and its content stays in the tree, so its state survives the collapse.
func (*PaneElement) Collapsible ¶
func (p *PaneElement) Collapsible() *PaneElement
Collapsible lets the user collapse the pane to zero size, with Enter or a double-click on the divider that collapses it, and restore it the same way. The divider is the one between the pane and the split's nearest fill pane, on that side; with no fill pane, the divider after the pane, or before it for the last pane. A divider collapses one pane, and the first one in order keeps it when two would share it. A collapsed pane keeps its size, and its divider and the divider beside it do not move while it is collapsed. The state is kept by the split unless Collapsed is given.
func (*PaneElement) Key ¶
func (p *PaneElement) Key(k string) *PaneElement
Key gives the pane an identity among the panes of its split, so its content keeps its state when panes are added, removed or reordered. The keys of a split's panes must differ. A pane without a key is known by its index.
func (*PaneElement) Label ¶
func (p *PaneElement) Label(name string) *PaneElement
Label names the pane's group for assistive technology, such as "Notes". A pane without a name is not a group in the accessibility tree.
func (*PaneElement) Max ¶
func (p *PaneElement) Max(l Length) *PaneElement
Max sets the most size of the pane, in ui.Px or ui.Percent. A divider stops before the pane goes past it. When Min and Max contradict each other, Min wins.
func (*PaneElement) Min ¶
func (p *PaneElement) Min(l Length) *PaneElement
Min sets the least size of the pane, in ui.Px or ui.Percent. A divider stops before the pane goes below it.
func (*PaneElement) Size ¶
func (p *PaneElement) Size(l Length) *PaneElement
Size sets the pane's starting size, in ui.Px or ui.Percent. A percentage is of the length the panes have, which is the split's length less its dividers. The split keeps the size as the user moves the dividers, in the same unit. The starting size applies when the pane first appears, and is ignored when the pane has a SizeSignal.
func (*PaneElement) SizeSignal ¶
func (p *PaneElement) SizeSignal(v *Signal[Length]) *PaneElement
SizeSignal stores the pane's size in v, and sets it when the user moves a divider beside the pane, so the app can save the size and restore it. The signal holds ui.Px or ui.Percent lengths: a divider keeps the unit of the pane, and a pixel pane keeps its pixels when the window is resized. The split reads the signal, so the app can also change the size.
type PartState ¶
type PartState struct {
Hovered bool // the pointer is over the part
Pressed bool // the part is being pressed
Focused bool // the part has focus (for a select option: it is highlighted)
Selected bool // the part is the selected one
Disabled bool // the part cannot be used
HighContrast bool // high contrast is on; colors are the system colors
}
PartState is the state of one part of a widget. A render slot (such as TabsElement.RenderTab) is called with it, so the content it returns can follow the state. Hovered and Pressed are kept current: the slot's component re-renders when they change.
Focused is keyboard focus on the part. For a select option, which is never focused itself, it means the option is the highlighted one in the open list.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a shape for a Canvas: lines, curves and arcs, in one or more subpaths. Its methods return the path, so they chain.
func (*Path) Arc ¶
Arc adds an arc of the circle of radius r about cx, cy, from the angle start to end in radians: 0 points right, and angles grow clockwise. It runs clockwise when end is greater than start, counterclockwise when it is less, and a sweep of a full turn draws the whole circle. A line joins the end of the path so far to the arc's start.
func (*Path) ArcTo ¶
ArcTo adds an elliptical arc to x, y, as SVG's arc command: radii rx and ry, the ellipse rotated by rotation degrees, and large and sweep picking one of the four arcs that join the points (sweep is clockwise).
func (*Path) EvenOdd ¶
EvenOdd fills the path with the even-odd rule: where subpaths overlap, or one lies inside another, they make a hole. By default (nonzero) a subpath inside another is filled too, unless it runs the other way round.
type PinchEvent ¶
type PinchEvent struct {
// Scale is the scale of the gesture so far.
Scale float32
// PanX and PanY are the pan of the gesture, in logical pixels.
PanX, PanY float32
// Phase is the phase of the gesture: its start, a change, or its end.
Phase GesturePhase
// Inertia is set while the gesture continues after the fingers have lifted.
// With reduced motion the change of an inertia event is left out.
Inertia bool
// X, Y relative to the window, at the center of the gesture; LocalX, LocalY
// relative to the element whose handler is running.
X, Y float32
// LocalX and LocalY are the position relative to the element whose handler is running.
LocalX, LocalY float32
// Width and Height are the size of the element whose handler is running.
Width, Height float32
// Mods are the modifier keys held.
Mods input.Modifiers
// contains filtered or unexported fields
}
PinchEvent describes a pinch (zoom) gesture of a touchpad or touchscreen. A gesture is a GestureBegin, any number of GestureUpdate events, and a GestureEnd. Scale, PanX and PanY are the change since the previous event of the gesture: Scale is multiplicative, 1 when nothing changed, and PanX and PanY are in logical pixels.
func (*PinchEvent) StopPropagation ¶
func (e *PinchEvent) StopPropagation()
StopPropagation prevents ancestors from handling the gesture. The zoom of the window is then left alone too.
type Placement ¶
type Placement uint8
Placement says where an Overlay sits relative to its parent (the anchor).
const ( BelowStart Placement = iota + 1 // under the anchor, left edges aligned BelowCenter // under the anchor, centered BelowEnd // under the anchor, right edges aligned // AboveStart is above the anchor, left edges aligned. AboveStart // AboveCenter is above the anchor, centered. AboveCenter // AboveEnd is above the anchor, right edges aligned. AboveEnd RightStart // right of the anchor, top edges aligned LeftStart // left of the anchor, top edges aligned OverCenter // over the anchor, centered in both directions (a Modal's panel) RightCenter // right of the anchor, centered vertically RightEnd // right of the anchor, bottom edges aligned LeftCenter // left of the anchor, centered vertically LeftEnd // left of the anchor, bottom edges aligned )
type PopoverElement ¶
type PopoverElement struct {
// contains filtered or unexported fields
}
PopoverElement is a trigger that opens a floating panel of any content, such as filters or a small form, next to it. It opens and closes itself, as a DropdownMenu does: a click (or Enter or Space) on the trigger toggles it, and Escape or a click outside closes it. When it opens, keyboard focus moves to the first field or button of the panel; when Escape closes it, focus returns to the trigger. Assistive technology sees the trigger as a button that opens a dialog, and the panel as that dialog.
func Popover ¶
func Popover(trigger Element, content func() Element) *PopoverElement
Popover creates a popover: trigger opens a panel showing what content returns. content runs while the panel is open, like a component's render.
ui.Popover(ui.Button("Filters").Icon(icons.Filter), func() ui.Element {
return filterForm()
}).Placement(ui.BelowStart)
func (*PopoverElement) Key ¶
func (p *PopoverElement) Key(k string) *PopoverElement
Key identifies the popover among its siblings, so it keeps its state when the siblings around it change (see DivElement.Key).
func (*PopoverElement) Label ¶
func (p *PopoverElement) Label(name string) *PopoverElement
Label names the panel for assistive technology. It defaults to the trigger's name, such as the button's label.
func (*PopoverElement) OnChange ¶
func (p *PopoverElement) OnChange(fn func(open bool)) *PopoverElement
OnChange runs fn when the popover opens or closes.
func (*PopoverElement) Placement ¶
func (p *PopoverElement) Placement(pl Placement) *PopoverElement
Placement sets where the panel opens next to the trigger, BelowStart by default. It flips to the other side when it does not fit (see Overlay).
func (*PopoverElement) Styles ¶
func (p *PopoverElement) Styles(st PopoverStyle) *PopoverElement
Styles sets the look of the panel, for this instance only. Set fields win over the theme's Popover and the defaults. Calling Styles again merges.
type PopoverStyle ¶
type PopoverStyle struct {
Panel Style // the floating panel that holds the content
}
PopoverStyle is the look of a popover's panel. It merges over the built-in defaults, then over the theme's Popover, then over the Styles of the instance; see docs/styling.md.
type ProgressBarElement ¶
type ProgressBarElement struct {
// contains filtered or unexported fields
}
ProgressBarElement shows how far an operation has got, as a bar. A determinate bar fills from the low end of its range to its value. An indeterminate bar slides while the work runs, for work whose length is not known. It is read-only: nothing the user does changes it.
func ProgressBar ¶
func ProgressBar(value float64) *ProgressBarElement
ProgressBar creates a bar showing value. The range is 0 to 1 by default; see Min and Max. For work of unknown length, see Indeterminate. The bar fills the width of its container by default (see Width).
func (*ProgressBarElement) Color ¶
func (p *ProgressBarElement) Color(c Color) *ProgressBarElement
Color sets the color of the fill, for an app that has a color of its own, such as a project's. The default is the theme accent. The app is responsible for the contrast of its color against the track: the fill is a non-text object and needs 3:1 against the track (WCAG 1.4.11). Under high contrast the fill is the Highlight color, and Color is not used.
func (*ProgressBarElement) Format ¶
func (p *ProgressBarElement) Format(fn func(float64) string) *ProgressBarElement
Format sets the readout beside the bar. The default shows the share of the range that is done, as a percentage. An indeterminate bar has no readout, and neither has a bar whose Format returns "" (see HideValue).
func (*ProgressBarElement) GridSpan ¶
func (p *ProgressBarElement) GridSpan(cols, rows int) *ProgressBarElement
GridSpan sets how many columns and rows the progress bar covers in its parent's grid.
func (*ProgressBarElement) Grow ¶
func (p *ProgressBarElement) Grow(f float32) *ProgressBarElement
Grow makes the progress bar take a share of the free space on its parent's main axis.
func (*ProgressBarElement) HideValue ¶ added in v0.6.0
func (p *ProgressBarElement) HideValue() *ProgressBarElement
HideValue leaves out the readout, so the track takes the bar's whole width, as when the text beside the bar already says "21/25". A Format that returns "" does the same. Assistive technology still reads the value through the range.
func (*ProgressBarElement) Indeterminate ¶
func (p *ProgressBarElement) Indeterminate() *ProgressBarElement
Indeterminate makes the bar show work of unknown length, such as ui.ProgressBar(0).Indeterminate(). It slides while the work runs, and is drawn in the middle when reduced motion is on. Its value is not shown.
func (*ProgressBarElement) Key ¶
func (p *ProgressBarElement) Key(k string) *ProgressBarElement
Key identifies the progress bar among its siblings (see DivElement.Key).
func (*ProgressBarElement) Label ¶
func (p *ProgressBarElement) Label(name string) *ProgressBarElement
Label names the bar for assistive technology, such as "Upload". Without it the bar is named with the Progress text of the window's Strings, or with its Loading… text when it is indeterminate.
func (*ProgressBarElement) Max ¶
func (p *ProgressBarElement) Max(hi float64) *ProgressBarElement
Max sets the high end of the value's range, 1 by default. A value outside the range is clamped.
func (*ProgressBarElement) MaxWidth ¶
func (p *ProgressBarElement) MaxWidth(l Length) *ProgressBarElement
MaxWidth sets the largest width of the progress bar.
func (*ProgressBarElement) Min ¶
func (p *ProgressBarElement) Min(lo float64) *ProgressBarElement
Min sets the low end of the value's range, 0 by default. A value outside the range is clamped.
func (*ProgressBarElement) MinWidth ¶
func (p *ProgressBarElement) MinWidth(l Length) *ProgressBarElement
MinWidth sets the smallest width of the progress bar.
func (*ProgressBarElement) Styles ¶
func (p *ProgressBarElement) Styles(st ProgressBarStyle) *ProgressBarElement
Styles sets the look of the parts of the bar, for this instance only. Set fields win over the theme's ProgressBar and the defaults; see ProgressBarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ProgressBarElement) Width ¶
func (p *ProgressBarElement) Width(l Length) *ProgressBarElement
The sizing methods give the bar's outer box a size, including its readout. A bar fills its container by default; Width(Px(240)) fixes it, and the track keeps the room that is left for the readout. See Sizing in docs/styling.md.
type ProgressBarStyle ¶
type ProgressBarStyle struct {
Track Style // the groove the fill is drawn in
Fill Style // the filled part, or the sliding segment of an indeterminate bar
Label Style // the readout beside the bar, a percentage by default
}
ProgressBarStyle is the look of each part of a progress bar, determinate or indeterminate. A part's style merges over the built-in defaults, then over the theme's ProgressBar, then over the Styles of the instance; see docs/styling.md. Track is the bar's groove, Fill the part that shows the progress (in an indeterminate bar, the segment that slides along the groove), and Label the readout beside the bar. The width of Fill follows the value, so set its colors, radius and border, not its width.
type ProgressRingElement ¶
type ProgressRingElement struct {
// contains filtered or unexported fields
}
ProgressRingElement is a busy indicator: a ring of dots that turns while the app waits for something. It has no value, so it says only that work is under way. It is named with the LoadingEllipsis text of the window's Strings unless Label gives another name.
func ProgressRing ¶
func ProgressRing() *ProgressRingElement
ProgressRing creates a busy indicator of the medium size (RingMedium).
func (*ProgressRingElement) Key ¶
func (r *ProgressRingElement) Key(k string) *ProgressRingElement
Key identifies the progress ring among its siblings (see DivElement.Key).
func (*ProgressRingElement) Label ¶
func (r *ProgressRingElement) Label(name string) *ProgressRingElement
Label names the indicator for assistive technology, such as "Sending reply".
func (*ProgressRingElement) Size ¶
func (r *ProgressRingElement) Size(px float32) *ProgressRingElement
Size sets the diameter, in logical pixels: RingSmall, RingMedium or RingLarge.
func (*ProgressRingElement) Styles ¶
func (r *ProgressRingElement) Styles(st ProgressRingStyle) *ProgressRingElement
Styles sets the look of the parts of the ring, for this instance only. Set fields win over the theme's ProgressRing and the defaults; see ProgressRingStyle and docs/styling.md. Calling Styles again merges with the earlier values.
type ProgressRingStyle ¶
type ProgressRingStyle struct {
Ring Style // the box of the ring
Dot Style // each dot of the ring
}
ProgressRingStyle is the look of a progress ring. A part's style merges over the built-in defaults, then over the theme's ProgressRing, then over the Styles of the instance; see docs/styling.md. Ring is the box the dots are drawn in, whose size is the ring's Size. Dot is each dot: its color and its opacity follow the motion of the ring and the contrast, and a Dot style merges over them, so a Background in it replaces the dot's color.
type QueryOption ¶ added in v0.4.0
type QueryOption func(*queryOptions)
QueryOption configures Query. See QueryRetry, QueryRetryDelay, QueryStaleTime, QueryCacheTime, QueryKeepPrevious and QueryEnabled.
func QueryCacheTime ¶ added in v0.4.0
func QueryCacheTime(d time.Duration) QueryOption
QueryCacheTime sets how long the data of a key that no component uses is kept. The default is five minutes. Zero or less drops it at once.
func QueryEnabled ¶ added in v0.4.0
func QueryEnabled(on bool) QueryOption
QueryEnabled sets whether the query fetches. With false, no fetch starts: not when a component starts using the key, not on invalidation, and not on Refetch, which does nothing for a key with no enabled user. Refetch is blocked on purpose, so that a disabled query never fetches. The default is true.
func QueryKeepPrevious ¶ added in v0.4.0
func QueryKeepPrevious() QueryOption
QueryKeepPrevious makes a key change keep showing the data of the previous key, with Fetching set, until the new key's data arrives. Without it a key with no data shows no data. The previous key is the one the Query call at the same position used in the component's previous render, so make the calls in the same order on each render.
func QueryRetry ¶ added in v0.4.0
func QueryRetry(n int) QueryOption
QueryRetry sets how many times a failed fetch is run again before its error is kept. The default is 0: desktop data is mostly local, so a failure is shown at once. Each retry waits longer than the one before it (see QueryRetryDelay).
func QueryRetryDelay ¶ added in v0.4.0
func QueryRetryDelay(d time.Duration) QueryOption
QueryRetryDelay sets how long the first retry waits. Each later retry waits twice as long as the one before, up to 30 seconds, or up to d when d is longer. The default is one second, so retries wait 1 s, 2 s, 4 s and so on.
func QueryStaleTime ¶ added in v0.4.0
func QueryStaleTime(d time.Duration) QueryOption
QueryStaleTime sets how long fetched data counts as fresh. A component that starts using a key fetches again when its data is older than this, and an invalidated key is fetched again whatever its age. The default is 0: data is stale at once, so each new user of a key refetches it.
type QueryResult ¶ added in v0.4.0
type QueryResult[T any] struct { // Data is the last data fetched successfully for the key, or the zero value. Data T // Err is the error of the last fetch that failed, and nil once a fetch succeeds. Err error // Loading is true when there is no data yet and a fetch is in flight. Loading bool // Fetching is true while any fetch of the key is in flight, including a refetch // while Data is shown. Fetching bool // UpdatedAt is the time of the last successful fetch, or of SetQueryData. UpdatedAt time.Time // contains filtered or unexported fields }
QueryResult is what Query returns for one render: the data of the key and the state of its fetch.
func Query ¶ added in v0.4.0
func Query[T any](ctx *Context, key string, fetch func(context.Context) (T, error), opts ...QueryOption) QueryResult[T]
Query reads the data of key, fetching it when needed, and returns it for the component's render. Components that use the same key share one entry and one fetch: while a fetch is in flight, no other starts for the key. The cache is per window.
res := ui.Query(ctx, "commit:"+hash, func(c context.Context) (repo.Details, error) {
return repo.Show(c, root, hash)
}, ui.QueryKeepPrevious())
if res.Loading {
return ui.Skeleton()
}
The fetch runs off the UI thread and gets a context. That context is canceled when no component uses the key any more, when a refetch of the key starts while the fetch runs, and when the window closes. A panic in fetch becomes an error. The result reaches the UI thread through Post. A canceled fetch's result is dropped, even when the fetch returns data anyway, so the cache holds only the data of fetches that finished while they were wanted. A component that moves to another key never shows the old key's result.
A fetch starts when a component starts using a key whose data is missing or stale (see QueryStaleTime), when an invalidated key has an enabled user, and on Refetch. The component re-renders when the entry changes. The fetch function of the latest render is the one that runs.
QueryKeepPrevious compares each Query call with the call at the same position in the component's previous render, so a component should make its Query calls in the same order on every render, as it would with hooks.
The key holds one type: a Query and a SetQueryData for the same key must use the same T, or the call panics.
func (QueryResult[T]) Refetch ¶ added in v0.4.0
func (r QueryResult[T]) Refetch()
Refetch fetches the key again now, cancelling a fetch that is in flight. It runs on the UI thread, such as from a click handler.
type RadioGroupElement ¶
type RadioGroupElement[T comparable] struct { // contains filtered or unexported fields }
RadioGroupElement is a set of radio buttons, one per option, bound to a value. The selected option is the one whose value equals the signal's. The group is one Tab stop: Tab enters it at the selected option, and the arrow keys move to the next option and select it. Up and Left go back; Down and Right go on. They wrap around and skip disabled options, as Windows radio buttons do.
func RadioGroup ¶
func RadioGroup[T comparable](value *Signal[T], options ...Option[T]) *RadioGroupElement[T]
RadioGroup creates a group of radio buttons that reads and writes value.
func (*RadioGroupElement[T]) Disabled ¶
func (r *RadioGroupElement[T]) Disabled(d bool) *RadioGroupElement[T]
Disabled shows every option but lets none of them be chosen.
func (*RadioGroupElement[T]) FocusHandle ¶
func (r *RadioGroupElement[T]) FocusHandle(h *FocusHandle) *RadioGroupElement[T]
FocusHandle lets code focus the group's tab stop: the checked option, or the first enabled one (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*RadioGroupElement[T]) GridSpan ¶
func (r *RadioGroupElement[T]) GridSpan(cols, rows int) *RadioGroupElement[T]
GridSpan sets how many columns and rows the radio group covers in its parent's grid.
func (*RadioGroupElement[T]) Grow ¶
func (r *RadioGroupElement[T]) Grow(f float32) *RadioGroupElement[T]
Grow makes the radio group take a share of the free space on its parent's main axis.
func (*RadioGroupElement[T]) Height ¶
func (r *RadioGroupElement[T]) Height(l Length) *RadioGroupElement[T]
Height sets the height of the radio group.
func (*RadioGroupElement[T]) Key ¶
func (r *RadioGroupElement[T]) Key(k string) *RadioGroupElement[T]
Key identifies the radio group among its siblings (see DivElement.Key).
func (*RadioGroupElement[T]) Label ¶
func (r *RadioGroupElement[T]) Label(s string) *RadioGroupElement[T]
Label names the group for assistive technology, such as "Frequency". The group has no visible name of its own, so give it one.
func (*RadioGroupElement[T]) LabelledBy ¶
func (r *RadioGroupElement[T]) LabelledBy(keys ...string) *RadioGroupElement[T]
LabelledBy names the group by the text of the elements with the given keys, such as a visible label above it (see DivElement.LabelledBy).
func (*RadioGroupElement[T]) MaxWidth ¶
func (r *RadioGroupElement[T]) MaxWidth(l Length) *RadioGroupElement[T]
MaxWidth sets the largest width of the radio group.
func (*RadioGroupElement[T]) MinWidth ¶
func (r *RadioGroupElement[T]) MinWidth(l Length) *RadioGroupElement[T]
MinWidth sets the smallest width of the radio group.
func (*RadioGroupElement[T]) OnChange ¶
func (r *RadioGroupElement[T]) OnChange(fn func(T)) *RadioGroupElement[T]
OnChange runs fn with the chosen value after the user selects an option, by a click or by the arrow keys. The signal is set first.
func (*RadioGroupElement[T]) Styles ¶
func (r *RadioGroupElement[T]) Styles(st RadioGroupStyle) *RadioGroupElement[T]
Styles sets the look of the parts of the radio group, for this instance only. Set fields win over the theme's RadioGroup and the defaults; see RadioGroupStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*RadioGroupElement[T]) Tooltip ¶
func (r *RadioGroupElement[T]) Tooltip(s string) *RadioGroupElement[T]
Tooltip shows s below the group after the pointer rests on it. Assistive technology reads it as the group's description, unless it has another.
func (*RadioGroupElement[T]) Validate ¶
func (r *RadioGroupElement[T]) Validate(rules ...Validator[T]) *RadioGroupElement[T]
Validate sets the validators of the chosen value. The zero value is no choice, so Required[T] rejects it (see Field).
func (*RadioGroupElement[T]) Width ¶
func (r *RadioGroupElement[T]) Width(l Length) *RadioGroupElement[T]
The sizing methods give the group's outer box a size. A group is as wide as its widest option by default; see Sizing in docs/styling.md.
type RadioGroupStyle ¶
type RadioGroupStyle struct {
Group Style // the column of options
Radio Style // each option: its ring and its label
RadioFocusVisible Style // an option that has keyboard focus
RadioDisabled Style // an option that cannot be chosen
Ring Style // the circle of each option
RingChecked Style // the circle of the selected option
RingDisabled Style // the circle of an option that cannot be chosen
RingInvalid Style // the circle of each option when the group's value is not valid (see Field)
Dot Style // the dot in the circle of the selected option
DotDisabled Style // the dot of a selected option that cannot be chosen
Label Style // the text of each option
LabelDisabled Style // the text of an option that cannot be chosen
}
RadioGroupStyle is the look of each part of a radio group. A part's style merges over the built-in defaults, then over the theme's RadioGroup, then over the Styles of the instance; see docs/styling.md. Group is the column of options. Each option is a Radio row, with a Ring (the circle) and a Dot in the ring when the option is selected, and a Label. The states are parts of their own: RingChecked for the selected option's ring, RingDisabled and RadioDisabled for an option that cannot be chosen, RadioFocusVisible while the option has keyboard focus, and LabelDisabled for its text.
type RangeSliderElement ¶ added in v0.3.0
type RangeSliderElement struct {
// contains filtered or unexported fields
}
RangeSliderElement sets a range, a low and a high value, with two thumbs on one track from lo to hi, in steps of step. The track between the thumbs is filled. The thumbs cannot cross: a thumb moved into the other stops there, or MinGap before it. A press on the track moves the nearer thumb there, and a drag moves it on. Each thumb is a Tab stop, with the keys of a Slider: the arrows move it by one step, Page Up and Page Down by a tenth of the range, and Home and End as far as it can go.
func RangeSlider ¶ added in v0.3.0
func RangeSlider(low, high *Signal[float64], lo, hi, step float64) *RangeSliderElement
RangeSlider creates a range slider that reads and writes low and high, from lo to hi in steps of step. It fills the width of its container by default, as a Slider does (see Width).
func (*RangeSliderElement) Disabled ¶ added in v0.3.0
func (s *RangeSliderElement) Disabled(d bool) *RangeSliderElement
Disabled shows the range slider but does not let it change.
func (*RangeSliderElement) FocusHandle ¶ added in v0.3.0
func (s *RangeSliderElement) FocusHandle(h *FocusHandle) *RangeSliderElement
FocusHandle lets code focus the low thumb (see NewFocusHandle).
func (*RangeSliderElement) Format ¶ added in v0.3.0
func (s *RangeSliderElement) Format(fn func(float64) string) *RangeSliderElement
Format sets how each value is shown beside the track and read by assistive technology. The default shows the value with as many decimals as the step has.
func (*RangeSliderElement) GridSpan ¶ added in v0.3.0
func (s *RangeSliderElement) GridSpan(cols, rows int) *RangeSliderElement
GridSpan sets how many columns and rows the range slider covers in its parent's grid.
func (*RangeSliderElement) Grow ¶ added in v0.3.0
func (s *RangeSliderElement) Grow(f float32) *RangeSliderElement
Grow makes the range slider take a share of the free space on its parent's main axis.
func (*RangeSliderElement) Key ¶ added in v0.3.0
func (s *RangeSliderElement) Key(k string) *RangeSliderElement
Key identifies the range slider among its siblings (see DivElement.Key).
func (*RangeSliderElement) Label ¶ added in v0.3.0
func (s *RangeSliderElement) Label(name string) *RangeSliderElement
Label names the range slider for assistive technology, such as "Price". It is the name of the group that holds the two thumbs, which are named Strings.Minimum and Strings.Maximum.
func (*RangeSliderElement) LabelledBy ¶ added in v0.3.0
func (s *RangeSliderElement) LabelledBy(keys ...string) *RangeSliderElement
LabelledBy names the range slider's group by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*RangeSliderElement) MaxWidth ¶ added in v0.3.0
func (s *RangeSliderElement) MaxWidth(l Length) *RangeSliderElement
MaxWidth sets the largest width of the range slider.
func (*RangeSliderElement) MinGap ¶ added in v0.3.0
func (s *RangeSliderElement) MinGap(gap float64) *RangeSliderElement
MinGap keeps the high value at least gap above the low value, so the thumbs stop gap apart. It is 0 by default, where the two values may be equal. Give a whole number of steps.
func (*RangeSliderElement) MinWidth ¶ added in v0.3.0
func (s *RangeSliderElement) MinWidth(l Length) *RangeSliderElement
MinWidth sets the smallest width of the range slider.
func (*RangeSliderElement) OnChange ¶ added in v0.3.0
func (s *RangeSliderElement) OnChange(fn func(low, high float64)) *RangeSliderElement
OnChange runs fn with the new values when the user moves a thumb to a value that differs from its current one. The signals are set first.
func (*RangeSliderElement) Styles ¶ added in v0.3.0
func (s *RangeSliderElement) Styles(st RangeSliderStyle) *RangeSliderElement
Styles sets the look of the parts of the range slider, for this instance only. Set fields win over the theme's RangeSlider and the defaults; see RangeSliderStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*RangeSliderElement) Tooltip ¶ added in v0.3.0
func (s *RangeSliderElement) Tooltip(text string) *RangeSliderElement
Tooltip shows s below the range slider after the pointer rests on it. Assistive technology reads it as the group's description, unless it has another.
func (*RangeSliderElement) Width ¶ added in v0.3.0
func (s *RangeSliderElement) Width(l Length) *RangeSliderElement
The sizing methods give the range slider's outer box a size, including its readout, as for a Slider. See Sizing in docs/styling.md.
type RangeSliderStyle ¶ added in v0.3.0
type RangeSliderStyle struct {
Track Style // the area that takes the pointer
Rail Style // the line the values are drawn on
Fill Style // the part of the rail between the thumbs
Thumb Style // each knob
ThumbHover Style // a knob while the pointer is over it
ThumbPressed Style // the knob that is dragged
ThumbFocusVisible Style // a knob while it has keyboard focus
ValueText Style // the readout beside the track
}
RangeSliderStyle is the look of each part of a range slider. A part's style merges over the built-in defaults, then over the theme's RangeSlider, then over the Styles of the instance; see docs/styling.md.
Track is the area that takes the pointer, with the rail and the thumbs drawn over it. Rail is the line the values are drawn on, and Fill the part of the rail between the two thumbs (its width comes from the values, so Grow is not set by the style). Thumb is each knob, always sliderThumb pixels wide. The thumbs are the controls that take focus: ThumbFocusVisible is a thumb with keyboard focus, ThumbHover a thumb under the pointer while the slider is enabled, and ThumbPressed the thumb that is dragged. ValueText is the readout of the two values beside the track.
type RatingElement ¶ added in v0.3.0
type RatingElement struct {
// contains filtered or unexported fields
}
RatingElement is a row of stars that shows and sets a whole number from 0 to its maximum, bound to an int signal. The pointer over a star previews that value, a click sets it, and a click on the star of the current value clears it to 0. Keys: Left and Down lower the value by one, Right and Up raise it, Home sets 0, End the maximum, and a digit key sets that value when it is not above the maximum. Assistive technology reads it as a slider from 0 to the maximum, with a value text such as "3 of 5 stars" (Strings.RatingValue).
func Rating ¶ added in v0.3.0
func Rating(label string, value *Signal[int]) *RatingElement
Rating creates a rating of 5 stars that reads and writes value. label names the rating for assistive technology, such as "Rating"; a Field's label replaces it.
func (*RatingElement) Disabled ¶ added in v0.3.0
func (r *RatingElement) Disabled(d bool) *RatingElement
Disabled shows the rating dimmed and does not let it change.
func (*RatingElement) FocusHandle ¶ added in v0.3.0
func (r *RatingElement) FocusHandle(h *FocusHandle) *RatingElement
FocusHandle lets code focus the rating (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*RatingElement) GridSpan ¶ added in v0.3.0
func (r *RatingElement) GridSpan(cols, rows int) *RatingElement
GridSpan sets how many columns and rows the rating covers in its parent's grid.
func (*RatingElement) Grow ¶ added in v0.3.0
func (r *RatingElement) Grow(f float32) *RatingElement
Grow makes the rating take a share of the free space on its parent's main axis.
func (*RatingElement) Key ¶ added in v0.3.0
func (r *RatingElement) Key(k string) *RatingElement
Key identifies the rating among its siblings (see DivElement.Key).
func (*RatingElement) Max ¶ added in v0.3.0
func (r *RatingElement) Max(n int) *RatingElement
Max sets the number of stars, which is the highest value. It is 5 by default, and at least 1.
func (*RatingElement) MaxWidth ¶ added in v0.3.0
func (r *RatingElement) MaxWidth(l Length) *RatingElement
MaxWidth sets the largest width of the rating.
func (*RatingElement) MinWidth ¶ added in v0.3.0
func (r *RatingElement) MinWidth(l Length) *RatingElement
MinWidth sets the smallest width of the rating.
func (*RatingElement) OnChange ¶ added in v0.3.0
func (r *RatingElement) OnChange(fn func(int)) *RatingElement
OnChange runs fn with the new value after the user changes the rating, by the pointer, the keys or assistive technology. The signal is set first.
func (*RatingElement) ReadOnly ¶ added in v0.3.0
func (r *RatingElement) ReadOnly() *RatingElement
ReadOnly shows the value, not dimmed, and does not let it change: the rating takes no focus, pointer or keys. Assistive technology still reads it, as a read-only slider.
func (*RatingElement) Styles ¶ added in v0.3.0
func (r *RatingElement) Styles(st RatingStyle) *RatingElement
Styles sets the look of the parts of the rating, for this instance only. Set fields win over the theme's Rating and the defaults; see RatingStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*RatingElement) Tooltip ¶ added in v0.3.0
func (r *RatingElement) Tooltip(s string) *RatingElement
Tooltip shows s below the rating after the pointer rests on it. Assistive technology reads it as the rating's description, unless it has another.
func (*RatingElement) Validate ¶ added in v0.3.0
func (r *RatingElement) Validate(rules ...Validator[int]) *RatingElement
Validate sets the validators of the value. 0 is no rating, so Required[int] rejects it (see Field).
func (*RatingElement) Width ¶ added in v0.3.0
func (r *RatingElement) Width(l Length) *RatingElement
The sizing methods give the row of stars a size. A rating is as wide as its stars by default; see Sizing in docs/styling.md.
type RatingStyle ¶ added in v0.3.0
type RatingStyle struct {
Root Style // the row of stars: the focus element
RootFocusVisible Style // the row while it has keyboard focus
RootDisabled Style // the row when the rating is disabled
Star Style // each star: its box, and the color of its icon (TextColor)
StarChecked Style // a star at or below the value, drawn filled
StarHover Style // a star up to the one under the pointer, drawn filled
StarDisabled Style // each star when the rating is disabled
}
RatingStyle is the look of each part of a rating. A part's style merges over the built-in defaults, then over the theme's Rating, then over the Styles of the instance; see docs/styling.md. Root is the row of stars: it takes focus and the pointer. Each Star holds its icon, which is drawn in the star's TextColor: an outline for a star above the value, and a filled star for one at or below it. The states are parts of their own: StarChecked for a filled star, StarHover for the stars up to the one under the pointer, which preview the value a click sets, StarDisabled and RootDisabled when the rating cannot change, and RootFocusVisible while it has keyboard focus.
type Rect ¶
Rect is a rectangle in logical pixels: X and Y are the top-left corner, and W and H the size. Element-relative where a function says so (IME.Caret), window coordinates otherwise.
type RelativeUnit ¶ added in v0.4.0
type RelativeUnit int
RelativeUnit is a unit of time in a relative time, such as "3 days ago": the minutes, hours, days, weeks, months and years that Strings.RelativeAgo and Strings.RelativeIn name.
const ( RelativeMinute RelativeUnit = iota RelativeHour RelativeDay RelativeWeek RelativeMonth RelativeYear )
The units of a relative time, from the shortest to the longest.
type Renderer ¶
type Renderer interface {
Element
// Render returns the element's content, built with ctx.
Render(ctx *Context) Element
}
Renderer is an element defined in another package (see Composite).
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime turns a root render function into scenes and routes input to element handlers. The app package drives it; it has no platform or GPU dependencies, which also makes it usable headless in tests.
A Runtime is not safe for concurrent use: call Frame and the input methods from one goroutine (the UI thread). Signals are the exception and may be set from anywhere.
func NewRuntime ¶
NewRuntime creates a runtime for the given root render function.
func (*Runtime) AccessBridge ¶
AccessBridge returns the bridge that publishes the runtime's accessibility tree to the platform adapter. The host passes it to the adapter (see platform.AccessHandler). It is created on first use and is safe to call on the UI thread.
func (*Runtime) AccessTree ¶
AccessTree builds the accessibility tree now, from the current nodes, for tests and the tree dump. It does not publish it.
func (*Runtime) AddBindings ¶
AddBindings adds key bindings. Later bindings for the same keys take precedence over earlier ones at the same level.
func (*Runtime) AppTheme ¶
AppTheme returns the theme the app set with SetTheme. Under high contrast the active theme is the high contrast one, so this is the theme to show as chosen.
func (*Runtime) AvailableActions ¶
AvailableActions lists the actions handled on the focus path, deepest element first, without duplicates. Menus and the command palette use it.
func (*Runtime) ContentWidth ¶
ContentWidth returns how far right the laid-out content reaches, in logical pixels, ignoring content inside clipping or scrolling containers. A value above the window width means the UI overflows horizontally — a handy assertion for layout tests at a minimum window size.
func (*Runtime) Dispatch ¶
Dispatch runs a on the focus path (the focused element, then its ancestors, or the root when nothing is focused): the deepest element with an OnAction handler for a runs it. It reports whether a handler ran.
func (*Runtime) DropFiles ¶
DropFiles delivers files dropped from the operating system at (x, y), in device-logical pixels like the Pointer methods. The files go to the deepest element with a Drop[Files] target. There are no Over, Move or Leave callbacks for them: the platform does not report the pointer during a drop from outside the app.
func (*Runtime) Dump ¶
Dump writes the current element tree with laid-out positions (logical pixels, window coordinates). maxDepth limits the depth; 0 means no limit. It is meant for debugging layouts, by humans or coding agents:
rt.Frame(time.Now()) rt.Dump(os.Stdout, 6)
func (*Runtime) Fetching ¶ added in v0.6.0
Fetching reports whether a Query of the window has a fetch in flight or waits to retry one. Settled does not count fetches, since they run in real time; the JAMB_SCRIPT idle step waits for both. Call it on the UI goroutine.
func (*Runtime) Find ¶
Find returns the laid-out rectangle (logical pixels, window coordinates) of the first element in tree order whose key is key. Keys of components and composite elements (TextInput, Button, ...) belong to the element they render. For elements that are not on screen, the rectangle comes from layout: their position plus the scroll offsets of their scrolling ancestors.
func (*Runtime) FocusedHandle ¶
func (rt *Runtime) FocusedHandle() *FocusHandle
FocusedHandle returns a handle to whatever has keyboard focus now, or to "nothing focused", so focus can be restored later, for example when a palette or dialog closes. Element IDs are stable across rebuilds, so the handle keeps working after re-renders.
func (*Runtime) Frame ¶
Frame brings the scene up to date, as the window host does before it draws. Each stage does only the work its inputs require: dirty components re-render and rebuild just their subtrees, layout revisits only invalidated or resized subtrees, and an idle frame keeps the retained scene untouched. The window host draws the scene that a frame brings up to date (see runtimeHost.Frame).
func (*Runtime) FrameRequested ¶ added in v0.4.0
FrameRequested reports whether a frame is wanted now: NeedsFrame, or a wake-up requested since the last Frame began (by Post, a change made from another goroutine, or a timer). Frame statistics use it to tell a frame that followed at once from one that came after an idle gap.
func (*Runtime) HighContrast ¶
HighContrast reports whether the high contrast theme is in use.
func (*Runtime) HostLayerShown ¶ added in v0.6.2
HostLayerShown reports whether the host layer is attached to the window's tree, so that what it renders shows. It is false before SetHostLayer, before the first frame, and while the app's root element is not a Div.
func (*Runtime) KeyDown ¶
KeyDown handles a key press. Bindings and element handlers run in this order, which docs/input.md describes:
- the OnKeyDown of the focused text field, if it has one: a stopped key goes no further
- a chord in progress: a key that starts a longer binding waits, for up to chordTimeout, for the rest of the chord; when the keys held back match nothing, they are replayed and this key is handled again
- all bindings, contextual (BindIn) and global (Bind), in precedence order; the first whose action has a handler on the focus path runs
- OnKeyDown, from the focused element up to the root; then Escape closes the topmost overlay with an OnClickOutside, or hides a tooltip, in place of the field's Cancel (see escapeDismisses); the auto-repeats of that press are ignored, so holding Escape closes one overlay
- Enter or Space (without modifiers, not a repeat) runs the focused element's OnClick; a text field keeps these keys
- Tab (which also reveals the element it moves to), the Menu key and Shift+F10 (which open the focused element's context menu), and the zoom keys
So a key that is both a binding and the start of a longer chord waits up to a second before it runs. A chord that starts with a printable key, such as "g g", delays typing that key in fields by up to a second; prefer modifiers, or a context such as "!Editor".
func (*Runtime) KeyUp ¶
KeyUp handles a key release. The text a key types arrives between its press and its release, so the release also ends any swallowing of text.
func (*Runtime) KeysFor ¶
KeysFor returns the display text of the most recently added binding for a, such as "Ctrl+Shift+P" or "Ctrl+K Ctrl+T", or "" if a is not bound. A binding that a later NoAction or Unbind turns off does not count.
func (*Runtime) NeedsFrame ¶
NeedsFrame reports whether something changed since the last Frame. An animation waiting out its Delay asks for no frame: the window is woken when it is due.
func (*Runtime) Pinch ¶
func (rt *Runtime) Pinch(x, y float32, phase GesturePhase, scale, panX, panY float32, inertia bool, mods input.Modifiers)
Pinch handles a pinch gesture of a touchpad or touchscreen, whose center is at (x, y) in device-logical pixels. Like Scroll, it goes to the deepest element under the center that has OnPinch, then to its ancestors, until one stops it. A pinch that nothing stops zooms the window, one zoom step per pinchStep of scale, when the zoom shortcuts are on. With reduced motion the change of an inertia event is left out, and the gesture still begins and ends. The platform calls this (see PinchEvent for the fields); tests and scripts may call it too.
func (*Runtime) PointerDown ¶
PointerDown handles a button press.
func (*Runtime) PointerMove ¶
PointerMove handles pointer motion in logical pixels.
func (*Runtime) PointerUp ¶
PointerUp handles a button release, firing OnClick when the release happens over an element that was pressed.
func (*Runtime) Post ¶
func (rt *Runtime) Post(fn func())
Post runs fn on the UI thread at the start of the next frame and requests that frame. Safe from any goroutine: background work hands results to the UI this way.
func (*Runtime) ReducedMotion ¶
ReducedMotion reports whether the user asked for less motion.
func (*Runtime) ResetZoom ¶
func (rt *Runtime) ResetZoom()
ResetZoom returns the content to 100 percent.
func (*Runtime) ScrollIntoView ¶ added in v0.6.2
ScrollIntoView scrolls the element whose node in AccessTree has the ID into view, as an assistive technology's ScrollIntoView does: its nearest scroll container moves the least amount that shows it. The scroll is applied by the frames that follow. It reports whether the tree has an element with the ID.
func (*Runtime) SetAccessWarnings ¶
SetAccessWarnings turns the development warnings on or off. While they are on, the tree is built after each change even without an assistive technology, so that unlabeled elements are reported when they are built. Each element is reported once. Warnings go to the function set by SetWarnFunc.
func (*Runtime) SetBindings ¶
SetBindings replaces all bindings of one layer with bs. The new bindings take the place of the layer's first binding, so the layer keeps its precedence against bindings added before and after it; a layer with no bindings yet is added at the end. Empty bs removes the layer. layer must not be "": that is the layer AddBindings uses.
func (*Runtime) SetDefaultTitleBar ¶ added in v0.6.2
SetDefaultTitleBar gives the window a title bar of the runtime's own, with title and the caption buttons (minimize, maximize and close), or takes it away. The host turns it on for a window that asked for the system's title bar on a desktop that draws none, such as GNOME, whose compositor leaves window frames to the apps. The app's root element is laid out under the bar, in the rest of the window, and keeps its IDs and its layout otherwise. Calling it again with on changes the title. Call it on the UI thread.
func (*Runtime) SetHostLayer ¶ added in v0.6.2
SetHostLayer gives the host of the runtime, such as package app, a layer of its own above the app's UI. fn is a component that renders the layer: it runs again when the signals it reads change, as any component does. It renders overlays, such as an AlertDialog or a Modal, or nil for nothing. What it renders joins the window's tree after the app's root element, so a modal in it takes the focus, traps Tab and is found by screen readers and the control channel, as one the app opened is. The app's elements keep their IDs and their layout: the layer is attached beside them, not around them. It needs a root element that lays out children, a Div or a component that renders one, as nearly every app's root is; HostLayerShown reports whether it has one.
The app package uses it for the prompt about unsaved changes when a window closes (see app.Window.Unsaved). Call it on the UI thread. A nil fn removes the layer.
func (*Runtime) SetStrings ¶
SetStrings sets the text the built-in controls show and announce, and re-renders all components. Fields that s leaves empty show the English text (see Strings). A nil s is English. A new runtime is English until SetStrings is called.
func (*Runtime) SetSystemSettings ¶
func (rt *Runtime) SetSystemSettings(s SystemSettings)
SetSystemSettings applies the operating system's settings. Every component is rendered again, so that a change of theme or text size shows at once.
func (*Runtime) SetThemes ¶
SetThemes makes the runtime follow the system's app mode: it uses dark while the system is in dark mode (SystemSettings.Dark), and light otherwise, and switches when the setting changes. SetTheme stops following and sets one theme. Under high contrast the high contrast theme is built from the one in use.
func (*Runtime) SetViewport ¶
SetViewport sets the window size in logical pixels and the device scale.
func (*Runtime) SetWarnFunc ¶
SetWarnFunc replaces where non-fatal warnings (such as duplicate keys) go. The default prints to stderr.
func (*Runtime) SetWindow ¶
SetWindow connects the runtime to its window. The app calls it once, before the first frame.
func (*Runtime) SetZoom ¶
SetZoom scales the whole UI, clamped to 50%–300%. Text and shapes are re-rendered at the new size, so they stay sharp.
func (*Runtime) SetZoomShortcuts ¶
SetZoomShortcuts enables (default) or disables the built-in Ctrl+= / Ctrl+- / Ctrl+0 keys and Ctrl+wheel zooming.
func (*Runtime) Settled ¶
Settled reports whether the UI has come to rest: nothing changed since the last Frame, nothing animates toward an end, and no animation waits out its Delay or has an OnDone still to run. Repeating animations (see Animation.Repeat) never end, so they do not count; NeedsFrame still reports them.
func (*Runtime) Stats ¶
func (rt *Runtime) Stats() FrameStats
Stats returns statistics about the last frame.
func (*Runtime) StyleOf ¶ added in v0.2.0
func (rt *Runtime) StyleOf(key string) (DrawnStyle, bool)
StyleOf returns how the latest paint drew the first element in tree order whose key is key (see Find, and DrawnStyle), and false when there is no such element. Call it after Frame. It is meant for tests and tools, and reads what paint recorded without changing anything.
func (*Runtime) SystemSettings ¶
func (rt *Runtime) SystemSettings() SystemSettings
SystemSettings returns the settings the runtime uses, normalized.
func (*Runtime) TextInput ¶
TextInput delivers typed text to the focused element. Text produced by a key that a binding consumed is dropped, unless the key is part of a chord: then the text is kept with that stroke, to be typed if the chord is replayed.
type SVGElement ¶
type SVGElement struct {
// contains filtered or unexported fields
}
SVGElement draws an SVGSource.
func SVG ¶
func SVG(src *SVGSource) *SVGElement
SVG creates an element that draws src, at its own size unless Size sets one; the image keeps its aspect ratio inside the box, as its preserveAspectRatio says, unless Fit places it. It is drawn at the display's resolution, so it is sharp at any size and zoom, and drawn again only when its size, scale or color changes.
currentColor in the image is the inherited text color, as for an Icon, so a monochrome icon set (such as Lucide's or Heroicons' SVG files) follows the text and the theme; Color sets it instead.
//go:embed logo.svg
var logoSVG []byte
var logo = ui.MustSVG(logoSVG)
ui.SVG(logo).Size(ui.Px(120), ui.Px(40)).Alt("Acme")
func (*SVGElement) Alt ¶
func (e *SVGElement) Alt(s string) *SVGElement
Alt describes the image for assistive technology, which then reads it as an image. Without it the image is decorative, as an Icon is, and left out.
func (*SVGElement) Color ¶
func (e *SVGElement) Color(c Color) *SVGElement
Color sets the color that currentColor in the image stands for.
func (*SVGElement) Fit ¶ added in v0.2.0
func (e *SVGElement) Fit(f ImageFit) *SVGElement
Fit chooses cover, contain or fill, as it does for an Image: cover fills the box, cropping the image, contain shows the whole image, letterboxed, and fill stretches the image to the box. Without Fit the image is fitted as its preserveAspectRatio says, which is contain for most files.
func (*SVGElement) Key ¶
func (e *SVGElement) Key(k string) *SVGElement
Key identifies the image among its siblings (see DivElement.Key).
func (*SVGElement) Opacity ¶ added in v0.2.0
func (e *SVGElement) Opacity(o float32) *SVGElement
Opacity fades the image.
func (*SVGElement) Radius ¶ added in v0.2.0
func (e *SVGElement) Radius(r float32) *SVGElement
Radius rounds the image corners.
func (*SVGElement) Size ¶
func (e *SVGElement) Size(w, h Length) *SVGElement
Size sets the width and height of the box the image is fitted into.
func (*SVGElement) Style ¶
func (e *SVGElement) Style(s Style) *SVGElement
Style merges layout fields (margins, alignment, opacity...) of s.
type SVGSource ¶
type SVGSource struct {
// contains filtered or unexported fields
}
SVGSource is a parsed SVG image. Create it once (for example at package init, from an embedded file) and reuse it.
func SVGFromBytes ¶
SVGFromBytes parses an SVG image. It draws the static parts of SVG that icon sets and design tools write: paths and the basic shapes, groups, use, transforms, fills and strokes in colors or gradients, opacity, clip paths, the viewBox and preserveAspectRatio, and styles from presentation attributes, style attributes and style sheets with type, class and id selectors. Text, filters, masks, patterns, markers, embedded images and animation draw nothing.
type ScrollEvent ¶
type ScrollEvent struct {
// DeltaX and DeltaY are the amount of the scroll, in logical pixels.
DeltaX, DeltaY float32
// Mods are the modifier keys held.
Mods input.Modifiers
// contains filtered or unexported fields
}
ScrollEvent describes a wheel or touchpad scroll in logical pixels.
func (*ScrollEvent) StopPropagation ¶
func (e *ScrollEvent) StopPropagation()
StopPropagation prevents ancestors (and built-in scrolling) from handling the event.
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
Segment is one piece of rich text built with Rich.
func Link ¶
Link is a clickable piece of text. It takes the theme's Link color (when no Color is set) and underlines while the pointer is over it. Tab stops on it, a ring shows its keyboard focus, and Enter follows it (see OnClick).
func LinkSegs ¶ added in v0.3.0
LinkSegs makes one link of the segments segs, as Link does for one: each takes the theme's Link color unless it sets a Color, underlines while the pointer is over the link (unless it has a Hover of its own), and a click on any of them runs fn. Use it for a link whose text mixes styles, such as a bold word in it:
ui.Rich(append([]ui.Segment{ui.Seg("See ")},
ui.LinkSegs(open, ui.Seg("the "), ui.Seg("guide").Bold())...)...)
Placed one after another in a Rich text, the segments are one link: one stop in the Tab order, one focus ring around all of their words, and one link for assistive technology, named by their joined text. Enter runs fn once.
func (Segment) Background ¶
Background sets the color behind the segment's text.
func (Segment) Hover ¶
Hover merges h into the segment while the pointer is over it. Only the fields that do not change the shaping apply (Color, Background, Underline, Strikethrough), so hovering never re-lays out the text.
func (Segment) OnClick ¶
OnClick makes the segment clickable: the pointer is a hand over it, and a click runs fn instead of the clickable elements around it. The segment is a link to assistive technology and a stop of its own in the Tab order, and Enter runs fn while it has focus.
func (Segment) Strikethrough ¶
Strikethrough draws a line through the segment's text.
type SelectElement ¶
type SelectElement[T comparable] struct { // contains filtered or unexported fields }
SelectElement is a drop-down list: a field that shows the chosen option, and opens a list of the options below it (above it when there is no room).
Click, Enter, Space, Alt+Down or F4 open the list. While it is closed, Up and Down choose the previous and next option, Home and End choose the first and last, and typing letters chooses the first option that starts with them. In the list, Up and Down move the highlight (without wrapping), Home and End go to the ends, and typing moves to a matching option. Enter or Space chooses the highlighted option and closes the list. Escape, Tab and a press outside the list close it without a change. Focus returns to the field when the list closes, as it does for a menu.
func Select ¶
func Select[T comparable](value *Signal[T], options ...Option[T]) *SelectElement[T]
Select creates a drop-down list that reads and writes value. The options are shown in order. The default width is 220 px at the Text size of 100 percent.
func (*SelectElement[T]) Disabled ¶
func (s *SelectElement[T]) Disabled(d bool) *SelectElement[T]
Disabled shows the field but does not let it change.
func (*SelectElement[T]) FocusHandle ¶
func (s *SelectElement[T]) FocusHandle(h *FocusHandle) *SelectElement[T]
FocusHandle lets code focus the select (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*SelectElement[T]) GridSpan ¶
func (s *SelectElement[T]) GridSpan(cols, rows int) *SelectElement[T]
GridSpan sets how many columns and rows the select covers in its parent's grid.
func (*SelectElement[T]) Grow ¶
func (s *SelectElement[T]) Grow(f float32) *SelectElement[T]
Grow makes the select take a share of the free space on its parent's main axis.
func (*SelectElement[T]) Height ¶
func (s *SelectElement[T]) Height(l Length) *SelectElement[T]
Height sets the height of the select.
func (*SelectElement[T]) Key ¶
func (s *SelectElement[T]) Key(k string) *SelectElement[T]
Key identifies the select among its siblings (see DivElement.Key).
func (*SelectElement[T]) Label ¶
func (s *SelectElement[T]) Label(name string) *SelectElement[T]
Label names the field for assistive technology, such as "Channel".
func (*SelectElement[T]) LabelledBy ¶
func (s *SelectElement[T]) LabelledBy(keys ...string) *SelectElement[T]
LabelledBy names the field by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*SelectElement[T]) Large ¶
func (s *SelectElement[T]) Large() *SelectElement[T]
Large makes the field larger: 40 px high with 16 px text, like Button.Large and TextInput.Large, for touch-friendly or prominent forms. Small and Large replace each other.
func (*SelectElement[T]) MaxHeight ¶
func (s *SelectElement[T]) MaxHeight(l Length) *SelectElement[T]
MaxHeight sets the largest height of the select.
func (*SelectElement[T]) MaxWidth ¶
func (s *SelectElement[T]) MaxWidth(l Length) *SelectElement[T]
MaxWidth sets the largest width of the select.
func (*SelectElement[T]) MinHeight ¶
func (s *SelectElement[T]) MinHeight(l Length) *SelectElement[T]
MinHeight sets the smallest height of the select.
func (*SelectElement[T]) MinWidth ¶
func (s *SelectElement[T]) MinWidth(l Length) *SelectElement[T]
MinWidth sets the smallest width of the select.
func (*SelectElement[T]) OnChange ¶
func (s *SelectElement[T]) OnChange(fn func(T)) *SelectElement[T]
OnChange runs fn with the chosen value after the user chooses an option, by the list or by the keys. The signal is set first.
func (*SelectElement[T]) Placeholder ¶
func (s *SelectElement[T]) Placeholder(text string) *SelectElement[T]
Placeholder is the text shown while no option is chosen.
func (*SelectElement[T]) RenderOption ¶
func (s *SelectElement[T]) RenderOption(fn func(opt Option[T], state PartState) Element) *SelectElement[T]
RenderOption replaces the label of each option in the open list with what fn returns. The option keeps its check mark, role, selection and highlight, and its accessible name stays its label. The content is hidden from assistive technology. The state's Focused means the option is highlighted.
ui.Select(color, options...).RenderOption(func(o ui.Option[string], s ui.PartState) ui.Element {
return ui.Div().Size(ui.Px(12), ui.Px(12)).Radius(6).Background(swatch[o.Value])
})
func (*SelectElement[T]) RenderValue ¶
func (s *SelectElement[T]) RenderValue(fn func(opt Option[T], state PartState) Element) *SelectElement[T]
RenderValue replaces the label of the chosen option in the field with what fn returns, for example a swatch and the label. fn is called only while an option is chosen; the placeholder is shown otherwise. The field keeps its behavior, and its accessible name and value stay the option's label. The content is hidden from assistive technology.
func (*SelectElement[T]) Small ¶
func (s *SelectElement[T]) Small() *SelectElement[T]
Small makes the field compact: 28 px high with smaller text, like Button.Small and TextInput.Small, for toolbars and dense forms.
func (*SelectElement[T]) Styles ¶
func (s *SelectElement[T]) Styles(st SelectStyle) *SelectElement[T]
Styles sets the look of the parts of the select, for this instance only. Set fields win over the theme's Select and the defaults; see SelectStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SelectElement[T]) Tooltip ¶
func (s *SelectElement[T]) Tooltip(text string) *SelectElement[T]
Tooltip shows s below the select after the pointer rests on it. Assistive technology reads it as the select's description, unless it has another.
func (*SelectElement[T]) Validate ¶
func (s *SelectElement[T]) Validate(rules ...Validator[T]) *SelectElement[T]
Validate sets the validators of the chosen value. The zero value is the placeholder, so Required[T] rejects it: a field must show a choice (see Field).
func (*SelectElement[T]) Width ¶
func (s *SelectElement[T]) Width(l Length) *SelectElement[T]
The sizing methods give the field a size. The field is 220 px wide at the Text size of 100 percent by default; Width(Full) fills its container. The list is at least as wide as the field. See Sizing in docs/styling.md.
type SelectStyle ¶
type SelectStyle struct {
Trigger Style // the field that shows the chosen option
TriggerHover Style // the field while the pointer is over it
TriggerFocusVisible Style // the field while it has keyboard focus
TriggerDisabled Style // the field when it is disabled
TriggerInvalid Style // the field when its value is not valid (see Field)
Value Style // the label of the chosen option in the field
Placeholder Style // the placeholder, while no option is chosen
Chevron Style // the arrow at the right of the field
Popup Style // the open list of options
Option Style // each option in the list
OptionHighlighted Style // the option that has keyboard focus in the list
OptionSelected Style // the chosen option
OptionDisabled Style // an option that cannot be chosen
}
SelectStyle is the look of each part of a select. A part's style merges over the built-in defaults, then over the theme's Select, then over the Styles of the instance; see docs/styling.md. The states are parts of their own: TriggerHover while the pointer is over the field, TriggerFocusVisible while it has keyboard focus, TriggerDisabled when it is disabled, OptionHighlighted for the option that has keyboard focus in the open list, OptionSelected for the chosen option and OptionDisabled for an option that cannot be chosen.
type SelectionMode ¶
type SelectionMode uint8
SelectionMode says how many rows the user can select at once.
const ( SelectionNone SelectionMode = iota // rows cannot be selected SelectionSingle // one row at a time SelectionMultiple // any number of rows, with Ctrl and Shift )
type Shadow ¶
type Shadow struct {
// X and Y are the offset of the shadow, in logical pixels.
X, Y float32
Blur float32 // blur radius in logical pixels (≈ 2× the Gaussian sigma)
// Spread grows the shadow, or shrinks it when it is negative, in logical pixels.
Spread float32
// Color is the color of the shadow.
Color Color
}
Shadow is a drop shadow.
type SidebarElement ¶
type SidebarElement struct {
// contains filtered or unexported fields
}
SidebarElement is a vertical navigation pane, as the left pane of WinUI's NavigationView. The item whose key is the selected signal's value is selected.
The pane is one Tab stop, at the selected item, or at the first enabled item when the selected one is not among them. Up and Down move the keyboard focus to the previous and next enabled item, without wrapping, and skip the headings and the disabled items. Home and End go to the first and last enabled item. Focus follows the keys, but the selection does not change until the user presses Enter or Space on the focused item, or clicks it, as NavigationView does. A click selects an item and gives it the focus.
Assistive technology reads the pane as a group named by its Label (by default the Navigation text of the window's Strings), the items as the items of a list, and the headings as headings. The selected item reports the selected state and a disabled one the disabled state. An item with a badge is named with its count, as in "Inbox, 4".
The pane takes the height of its row, so put it in a Row beside the content. Its items scroll when they do not fit, and a Header and a Footer stay in place.
func Sidebar ¶
func Sidebar(selected *Signal[string], items ...SidebarItem) *SidebarElement
Sidebar creates a navigation pane of items, with the item whose key equals selected's value selected. The items are shown in order.
func (*SidebarElement) Collapsed ¶
func (s *SidebarElement) Collapsed(c *Signal[bool]) *SidebarElement
Collapsed makes the sidebar collapsible by c: when c is true the sidebar is about 48 px wide and shows only the icons of its items. Each item then shows its label as a tooltip, and each heading is a thin rule. An item with no icon shows nothing in a collapsed sidebar. The header and the footer are drawn as they are.
func (*SidebarElement) Footer ¶
func (s *SidebarElement) Footer(el Element) *SidebarElement
Footer puts el below the items, pinned at the bottom of the sidebar, such as a Settings item or an account Avatar.
func (*SidebarElement) GridSpan ¶
func (s *SidebarElement) GridSpan(cols, rows int) *SidebarElement
GridSpan sets how many columns and rows the sidebar covers in its parent's grid.
func (*SidebarElement) Header ¶
func (s *SidebarElement) Header(el Element) *SidebarElement
Header puts el above the items. It does not scroll.
func (*SidebarElement) Key ¶
func (s *SidebarElement) Key(k string) *SidebarElement
Key gives the sidebar a stable identity. It also scopes the keys of its items. Without a key the signal's identity scopes them.
func (*SidebarElement) Label ¶
func (s *SidebarElement) Label(name string) *SidebarElement
Label names the pane for assistive technology, such as "Main navigation". The default is the Navigation text of the window's Strings.
func (*SidebarElement) MaxWidth ¶
func (s *SidebarElement) MaxWidth(l Length) *SidebarElement
MaxWidth sets the largest width of the sidebar.
func (*SidebarElement) MinWidth ¶
func (s *SidebarElement) MinWidth(l Length) *SidebarElement
MinWidth sets the smallest width of the sidebar.
func (*SidebarElement) NoIndicator ¶ added in v0.6.0
func (s *SidebarElement) NoIndicator() *SidebarElement
NoIndicator leaves out the bar at the left of the selected item. The bar marks the selection by more than its color, so give ItemSelected a mark that does not rely on color alone, such as a bold label or a border, when it is left out. To leave it out of every sidebar, set the theme's Sidebar.Indicator to Style{Clear: ClearBackground}.
func (*SidebarElement) OnChange ¶
func (s *SidebarElement) OnChange(fn func(key string)) *SidebarElement
OnChange runs fn with the key of the item after the user selects it, by a click, Enter or Space. The signal is set first.
func (*SidebarElement) Styles ¶
func (s *SidebarElement) Styles(st SidebarStyle) *SidebarElement
Styles sets the look of the parts of the sidebar, for this instance only. Set fields win over the theme's Sidebar and the defaults; see SidebarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SidebarElement) Toggle ¶
func (s *SidebarElement) Toggle() *SidebarElement
Toggle adds a menu button at the top of the sidebar that flips the signal given to Collapsed. It is named with the CollapseNavigation text of the window's Strings while the sidebar is expanded, and with the ExpandNavigation text while it is collapsed, and it reports the expanded state. It has no effect without Collapsed.
func (*SidebarElement) Tooltip ¶ added in v0.2.0
func (s *SidebarElement) Tooltip(text string) *SidebarElement
Tooltip shows s below the pane after the pointer rests on it; an item of a collapsed sidebar shows its own label instead. Assistive technology reads it as the pane's description, unless it has another.
func (*SidebarElement) Width ¶
func (s *SidebarElement) Width(l Length) *SidebarElement
The sizing methods give the expanded sidebar a width, which the Text size scales by default. A collapsed sidebar is always about 48 px wide, whatever they are set to. See Sizing in docs/styling.md.
type SidebarItem ¶
type SidebarItem struct {
// Key identifies the item among the items of the sidebar.
Key string
// Label is the text of the item.
Label string
// Icon is an icon shown before the label.
Icon *icons.Icon
Badge int // a count shown at the end of the item when it is above zero
// Disabled makes the item unable to be chosen.
Disabled bool
// contains filtered or unexported fields
}
SidebarItem is one entry of a Sidebar: a page or a command, with its key, its label, an optional icon and an optional count. Selecting an item sets the selected signal to its Key. A disabled item is shown but cannot be selected. A heading is made with SidebarHeading, and a rule with SidebarDivider.
func SidebarDivider ¶ added in v0.6.0
func SidebarDivider() SidebarItem
SidebarDivider returns a thin rule between two groups of items of a Sidebar, for groups that need no name. It is not selectable, and assistive technology does not see it; a group it should hear named needs a SidebarHeading.
func SidebarHeading ¶
func SidebarHeading(label string) SidebarItem
SidebarHeading returns a heading of a Sidebar: a line of text that names the group of items below it. A heading is not selectable, and in a collapsed sidebar it is drawn as a thin rule.
type SidebarStyle ¶
type SidebarStyle struct {
Pane Style // the column that holds the sidebar
Item Style // each item
ItemHover Style // an item the pointer is over, if it is enabled and not selected
ItemSelected Style // the selected item
ItemDisabled Style // a disabled item
ItemFocusVisible Style // an item that has keyboard focus
Indicator Style // the bar at the left of the selected item
Heading Style // each heading of an expanded sidebar
Divider Style // each divider, and each heading of a collapsed sidebar, which is drawn as a rule
Toggle Style // the button that collapses and expands the sidebar
}
SidebarStyle is the look of each part of a sidebar. A part's style merges over the built-in defaults, then over the theme's Sidebar, then over the Styles of the instance. The states are parts of their own: ItemHover applies to an enabled item the pointer is over, if it is not selected, ItemSelected to the selected item, ItemDisabled to a disabled one, and ItemFocusVisible to an item that has keyboard focus. Indicator is the bar at the left of the selected item, so the selection is not carried by color alone. See docs/styling.md.
type Signal ¶
type Signal[T any] struct { // contains filtered or unexported fields }
Signal is a reactive value. Reading it with Get inside a component's render function subscribes that component; Set re-renders every subscriber on the next frame. Signals are safe to use from any goroutine; off the UI thread, prefer Peek to Get.
Treat the value as immutable. To change a slice, map or struct pointer held in a signal, build a new one and Set it (slices.Clone, append to a copy, ...). Changing it in place does not notify anyone, and can race with a render reading it.
func Local ¶
Local returns a signal that belongs to the calling component and lives as long as the component does — state that no other part of the app needs, such as a draft being typed, an expanded/collapsed flag or a hover-card's visibility:
ui.Component(func(ctx *ui.Context) ui.Element {
open := ui.Local(ctx, "open", false)
return ui.Button("Details").OnClick(func() { open.Set(!open.Peek()) }) ...
})
Locals are found by name, not by call order, so calling Local inside conditions or loops is fine. The first call creates the signal with initial; later calls return it (initial is ignored). Reading it with Get re-renders the component when it changes, like any signal. Using the same name with a different type panics with an explanation.
func (*Signal[T]) Get ¶
func (s *Signal[T]) Get() T
Get returns the value and, during rendering, subscribes the rendering component.
type SkeletonElement ¶
type SkeletonElement struct {
// contains filtered or unexported fields
}
SkeletonElement is a placeholder for content that is still loading: a bar, a circle or a set of text lines, which pulses gently. It is hidden from assistive technology. The app marks the region that is loading as busy, or labels it "Loading", so that assistive technology knows that it is waiting.
func Skeleton ¶
func Skeleton() *SkeletonElement
Skeleton creates a placeholder bar of text height, full width of its container by default. See Circle and Lines for other shapes.
func (*SkeletonElement) Circle ¶
func (s *SkeletonElement) Circle(diameter float32) *SkeletonElement
Circle makes the skeleton a circle of the given diameter, in logical pixels at the default Text size, such as the placeholder of an Avatar. It grows with the Text size, as an Avatar of the same size does.
func (*SkeletonElement) GridSpan ¶
func (s *SkeletonElement) GridSpan(cols, rows int) *SkeletonElement
GridSpan sets how many columns and rows the skeleton covers in its parent's grid.
func (*SkeletonElement) Grow ¶
func (s *SkeletonElement) Grow(f float32) *SkeletonElement
Grow makes the skeleton take a share of the free space on its parent's main axis.
func (*SkeletonElement) Height ¶
func (s *SkeletonElement) Height(l Length) *SkeletonElement
Height sets the height of the skeleton.
func (*SkeletonElement) Key ¶
func (s *SkeletonElement) Key(k string) *SkeletonElement
Key identifies the skeleton among its siblings (see DivElement.Key).
func (*SkeletonElement) Lines ¶
func (s *SkeletonElement) Lines(n int) *SkeletonElement
Lines makes the skeleton n bars of text height, separated by a gap, as the placeholder of a paragraph. The last bar is about 60 percent wide. A count below one is one bar.
func (*SkeletonElement) MaxWidth ¶
func (s *SkeletonElement) MaxWidth(l Length) *SkeletonElement
MaxWidth sets the largest width of the skeleton.
func (*SkeletonElement) Styles ¶
func (s *SkeletonElement) Styles(st SkeletonStyle) *SkeletonElement
Styles sets the look of the parts of the skeleton, for this instance only. Set fields win over the theme's Skeleton and the defaults; see SkeletonStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SkeletonElement) Width ¶
func (s *SkeletonElement) Width(l Length) *SkeletonElement
The sizing methods give the skeleton's outer box a size. See Sizing in docs/styling.md.
type SkeletonStyle ¶
type SkeletonStyle struct {
Bone Style // each placeholder shape
}
SkeletonStyle is the look of each part of a skeleton. A part's style merges over the built-in defaults, then over the theme's Skeleton, then over the Styles of the instance; see docs/styling.md. Bone is each placeholder shape: its fill, its corners and its size. A Circle, or a sizing method, sets the size of a bone over its style.
type SliderElement ¶
type SliderElement struct {
// contains filtered or unexported fields
}
SliderElement moves a value along a track from lo to hi, in steps of step. The mouse sets the value by a click or a drag. Keys: the arrows move it by one step, Page Up and Page Down by a tenth of the range, and Home and End go to the ends.
func Slider ¶
func Slider(value *Signal[float64], lo, hi, step float64) *SliderElement
Slider creates a slider that reads and writes value, from lo to hi in steps of step. It fills the width of its container by default (see Width).
func (*SliderElement) Disabled ¶
func (s *SliderElement) Disabled(d bool) *SliderElement
Disabled shows the slider but does not let it change.
func (*SliderElement) FocusHandle ¶
func (s *SliderElement) FocusHandle(h *FocusHandle) *SliderElement
FocusHandle lets code focus the slider (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*SliderElement) Format ¶
func (s *SliderElement) Format(fn func(float64) string) *SliderElement
Format sets how the value is shown beside the track. The default shows the value with as many decimals as the step has.
func (*SliderElement) GridSpan ¶
func (s *SliderElement) GridSpan(cols, rows int) *SliderElement
GridSpan sets how many columns and rows the slider covers in its parent's grid.
func (*SliderElement) Grow ¶
func (s *SliderElement) Grow(f float32) *SliderElement
Grow makes the slider take a share of the free space on its parent's main axis.
func (*SliderElement) Key ¶
func (s *SliderElement) Key(k string) *SliderElement
Key identifies the slider among its siblings (see DivElement.Key).
func (*SliderElement) Label ¶
func (s *SliderElement) Label(name string) *SliderElement
Label names the slider for assistive technology, such as "Volume".
func (*SliderElement) LabelledBy ¶
func (s *SliderElement) LabelledBy(keys ...string) *SliderElement
LabelledBy names the slider by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*SliderElement) MaxWidth ¶
func (s *SliderElement) MaxWidth(l Length) *SliderElement
MaxWidth sets the largest width of the slider.
func (*SliderElement) MinWidth ¶
func (s *SliderElement) MinWidth(l Length) *SliderElement
MinWidth sets the smallest width of the slider.
func (*SliderElement) OnChange ¶
func (s *SliderElement) OnChange(fn func(float64)) *SliderElement
OnChange runs fn with the new value when the user moves the slider to a value that differs from the current one. The signal is set first.
func (*SliderElement) Styles ¶
func (s *SliderElement) Styles(st SliderStyle) *SliderElement
Styles sets the look of the parts of the slider, for this instance only. Set fields win over the theme's Slider and the defaults; see SliderStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SliderElement) Tooltip ¶
func (s *SliderElement) Tooltip(text string) *SliderElement
Tooltip shows s below the slider after the pointer rests on it. Assistive technology reads it as the slider's description, unless it has another.
func (*SliderElement) Width ¶
func (s *SliderElement) Width(l Length) *SliderElement
The sizing methods give the slider's outer box a size, including its readout. A slider fills its container by default, so Width(Px(240)) fixes it and MinWidth keeps its track usable. See Sizing in docs/styling.md.
type SliderStyle ¶
type SliderStyle struct {
Track Style // the control: it takes focus and the pointer
TrackFocusVisible Style // the control while it has keyboard focus
Rail Style // the line the value is drawn on
Fill Style // the part of the rail up to the value
Thumb Style // the knob at the value
ThumbHover Style // the knob while the pointer is over it
ThumbPressed Style // the knob while it is dragged
ValueText Style // the readout beside the track
}
SliderStyle is the look of each part of a slider. A part's style merges over the built-in defaults, then over the theme's Slider, then over the Styles of the instance; see docs/styling.md.
Track is the control itself: it takes focus and the pointer, and the rail and thumb are drawn over it. Rail is the line the value is drawn on, Fill is the part of the rail up to the value (its width comes from the value, so Grow is not set by the style), and Thumb is the knob, always sliderThumb pixels wide so that the ends of the track stay where the value puts them. The thumb's states are ThumbHover, while the pointer is over an enabled slider's thumb, and ThumbPressed, while it is dragged.
type SortState ¶
type SortState struct {
// Key is the key of the column that the grid is sorted by.
Key string
// Desc is true when the sort is descending.
Desc bool
}
SortState is the sort of a DataGrid: the rows ordered by the column with the key Key, in descending order when Desc is set. An empty Key leaves the rows in the order they were given.
type SpinPlacement ¶
type SpinPlacement uint8
SpinPlacement is where a number input's spin buttons are drawn. The zero value is SpinInline.
const ( // SpinInline draws a decrease and an increase button after the field, as two // square buttons with a minus and a plus sign. SpinInline SpinPlacement = iota // SpinStacked draws an up arrow above a down arrow at the right of the field, // as the up-down control of Windows does, in a compact column. SpinStacked )
type SplitButtonElement ¶ added in v0.3.0
type SplitButtonElement struct {
// contains filtered or unexported fields
}
SplitButtonElement is a button with a main action and a menu of related ones, such as Save beside Save as and Save a copy: two joined segments, the action and an arrow that opens the menu below the button. The action runs on a click, Enter or Space. The menu opens on a click on the arrow, on Enter, Space or Down while the arrow has focus, and on Alt+Down while either segment has focus. It closes as a DropdownMenu's does, and Escape returns the focus to where it was.
Each segment is a Tab stop. Assistive technology sees a group named by the label with two buttons: the action, named by the label, and the arrow, named Strings.MoreOptions, which reports whether its menu is expanded.
func SplitButton ¶ added in v0.3.0
func SplitButton(label string, onClick func(), build func() []MenuItem) *SplitButtonElement
SplitButton creates a split button that runs onClick for its label, and opens the menu that build returns from its arrow. build runs each time the menu opens; an empty result opens nothing. The default variant is Primary, as for Button.
func (*SplitButtonElement) Danger ¶ added in v0.3.0
func (b *SplitButtonElement) Danger() *SplitButtonElement
Danger sets the look to that of a ButtonDanger button.
func (*SplitButtonElement) Disabled ¶ added in v0.3.0
func (b *SplitButtonElement) Disabled(d bool) *SplitButtonElement
Disabled sets whether the split button is disabled: neither the action nor the menu can be used.
func (*SplitButtonElement) FocusHandle ¶ added in v0.3.0
func (b *SplitButtonElement) FocusHandle(h *FocusHandle) *SplitButtonElement
FocusHandle lets code focus the action segment (see NewFocusHandle).
func (*SplitButtonElement) Ghost ¶ added in v0.3.0
func (b *SplitButtonElement) Ghost() *SplitButtonElement
Ghost sets the look to that of a ButtonGhost button.
func (*SplitButtonElement) GridSpan ¶ added in v0.3.0
func (b *SplitButtonElement) GridSpan(cols, rows int) *SplitButtonElement
GridSpan sets how many columns and rows the split button covers in its parent's grid.
func (*SplitButtonElement) Grow ¶ added in v0.3.0
func (b *SplitButtonElement) Grow(f float32) *SplitButtonElement
Grow makes the split button take a share of the free space on its parent's main axis.
func (*SplitButtonElement) Icon ¶ added in v0.3.0
func (b *SplitButtonElement) Icon(ic *icons.Icon) *SplitButtonElement
Icon sets an icon drawn before the label.
func (*SplitButtonElement) Key ¶ added in v0.3.0
func (b *SplitButtonElement) Key(k string) *SplitButtonElement
Key identifies the split button among its siblings (see DivElement.Key).
func (*SplitButtonElement) Large ¶ added in v0.3.0
func (b *SplitButtonElement) Large() *SplitButtonElement
Large makes the split button use the large control size, as Button.Large does. Small and Large replace each other.
func (*SplitButtonElement) Loading ¶ added in v0.4.0
func (b *SplitButtonElement) Loading(on bool) *SplitButtonElement
Loading shows a busy ring on the action segment and makes both segments inert, as Button.Loading does: the action does not run and the menu does not open. Both keep their focus and Tab stops, and the split button keeps its width. Disabled(true) wins over Loading.
func (*SplitButtonElement) MaxWidth ¶ added in v0.3.0
func (b *SplitButtonElement) MaxWidth(l Length) *SplitButtonElement
MaxWidth sets the largest width of the split button.
func (*SplitButtonElement) MinWidth ¶ added in v0.3.0
func (b *SplitButtonElement) MinWidth(l Length) *SplitButtonElement
MinWidth sets the smallest width of the split button.
func (*SplitButtonElement) Primary ¶ added in v0.3.0
func (b *SplitButtonElement) Primary() *SplitButtonElement
Primary sets the look to that of a ButtonPrimary button.
func (*SplitButtonElement) Secondary ¶ added in v0.3.0
func (b *SplitButtonElement) Secondary() *SplitButtonElement
Secondary sets the look to that of a ButtonSecondary button.
func (*SplitButtonElement) Small ¶ added in v0.3.0
func (b *SplitButtonElement) Small() *SplitButtonElement
Small makes the split button use the small control size, as Button.Small does.
func (*SplitButtonElement) Styles ¶ added in v0.3.0
func (b *SplitButtonElement) Styles(st SplitButtonStyle) *SplitButtonElement
Styles sets the look of the parts of the split button, for this instance only. Set fields win over the theme's SplitButton and the defaults of the variant; see SplitButtonStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SplitButtonElement) Tooltip ¶ added in v0.3.0
func (b *SplitButtonElement) Tooltip(s string) *SplitButtonElement
Tooltip shows s below the split button after the pointer rests on it. Assistive technology reads it as the group's description, unless it has another.
func (*SplitButtonElement) Variant ¶ added in v0.3.0
func (b *SplitButtonElement) Variant(v ButtonVariant) *SplitButtonElement
Variant sets the look of the split button (see ButtonVariant).
func (*SplitButtonElement) Width ¶ added in v0.3.0
func (b *SplitButtonElement) Width(l Length) *SplitButtonElement
The sizing methods give the split button's outer box a size. It is as wide as its label and arrow by default, as a button is; a wider box widens the action segment. See Sizing in docs/styling.md.
type SplitButtonStyle ¶ added in v0.3.0
type SplitButtonStyle struct {
Root Style // the row of the two segments
Main Style // the segment that runs the action
MainHover Style // the action segment while the pointer is over it, if enabled
MainPressed Style // the action segment while it is pressed
MainDisabled Style // the action segment when the split button is disabled
MainLoading Style // the action segment while the split button is loading
MainFocusVisible Style // the action segment while it has keyboard focus
Arrow Style // the segment that opens the menu
ArrowHover Style // the arrow segment while the pointer is over it, if enabled
ArrowPressed Style // the arrow segment while it is pressed or its menu is open
ArrowDisabled Style // the arrow segment when the split button is disabled
ArrowLoading Style // the arrow segment while the split button is loading
ArrowFocusVisible Style // the arrow segment while it has keyboard focus
Label Style // the text of the action
Icon Style // the icon of the action
Chevron Style // the arrow's icon
}
SplitButtonStyle is the look of each part of a split button. A part's style merges over the built-in defaults of its variant, then over the theme's SplitButton, then over the Styles of the instance; see docs/styling.md.
Root is the row that joins the two segments, with the shadow of a button. Main is the segment that runs the action, with the size, font and colors of a Button of the same variant, and Arrow the segment that opens the menu. The two share the line between them, and only their outer corners are rounded. Each segment has the states of a button: Hover while the pointer is over it, Pressed while it is pressed (and, for the arrow, while its menu is open), Disabled when the split button is disabled, Loading while it is loading (see Loading), and FocusVisible while it has keyboard focus (its focus ring is added to its shadows). Label and Icon are the action's text and icon, and Chevron the arrow's icon.
type SplitElement ¶
type SplitElement struct {
// contains filtered or unexported fields
}
SplitElement lays out panes side by side, or stacked, with a divider between each two neighbours. The user drags a divider, or moves it with the keyboard, to give one pane more of the space. The panes are Elements of any kind, so a split can contain another split.
A pane with a Size keeps it as the user moves the dividers, in its own unit: a pixel pane keeps its pixels, and a percentage pane keeps its share of the length the panes have, which is the split's length less its dividers. A pane with neither a Size nor a SizeSignal fills the space that the sized panes leave, in proportion to their weights (equal by default). So a drag that changes a sized pane changes every fill pane, each in proportion to its weight. A drag between two fill panes moves space only between those two: their weights change, and their sum stays the same. A drag between two sized panes moves space only between those two, each in its own unit and within its limits, and stops when either reaches a limit. A divider beside a collapsed pane does not move.
The layout is resolved at the split's length (see resolvePanes). A pixel pane keeps its size when the window is resized, a percentage pane scales with it, and a fill pane takes the change. When no pane can take the space that is left over, the last visible pane is drawn with it, and its stored size does not change.
Each divider is one focusable element with the window splitter role of the Accessibility Programmatic Guidelines (https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/). Its value is the size of the pane it resizes, in that pane's unit, with the least and the greatest size that pane can take. The arrow keys move it along the split (Left and Right, or Up and Down in a vertical split), Shift for a larger step, and Home and End to the limits. Enter collapses or restores the pane that the divider collapses (see Pane.Collapsible), and a double-click on the divider does the same.
func Split ¶
func Split(panes ...*PaneElement) *SplitElement
Split lays out panes in order, with a divider between each two. One pane renders alone, with no divider, and no pane renders an empty box of the split's size. The panes need distinct keys (see Pane.Key), and the split fills its container by default (see Width).
func (*SplitElement) GridSpan ¶
func (s *SplitElement) GridSpan(cols, rows int) *SplitElement
GridSpan sets how many columns and rows the split covers in its parent's grid.
func (*SplitElement) Grip ¶
func (s *SplitElement) Grip(g SplitGrip) *SplitElement
Grip sets when the divider shows its grip: only while the pointer is over the divider or it is dragged or focused (SplitGripOnHover, the default), always (SplitGripShown), or never (SplitGripHidden). Without the grip, the divider is a line between the panes.
func (*SplitElement) Grow ¶
func (s *SplitElement) Grow(f float32) *SplitElement
Grow makes the split take a share of the free space on its parent's main axis.
func (*SplitElement) Height ¶
func (s *SplitElement) Height(l Length) *SplitElement
Height sets the height of the split.
func (*SplitElement) Key ¶
func (s *SplitElement) Key(k string) *SplitElement
Key gives the split a stable identity among its siblings.
func (*SplitElement) Label ¶
func (s *SplitElement) Label(name string) *SplitElement
Label names every divider of the split for assistive technology, such as "Resize sidebar". Without it, a divider whose two panes both have a Pane.Label is named after them, such as "Resize Sidebar and Editor", and any other divider is named with the Resize panes text of the window's Strings.
func (*SplitElement) MaxHeight ¶
func (s *SplitElement) MaxHeight(l Length) *SplitElement
MaxHeight sets the largest height of the split.
func (*SplitElement) MaxWidth ¶
func (s *SplitElement) MaxWidth(l Length) *SplitElement
MaxWidth sets the largest width of the split.
func (*SplitElement) MinHeight ¶
func (s *SplitElement) MinHeight(l Length) *SplitElement
MinHeight sets the smallest height of the split.
func (*SplitElement) MinWidth ¶
func (s *SplitElement) MinWidth(l Length) *SplitElement
MinWidth sets the smallest width of the split.
func (*SplitElement) OnChange ¶
func (s *SplitElement) OnChange(fn func()) *SplitElement
OnChange runs fn after the user changes the size of a pane, from the keyboard or the pointer, and only when a size actually changes. The sizes are set first (see Pane.SizeSignal). Collapsing or restoring a pane is not a size change, so it does not run fn.
func (*SplitElement) Orientation ¶
func (s *SplitElement) Orientation(o SplitOrientation) *SplitElement
Orientation sets whether the panes sit side by side (SplitHorizontal, the default) or are stacked (SplitVertical).
func (*SplitElement) Styles ¶
func (s *SplitElement) Styles(st SplitStyle) *SplitElement
Styles sets the look of the parts of the split, for this instance only. Set fields win over the theme's Split and the defaults; see SplitStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SplitElement) Width ¶
func (s *SplitElement) Width(l Length) *SplitElement
The sizing methods give the split's outer box a size. A split fills its container by default; see Sizing in docs/styling.md.
type SplitGrip ¶
type SplitGrip uint8
SplitGrip is when a split's divider shows its grip, the mark over the middle of its bar (the Grip part). The bar itself is always drawn.
const ( // SplitGripOnHover shows the grip only while the pointer is over the divider, while it is // dragged, and while it has keyboard focus. Otherwise the divider is the bar alone, a line // between the panes like a border. It is the default. SplitGripOnHover SplitGrip = iota // SplitGripShown always shows the grip. SplitGripShown // SplitGripHidden never shows the grip: the divider is the bar alone. It still changes color // when the pointer is over it (DividerHover), so it can be found. SplitGripHidden )
type SplitOrientation ¶
type SplitOrientation uint8
SplitOrientation says how the panes of a split are laid out.
const ( SplitHorizontal SplitOrientation = iota // the panes sit side by side (the default) SplitVertical // the panes are stacked, one above the other )
type SplitStyle ¶
type SplitStyle struct {
Divider Style // the bar in the middle of the divider; its Width (Height when vertical) is the thickness
DividerHover Style // the bar while the pointer is over the divider
DividerActive Style // the bar while the divider is dragged
DividerFocusVisible Style // the bar while the divider has keyboard focus
Grip Style // the mark over the middle of the bar
Pane Style // the box of each pane
}
SplitStyle is the look of each part of a split. A part's style merges over the built-in defaults, then over the theme's Split, then over the Styles of the instance; see docs/styling.md.
Divider is the bar drawn in the middle of the divider: its Width is the thickness of a horizontal split's divider, and its Height the thickness of a vertical one; it runs the divider's whole length by default. DividerHover is the bar while the pointer is over the divider, DividerActive while the divider is dragged, and DividerFocusVisible while it has keyboard focus. Grip is the mark drawn over the middle of the bar, and Pane is the box of each pane.
type Spring ¶ added in v0.4.0
type Spring struct {
// Duration is the perceived length of the response: the spring's natural
// period, which sets its stiffness. A critically damped spring is close to
// its target after one Duration.
Duration time.Duration
// Bounce is how much the spring overshoots: 0 is critically damped and
// never passes its target, and larger values swing more. It is clamped to
// [0, 0.9]; the damping ratio is 1-Bounce.
Bounce float32
}
Spring is a damped spring that moves an element's opacity, offset and scale toward their targets (see DivElement.Spring). Unlike a Transition it has a velocity: a target that changes mid-flight bends the motion rather than restarting it, and with a bounce it overshoots and swings back. The zero Spring is unset.
type StatusBarElement ¶ added in v0.3.0
type StatusBarElement struct {
// contains filtered or unexported fields
}
StatusBarElement is the bar along the bottom of a window, which shows the state of what the window holds, such as the current page, a count or the position of the caret. Its items sit at its start and at its end. Assistive technology sees a status bar (UI Automation's StatusBar control type) that holds the items.
A status bar is not a live region: a change to its text is not announced. An app that changes it after an action the user should hear about announces it too, with Announce.
func StatusBar ¶ added in v0.3.0
func StatusBar() *StatusBarElement
StatusBar creates an empty status bar. A status bar fills the width of its container by default; put it last in the window's column.
func (*StatusBarElement) End ¶ added in v0.3.0
func (s *StatusBarElement) End(els ...Element) *StatusBarElement
End appends items at the end of the bar, the right. nil items are ignored.
func (*StatusBarElement) GridSpan ¶ added in v0.3.0
func (s *StatusBarElement) GridSpan(cols, rows int) *StatusBarElement
GridSpan sets how many columns and rows the status bar covers in its parent's grid.
func (*StatusBarElement) Grow ¶ added in v0.3.0
func (s *StatusBarElement) Grow(f float32) *StatusBarElement
Grow makes the status bar take a share of the free space on its parent's main axis.
func (*StatusBarElement) Key ¶ added in v0.3.0
func (s *StatusBarElement) Key(k string) *StatusBarElement
Key identifies the status bar among its siblings (see DivElement.Key).
func (*StatusBarElement) Label ¶ added in v0.3.0
func (s *StatusBarElement) Label(name string) *StatusBarElement
Label names the status bar for assistive technology. A status bar needs no name, since its control type says what it is; a window with two status bars names them apart.
func (*StatusBarElement) MaxWidth ¶ added in v0.3.0
func (s *StatusBarElement) MaxWidth(l Length) *StatusBarElement
MaxWidth sets the largest width of the status bar.
func (*StatusBarElement) MinWidth ¶ added in v0.3.0
func (s *StatusBarElement) MinWidth(l Length) *StatusBarElement
MinWidth sets the smallest width of the status bar.
func (*StatusBarElement) Start ¶ added in v0.3.0
func (s *StatusBarElement) Start(els ...Element) *StatusBarElement
Start appends items at the start of the bar, the left. nil items are ignored.
func (*StatusBarElement) Styles ¶ added in v0.3.0
func (s *StatusBarElement) Styles(st StatusBarStyle) *StatusBarElement
Styles sets the look of the parts of the status bar, for this instance only. Set fields win over the theme's StatusBar and the defaults; see StatusBarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*StatusBarElement) Width ¶ added in v0.3.0
func (s *StatusBarElement) Width(l Length) *StatusBarElement
The sizing methods give the status bar's outer box a size. See Sizing in docs/styling.md.
type StatusBarStyle ¶ added in v0.3.0
type StatusBarStyle struct {
Bar Style // the strip: its height, padding, fill, top border and text
Start Style // the row of items at the start, which takes the free space
End Style // the row of items at the end
}
StatusBarStyle is the look of each part of a status bar. A part's style merges over the built-in defaults, then over the theme's StatusBar, then over the Styles of the instance; see docs/styling.md. Bar is the strip, with the size and color of its text, which the items inherit; Start holds the items at its start (the left), and End the items at its end (the right).
type Step ¶ added in v0.3.0
type Step struct {
// Title is the name of the step.
Title string
// Description is a line of text under the title.
Description string
// Icon is shown in the indicator in place of the step's number.
Icon *icons.Icon
}
Step is one step of a Stepper: its title, an optional description under the title and an optional icon, which the step's indicator shows in place of its number until the step is complete.
type StepperElement ¶ added in v0.3.0
type StepperElement struct {
// contains filtered or unexported fields
}
StepperElement shows the progress through the steps of a process, such as the pages of a checkout. The steps before the current one are complete, and show a check mark; the current one is highlighted, and the later ones are muted. The steps are numbered from 0 in the current signal, and a current step equal to the number of steps marks every step complete.
Without OnSelect the stepper only shows the progress, and it takes no focus. With OnSelect each step can be chosen: the stepper is one Tab stop, at the current step, the arrow keys move the focus between the steps, and Enter, Space or a click chooses the focused step.
The stepper is a list named by its Label, and each step is an item of it named by its position, title and state, such as "Step 2 of 4: Shipping, current". The current step is selected in the list.
func Stepper ¶ added in v0.3.0
func Stepper(current *Signal[int], steps ...Step) *StepperElement
Stepper creates a stepper over steps, shown left to right, with the step at index current (from 0) as the current one.
current is state that outlives a render: a signal of the app's model, or a Local of the component that shows the stepper, such as ui.Local(ctx, "step", 0). A signal made with NewSignal inside a render is a new signal each time the component renders, so the stepper would go back to its first value.
func (*StepperElement) Compact ¶ added in v0.6.0
func (s *StepperElement) Compact() *StepperElement
Compact shows the title and description of the current step only (the last step's, once every step is complete); the other steps show their indicator, and their title as a tooltip. It suits a narrow window, where the titles of every step would be cut short. Assistive technology still reads each step's title. A vertical stepper ignores it.
func (*StepperElement) Disabled ¶ added in v0.3.0
func (s *StepperElement) Disabled(d bool) *StepperElement
Disabled shows the steps of a stepper with OnSelect dimmed, and does not let them be chosen or focused. A stepper without OnSelect is not changed by it.
func (*StepperElement) FocusHandle ¶ added in v0.3.0
func (s *StepperElement) FocusHandle(h *FocusHandle) *StepperElement
FocusHandle lets code focus the step that Tab reaches, the current one (see NewFocusHandle). It applies to a stepper with OnSelect.
func (*StepperElement) GridSpan ¶ added in v0.3.0
func (s *StepperElement) GridSpan(cols, rows int) *StepperElement
GridSpan sets how many columns and rows the stepper covers in its parent's grid.
func (*StepperElement) Grow ¶ added in v0.3.0
func (s *StepperElement) Grow(f float32) *StepperElement
Grow makes the stepper take a share of the free space on its parent's main axis.
func (*StepperElement) Height ¶ added in v0.3.0
func (s *StepperElement) Height(l Length) *StepperElement
Height sets the height of the stepper.
func (*StepperElement) Key ¶ added in v0.3.0
func (s *StepperElement) Key(k string) *StepperElement
Key gives the stepper a stable identity. It also scopes the keys of its steps, so give two steppers over the same signal different keys. Without a key the signal's identity scopes them.
func (*StepperElement) Label ¶ added in v0.3.0
func (s *StepperElement) Label(name string) *StepperElement
Label names the stepper for assistive technology, such as "Checkout steps". It defaults to the Steps text of the window's Strings.
func (*StepperElement) MaxWidth ¶ added in v0.3.0
func (s *StepperElement) MaxWidth(l Length) *StepperElement
MaxWidth sets the largest width of the stepper.
func (*StepperElement) MinWidth ¶ added in v0.3.0
func (s *StepperElement) MinWidth(l Length) *StepperElement
MinWidth sets the smallest width of the stepper.
func (*StepperElement) OnSelect ¶ added in v0.3.0
func (s *StepperElement) OnSelect(fn func(i int)) *StepperElement
OnSelect makes the steps choosable: a click, or Enter or Space on the focused step, runs fn with the index of the step. The current signal is not set: fn sets it when the step may be shown, so the app decides whether a later step can be reached yet. Left and Right (Up and Down when Vertical) move the focus to the previous and next step, without wrapping, and Home and End to the first and last.
func (*StepperElement) Styles ¶ added in v0.3.0
func (s *StepperElement) Styles(st StepperStyle) *StepperElement
Styles sets the look of the parts of the stepper, for this instance only. Set fields win over the theme's Stepper and the defaults; see StepperStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*StepperElement) Tooltip ¶ added in v0.3.0
func (s *StepperElement) Tooltip(text string) *StepperElement
Tooltip shows text below the stepper after the pointer rests on it. Assistive technology reads it as the list's description, unless it has another.
func (*StepperElement) Vertical ¶ added in v0.3.0
func (s *StepperElement) Vertical() *StepperElement
Vertical stacks the steps from top to bottom, with the line between them running down from each indicator to the next, and the up and down arrows moving between them.
func (*StepperElement) Width ¶ added in v0.3.0
func (s *StepperElement) Width(l Length) *StepperElement
The sizing methods give the stepper's outer box a size. A horizontal stepper fills its container, and its lines share the room between the steps; a vertical one is as high as its steps. See Sizing in docs/styling.md.
type StepperStyle ¶ added in v0.3.0
type StepperStyle struct {
Stepper Style // the row, or the column, that holds the steps
Step Style // each step: its indicator and its text
StepHover Style // a step the pointer is over, if it can be chosen
StepFocusVisible Style // a step that has keyboard focus
StepDisabled Style // a step of a disabled stepper that has OnSelect
Indicator Style // the circle with the number or the icon of a step not reached yet
IndicatorComplete Style // the indicator of a step before the current one, over Indicator
IndicatorCurrent Style // the indicator of the current step, over Indicator
Title Style // the title of a step
Description Style // the description under the title
Connector Style // the line between two steps
ConnectorComplete Style // the line after a complete step, over Connector
}
StepperStyle is the look of each part of a stepper. A part's style merges over the built-in defaults, then over the theme's Stepper, then over the Styles of the instance; see docs/styling.md. Stepper is the row (or the column, when Vertical) that holds the steps, and Step each step: its indicator and its text. StepHover, StepFocusVisible and StepDisabled are the states of a step that can be chosen (see OnSelect). Indicator is the circle with the step's number or icon, the look of a step that is not reached yet; IndicatorComplete is drawn over it for a step before the current one, which shows a check mark, and IndicatorCurrent for the current step. Title and Description are the texts of a step. Connector is the line between two steps, and ConnectorComplete is drawn over it after a complete step.
type Strings ¶
type Strings struct {
// The default names of the controls, which assistive technology speaks when the
// app gives the control no name of its own.
Avatar string
// Breadcrumb is the default name of a breadcrumb trail.
Breadcrumb string
// Pagination is the default name of a pagination control.
Pagination string
Navigation string
// Options is the default name of a list of options.
Options string
// Suggestions is the default name of a list of suggestions.
Suggestions string
// Times is the default name of a list of times.
Times string
// Actions is the default name of a menu of actions.
Actions string
// Color is the default name of a color control.
Color string
// Progress is the default name of a progress bar.
Progress string
// Loading is the default name of a loading indicator.
Loading string
// Notifications is the default name of a list of notifications.
Notifications string
// ResizePanes is the name of a split's divider, which assistive technology reads.
ResizePanes string
// DateField is the default name of a date field.
DateField string
// DateRangeField is the default name of a date range field.
DateRangeField string
// Steps is the default name of a stepper.
Steps string
// CommandPalette is the name of a command palette.
CommandPalette string
// Carousel is the default name of a carousel, and the description of one that has a
// name, which tells assistive technology what the group is.
Carousel string
// Slides is the name of the group of a carousel's dots.
Slides string
// The labels of the controls that jamb draws.
LoadingEllipsis string
// LoadingSuggestions is the text shown while suggestions load.
LoadingSuggestions string
// CommandPalettePlaceholder is the text shown in a command palette's empty field.
CommandPalettePlaceholder string
// SaturationBrightness is the name of the area of a color picker that sets saturation and brightness.
SaturationBrightness string
// SaturationBrightnessValue is the value of the color area, read by assistive technology,
// such as "Saturation 50%, brightness 80%".
SaturationBrightnessValue func(saturation, brightness int) string
// Hue is the name of the hue slider of a color picker.
Hue string
// Opacity is the name of the opacity slider of a color picker.
Opacity string
// Hex is the name of the hexadecimal color field.
Hex string
// ChooseDate is the name of the button that opens a calendar.
ChooseDate string
// ChooseDates is the name of the button that opens a calendar for a date range.
ChooseDates string
// ShowTimes is the name of the button that opens the list of times.
ShowTimes string
// ShowHiddenLocations is the name of the button that shows the locations hidden in a breadcrumb trail.
ShowHiddenLocations string
CollapseNavigation string
ExpandNavigation string
// DismissNotification is the name of the button that dismisses a notification.
DismissNotification string
// ToastAnnouncement is the text a toast with a title is announced with, from the
// title and the message, such as "Upload: Uploaded".
ToastAnnouncement func(title, text string) string
// PreviousPage is the name of the button that goes to the previous page.
PreviousPage string
// NextPage is the name of the button that goes to the next page.
NextPage string
// PreviousSlide is the name of the button that goes to the previous slide of a carousel.
PreviousSlide string
// NextSlide is the name of the button that goes to the next slide of a carousel.
NextSlide string
// PauseSlides is the name of the button that stops a carousel's AutoPlay.
PauseSlides string
// PlaySlides is the name of the button that starts a carousel's AutoPlay again.
PlaySlides string
// PreviousYear is the name of the button that goes to the previous year.
PreviousYear string
// PreviousMonth is the name of the button that goes to the previous month.
PreviousMonth string
// NextMonth is the name of the button that goes to the next month.
NextMonth string
// NextYear is the name of the button that goes to the next year.
NextYear string
// Close is the name of a close button.
Close string
// OK is the label of the button that confirms an alert dialog (see AlertDialog).
OK string
// Cancel is the label of the button that cancels an alert dialog.
Cancel string
// The prompt about unsaved changes when a window closes or the app quits (see
// app.Window.Unsaved). SaveChanges and DiscardChanges are its titles, given
// what is unsaved, such as a document's name, or "" when the app names
// nothing. UnsavedLost is its message when the changes can be saved, and
// UnsavedNoSave when they cannot. SaveFailed is its message after a save
// failed, given the error. Save, DontSave, Discard and TryAgain label its buttons.
SaveChanges func(name string) string
DiscardChanges func(name string) string
UnsavedLost string
UnsavedNoSave string
SaveFailed func(err string) string
Save string
DontSave string
Discard string
TryAgain string
// Minimize is the name of the button that minimizes a window.
Minimize string
// Maximize is the name of the button that maximizes a window.
Maximize string
// Restore is the name of the button that restores a maximized window.
Restore string
// Copy is the name of a copy button that has no text of its own (see CopyButton).
Copy string
// Copied is the confirmation of a copy: the label of a copy button with text,
// and the text announced after a copy (see CopyButton.Copied).
Copied string
// Increase is the name of the button that increases a number.
Increase string
// Decrease is the name of the button that decreases a number.
Decrease string
// ShowPassword is the name of the button that shows the text of a masked field.
ShowPassword string
// HidePassword is the name of that button while the text is shown.
HidePassword string
// Clear is the name of the button that clears the text of a field.
Clear string
// Minimum is the name of the low thumb of a range slider.
Minimum string
// Maximum is the name of the high thumb of a range slider.
Maximum string
// MoreOptions is the name of the arrow of a split button, which opens its menu.
MoreOptions string
// AllTabs is the name of the button of a tab list that opens a menu of all its tabs
// (see Tabs.OverflowMenu).
AllTabs string
// ScrollTabsBack is the name of the button that scrolls a tab list toward its first tab.
ScrollTabsBack string
// ScrollTabsForward is the name of the button that scrolls a tab list toward its last tab.
ScrollTabsForward string
// CloseTab names the close button of a closable tab, such as "Close Sales" (see Tabs.OnClose).
CloseTab func(tab string) string
// The names of a dock's tab strip and of the commands of its tabs' menus.
PanelGroup string
// MovePanelLeft is the name of the command that moves a dock panel to the left.
MovePanelLeft string
// MovePanelRight is the name of the command that moves a dock panel to the right.
MovePanelRight string
// MovePanelUp is the name of the command that moves a dock panel up.
MovePanelUp string
// MovePanelDown is the name of the command that moves a dock panel down.
MovePanelDown string
// SplitPanelRight is the name of the command that splits a dock group to the right.
SplitPanelRight string
// SplitPanelDown is the name of the command that splits a dock group downward.
SplitPanelDown string
// FloatPanel is the name of the command that floats a dock panel in its own window.
FloatPanel string
// DockPanelBack is the name of the command that docks a floating panel back.
DockPanelBack string
// ClosePanel is the name of the command that closes a dock panel.
ClosePanel string
// Remove names the button that removes a tag, such as "Remove Sales".
Remove func(tag string) string
// ResizeBetween names the divider between two panes that have labels, such as "Resize Sidebar and
// Editor" (see Split.Label).
ResizeBetween func(first, second string) string
// TabMoved is announced after the user moves a tab (see Tabs.Reorderable), such as
// "Sales moved to position 2 of 3".
TabMoved func(tab string, position, count int) string
// ColumnMoved is announced after the user moves a column of a grid (see
// DataColumn.Movable), such as "Status moved to position 2 of 5".
ColumnMoved func(column string, position, count int) string
// Page is the name of a page button, such as "Page 3". CurrentPage names the page
// that is shown, and PageOf is the text of a compact pagination, such as "Page 3 of 9".
Page func(n int) string
// CurrentPage builds the name of the current page, from its number.
CurrentPage func(n int) string
// PageOf builds the name of a page, from its number and the number of pages.
PageOf func(page, pages int) string
// SlideOf names the slide a carousel shows, and is announced when the user changes it,
// such as "Slide 2 of 5".
SlideOf func(n, slides int) string
// GoToSlide names the dot of a carousel's slide, such as "Go to slide 3".
GoToSlide func(n int) string
// StepCompleted, StepCurrent and StepUpcoming name a step of a stepper, from its
// number, the number of steps and its title, such as "Step 2 of 4: Shipping,
// current". StepCompleted names a step before the current one.
StepCompleted func(n, steps int, title string) string
// StepCurrent names the current step of a stepper.
StepCurrent func(n, steps int, title string) string
// StepUpcoming names a step after the current one.
StepUpcoming func(n, steps int, title string) string
// RatingValue is the value of a rating that assistive technology reads, such as
// "3 of 5 stars".
RatingValue func(value, max int) string
// The notes of a calendar's days: Today, and the ends and the middle of a range.
Today string
// StartOfRange is the name of the start of a date range.
StartOfRange string
// EndOfRange is the name of the end of a date range.
EndOfRange string
// InRange is the name of a day that lies in a date range.
InRange string
// The empty and error texts of the lists, the grid and the suggestions.
NoResults string
// NoRows is the message shown when a grid has no rows.
NoRows string
// LoadingMore names the row at the end of a grid while it loads more rows, and is
// announced when the loading starts (see DataGrid.LoadingMore).
LoadingMore string
// NoMatchingCommands is the message shown when no command of a command palette matches.
NoMatchingCommands string
// CouldNotLoadSuggestions is the message shown when suggestions cannot be loaded.
CouldNotLoadSuggestions string
// SuggestionCount builds the message that gives the number of suggestions.
SuggestionCount func(n int) string
// NotInList is the message shown when the text of a combo box is not in its list, which is then cleared.
NotInList string
// NotInListReverted builds the message shown when the text is not in the list and reverts to a label.
NotInListReverted func(label string) string
// SortedAscending is the state of a column sorted in ascending order.
SortedAscending string
// SortedDescending is the state of a column sorted in descending order.
SortedDescending string
// The text of a badge that counts more than its maximum, such as "99+", and the
// name it adds to its owner, such as "more than 99 items".
BadgeOverflow func(max int) string
// BadgeMoreThan builds the text that is read for a badge whose count is above its maximum.
BadgeMoreThan func(max int) string
// BadgeMoreThanNoun builds the text that is read for a badge whose count is above its maximum, with the noun of the count.
BadgeMoreThanNoun func(max int, noun string) string
// The validation messages of the built-in validators and the controls.
Required string
// MinLength builds the message for text shorter than the minimum length.
MinLength func(n int) string
// MaxLength builds the message for text longer than the maximum length.
MaxLength func(n int) string
// ValueRange builds the message for a value outside the range, given the ends of the range.
ValueRange func(lo, hi string) string
// NumberRange builds the message for a number outside the range, given the ends of the range.
NumberRange func(lo, hi string) string
// DateOnOrAfter builds the message for a date before the earliest date that can be chosen.
DateOnOrAfter func(date string) string
// DateOnOrBefore builds the message for a date after the latest date that can be chosen.
DateOnOrBefore func(date string) string
// DateNotAllowed is the message for a date that cannot be chosen.
DateNotAllowed string
// DateExample builds the message that gives an example of a date.
DateExample func(example string) string
// RangeExample builds the message that gives an example of a range.
RangeExample func(example string) string
// RangeStartChosen is the message announced when the start of a date range is chosen.
RangeStartChosen string
// TimeFromTo builds the message for a time outside the range from one time to another.
TimeFromTo func(from, to string) string
// TimeExample builds the message that gives an example of a time.
TimeExample func(example string) string
// FieldsNeedAttention is the summary of a form with n fields that have a
// message, and FormSubmitFailed is the message of a form whose submit failed
// without a message of its own.
FieldsNeedAttention func(n int) string
// FormSubmitFailed is the message shown when a form cannot be submitted.
FormSubmitFailed string
// The code editor (package codeedit): its default name, the labels of its find and
// replace bar and of its go-to-line bar, and the words that its matches count shows.
// CodeEditorCount is the count of matches, such as "3 of 12".
CodeEditorLabel string
// CodeEditorFind is the label of the find box of a code editor.
CodeEditorFind string
// CodeEditorReplace is the label of the replace box of a code editor.
CodeEditorReplace string
// CodeEditorReplaceOne is the name of the button that replaces one match.
CodeEditorReplaceOne string
// CodeEditorReplaceAll is the name of the button that replaces every match.
CodeEditorReplaceAll string
// CodeEditorNext is the name of the button that goes to the next match.
CodeEditorNext string
// CodeEditorPrevious is the name of the button that goes to the previous match.
CodeEditorPrevious string
// CodeEditorClose is the name of the button that closes the find bar.
CodeEditorClose string
// CodeEditorMatchCase is the label of the option that makes the search case-sensitive.
CodeEditorMatchCase string
// CodeEditorWholeWord is the label of the option that matches whole words.
CodeEditorWholeWord string
// CodeEditorRegex is the label of the option that treats the query as a regular expression.
CodeEditorRegex string
// CodeEditorGoToLine is the label of the box that takes a line number.
CodeEditorGoToLine string
// CodeEditorGo is the name of the button that goes to the line.
CodeEditorGo string
// CodeEditorNoMatches is the message shown when a find has no matches.
CodeEditorNoMatches string
// CodeEditorBadPattern is the message shown for a regular expression that does not parse.
CodeEditorBadPattern string
// CodeEditorCount builds the message that gives the position of the current match, from its number and the total.
CodeEditorCount func(current, total int) string
// CodeEditorError is the name of the severity of an error diagnostic.
CodeEditorError string
// CodeEditorWarning is the name of the severity of a warning diagnostic.
CodeEditorWarning string
// CodeEditorInfo is the name of the severity of an information diagnostic.
CodeEditorInfo string
// CodeEditorHint is the name of the severity of a hint diagnostic.
CodeEditorHint string
// CodeEditorDiagnostic builds the message that announces a diagnostic, from the name of its
// severity, its line number and its message.
CodeEditorDiagnostic func(severity string, line int, message string) string
// CodeEditorCodeActions is the name of the menu of code actions.
CodeEditorCodeActions string
// CodeEditorQuickFix is the name of the group of quick fixes in the menu of code actions.
CodeEditorQuickFix string
// CodeEditorRefactor is the name of the group of refactorings in the menu of code actions.
CodeEditorRefactor string
// CodeEditorSourceAction is the name of the group of source actions in the menu of code actions.
CodeEditorSourceAction string
// CodeEditorMoreActions is the name of the group of the other code actions.
CodeEditorMoreActions string
// CodeEditorNoCodeActions is the message shown when there are no code actions.
CodeEditorNoCodeActions string
// CodeEditorLoadingActions is the message shown while the code actions load.
CodeEditorLoadingActions string
// CodeEditorActionFailed is the message shown when the code actions could not load or be applied.
CodeEditorActionFailed string
// CodeEditorActionCount builds the message that gives the number of code actions.
CodeEditorActionCount func(n int) string
// title and the reason it is disabled.
CodeEditorActionUnavailable func(title, reason string) string
// The charts (package charts): the names of the chart types, which begin a chart's
// summary. ChartLine is the name of a line chart.
ChartLine string
// ChartArea is the name of an area chart.
ChartArea string
// ChartStackedArea is the name of a stacked area chart.
ChartStackedArea string
// ChartBar is the name of a bar chart.
ChartBar string
// ChartStackedBar is the name of a stacked bar chart.
ChartStackedBar string
// ChartHorizontalBar is the name of a horizontal bar chart.
ChartHorizontalBar string
// ChartStackedHorizontalBar is the name of a stacked horizontal bar chart.
ChartStackedHorizontalBar string
// ChartScatter is the name of a scatter plot.
ChartScatter string
// ChartPie is the name of a pie chart.
ChartPie string
// ChartDonut is the name of a donut chart.
ChartDonut string
// ChartRadar is the name of a radar chart.
ChartRadar string
// ChartCandlestick is the name of a candlestick chart.
ChartCandlestick string
// ChartSankey is the name of a Sankey diagram.
ChartSankey string
// The summary of a chart, which names it for assistive technology. Each message is
// a whole clause, and the clauses after the first take the summary so far, so that a
// language sets its own order and punctuation. ChartSeriesSummary begins the
// summary of a chart of series, from the name of its type, the number of series and
// the least and the most points of a series, such as "Line chart, 2 series, 7 points
// each". With no series, least and most are 0.
ChartSeriesSummary func(chart string, series, least, most int) string
// ChartCandleSummary begins the summary of a candlestick chart, such as "Candlestick chart, 30 candles".
ChartCandleSummary func(chart string, candles int) string
// ChartPieSummary begins the summary of a pie or a donut chart, such as "Pie chart, 7 slices".
ChartPieSummary func(chart string, slices int) string
// ChartSankeySummary is the summary of a Sankey diagram, such as "Sankey diagram, 3 nodes, 2 links; total flow 5".
ChartSankeySummary func(chart string, nodes, links int, total string) string
// ChartLargestSlice adds the largest slice and its share to the summary of a pie, such as
// "Pie chart, 7 slices; largest is Saturday at 20%".
ChartLargestSlice func(summary, slice, share string) string
// ChartPositionRange adds the first and the last position to a summary, such as
// "Line chart, 2 series, 7 points each, from Monday to Sunday".
ChartPositionRange func(summary, from, to string) string
// ChartValueRanges adds the value ranges of the series, each made by ChartValueRange, to a
// summary, such as "…, from Monday to Sunday; Visits from 120 to 300, Returns from 10 to 40".
ChartValueRanges func(summary string, ranges []string) string
// ChartValueRange is the range of the values of one series, such as "Visits from 120 to 300".
ChartValueRange func(series, lo, hi string) string
// The announcements of the keyboard walk and the lines of the tooltips. ChartPointValue
// announces a point, from its position, its series and its value, such as "Tuesday, Visits 180".
ChartPointValue func(position, series, value string) string
// ChartPointNoValue announces a position where the series has no point, such as "Tuesday, Visits no value".
ChartPointNoValue func(position, series string) string
// ChartSeriesValue is a line of a tooltip, a name and its value, such as "Visits 180" or "Open 12".
ChartSeriesValue func(series, value string) string
// ChartSliceValue announces a slice of a pie, such as "Saturday, 300 (20%)".
ChartSliceValue func(slice, value, share string) string
ChartValueShare func(value, share string) string
// ChartCandleValue announces a candle, such as "Monday, open 10, high 14, low 9, close 12".
ChartCandleValue func(position, opening, high, low, closing string) string
// ChartLink names a link of a Sankey diagram in its tooltip, such as "Home to Signup".
ChartLink func(from, to string) string
// ChartLinkValue announces a link of a Sankey diagram, such as "Home to Signup, 130".
ChartLinkValue func(from, to, value string) string
// The legend and the table of a chart. ChartLegend is the name of the legend.
ChartLegend string
// ChartSeriesNumber names a series that has no name, from its number, such as "Series 2".
ChartSeriesNumber func(n int) string
// ChartDataTable names the table of a chart's data, from the chart's summary, such as
// "Data table: Line chart, …".
ChartDataTable func(summary string) string
// ChartDate is the header of the column of positions on a time axis.
ChartDate string
// ChartCategory is the header of the column of positions on a category axis.
ChartCategory string
// ChartPosition is the header of the column of positions on a number axis.
ChartPosition string
// ChartSlice is the header of the column of a pie's slices.
ChartSlice string
// ChartValue is the header of the column of values of a pie or a Sankey diagram.
ChartValue string
ChartShare string
// ChartFrom is the header of the column of the sources of a Sankey diagram's links.
ChartFrom string
// ChartTo is the header of the column of the targets of a Sankey diagram's links.
ChartTo string
// ChartOpen is the opening value of a candle, in its tooltip and its table.
ChartOpen string
// ChartHigh is the highest value of a candle, in its tooltip and its table.
ChartHigh string
// ChartLow is the lowest value of a candle, in its tooltip and its table.
ChartLow string
// ChartClose is the closing value of a candle, in its tooltip and its table.
ChartClose string
// The words of the Markdown view (package markdown). MarkdownImage names an image
// that has no alternative text.
MarkdownImage string
// MarkdownImageNotShown is the text of the placeholder of an image that is not
// shown, from its alternative text, such as "Image not shown: Build status". The
// alternative text may be empty.
MarkdownImageNotShown func(alt string) string
// MarkdownTask names the check box of a task whose item has no text.
MarkdownTask string
// MarkdownCode names a code block from the language of its fence, such as
// "Code, go". The language may be empty.
MarkdownCode func(language string) string
// MarkdownFootnotes names the list of footnotes at the end of a document.
MarkdownFootnotes string
// RelativeNow is a time within a minute of now, in a relative time such as "now".
RelativeNow string
// RelativeYesterday and RelativeTomorrow name the day before and the day after today.
RelativeYesterday string
RelativeTomorrow string
// RelativeAgo builds a time in the past from its unit and count, such as "3 days ago"
// (see FormatRelative). RelativeIn builds a time in the future, such as "in 3 days".
RelativeAgo func(unit RelativeUnit, n int) string
RelativeIn func(unit RelativeUnit, n int) string
// Byte is the size of one byte, "1 byte", and Bytes the size of any other count of
// bytes below 1024, such as "512 bytes" (see FormatBytes). KB to PB are the units of
// the larger sizes, such as "1.00 KB".
Byte, Bytes string
KB, MB, GB string
TB, PB string
}
Strings is the text that jamb shows and announces: the names and labels of the controls, the words of the pickers, the validation messages and the announcements. Each field is one message. A message with values is a function of them, so that each language sets its own word order and its own plural forms.
An app replaces any of the text with a Strings value, with Runtime.SetStrings or app.Window.Strings. A field that is empty (or a function that is nil) shows the English text, so a Strings value needs only the messages it changes. The packs of StringsFor translate the messages whose translation is short and unambiguous; the others stay English in every language.
The messages of programmer errors, such as the panics of the builders and the errors of the parsers, and the diagnostics of the accessibility check are not here. They are for the developer and stay English. The names of the built-in actions (see NewAction) are not here either, since they are identifiers of the keymap.
func EnglishStrings ¶
func EnglishStrings() *Strings
EnglishStrings returns the English text as a new Strings value, which the app can change and set. It is a copy, so a change does not reach other windows.
func StringsFor ¶
StringsFor returns the text for a language, given as a BCP 47 tag such as "it-IT", "zh-Hant-TW" or "zh-HK". The packs are zh-CN (Simplified Chinese, the default for any other zh tag), zh-TW and zh-HK (Traditional Chinese, for Taiwan and Hong Kong or Macao, or any Hant tag), and it (Italian). A tag without a pack gives the English text. A field that the pack leaves empty is English, so the result is complete.
func SystemStrings ¶
func SystemStrings() *Strings
SystemStrings returns the text for the display language of the user's Windows, the first of its preferred UI languages (see StringsFor). Elsewhere, and where the language cannot be read, it is the English text.
type StrokeStyle ¶
type StrokeStyle struct {
Width float32 // 0 means 1
// Color is the color of the stroke, unless Paint is set.
Color Color
// Paint, when set, paints the stroke in place of Color, such as with a
// gradient.
Paint Paint
// Cap is the shape of the ends of an open path.
Cap LineCap
// Join is the shape of the corners of the path.
Join LineJoin
// MiterLimit is the longest a miter join gets, as a multiple of Width,
// before it is cut flat; 0 means 4.
MiterLimit float32
// Dash alternates dash and gap lengths, such as {4, 2}; empty is solid.
// DashOffset starts the pattern that far in.
Dash []float32
// DashOffset starts the dash pattern that far in.
DashOffset float32
}
StrokeStyle is how Painter.Stroke draws a path's outline.
type Style ¶
type Style struct {
// Visuals
Background Color
// BorderColor is the color of the border.
BorderColor Color
// TextColor is the color of the text, inherited by the descendants.
TextColor Color
Gradient Gradient // replaces Background when set (see LinearGradient)
// Corners sets a radius for each corner, in place of Radius.
Corners Corners
// BorderWidth is the width of the border on every side, in logical pixels.
BorderWidth float32
// Radius is the radius of the rounded corners, in logical pixels.
Radius float32
// Gap is the space between the children, in logical pixels.
Gap float32
// Grow is the share of the free space that the element takes on its parent's main axis.
Grow float32
// Shrink is how much the element shrinks when the space is short.
Shrink float32
Opacity float32 // 0 = unset (opaque)
// Paint-only motion, applied after layout (see Offset and Scale). Layout
// and hit testing of the element's position follow the offset.
OffsetX, OffsetY float32
Scale float32 // 0 = unset (1), about the element's center
// FontSize is the font size in logical pixels, inherited by the descendants.
FontSize float32
// LineHeight is the distance between lines of text, in logical pixels.
LineHeight float32
// BorderEdges, when not zero, gives each side its own width (top, right,
// bottom, left) in place of BorderWidth. See BorderEdges.
BorderEdges Edges
// Padding is the space between the border and the content, on each side.
Padding Edges
// Margin is the space outside the border, on each side.
Margin Edges
// Inset holds the offsets of an Absolute element from the edges of its parent.
Inset Edges
// Width is the width of the element's border box.
Width Length
// Height is the height of the element's border box.
Height Length
// MinWidth is the smallest width that the element can take.
MinWidth Length
// MinHeight is the smallest height that the element can take.
MinHeight Length
// MaxWidth is the largest width that the element can take.
MaxWidth Length
// MaxHeight is the largest height that the element can take.
MaxHeight Length
// Basis is the starting main size before growing/shrinking (Auto = content).
Basis Length
// Layout
Direction Direction
// Wrap flows children onto more lines when a row (or column) is full.
Wrap bool
// NoShrink stops the element from shrinking below its size (Shrink 0).
NoShrink bool
Align Alignment // children on the cross axis
// AlignSelf overrides the parent's Align for this element.
AlignSelf Alignment
Justify Alignment // children on the main axis
// Absolute removes the element from the flow; position it with Inset.
Absolute bool
// OverflowX is how the content that goes past the element's width is drawn.
OverflowX Overflow
// OverflowY is how the content that goes past the element's height is drawn.
OverflowY Overflow
// Cursor is the mouse cursor shown over the element.
Cursor Cursor
// TextAlign is the horizontal alignment of the text.
TextAlign Alignment
// FontWeight is the weight of the text, inherited by the descendants.
FontWeight FontWeight
// Clear removes the fields it names from the style it is merged into, before
// the set fields of this style are applied, so a style can turn a default off:
// the zero value of a field means unset and cannot replace a default by itself.
// The clears are kept when styles are merged, so a style merged in later, such
// as an instance's Styles, still clears the defaults it names. See ClearSet.
Clear ClearSet
// Transition eases colors, opacity, offset and scale (hover, press, theme,
// and changes made by a new render) over this duration.
Transition time.Duration
// Spring moves opacity, offset and scale as a damped spring instead: a
// change mid-flight keeps the velocity it had. Colors still ease, over
// Transition when it is set. The zero Spring is unset.
Spring Spring
// ZIndex orders overlapping siblings; a higher value is drawn on top.
ZIndex int
// ColSpan and RowSpan are the number of grid columns and rows that the item covers; zero means one.
ColSpan, RowSpan int
// GridColumns makes the element a grid (see DivElement.Grid), with one
// track per column; GridRows sizes its first rows, and the others fit their
// content. ColSpan and RowSpan make a grid item cover that many columns and
// rows; 0 means 1.
GridColumns, GridRows []Length
// Shadows are the drop shadows of the element, drawn in order.
Shadows []Shadow
// FontFamily is the name of the font family, inherited by the descendants.
FontFamily string
// contains filtered or unexported fields
}
Style is plain typed data describing how an element looks and lays out. Zero-valued fields are "unset": merging a Style into an element only changes the fields that are set. Define reusable styles as variables:
var Card = ui.Style{Padding: ui.All(16), Radius: 12, Background: ui.Hex("#18181b")}
ui.Div().Style(Card)
type SwitchElement ¶
type SwitchElement struct {
// contains filtered or unexported fields
}
SwitchElement is an on/off switch bound to a bool signal. It is drawn as a track and a knob, without text: its label is what assistive technology reads, and the text beside it is drawn by the app, as a settings row does. ShowLabel draws the label beside the track instead.
func Switch ¶
func Switch(label string, on *Signal[bool]) *SwitchElement
Switch creates a switch that is on while on is true. label names the switch for assistive technology; it is not drawn unless ShowLabel is set.
func (*SwitchElement) Disabled ¶
func (s *SwitchElement) Disabled(d bool) *SwitchElement
Disabled shows the switch but does not let it change.
func (*SwitchElement) FocusHandle ¶
func (s *SwitchElement) FocusHandle(h *FocusHandle) *SwitchElement
FocusHandle lets code focus the switch (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*SwitchElement) GridSpan ¶
func (s *SwitchElement) GridSpan(cols, rows int) *SwitchElement
GridSpan sets how many columns and rows the switch covers in its parent's grid.
func (*SwitchElement) Grow ¶
func (s *SwitchElement) Grow(f float32) *SwitchElement
Grow makes the switch take a share of the free space on its parent's main axis.
func (*SwitchElement) Key ¶
func (s *SwitchElement) Key(k string) *SwitchElement
Key identifies the switch among its siblings (see DivElement.Key).
func (*SwitchElement) MaxWidth ¶
func (s *SwitchElement) MaxWidth(l Length) *SwitchElement
MaxWidth sets the largest width of the switch.
func (*SwitchElement) MinWidth ¶
func (s *SwitchElement) MinWidth(l Length) *SwitchElement
MinWidth sets the smallest width of the switch.
func (*SwitchElement) OnChange ¶
func (s *SwitchElement) OnChange(fn func(bool)) *SwitchElement
OnChange runs fn with the new state after the user changes the switch. The signal is set first.
func (*SwitchElement) ShowLabel ¶ added in v0.6.0
func (s *SwitchElement) ShowLabel() *SwitchElement
ShowLabel draws the label to the right of the track, as a check box draws its own. A click on it changes the switch, as a click on the track does. Without it the switch shows no text, and the label only names it for assistive technology.
func (*SwitchElement) Styles ¶
func (s *SwitchElement) Styles(st SwitchStyle) *SwitchElement
Styles sets the look of the parts of the switch, for this instance only. Set fields win over the theme's Switch and the defaults; see SwitchStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*SwitchElement) Tooltip ¶
func (s *SwitchElement) Tooltip(text string) *SwitchElement
Tooltip shows s below the switch after the pointer rests on it. Assistive technology reads it as the switch's description, unless it has another.
func (*SwitchElement) Width ¶
func (s *SwitchElement) Width(l Length) *SwitchElement
The sizing methods give the track a width. The track is 38 px wide by default, and the knob stays 3 px from the end it is at. See Sizing in docs/styling.md.
type SwitchStyle ¶
type SwitchStyle struct {
Track Style // the track: its size, shape, fill and border
TrackChecked Style // the track when the switch is on
TrackHover Style // the track while the pointer is over an enabled switch
TrackFocusVisible Style // the track while it has keyboard focus
TrackDisabled Style // the track when the switch is disabled
Knob Style // the knob: its size, color and shadow
KnobChecked Style // the knob when the switch is on
KnobDisabled Style // the knob when the switch is disabled
Label Style // the text beside the track, with ShowLabel
}
SwitchStyle is the look of each part of a switch. A part's style merges over the built-in defaults, then over the theme's Switch, then over the Styles of the instance; see docs/styling.md. Track is the pill, and Knob the circle that moves along it. The position of the knob follows the state and is not a style: a Knob style sets its color, border, shadow and size. The states are parts of their own: TrackChecked when the switch is on, TrackHover while the pointer is over an enabled switch, TrackFocusVisible while it has keyboard focus, TrackDisabled and KnobDisabled when it cannot change, and KnobChecked for the knob of an on switch. Label is the text beside the track of a switch with ShowLabel.
type SyntaxStyle ¶
type SyntaxStyle struct {
// Color is the color of the text for the capture.
Color Color
// Italic sets the text in italic.
Italic bool
// Bold sets the text in bold.
Bold bool
}
SyntaxStyle is the look of one syntax token in a code editor: its color, and whether its text is italic or bold. Theme.Syntax is keyed by the token name, as in Zed's themes, such as "keyword" or "string.escape". A token whose name is not in the map, nor a shorter form of it ("keyword" for "keyword.control"), takes the editor foreground.
type SystemColors ¶
type SystemColors struct {
// Window and WindowText are the system colors of window backgrounds and text.
Window, WindowText Color
// Highlight and HighlightText are the system colors of a selection.
Highlight, HighlightText Color
// HotLight and GrayText are the system colors of a hot-tracked item and of disabled text.
HotLight, GrayText Color
// ButtonFace and ButtonText are the system colors of buttons.
ButtonFace, ButtonText Color
// ButtonShadow and WindowFrame are the system colors of a button's shadow and of a window frame.
ButtonShadow, WindowFrame Color
// CaptionText and ActiveCaption are the system colors of a title bar.
CaptionText, ActiveCaption Color
// Menu, MenuText and InfoBack are the system colors of menus and of tooltips.
Menu, MenuText, InfoBack Color
}
SystemColors are the Windows system colors that a high contrast theme uses (see GetSysColor). Each is opaque.
func HighContrastBlack ¶
func HighContrastBlack() SystemColors
HighContrastBlack is a representative high contrast scheme: white text on black. It is used when the system colors are not given, and by the dev override JAMB_HIGH_CONTRAST (see the app package). It is not read from a system.
func HighContrastWhite ¶
func HighContrastWhite() SystemColors
HighContrastWhite is a representative high contrast scheme: black text on white. It is used by the dev override JAMB_HIGH_CONTRAST=white. It is not read from a system.
type SystemSettings ¶
type SystemSettings struct {
// Dark is the system's app mode: Windows' "Choose your app mode" is Dark.
// A runtime that follows the system (see Runtime.SetThemes) uses its dark
// theme then, and its light theme otherwise.
Dark bool
// HighContrast selects the high contrast theme, built from Colors. The
// theme is used automatically; see HighContrastTheme.
HighContrast bool
// Colors are the system colors the high contrast theme is built from. A
// zero Colors uses the representative black scheme (HighContrastBlack).
Colors SystemColors
// TextScale is the Text size setting, in percent from 100 to 225. It scales
// text only, not the layout or the zoom. Zero means 100.
TextScale int
// ReducedMotion asks for less motion: transitions, enter and exit motions
// and smooth scrolling jump to their end, and animations stop (see
// Animate).
ReducedMotion bool
// CaretBlinkOff keeps the text caret solid. CaretBlink is how long the
// caret stays on, and then off, in each blink; zero means 530 ms.
CaretBlinkOff bool
// CaretBlink is how long the caret stays on, and then off, in each blink.
CaretBlink time.Duration
// CaretWidth scales the caret's thickness, whose default is 1.5 logical
// pixels. Zero means 1. A display's scale is applied as for the rest of
// the UI.
CaretWidth int
}
SystemSettings are the operating system's accessibility and text settings as the runtime uses them. The app package reads them from the platform and passes them in with Runtime.SetSystemSettings, at start and whenever they change. The zero value is the default: 100% text, no high contrast, motion on, a caret that blinks every 530 ms and is 1.5 px wide.
type Tab ¶
type Tab[T comparable] struct { // Value identifies the tab; the selected signal holds it. Value T // Label is the text of the tab. Label string // Icon is an icon shown before the label. Icon *icons.Icon // Disabled makes the tab unable to be chosen. Disabled bool // Closable lets the user close the tab, when the Tabs has OnClose: a close button // shows on the selected tab and on the tab under the pointer, and the tab can be // closed from the keys (see OnClose). A disabled tab cannot be closed. Closable bool // Panel builds the content of the tab, which is shown while the tab is selected. Panel func() Element // Popup builds what a floating panel under the tab shows, such as a menu of // actions or a small form. It opens when the selected tab is clicked again, // and with Down, Shift+F10 or the Menu key while the tab has focus. Escape, a // click outside or a call to close closes it. Its focus behaves as a Popover's: // it moves into the panel when the panel opens, and back to the tab when // Escape or close is used. The panel is styled as a Popover. Assistive // technology hears the tab as expanded or collapsed. Popup func(close func()) Element }
Tab is one tab of a Tabs: the value it selects, its label, an optional icon and the panel it shows. Panel is called only while the tab is selected, so the panels of the other tabs are not built, unless the Tabs keeps its panels (see KeepMounted). A disabled tab is shown but cannot be selected.
type TabsElement ¶
type TabsElement[T comparable] struct { // contains filtered or unexported fields }
TabsElement is a tab list and the panel of the selected tab. The selected tab is the one whose value equals the signal's.
The tab list is one Tab stop, at the selected tab, as Microsoft's tab guidance describes for TabView: Tab enters the strip at the selected tab, and Tab again leaves it for the panel. Left and Right move to the previous and next enabled tab and select it at once (automatic activation), without wrapping; Home and End go to the first and last. Space and Enter select the focused tab. Ctrl+Tab and Ctrl+Shift+Tab select the next and previous enabled tab, and wrap around. They work from the tab list and from the panel, as in TabView, and focus moves to the tab that was selected. Ctrl+Tab is not otherwise bound in the framework, so it moves focus as Tab does everywhere else.
The tabs take the space their parent gives them, as a column does, so the panel can fill a window: a list in a panel grows to the height left under the tabs.
When the tabs are wider than the strip, the strip scrolls sideways, as WinUI's TabView does: two buttons after it scroll it back and forward (see ScrollButtons), a vertical wheel over it scrolls it sideways, and the selected tab is scrolled into view whenever the selection changes, with a little of the next tab showing. The buttons are not Tab stops: the keys that move between the tabs move the strip too. Tabs that fit are drawn as they are without overflow.
func Tabs ¶
func Tabs[T comparable](selected *Signal[T], tabs ...Tab[T]) *TabsElement[T]
Tabs creates a tab list over tabs, showing the panel of the tab that selected reads and writes. The tabs are shown in order.
func (*TabsElement[T]) FocusHandle ¶
func (t *TabsElement[T]) FocusHandle(h *FocusHandle) *TabsElement[T]
FocusHandle lets code focus the selected tab (the tab Tab reaches) (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*TabsElement[T]) KeepMounted ¶
func (t *TabsElement[T]) KeepMounted() *TabsElement[T]
KeepMounted keeps each panel once it has been built. A panel is built the first time its tab is selected, as it is by default, and then stays in the tree while other tabs are selected, hidden with Display. Its component instances, Local state, text, selection, scroll positions and lists survive switching tabs. Tabs that were never selected are not built. Without KeepMounted only the selected panel exists, and the state of the others is discarded.
A kept panel renders again when the code that makes the tabs runs again, and when its own state changes. Switching tabs does not render it.
func (*TabsElement[T]) Key ¶
func (t *TabsElement[T]) Key(k string) *TabsElement[T]
Key gives the tabs a stable identity. It also scopes the keys that name each panel by its tab, so give two tab lists that show the same values different keys. Without a key the signal's identity scopes them.
func (*TabsElement[T]) Label ¶
func (t *TabsElement[T]) Label(name string) *TabsElement[T]
Label names the tab list for assistive technology, such as "Settings sections".
func (*TabsElement[T]) MaxWidth ¶
func (t *TabsElement[T]) MaxWidth(l Length) *TabsElement[T]
MaxWidth sets the largest width of the tabs.
func (*TabsElement[T]) MinWidth ¶
func (t *TabsElement[T]) MinWidth(l Length) *TabsElement[T]
MinWidth sets the smallest width of the tabs.
func (*TabsElement[T]) OnChange ¶
func (t *TabsElement[T]) OnChange(fn func(T)) *TabsElement[T]
OnChange runs fn with the new value after the user selects a tab, by a click, by the keys or by Ctrl+Tab. The signal is set first.
func (*TabsElement[T]) OnClose ¶ added in v0.4.0
func (t *TabsElement[T]) OnClose(fn func(T)) *TabsElement[T]
OnClose runs fn with the value of a closable tab (see Tab.Closable) when the user asks to close it: by the tab's close button, by a middle click on the tab, by Delete on the focused tab, or by Ctrl+W or Ctrl+F4 while the focus is in the tab list or its panel. The Tabs does not remove the tab. The app does, from its own list, and when the selected tab is the one closed the app selects another in the same handler, so the selection never names a missing tab. Here open holds the open documents, in order, and the tabs are built from it on each render:
open := ui.NewSignal([]string{"main.go", "tabs.go"})
doc := ui.NewSignal("main.go")
ui.Tabs(doc, tabsOf(open.Get())...). // one Closable tab per document
OnClose(func(v string) {
i := slices.Index(open.Get(), v)
list := slices.Delete(slices.Clone(open.Get()), i, i+1)
open.Set(list)
if doc.Peek() == v && len(list) > 0 {
doc.Set(list[min(i, len(list)-1)]) // the tab that took its place, or the last
}
})
Without OnClose no tab shows a close button, and the keys do nothing. After a tab is closed the focus moves to the selected tab.
func (*TabsElement[T]) OnReorder ¶ added in v0.3.0
func (t *TabsElement[T]) OnReorder(fn func(order []T)) *TabsElement[T]
OnReorder runs fn with the values of the tabs in their new order after the user moves a tab (see Reorderable), for example to save it. Passing the tabs in that order next time restores it.
func (*TabsElement[T]) OnReselect ¶ added in v0.3.0
func (t *TabsElement[T]) OnReselect(fn func(T)) *TabsElement[T]
OnReselect runs fn with the selected tab's value when the user activates that tab again, by a click, Enter or Space. A tab with a Popup also opens or closes it then.
func (*TabsElement[T]) OverflowMenu ¶ added in v0.4.0
func (t *TabsElement[T]) OverflowMenu() *TabsElement[T]
OverflowMenu adds a button after the strip that opens a menu of every tab, in order and with its full label: the selected tab is checked and a disabled one cannot be chosen. Choosing a tab selects it as a click does, then scrolls it into view and focuses it. The button is one Tab stop after the tab list.
func (*TabsElement[T]) Prefix ¶ added in v0.4.0
func (t *TabsElement[T]) Prefix(e Element) *TabsElement[T]
Prefix puts e before the strip, in the same row: outside the tab list, and outside what scrolls when the tabs overflow.
func (*TabsElement[T]) RenderTab ¶
func (t *TabsElement[T]) RenderTab(fn func(tab Tab[T], state PartState) Element) *TabsElement[T]
RenderTab replaces the content of each tab (its icon and label) with what fn returns. The tab keeps its behavior, its focus, selection and state styles, and its accessible name is still its Label, so put in the label anything a user must hear, such as a count. The content is hidden from assistive technology. fn is called again when the tab's state changes, with the state in the PartState.
ui.Tabs(view, tabs...).RenderTab(func(tab ui.Tab[string], s ui.PartState) ui.Element {
return ui.Div().Row().Align(ui.Center).Gap(6).
Child(ui.Text(names[tab.Value])).
Child(ui.Badge(counts[tab.Value]))
})
func (*TabsElement[T]) Reorderable ¶ added in v0.3.0
func (t *TabsElement[T]) Reorderable() *TabsElement[T]
Reorderable lets the user move the tabs: drag a tab and drop it on the half of another tab it should go beside, where a line shows it will land, or press Ctrl+Shift+Left or Ctrl+Shift+Right on the focused tab. Assistive technology hears the new position. The Tabs keeps the user's order; tabs it has not seen before go after the others, in the order given. A disabled tab cannot be dragged, but a tab can be put beside it.
func (*TabsElement[T]) ScrollButtons ¶ added in v0.4.0
func (t *TabsElement[T]) ScrollButtons(on bool) *TabsElement[T]
ScrollButtons sets whether buttons that scroll the strip are shown while the tabs overflow it; they are on by default. They are hidden while the tabs fit, and each is disabled at its end of the strip. Without them the strip still scrolls, with the wheel, the keys and the selection.
func (*TabsElement[T]) Styles ¶
func (t *TabsElement[T]) Styles(s TabsStyle) *TabsElement[T]
Styles sets the look of the parts of the tab list, for this instance only. Set fields win over the theme's Tabs and the defaults; see TabsStyle and docs/styling.md. Calling Styles again merges with the earlier values.
ui.Tabs(view, tabs...).Styles(ui.TabsStyle{
Indicator: ui.Style{Height: ui.Px(3)},
})
func (*TabsElement[T]) Suffix ¶ added in v0.4.0
func (t *TabsElement[T]) Suffix(e Element) *TabsElement[T]
Suffix puts e after the strip and its buttons, in the same row, such as a button that adds a tab. It does not scroll with the tabs.
func (*TabsElement[T]) TabMaxWidth ¶ added in v0.4.0
func (t *TabsElement[T]) TabMaxWidth(l Length) *TabsElement[T]
TabMaxWidth caps the width of each tab at l. A longer label is cut short with an ellipsis, and its tooltip shows it whole; its accessible name is still the whole label. With RenderTab the cap applies to the tab, and the content is the app's to fit.
func (*TabsElement[T]) Variant ¶
func (t *TabsElement[T]) Variant(v TabsVariant) *TabsElement[T]
Variant sets the look of the tab list: TabsUnderline (the default) or TabsSegmented. The behavior is the same in both.
func (*TabsElement[T]) Width ¶
func (t *TabsElement[T]) Width(l Length) *TabsElement[T]
The sizing methods give the tab list a width; the panel always fills the width of the Tabs. The segmented tab list is as wide as its tabs by default, and the underline tab list fills its container, as WinUI's TabView does. See Sizing in docs/styling.md.
type TabsStyle ¶
type TabsStyle struct {
Bar Style // the row of the prefix, the strip, its buttons and the suffix
List Style // the strip that holds the tabs
Tab Style // each tab
TabHover Style // a tab the pointer is over, if it is enabled and not selected
TabSelected Style // the selected tab
TabDisabled Style // a disabled tab
TabFocusVisible Style // a tab that has keyboard focus
Indicator Style // the line under a tab in TabsUnderline; only the selected one shows it
Panel Style // the panel of the selected tab
DropLine Style // the line that shows where a dragged tab lands (see Reorderable)
ScrollButton Style // each button that scrolls the strip while the tabs overflow it
MenuButton Style // the button that opens the menu of all the tabs (see OverflowMenu)
}
TabsStyle is the look of each part of a tab list. A part's style merges over the built-in defaults of its variant, then over the theme's Tabs, then over the Styles of the instance. The states are parts of their own: TabSelected applies to the selected tab, TabDisabled to a disabled one, TabHover while the pointer is over an enabled tab that is not selected, and TabFocusVisible while the tab has keyboard focus. Bar is the row that holds the strip with the Prefix, the Suffix, the scroll buttons and the overflow menu's button; it is built only when one of them is shown. ScrollButton and MenuButton are the Root of those buttons. See docs/styling.md.
type TabsVariant ¶
type TabsVariant uint8
TabsVariant selects the look of a tab list.
const ( // TabsUnderline draws a line under the selected tab. It is the default. TabsUnderline TabsVariant = iota // TabsSegmented draws the tabs as one row of segments: a sunken track, with the // selected segment raised. It is the look of a segmented control. Its selected // segment is not filled with the accent; see docs/widgets-navigation.md for how to // get the accent fill back. TabsSegmented )
type TagElement ¶
type TagElement struct {
// contains filtered or unexported fields
}
TagElement is a small rounded chip with a text, for a label or a filter. A tag can have a leading icon, and a remove button that the user can press to take the tag away.
func Tag ¶
func Tag(text string) *TagElement
Tag creates a tag showing text. A tag is as wide as its text by default. Under a MaxWidth, a text that does not fit ends with an ellipsis.
func (*TagElement) Color ¶ added in v0.4.0
func (g *TagElement) Color(c Color) *TagElement
Color tints the tag with c, for a tag that marks a category: a fill of c at about 14% alpha, a border of c at about 32%, and the icon in c. The text keeps the theme's text color, so it stays readable. Styles still wins over it, and under high contrast Color is not used.
func (*TagElement) GridSpan ¶
func (g *TagElement) GridSpan(cols, rows int) *TagElement
GridSpan sets how many columns and rows the tag covers in its parent's grid.
func (*TagElement) Grow ¶
func (g *TagElement) Grow(f float32) *TagElement
Grow makes the tag take a share of the free space on its parent's main axis.
func (*TagElement) Icon ¶
func (g *TagElement) Icon(ic *icons.Icon) *TagElement
Icon sets an icon in front of the text.
func (*TagElement) Key ¶
func (g *TagElement) Key(k string) *TagElement
Key identifies the tag among its siblings (see DivElement.Key).
func (*TagElement) MaxWidth ¶
func (g *TagElement) MaxWidth(l Length) *TagElement
MaxWidth sets the largest width of the tag.
func (*TagElement) MinWidth ¶
func (g *TagElement) MinWidth(l Length) *TagElement
MinWidth sets the smallest width of the tag.
func (*TagElement) OnRemove ¶
func (g *TagElement) OnRemove(fn func()) *TagElement
OnRemove adds a remove button after the text, which calls fn when it is pressed with the mouse, or with Enter or Space. The button is named "Remove" and the tag's text, such as "Remove Sales".
func (*TagElement) Styles ¶
func (g *TagElement) Styles(st TagStyle) *TagElement
Styles sets the look of the parts of the tag, for this instance only. Set fields win over the theme's Tag and the defaults; see TagStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*TagElement) Tooltip ¶ added in v0.2.0
func (g *TagElement) Tooltip(s string) *TagElement
Tooltip shows s below the tag after the pointer rests on it, such as the full text of a truncated tag. Assistive technology reads it as the tag's description, unless it has another.
func (*TagElement) Width ¶
func (g *TagElement) Width(l Length) *TagElement
The sizing methods give the tag's outer box a size. See Sizing in docs/styling.md.
type TagStyle ¶
type TagStyle struct {
Tag Style // the chip: its shape, fill and border
Label Style // the text of the tag
Remove Style // the box around the remove button
}
TagStyle is the look of each part of a tag. A part's style merges over the built-in defaults, then over the theme's Tag, then over the Styles of the instance; see docs/styling.md. Tag is the chip: its shape, fill and border. Label is its text, and Remove the box around the remove button, which a tag has only when it has OnRemove.
type TaskbarProgress ¶
type TaskbarProgress struct {
// State is the state of the progress bar, such as normal or error (see TaskbarState).
State TaskbarState
// Value is the progress, from 0 to 1. A value outside that range, and NaN,
// are clamped to it. TaskbarNone and TaskbarIndeterminate ignore it.
Value float64
}
TaskbarProgress is the progress bar of a window's taskbar button, which Window.SetTaskbarProgress sets. The button is shown while the window is.
type TaskbarState ¶
type TaskbarState uint8
TaskbarState is the state of a taskbar button's progress bar; see TaskbarProgress.
const ( // TaskbarNone shows no progress bar. It is the state of a new window. TaskbarNone TaskbarState = iota // TaskbarNormal shows progress up to the value. TaskbarNormal // TaskbarIndeterminate shows that work is going on, without a value. TaskbarIndeterminate // TaskbarPaused shows progress up to the value, in the paused color. TaskbarPaused // TaskbarError shows progress up to the value, in the error color. TaskbarError )
type TextAccess ¶
type TextAccess struct {
// Info returns the state of the text, or nil for no pattern. It is called on the
// UI thread each time the access tree is built, and returns the content
// (access.TextModel), the selection and caret as points, and the font, with
// FontSize in points at the default text size. The runtime sets where the content
// is drawn: OriginX and OriginY from the element's position, Scale from the display
// scale, Clip from the element's bounds, and it scales FontSize by the text size
// setting. A result with no content leaves the element without the pattern.
//
// The content must be immutable, since the published tree is read from any
// goroutine after Info returns: it must not refer to state that the UI thread
// changes. A change of the content's text is reported to assistive technology as
// a text change, and a change of the selection as a selection change, when the
// tree is built again. The tree is built again after a frame that changed the UI,
// so the element should render the state it reports (as an editor renders its
// view): a change that nothing renders waits for the next frame that changes
// something else.
Info func() *access.TextInfo
// Select makes the Text pattern writable: when assistive technology selects a range
// of its text (Select, or a selection set on the Text pattern), Select is called on
// the UI thread with the range's byte offsets, anchor and caret, as the content's
// model gives them. The element should apply the selection and render it. Without
// Select the pattern is read-only, and the element's actions do not include setting
// the selection.
Select func(anchor, caret int)
// Reveal makes ScrollIntoView of the element's text work for an element that
// scrolls its own text: Reveal is called on the UI thread, and it should scroll the
// caret into view. Without it, ScrollIntoView scrolls the element into view in its
// scroll container, as for any element.
Reveal func()
}
TextAccess is the Text pattern of an element that draws its own text, given to DivElement.TextAccess. Info gives the pattern; Select and Reveal are its writable side, and each may be nil.
type TextAreaElement ¶
type TextAreaElement struct {
// contains filtered or unexported fields
}
TextAreaElement is a multi-line text editor bound to a string signal. It wraps lines, grows with its content and keeps the caret visible inside the nearest scrolling ancestor.
func TextArea ¶
func TextArea(value *Signal[string]) *TextAreaElement
TextArea creates a multi-line editor that reads and writes value.
func (*TextAreaElement) AutoFocus ¶
func (ta *TextAreaElement) AutoFocus() *TextAreaElement
AutoFocus focuses the editor when it first appears.
func (*TextAreaElement) Borderless ¶
func (ta *TextAreaElement) Borderless() *TextAreaElement
Borderless drops the frame and padding, for full-pane editors. The Frame part is not drawn, so its styles do not apply.
func (*TextAreaElement) DescribedBy ¶
func (ta *TextAreaElement) DescribedBy(keys ...string) *TextAreaElement
DescribedBy describes the editor by the text of the elements with the given keys.
func (*TextAreaElement) Disabled ¶
func (ta *TextAreaElement) Disabled(d bool) *TextAreaElement
Disabled shows the text but takes the field out of use: it can't be focused, selected or changed. Its frame is the FrameDisabled part.
func (*TextAreaElement) FocusHandle ¶
func (ta *TextAreaElement) FocusHandle(h *FocusHandle) *TextAreaElement
FocusHandle lets code focus the editor (see NewFocusHandle).
func (*TextAreaElement) GridSpan ¶
func (ta *TextAreaElement) GridSpan(cols, rows int) *TextAreaElement
GridSpan sets how many columns and rows the text area covers in its parent's grid.
func (*TextAreaElement) Grow ¶
func (ta *TextAreaElement) Grow(f float32) *TextAreaElement
Grow makes the text area take a share of the free space on its parent's main axis.
func (*TextAreaElement) Height ¶
func (ta *TextAreaElement) Height(l Length) *TextAreaElement
Height sets the height of the text area.
func (*TextAreaElement) Key ¶
func (ta *TextAreaElement) Key(k string) *TextAreaElement
Key identifies the text area among its siblings (see DivElement.Key).
func (*TextAreaElement) Label ¶
func (ta *TextAreaElement) Label(s string) *TextAreaElement
Label names the field for assistive technology; see TextInputElement.Label.
func (*TextAreaElement) LabelledBy ¶
func (ta *TextAreaElement) LabelledBy(keys ...string) *TextAreaElement
LabelledBy names the editor by the text of the elements with the given keys; see TextInputElement.LabelledBy.
func (*TextAreaElement) Leading ¶
func (ta *TextAreaElement) Leading(el Element) *TextAreaElement
Leading puts el inside the frame before the text. It is drawn in the Leading part; see TextInputElement.Leading.
func (*TextAreaElement) MaxHeight ¶
func (ta *TextAreaElement) MaxHeight(l Length) *TextAreaElement
MaxHeight sets the largest height of the text area.
func (*TextAreaElement) MaxWidth ¶
func (ta *TextAreaElement) MaxWidth(l Length) *TextAreaElement
MaxWidth sets the largest width of the text area.
func (*TextAreaElement) MinHeight ¶
func (ta *TextAreaElement) MinHeight(l Length) *TextAreaElement
MinHeight sets the smallest height of the text area.
func (*TextAreaElement) MinRows ¶
func (ta *TextAreaElement) MinRows(n int) *TextAreaElement
MinRows sets the minimum height in lines (default 3).
func (*TextAreaElement) MinWidth ¶
func (ta *TextAreaElement) MinWidth(l Length) *TextAreaElement
MinWidth sets the smallest width of the text area.
func (*TextAreaElement) OnChange ¶
func (ta *TextAreaElement) OnChange(fn func(string)) *TextAreaElement
OnChange sets the function that runs with the text on each change.
func (*TextAreaElement) OnKeyDown ¶ added in v0.4.0
func (ta *TextAreaElement) OnKeyDown(fn func(*KeyEvent)) *TextAreaElement
OnKeyDown sets the function that runs on each key press while the area has focus, before the area handles the key; see TextInput.OnKeyDown. Calling e.StopPropagation keeps the area from handling the key.
func (*TextAreaElement) OnPasteImage ¶
func (ta *TextAreaElement) OnPasteImage(fn func(image.Image)) *TextAreaElement
OnPasteImage runs fn with the image on the clipboard when the user pastes and the clipboard holds an image but no text (see TextInputElement.OnPasteImage).
func (*TextAreaElement) Placeholder ¶
func (ta *TextAreaElement) Placeholder(s string) *TextAreaElement
Placeholder sets the text shown while the area is empty.
func (*TextAreaElement) ReadOnly ¶
func (ta *TextAreaElement) ReadOnly(on bool) *TextAreaElement
ReadOnly shows the text without letting it change: the field can still be focused, and its text selected and copied. Assistive technology reports it as read-only. Its frame is the FrameReadOnly part.
func (*TextAreaElement) Style ¶
func (ta *TextAreaElement) Style(s Style) *TextAreaElement
Style is merged into the Frame part of the editor, as for TextInputElement.Style.
func (*TextAreaElement) Styles ¶
func (ta *TextAreaElement) Styles(s FieldStyle) *TextAreaElement
Styles sets the look of the parts of the editor, for this instance only; see TextInputElement.Styles.
func (*TextAreaElement) Tooltip ¶
func (ta *TextAreaElement) Tooltip(s string) *TextAreaElement
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*TextAreaElement) Trailing ¶
func (ta *TextAreaElement) Trailing(el Element) *TextAreaElement
Trailing puts el inside the frame after the text. It is drawn in the Trailing part; see TextInputElement.Trailing.
func (*TextAreaElement) Validate ¶
func (ta *TextAreaElement) Validate(rules ...Validator[string]) *TextAreaElement
Validate sets the validators of the text; see TextInputElement.Validate.
func (*TextAreaElement) Width ¶
func (ta *TextAreaElement) Width(l Length) *TextAreaElement
The sizing methods give the editor's frame a size, as for TextInput. A text area is textFieldWidth wide by default.
type TextElement ¶
type TextElement struct {
// contains filtered or unexported fields
}
TextElement is a run of text. Unset properties (color, size, weight...) are inherited from the nearest ancestor that sets them, then the theme.
func Rich ¶
func Rich(segs ...Segment) *TextElement
Rich creates one text element from segments. It is laid out, wrapped, truncated and aligned like Text.
func Textf ¶
func Textf(format string, args ...any) *TextElement
Textf creates a text element with fmt.Sprintf formatting.
func (*TextElement) Align ¶
func (t *TextElement) Align(a Alignment) *TextElement
Align aligns lines within the element: Start, Center or End.
func (*TextElement) Basis ¶ added in v0.6.0
func (t *TextElement) Basis(l Length) *TextElement
Basis sets the text's starting size along its parent's main axis, before free space is shared out, as DivElement.Basis does. Grow(1).Basis(Px(0)) shares a row equally with the items beside it.
func (*TextElement) Bold ¶
func (t *TextElement) Bold() *TextElement
Bold sets the text's weight to FontBold.
func (*TextElement) Font ¶
func (t *TextElement) Font(family string) *TextElement
Font selects a font family registered with the text system.
func (*TextElement) FontSize ¶
func (t *TextElement) FontSize(px float32) *TextElement
FontSize sets the font size in logical pixels.
func (*TextElement) FontWeight ¶ added in v0.4.0
func (t *TextElement) FontWeight(w FontWeight) *TextElement
FontWeight sets the font weight, as DivElement.FontWeight does for the text inside a Div.
func (*TextElement) GridSpan ¶
func (t *TextElement) GridSpan(cols, rows int) *TextElement
GridSpan makes the text cover cols columns and rows rows of the grid it is in (see DivElement.Grid).
func (*TextElement) Grow ¶
func (t *TextElement) Grow(f float32) *TextElement
Grow lets the text take free space on its parent's main axis.
func (*TextElement) Highlight ¶
func (t *TextElement) Highlight(start, end int, h Highlight) *TextElement
Highlight styles the bytes [start, end) of the text, with offsets from strings.Index on the same string. Later highlights win field by field over earlier ones and over the segments of a Rich text. It panics on offsets outside the text or inside a UTF-8 sequence.
func (*TextElement) HighlightMatches ¶
func (t *TextElement) HighlightMatches(query string, h Highlight) *TextElement
HighlightMatches styles every case-insensitive occurrence of query in the text with h, as a search does. A blank query leaves the text as it is. For a Rich text the joined text is searched. Offsets are into the text itself, so text whose lowercase form has another length (İ, the Kelvin sign) still matches correctly.
func (*TextElement) Italic ¶
func (t *TextElement) Italic() *TextElement
Italic sets the whole text in the italic face (upright when the family has none).
func (*TextElement) Key ¶
func (t *TextElement) Key(k string) *TextElement
Key gives the element a stable identity among its siblings.
func (*TextElement) LineHeight ¶
func (t *TextElement) LineHeight(m float32) *TextElement
LineHeight sets the line height as a multiple of the font size.
func (*TextElement) Margin ¶ added in v0.6.0
func (t *TextElement) Margin(px float32) *TextElement
Margin sets the space outside the text on every side, as DivElement.Margin does.
func (*TextElement) MarginBottom ¶ added in v0.6.0
func (t *TextElement) MarginBottom(px float32) *TextElement
MarginBottom sets the space below the text.
func (*TextElement) MarginLeft ¶ added in v0.6.0
func (t *TextElement) MarginLeft(px float32) *TextElement
MarginLeft sets the space to the left of the text.
func (*TextElement) MarginRight ¶ added in v0.6.0
func (t *TextElement) MarginRight(px float32) *TextElement
MarginRight sets the space to the right of the text.
func (*TextElement) MarginTop ¶ added in v0.6.0
func (t *TextElement) MarginTop(px float32) *TextElement
MarginTop sets the space above the text.
func (*TextElement) MarginX ¶ added in v0.6.0
func (t *TextElement) MarginX(px float32) *TextElement
MarginX sets the space outside the text on the left and right.
func (*TextElement) MarginY ¶ added in v0.6.0
func (t *TextElement) MarginY(px float32) *TextElement
MarginY sets the space outside the text above and below.
func (*TextElement) MaxLines ¶
func (t *TextElement) MaxLines(n int) *TextElement
MaxLines limits the number of lines, ending with an ellipsis.
func (*TextElement) MaxWidth ¶
func (t *TextElement) MaxWidth(l Length) *TextElement
MaxWidth sets the widest the text may grow to.
func (*TextElement) Medium ¶
func (t *TextElement) Medium() *TextElement
Medium, Semibold and Bold are shorthands for FontWeight.
func (*TextElement) MinWidth ¶
func (t *TextElement) MinWidth(l Length) *TextElement
MinWidth sets the narrowest the text may shrink to in a shrinking row. The automatic minimum is the widest word (see Shrinking and minimum sizes).
func (*TextElement) NoWrap ¶
func (t *TextElement) NoWrap() *TextElement
NoWrap keeps the text on one line.
func (*TextElement) Selectable ¶
func (t *TextElement) Selectable() *TextElement
Selectable lets the user select the text and copy it, as in an error message or a details pane: drag across it, double-click a word, triple-click a paragraph, Shift+click to extend, and Ctrl+A and Ctrl+C (or Ctrl+Insert) once it has been clicked. A click puts keyboard focus on the text, but Tab does not stop on it, as with selectable text elsewhere in Windows. The selection is cleared when focus moves away. In rich text, a click on a link still follows the link.
func (*TextElement) Semibold ¶
func (t *TextElement) Semibold() *TextElement
Semibold sets the text's weight to FontSemibold.
func (*TextElement) Shrink ¶ added in v0.6.1
func (t *TextElement) Shrink(f float32) *TextElement
Shrink sets how much the text gives up when its row is too narrow, relative to the items beside it; 1 by default. Shrink(0) keeps the text at its full width, so a name keeps its width while the text beside it truncates.
func (*TextElement) Style ¶
func (t *TextElement) Style(s Style) *TextElement
Style merges layout and text fields of s.
func (*TextElement) TextColor ¶
func (t *TextElement) TextColor(c Color) *TextElement
TextColor sets the text color.
func (*TextElement) Truncate ¶
func (t *TextElement) Truncate() *TextElement
Truncate keeps the text on one line, ending with an ellipsis if it does not fit.
func (*TextElement) Weight
deprecated
func (t *TextElement) Weight(w FontWeight) *TextElement
Weight sets the font weight.
Deprecated: use FontWeight, the name a Div uses for the same setting.
func (*TextElement) Width ¶
func (t *TextElement) Width(l Length) *TextElement
Width sets a fixed width, or a Percent or Full width of the parent. Text has no defaults of its own, so a size set here is the one the text has (see Style).
type TextFormat ¶
type TextFormat struct {
FontSize float32 // 0 means the theme's text size
Color Color // zero means the inherited text color (see Painter.TextColor)
// Weight is the font weight of the text.
Weight FontWeight
// Mono sets the text in the monospace family, as code is set.
Mono bool
// Italic draws the text in the italic face of its family. A family with no
// italic face for the weight draws it upright: the text system has no
// synthetic oblique. Windows has italic faces for the sans and the monospace
// families, and the embedded fonts on other systems do too.
Italic bool
// Align places the text horizontally against x: Start puts its left edge
// there, Center its middle, End its right edge. VAlign does the same
// vertically against y, with Start its top.
Align, VAlign Alignment
}
TextFormat is how Painter.Text draws text.
type TextInputElement ¶
type TextInputElement struct {
// contains filtered or unexported fields
}
TextInputElement is a single-line text field bound to a string signal. It supports selection (mouse, Shift+arrows, double-click), clipboard, undo/redo, word navigation (Ctrl+arrows) and any script.
func TextInput ¶
func TextInput(value *Signal[string]) *TextInputElement
TextInput creates a text field that reads and writes value.
func (*TextInputElement) Accept ¶ added in v0.4.0
func (ti *TextInputElement) Accept(fn func(next string) bool) *TextInputElement
Accept sets the function that decides whether an edit by the user may change the text: fn gets the raw value the edit would make (after the Format took the edit), and when it returns false nothing changes: no OnChange and no undo step, and the caret stays where it was. It runs on typing, an input method's result, paste, delete, cut and a value set by assistive technology. The empty text is always accepted, and undo, redo and the app's own Set are not checked. Since fn sees the text as it is being typed, a regular expression used here must match the start of a valid text too: ^[0-9]{0,5}$, not ^[0-9]{5}$ (use Validate for the whole text).
func (*TextInputElement) AutoFocus ¶
func (ti *TextInputElement) AutoFocus() *TextInputElement
AutoFocus focuses the field when it first appears.
func (*TextInputElement) Borderless ¶
func (ti *TextInputElement) Borderless() *TextInputElement
Borderless drops the field's frame and padding, for inputs that should look like plain text until clicked (titles, inline renames). The Frame part is not drawn, so its styles do not apply.
func (*TextInputElement) Clearable ¶ added in v0.3.0
func (ti *TextInputElement) Clearable() *TextInputElement
Clearable adds a small X button after the text while the field has text. A click on it clears the text, runs OnChange with "", and leaves the focus in the field. Escape clears the text too, when the field has text; with the field empty, Escape does what it does in any field (it leaves the field, or closes the modal). The button is not a Tab stop, and assistive technology reads it as a button named Strings.Clear. A read-only or disabled field shows no button. The button is drawn in the Button part, inside the Trailing part: the clear button, then the reveal button (see Revealable), then the Trailing element.
func (*TextInputElement) DescribedBy ¶
func (ti *TextInputElement) DescribedBy(keys ...string) *TextInputElement
DescribedBy describes the field by the text of the elements with the given keys.
func (*TextInputElement) Disabled ¶
func (ti *TextInputElement) Disabled(d bool) *TextInputElement
Disabled shows the text but takes the field out of use: it can't be focused, selected or changed. Its frame is the FrameDisabled part.
func (*TextInputElement) FocusHandle ¶
func (ti *TextInputElement) FocusHandle(h *FocusHandle) *TextInputElement
FocusHandle lets code focus the field (see NewFocusHandle).
func (*TextInputElement) Format ¶ added in v0.4.0
func (ti *TextInputElement) Format(f InputFormat) *TextInputElement
Format shows the text in the shape f as the user types it, such as a phone number (TemplateFormat("(999) 999-9999")) or a number with the locale's separators (NumberFormat). The signal holds the raw value: "5551234567" for (555) 123-4567, and "-1234.5" for -1,234.5. Characters the format does not take are not typed, a paste takes what fits, and the caret moves over the slots, not the literals. A template draws its slots not filled yet as _ after the text, in the placeholder's color; an empty field draws them while it has focus, and its placeholder, when it has one, while it has not. Leaving the field puts a number in its shortest form ("12." becomes "12"). Copy copies the text as shown, and assistive technology reads it as shown, so say what the format is in the Tooltip or the Label too. Validate sees the raw value; Complete checks that it is complete. With Masked, the field draws a bullet for each character, without the literals.
func (*TextInputElement) GridSpan ¶
func (ti *TextInputElement) GridSpan(cols, rows int) *TextInputElement
GridSpan sets how many columns and rows the text input covers in its parent's grid.
func (*TextInputElement) Grow ¶
func (ti *TextInputElement) Grow(f float32) *TextInputElement
Grow makes the text input take a share of the free space on its parent's main axis.
func (*TextInputElement) Height ¶
func (ti *TextInputElement) Height(l Length) *TextInputElement
Height sets the height of the text input.
func (*TextInputElement) Icon ¶
func (ti *TextInputElement) Icon(ic *icons.Icon) *TextInputElement
Icon sets an icon drawn inside the field, before the text.
func (*TextInputElement) Key ¶
func (ti *TextInputElement) Key(k string) *TextInputElement
Key identifies the text input among its siblings (see DivElement.Key).
func (*TextInputElement) Label ¶
func (ti *TextInputElement) Label(s string) *TextInputElement
Label names the field for assistive technology. A field has no visible name of its own, so it should be given one; the placeholder is not used.
func (*TextInputElement) LabelledBy ¶
func (ti *TextInputElement) LabelledBy(keys ...string) *TextInputElement
LabelledBy names the field by the text of the elements with the given keys, such as a visible label above it (see DivElement.LabelledBy).
func (*TextInputElement) Large ¶
func (ti *TextInputElement) Large() *TextInputElement
Large makes the field larger: 40 px high with 16 px text, like Button.Large. Small and Large replace each other.
func (*TextInputElement) Leading ¶
func (ti *TextInputElement) Leading(el Element) *TextInputElement
Leading puts el inside the frame before the text, after the icon (see Icon). It is drawn in the Leading part.
func (*TextInputElement) Masked ¶ added in v0.3.0
func (ti *TextInputElement) Masked() *TextInputElement
Masked draws a bullet (•) in place of each character, as a password box does. The caret and the selection still move by characters. Copy and cut do nothing, so the text stays off the clipboard, while paste works. A word is the whole text, since its words are not shown: a double-click selects it all, and Ctrl+Left, Ctrl+Right, Ctrl+Backspace and Ctrl+Delete go to the start or the end. An input method's composition is not shown in the field: the text that it confirms is typed as typed text is, as in an OTPInput. Assistive technology reads the field as a password field, whose value is a bullet for each character.
func (*TextInputElement) MaxHeight ¶
func (ti *TextInputElement) MaxHeight(l Length) *TextInputElement
MaxHeight sets the largest height of the text input.
func (*TextInputElement) MaxWidth ¶
func (ti *TextInputElement) MaxWidth(l Length) *TextInputElement
MaxWidth sets the largest width of the text input.
func (*TextInputElement) MinHeight ¶
func (ti *TextInputElement) MinHeight(l Length) *TextInputElement
MinHeight sets the smallest height of the text input.
func (*TextInputElement) MinWidth ¶
func (ti *TextInputElement) MinWidth(l Length) *TextInputElement
MinWidth sets the smallest width of the text input.
func (*TextInputElement) OnChange ¶
func (ti *TextInputElement) OnChange(fn func(string)) *TextInputElement
OnChange sets the function that runs with the text on each change.
func (*TextInputElement) OnKeyDown ¶ added in v0.4.0
func (ti *TextInputElement) OnKeyDown(fn func(*KeyEvent)) *TextInputElement
OnKeyDown sets the function that runs on each key press while the field has focus, before the field handles the key. The field's own keys (typing, arrows, Enter, Ctrl+A...) still come after it. Calling e.StopPropagation keeps the field from handling the key, so an app can take a key the field would use, such as Shift+Enter for a search's previous match.
func (*TextInputElement) OnPasteImage ¶
func (ti *TextInputElement) OnPasteImage(fn func(image.Image)) *TextInputElement
OnPasteImage runs fn with the image on the clipboard when the user pastes (Ctrl+V or the Paste action) and the clipboard holds an image but no text, as when a screenshot is pasted into a message box. Without it, such a paste does nothing. A read-only or disabled field ignores it.
func (*TextInputElement) OnSubmit ¶
func (ti *TextInputElement) OnSubmit(fn func(string)) *TextInputElement
OnSubmit sets the function that runs with the text when Enter is pressed.
func (*TextInputElement) Placeholder ¶
func (ti *TextInputElement) Placeholder(s string) *TextInputElement
Placeholder sets the text shown while the field is empty.
func (*TextInputElement) ReadOnly ¶
func (ti *TextInputElement) ReadOnly(on bool) *TextInputElement
ReadOnly shows the text without letting it change: the field can still be focused, and its text selected and copied. Assistive technology reports it as read-only. Its frame is the FrameReadOnly part.
func (*TextInputElement) Revealable ¶ added in v0.3.0
func (ti *TextInputElement) Revealable() *TextInputElement
Revealable adds a button after the text of a Masked field that shows the text and masks it again, as the reveal button of a Windows password box does; Alt+F8 does the same while the field has focus. The button is not a Tab stop, and pressing it leaves the focus in the field. Assistive technology reads it as a toggle button named Strings.ShowPassword, or HidePassword while the text is shown, which is pressed while the text is shown. A shown text is drawn and read as it is, but copy and cut still do nothing and the field is still a password field. The button is drawn in the Button part, inside the Trailing part and before the Trailing element. Without Masked, Revealable does nothing.
func (*TextInputElement) Small ¶
func (ti *TextInputElement) Small() *TextInputElement
Small makes a compact field (28px tall, 13px text), matching Button.Small.
func (*TextInputElement) Style ¶
func (ti *TextInputElement) Style(s Style) *TextInputElement
Style is merged into the Frame part of the field, over the Styles of the instance: Padding, Margin, Radius, Background and BorderColor/BorderWidth apply to the frame, and FontSize, FontWeight, FontFamily and TextColor are inherited by the text inside. A size set here is overridden by the sizing methods (Width and the others); see Sizing in docs/styling.md. It is the same as Styles(FieldStyle{Frame: s}).
func (*TextInputElement) Styles ¶
func (ti *TextInputElement) Styles(s FieldStyle) *TextInputElement
Styles sets the look of the parts of the field, for this instance only. Set fields win over the theme's Field and the defaults; see FieldStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*TextInputElement) Tooltip ¶
func (ti *TextInputElement) Tooltip(s string) *TextInputElement
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*TextInputElement) Trailing ¶
func (ti *TextInputElement) Trailing(el Element) *TextInputElement
Trailing puts el inside the frame after the text, such as a button. It is drawn in the Trailing part.
func (*TextInputElement) Validate ¶
func (ti *TextInputElement) Validate(rules ...Validator[string]) *TextInputElement
Validate sets the validators of the text: the field shows the first error of them once the user has changed the text and left the field, and on submit when it is in a Form (see Field and Validator). An empty text passes MinLength and Pattern, so pair those with Required when the field must be filled in.
func (*TextInputElement) Width ¶
func (ti *TextInputElement) Width(l Length) *TextInputElement
The sizing methods give the field's frame a size. A field is textFieldWidth wide by default, so Width(Full) fills its container, and the frame never shrinks below the room for a few characters (see MinWidth). See Sizing in docs/styling.md.
type Theme ¶
type Theme struct {
// Name is the name of the theme.
Name string
// Dark reports whether the theme is a dark theme.
Dark bool
// HighContrast is true for the high contrast theme, which HighContrastTheme
// builds from the system colors. Apps can read it to choose their own colors.
HighContrast bool
Background Color // window background
Panel Color // secondary panels
Surface Color // cards, inputs
// SurfaceHover is the surface color under the pointer.
SurfaceHover Color
// SurfaceActive is the surface color while it is pressed.
SurfaceActive Color
// Border is the color of the borders of the controls.
Border Color
// BorderStrong is the stronger border color, for a control that needs more contrast.
BorderStrong Color
// Text is the main text color.
Text Color
// TextMuted is the color of secondary text.
TextMuted Color
// TextSubtle is the color of the least important text.
TextSubtle Color
// Accent is the accent color, for primary buttons and selections.
Accent Color
Link Color // hyperlink text; a separate token so that Accent can fill buttons
// Disabled is the color of disabled text, icons and borders. Under high
// contrast it is GrayText; in the normal themes disabled controls are dimmed
// with Opacity instead, so it equals TextSubtle there.
Disabled Color
// AccentHover is the accent color under the pointer.
AccentHover Color
// AccentActive is the accent color while it is pressed.
AccentActive Color
AccentText Color // text on Accent
AccentSoft Color // tinted backgrounds (selection, badges)
// Success is the color of success states.
Success Color
// Warning is the color of warning states.
Warning Color
// Danger is the color of error and dangerous states.
Danger Color
// Scrollbar is the color of scroll bars.
Scrollbar Color
// FocusRing is the color of the ring that shows keyboard focus.
FocusRing Color
Scrim Color // the dimmed backdrop behind a Modal
// Radius is the default corner radius of the controls, in logical pixels.
Radius float32
// FontSize is the default text size, in logical pixels.
FontSize float32
// Motion is the timing of the built-in widgets' motion. Its zero value
// keeps the built-in timings.
Motion MotionTokens
// Syntax is the look of each syntax token of a code editor, keyed by the
// token name (see SyntaxStyle). Under high contrast it keeps the
// same names, with system colors.
Syntax map[string]SyntaxStyle
// CodeEditor is the colors of a code editor.
CodeEditor CodeEditorColors
// The parts of the built-in widgets, for every widget of that kind in the
// app. They merge over the built-in defaults, which are made from the colors
// above, and an instance's Styles merge over them. Under high contrast only
// their sizes, spacing, fonts, radius and border widths apply (see
// docs/styling.md).
Tabs TabsStyle
// Select is the look of every select box, including its list.
Select SelectStyle
// Combobox is the look of every combo box: its text frame (Field), its list and
// its rows.
Combobox ComboboxStyle
// DatePicker and TimePicker are the look of every date picker (with its calendar) and
// every time picker.
DatePicker DatePickerStyle
// TimePicker is the look of every time picker.
TimePicker TimePickerStyle
// Slider is the look of every slider.
Slider SliderStyle
// RangeSlider is the look of every range slider.
RangeSlider RangeSliderStyle
// SplitButton is the look of every split button.
SplitButton SplitButtonStyle
// Split is the look of every split, including its dividers and grips.
Split SplitStyle
// Dock is the look of every dock: its tab groups, tabs, panels and drop preview.
Dock DockStyle
// Field is the text frame of every TextInput and TextArea, and of every
// NumberInput's frame, before the NumberInput parts below.
Field FieldStyle
// NumberInput is the look of the parts of every number input, beyond its text frame.
NumberInput NumberInputStyle
// Button is the look of every button, whatever its variant. Buttons is the
// look of each variant, and merges over Button.
Button ButtonStyle
// Buttons is the look of each variant of button, and merges over Button.
Buttons ButtonVariants
// Checkbox is the look of every check box, including CheckboxTri.
Checkbox CheckboxStyle
// RadioGroup is the look of every radio group.
RadioGroup RadioGroupStyle
// Switch is the look of every switch.
Switch SwitchStyle
// Toggle is the look of every toggle.
Toggle ToggleStyle
// ToggleGroup is the look of every toggle group.
ToggleGroup ToggleGroupStyle
// Rating is the look of every rating.
Rating RatingStyle
// Collapsible is the look of every collapsible section, including the
// sections of an Accordion.
Collapsible CollapsibleStyle
// Tree is the look of every tree.
Tree TreeStyle
// ListBox is the look of every list box.
ListBox ListBoxStyle
// DataGrid is the look of every data grid.
DataGrid DataGridStyle
// Menu is the look of every menu: dropdown, context and the menus of a MenuBar.
Menu MenuStyle
// MenuBar is the look of every menu bar.
MenuBar MenuBarStyle
// Modal is the look of every modal dialog, Drawer of every drawer, and
// Popover of every popover's panel.
Modal ModalStyle
// Drawer is the look of every drawer.
Drawer DrawerStyle
// AlertDialog is the look of every alert dialog.
AlertDialog AlertDialogStyle
// Popover is the look of the panel of every popover.
Popover PopoverStyle
// HoverCard is the look of the panel of every hover card.
HoverCard HoverCardStyle
// CommandPalette is the look of every command palette.
CommandPalette CommandPaletteStyle
// FormField is the look of every field (its label, help text and error), and Form
// is the look of every form's error summary.
FormField FormFieldStyle
// Form is the look of every form's error summary.
Form FormStyle
// ProgressBar is the look of every progress bar, determinate or not.
ProgressBar ProgressBarStyle
// ProgressRing is the look of every progress ring.
ProgressRing ProgressRingStyle
// Badge is the look of every badge, whatever its variant. Badges is the look
// of each variant, and merges over Badge.
Badge BadgeStyle
// Badges is the look of each badge variant, and merges over Badge.
Badges BadgeVariants
// Toast is the look of every toast, whatever its kind. Toasts is the look of
// each kind, and merges over Toast.
Toast ToastStyle
// Toasts is the look of each toast kind, and merges over Toast.
Toasts ToastVariants
// Alert is the look of every alert, whatever its variant. Alerts is the look
// of each variant, and merges over Alert.
Alert AlertStyle
// Alerts is the look of each alert variant, and merges over Alert.
Alerts AlertVariants
// Tooltip is the look of every tooltip.
Tooltip TooltipStyle
// Avatar is the look of every avatar.
Avatar AvatarStyle
// Tag is the look of every tag.
Tag TagStyle
// GroupBox is the look of every group box, outlined or filled.
GroupBox GroupBoxStyle
// Card is the look of every card, whatever its variant. Cards is the look of
// each variant, and merges over Card.
Card CardStyle
// Cards is the look of each card variant, and merges over Card.
Cards CardVariants
// DescriptionList is the look of every description list.
DescriptionList DescriptionListStyle
// Kbd is the look of every keyboard shortcut drawn as key caps.
Kbd KbdStyle
// Skeleton is the look of every skeleton placeholder.
Skeleton SkeletonStyle
// Sidebar is the look of every sidebar. Panel is the background color of the
// theme's secondary panels, which the sidebar and other parts also use.
Sidebar SidebarStyle
// Breadcrumbs is the look of every breadcrumb trail.
Breadcrumbs BreadcrumbsStyle
// Pagination is the look of every pagination control.
Pagination PaginationStyle
// Stepper is the look of every stepper.
Stepper StepperStyle
// OTPInput is the look of every one-time code input.
OTPInput OTPInputStyle
// DateRangePicker is the look of every date range picker and its calendar. It is not
// DatePicker: a range has its own parts, such as DayInRange.
DateRangePicker DateRangePickerStyle
// Calendar is the look of every calendar on the page, Calendar and CalendarRange. It is
// not DatePicker: the calendar of a picker is its popup, and its parts are the picker's.
Calendar CalendarStyle
// Carousel is the look of every carousel. Its previous and next buttons are
// IconButtons, which Button styles.
Carousel CarouselStyle
// ColorPicker is the look of every color picker: its trigger, its panel and the
// sliders of the panel.
ColorPicker ColorPickerStyle
// StatusBar is the look of every status bar.
StatusBar StatusBarStyle
// Toolbar is the look of every toolbar and its separators.
Toolbar ToolbarStyle
// Empty is the look of every empty state.
Empty EmptyStyle
// contains filtered or unexported fields
}
Theme is a set of semantic colors and metrics used by built-in widgets and available to applications through Context.Theme.
func DarkTheme ¶
func DarkTheme() *Theme
DarkTheme returns the built-in dark theme: a neutral zinc palette with an indigo accent. Each call returns a new copy, which the caller may change.
func HighContrastTheme ¶
func HighContrastTheme(c SystemColors, base *Theme) *Theme
HighContrastTheme returns the theme that the runtime uses while Windows high contrast is on. It is built from the system colors only: solid colors, no gradients, no shadows and no tints, so that text, focus and control borders stay readable (Microsoft's guidance is at https://learn.microsoft.com/en-us/windows/apps/design/accessibility/high-contrast-themes). Text is WindowText, and selection and the primary action are Highlight with HighlightText. Status colors are WindowText too, so a status is shown by its text and icon, not by its color. Syntax keeps the capture names of base, in WindowText, and keywords in Highlight. Radius, FontSize and the widget parts (the Theme fields for each widget kind, such as Tabs, Button and Toast) are taken from base; the parts keep only their sizes and spacing under high contrast (see plainStyle). So are the styles that SetThemeStyle stored on base, which widgets read the same way: sizes and spacing, with the system colors.
func LightTheme ¶
func LightTheme() *Theme
LightTheme returns the built-in light theme, the counterpart of DarkTheme. Each call returns a new copy, which the caller may change.
func NewTheme ¶
NewTheme returns a new copy of the predefined theme with the given name from Themes, and true. It returns nil and false for a name that is not in Themes. The name must match exactly. Each call returns a new copy, which the caller may change. The Name of each copy is the name in Themes, so NewTheme(t.Name) returns a theme for every predefined theme.
func (*Theme) Clone ¶
Clone returns a copy of the theme, to change for an app without changing the built-in theme it was copied from. The copy shares the Shadows slices of its part styles, so change a part by assigning a new style to its field, and do not append to or change those slices in place. The copy has its own Syntax map. It has the styles that SetThemeStyle stored on t; setting one on the copy does not change t, nor the other way round.
type ThemeInfo ¶
type ThemeInfo struct {
Name string // the name of the theme, such as "Catppuccin Mocha"; NewTheme takes it
Family string // the scheme the theme is a variant of, or "jamb" for Dark and Light
Author string // the author of the scheme as credited upstream; empty for Dark and Light
URL string // the upstream address of the scheme; empty for Dark and Light
Dark bool // true for a dark variant
}
ThemeInfo describes one predefined theme, as Themes lists it. The variants of one scheme share a Family, such as "Catppuccin" for Catppuccin Latte and Catppuccin Mocha, so an app can pick a light and a dark variant for the LightTheme and DarkTheme of an app.Window.
type TimePickerElement ¶
type TimePickerElement struct {
// contains filtered or unexported fields
}
TimePickerElement is a text field for a time of day, with a list of the times at a fixed step below it. The text is the time in the clock format of the user's locale (see the docs/widgets-selection.md, Date and time). The value is a time.Time: its clock is the time and its date is kept, so one signal can hold a date and a time (see DatePicker); a zero time is no time.
Up and Down step the time by the step while the list is closed, and move the highlight through the list while it is open. Alt+Down and F4 open the list, Enter chooses the highlighted time, and Escape or Tab closes it. Focus stays in the text, as it does in a combo box. A time that is not between Min and Max cannot be chosen.
func TimePicker ¶
func TimePicker(value *Signal[time.Time]) *TimePickerElement
TimePicker creates a time picker that reads and writes value, with a list of the times every 15 minutes (see MinuteStep). The default width is 140 px at the Text size of 100 percent. A zero time is no time, and the field is empty.
func (*TimePickerElement) Disabled ¶
func (p *TimePickerElement) Disabled(on bool) *TimePickerElement
Disabled shows the field, with its time, and does not let it change.
func (*TimePickerElement) FocusHandle ¶
func (p *TimePickerElement) FocusHandle(h *FocusHandle) *TimePickerElement
FocusHandle lets code focus the time field (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*TimePickerElement) GridSpan ¶
func (p *TimePickerElement) GridSpan(cols, rows int) *TimePickerElement
GridSpan sets how many columns and rows the time picker covers in its parent's grid.
func (*TimePickerElement) Grow ¶
func (p *TimePickerElement) Grow(f float32) *TimePickerElement
Grow makes the time picker take a share of the free space on its parent's main axis.
func (*TimePickerElement) Height ¶
func (p *TimePickerElement) Height(l Length) *TimePickerElement
Height sets the height of the time picker.
func (*TimePickerElement) Key ¶
func (p *TimePickerElement) Key(k string) *TimePickerElement
Key identifies the time picker among its siblings (see DivElement.Key).
func (*TimePickerElement) Label ¶
func (p *TimePickerElement) Label(name string) *TimePickerElement
Label names the field for assistive technology, such as "Start time".
func (*TimePickerElement) LabelledBy ¶
func (p *TimePickerElement) LabelledBy(keys ...string) *TimePickerElement
LabelledBy names the field by the text of the elements with the given keys; see DivElement.LabelledBy.
func (*TimePickerElement) Large ¶
func (p *TimePickerElement) Large() *TimePickerElement
Large makes the field larger: 40 px high with 16 px text, like Button.Large and TextInput.Large, for touch-friendly or prominent forms. Small and Large replace each other.
func (*TimePickerElement) Max ¶
func (p *TimePickerElement) Max(t time.Time) *TimePickerElement
Max sets the latest time that can be chosen. Only its clock is used; a zero time means there is no latest time.
func (*TimePickerElement) MaxHeight ¶
func (p *TimePickerElement) MaxHeight(l Length) *TimePickerElement
MaxHeight sets the largest height of the time picker.
func (*TimePickerElement) MaxWidth ¶
func (p *TimePickerElement) MaxWidth(l Length) *TimePickerElement
MaxWidth sets the largest width of the time picker.
func (*TimePickerElement) Min ¶
func (p *TimePickerElement) Min(t time.Time) *TimePickerElement
Min sets the earliest time that can be chosen. Only its clock is used; a zero time means there is no earliest time.
func (*TimePickerElement) MinHeight ¶
func (p *TimePickerElement) MinHeight(l Length) *TimePickerElement
MinHeight sets the smallest height of the time picker.
func (*TimePickerElement) MinWidth ¶
func (p *TimePickerElement) MinWidth(l Length) *TimePickerElement
MinWidth sets the smallest width of the time picker.
func (*TimePickerElement) MinuteStep ¶
func (p *TimePickerElement) MinuteStep(minutes int) *TimePickerElement
MinuteStep sets the minutes between the times of the list, and the step of Up and Down. The default is 15. A step below one minute is ignored.
func (*TimePickerElement) OnChange ¶
func (p *TimePickerElement) OnChange(fn func(time.Time)) *TimePickerElement
OnChange runs fn with the new value after the user chooses a time, or types one that can be chosen. It does not run when the value is set from outside.
func (*TimePickerElement) Placeholder ¶
func (p *TimePickerElement) Placeholder(s string) *TimePickerElement
Placeholder is the text shown while the field is empty. The default is the hint of the locale's clock, such as "h:mm AM" on a 12 hour clock (see timePlaceholder).
func (*TimePickerElement) Small ¶
func (p *TimePickerElement) Small() *TimePickerElement
Small makes the field compact: 28 px high with smaller text, like Button.Small and TextInput.Small, for toolbars and dense forms.
func (*TimePickerElement) Styles ¶
func (p *TimePickerElement) Styles(st TimePickerStyle) *TimePickerElement
Styles sets the look of the parts of the time picker, for this instance only. Set fields win over the theme's TimePicker and the defaults; see TimePickerStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*TimePickerElement) Tooltip ¶
func (p *TimePickerElement) Tooltip(s string) *TimePickerElement
Tooltip shows s below the field after the pointer rests on it. Assistive technology reads it as the field's description, unless it has another.
func (*TimePickerElement) Validate ¶
func (p *TimePickerElement) Validate(rules ...Validator[time.Time]) *TimePickerElement
Validate sets the validators of the value. A zero time is no time, so Required rejects an empty field (see Field).
func (*TimePickerElement) Width ¶
func (p *TimePickerElement) Width(l Length) *TimePickerElement
The sizing methods give the field a size. The field is timePickerWidth wide at the Text size of 100 percent by default; Width(Full) fills its container, and the list is at least as wide as the field. See Sizing in docs/styling.md.
type TimePickerStyle ¶
type TimePickerStyle struct {
// Field is the text frame of the time picker.
Field FieldStyle
// Button is the button that opens the list of times.
Button Style
// Message is the message under the field.
Message Style
// Popup is the panel of the list of times.
Popup Style
// Option is the style of each time in the list.
Option Style
// OptionHighlighted is the style of the time that the keyboard or the pointer is on.
OptionHighlighted Style
// OptionSelected is the style of the time that is chosen.
OptionSelected Style
}
TimePickerStyle is the look of each part of a time picker. A part's style merges over the built-in defaults, then over the theme's TimePicker, then over the Styles of the instance; see docs/styling.md.
Field is the text frame, a FieldStyle as TextInput's is, with its states. Button is the button at the end of the field that opens the list of times, and Message the row that says why the text is not a time that can be chosen (as NumberInput's message). Popup is the open list, Option each time in it, OptionHighlighted the time the keys have reached, and OptionSelected the time that the field holds. Under high contrast the highlighted time is drawn in the system Highlight colors, and the selected one has a check mark, so that no state is shown by color alone.
type Timeline ¶ added in v0.4.0
type Timeline struct {
// contains filtered or unexported fields
}
Timeline arranges animations in time, for AnimateTimeline: steps that run one after another (Sequence), timelines that run together (Parallel), one timeline after another (Then), and a timeline that loops (Repeat). Its steps are the Animations it was built from, in the order they were given; each has a progress of its own.
tl := ui.Sequence(fadeIn, slide).Then(ui.Parallel(ui.Sequence(pop), ui.Sequence(glow)))
func Parallel ¶ added in v0.4.0
Parallel is a timeline of the parts all starting together. It lasts as long as the longest of them.
func Sequence ¶ added in v0.4.0
Sequence is a timeline of the steps one after another: each starts when the one before it ends, after its own Delay. A step's Easing shapes its own progress, and its OnDone runs when it ends; its Repeat and Stagger are not used.
func (Timeline) Duration ¶ added in v0.4.0
Duration returns how long the timeline lasts: until its last step ends.
type TitleBarElement ¶ added in v0.4.0
type TitleBarElement struct {
// contains filtered or unexported fields
}
TitleBarElement is a window's own title bar, for a window with the app's chrome (see app.ChromeCustom). It is a row: the children go at its start, the left, in order, as in a Div. Trailing items and the caption buttons go at its end, the right. Center puts an element in the middle of the window, not between the sides: the element gets the room between the wider side and the other one, so it is centered on the bar's whole width and never covers a side. Wider content than that room is clipped.
The bar is a window drag area (see WindowAreaDrag): its empty parts move the window, and its children that take input still work. Its content dims while the window is not focused, and the caption buttons do not.
func TitleBar ¶ added in v0.4.0
func TitleBar() *TitleBarElement
TitleBar creates an empty title bar, with the caption buttons at its end.
func (*TitleBarElement) Buttons ¶ added in v0.4.0
func (t *TitleBarElement) Buttons(show bool) *TitleBarElement
Buttons sets whether the caption buttons (minimize, maximize or restore, and close, see TitleBarButtons) are at the end of the bar. They are shown by default. Turn them off when the window has no caption buttons of its own.
func (*TitleBarElement) Center ¶ added in v0.4.0
func (t *TitleBarElement) Center(e Element) *TitleBarElement
Center puts e in the middle of the window's width. It is laid out in the room the sides leave: the wider of the start side and the end side is kept clear on both ends, so e never covers them. When the sides leave too little room, e is clipped to what is left. A nil e is ignored.
func (*TitleBarElement) Child ¶ added in v0.4.0
func (t *TitleBarElement) Child(e Element) *TitleBarElement
Child appends an item at the start of the bar, the left. A nil item is ignored.
func (*TitleBarElement) Height ¶ added in v0.4.0
func (t *TitleBarElement) Height(l Length) *TitleBarElement
Height sets the height of the bar. The default is 40 px at 100 percent Text size; see TitleBar.
func (*TitleBarElement) Key ¶ added in v0.4.0
func (t *TitleBarElement) Key(k string) *TitleBarElement
Key identifies the title bar among its siblings (see DivElement.Key).
func (*TitleBarElement) Style ¶ added in v0.4.0
func (t *TitleBarElement) Style(s Style) *TitleBarElement
Style sets the look of the bar's Bar part, for this instance only. It is the same as Styles(TitleBarStyle{Bar: s}); calling it again merges.
func (*TitleBarElement) Styles ¶ added in v0.4.0
func (t *TitleBarElement) Styles(st TitleBarStyle) *TitleBarElement
Styles sets the look of the parts of the bar, for this instance only. Set fields win over the defaults; see TitleBarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*TitleBarElement) Trailing ¶ added in v0.4.0
func (t *TitleBarElement) Trailing(els ...Element) *TitleBarElement
Trailing appends items at the end of the bar, before the caption buttons. nil items are ignored.
func (*TitleBarElement) Width ¶ added in v0.4.0
func (t *TitleBarElement) Width(l Length) *TitleBarElement
The sizing methods give the bar's outer box a size. The bar is as high as the Text size scale makes its default, 40 px at 100 percent, and it fills the width of a column (see Sizing in docs/styling.md). Windows' own caption buttons are 32 px high, so a bar lower than 32 px cannot hold them.
type TitleBarStyle ¶ added in v0.4.0
type TitleBarStyle struct {
Bar Style // the strip: its height, fill, bottom border and text
Center Style // the box of the centered element
}
TitleBarStyle is the look of the parts of a title bar. A part's style merges over the built-in defaults, then over the instance's Styles; see docs/styling.md. Bar is the strip, with its height, fill, bottom border and text color, which the items inherit; Center is the box of the centered element, which fills the room between the sides.
type Toast ¶
type Toast struct {
// contains filtered or unexported fields
}
Toast is a notification in the Toaster. Context.Toast makes one; the methods below set its action, its time and its dismissal.
func (*Toast) Action ¶
Action adds a button labelled label to the toast, such as "Undo". Running it calls fn and dismisses the toast.
func (*Toast) Dismiss ¶
func (t *Toast) Dismiss()
Dismiss removes the toast now. If the focus is on the toast, it moves on as it does for the toast's close button.
func (*Toast) Duration ¶
Duration sets how long the toast stays. The time it is hovered or has keyboard focus does not count.
func (*Toast) Styles ¶
func (t *Toast) Styles(st ToastStyle) *Toast
Styles sets the look of the parts of this toast alone. Set fields win over the theme's Toast and Toasts and the defaults of its kind; see ToastStyle and docs/styling.md. Calling Styles again merges with the earlier values.
type ToastPlacement ¶
type ToastPlacement uint8
ToastPlacement is where a Toaster shows its stack of toasts.
const ( // ToastBottomRight stacks the toasts in the bottom-right corner. It is the default. ToastBottomRight ToastPlacement = iota // ToastTopRight stacks them in the top-right corner. ToastTopRight // ToastBottomCenter stacks them along the bottom, centered. ToastBottomCenter )
type ToastStyle ¶
type ToastStyle struct {
Container Style // the box of the toast
Icon Style // the icon, in the color of its variant
Title Style // the title, when the toast has one
Text Style // the message
Action Style // the wrapper of the action button
Close Style // the wrapper of the dismiss button
}
ToastStyle is the look of each part of a toast. A part's style merges over the built-in defaults of its variant, then over the theme's Toast, then over the theme's Toasts for that variant, then over the Styles of the toast; see docs/styling.md. Container is the box of a toast, Icon the icon of its variant (its TextColor is the icon's color), Title the title of a toast that has one, Text the message, and Action and Close the wrappers of the action button and the dismiss button.
type ToastVariant ¶
type ToastVariant uint8
ToastVariant is the kind of a toast. It sets the icon and the color, and how the toast is announced.
const ( // ToastInfo is a toast for information. ToastInfo ToastVariant = iota // ToastSuccess is a toast for a completed action. ToastSuccess // ToastWarning is a toast for a situation that needs attention. ToastWarning // ToastError is a toast for a failure. ToastError )
type ToastVariants ¶
type ToastVariants struct {
// Info, Success, Warning and Error are the styles of the toast kinds, and each merges over Toast.
Info, Success, Warning, Error ToastStyle
}
ToastVariants holds the style of each kind of toast, for the theme's Toasts. It merges over Theme.Toast, which applies to every kind.
type ToasterElement ¶
type ToasterElement struct {
// contains filtered or unexported fields
}
ToasterElement shows the window's toasts as a stack in the bottom-right corner. Place one in the window, as the last child of the root element, so that it is laid out over the content. Only one is needed; it shows every toast made with Context.Toast.
func Toaster ¶
func Toaster() *ToasterElement
Toaster creates the stack of toasts. Its region is focusable with F6, as Windows' notification regions are, and it is named with the Notifications text of the window's Strings.
func (*ToasterElement) Key ¶
func (tv *ToasterElement) Key(k string) *ToasterElement
Key identifies the toaster among its siblings (see DivElement.Key).
func (*ToasterElement) Max ¶
func (tv *ToasterElement) Max(n int) *ToasterElement
Max sets how many toasts are shown at once. The oldest is dismissed to make room for a new one. The default is 3.
func (*ToasterElement) Placement ¶
func (tv *ToasterElement) Placement(p ToastPlacement) *ToasterElement
Placement sets the corner or edge the stack is shown at: ToastBottomRight (the default), ToastTopRight or ToastBottomCenter.
type ToggleElement ¶ added in v0.3.0
type ToggleElement struct {
// contains filtered or unexported fields
}
ToggleElement is a button that stays pressed while it is on, such as a Bold button in a toolbar, bound to a bool signal. A click or Space turns it on or off. Enter does not: it goes on to the modal's default button, as for a switch. Assistive technology reads it as a toggle button with its state.
func Toggle ¶ added in v0.3.0
func Toggle(label string, on *Signal[bool]) *ToggleElement
Toggle creates a toggle that is on while on is true, with label as its text and its accessible name. Its look is that of a Ghost button by default.
func (*ToggleElement) Disabled ¶ added in v0.3.0
func (b *ToggleElement) Disabled(d bool) *ToggleElement
Disabled shows the toggle but does not let it change.
func (*ToggleElement) FocusHandle ¶ added in v0.3.0
func (b *ToggleElement) FocusHandle(h *FocusHandle) *ToggleElement
FocusHandle lets code focus the toggle (see NewFocusHandle).
func (*ToggleElement) Ghost ¶ added in v0.3.0
func (b *ToggleElement) Ghost() *ToggleElement
Ghost gives the toggle the look of a ButtonGhost button: no fill or border at rest. It is the default.
func (*ToggleElement) GridSpan ¶ added in v0.3.0
func (b *ToggleElement) GridSpan(cols, rows int) *ToggleElement
GridSpan sets how many columns and rows the toggle covers in its parent's grid.
func (*ToggleElement) Grow ¶ added in v0.3.0
func (b *ToggleElement) Grow(f float32) *ToggleElement
Grow makes the toggle take a share of the free space on its parent's main axis.
func (*ToggleElement) Height ¶ added in v0.3.0
func (b *ToggleElement) Height(l Length) *ToggleElement
Height sets the height of the toggle.
func (*ToggleElement) Icon ¶ added in v0.3.0
func (b *ToggleElement) Icon(ic *icons.Icon) *ToggleElement
Icon sets an icon drawn before the label.
func (*ToggleElement) IconOnly ¶ added in v0.3.0
func (b *ToggleElement) IconOnly() *ToggleElement
IconOnly draws the icon without the label, as a square button. The label stays the toggle's accessible name. A toggle with no icon still shows its label.
func (*ToggleElement) Key ¶ added in v0.3.0
func (b *ToggleElement) Key(k string) *ToggleElement
Key identifies the toggle among its siblings (see DivElement.Key).
func (*ToggleElement) Large ¶ added in v0.3.0
func (b *ToggleElement) Large() *ToggleElement
Large makes the toggle use the large control size, as Button.Large does. Small and Large replace each other.
func (*ToggleElement) MaxHeight ¶ added in v0.3.0
func (b *ToggleElement) MaxHeight(l Length) *ToggleElement
MaxHeight sets the largest height of the toggle.
func (*ToggleElement) MaxWidth ¶ added in v0.3.0
func (b *ToggleElement) MaxWidth(l Length) *ToggleElement
MaxWidth sets the largest width of the toggle.
func (*ToggleElement) MinHeight ¶ added in v0.3.0
func (b *ToggleElement) MinHeight(l Length) *ToggleElement
MinHeight sets the smallest height of the toggle.
func (*ToggleElement) MinWidth ¶ added in v0.3.0
func (b *ToggleElement) MinWidth(l Length) *ToggleElement
MinWidth sets the smallest width of the toggle.
func (*ToggleElement) OnChange ¶ added in v0.3.0
func (b *ToggleElement) OnChange(fn func(bool)) *ToggleElement
OnChange runs fn with the new state after the user turns the toggle on or off. The signal is set first.
func (*ToggleElement) Secondary ¶ added in v0.3.0
func (b *ToggleElement) Secondary() *ToggleElement
Secondary gives the toggle the look of a ButtonSecondary button: a surface fill and a border at rest.
func (*ToggleElement) Small ¶ added in v0.3.0
func (b *ToggleElement) Small() *ToggleElement
Small makes the toggle use the small control size, as Button.Small does.
func (*ToggleElement) Styles ¶ added in v0.3.0
func (b *ToggleElement) Styles(st ToggleStyle) *ToggleElement
Styles sets the look of the parts of the toggle, for this instance only. Set fields win over the theme's Toggle and the defaults; see ToggleStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ToggleElement) Tooltip ¶ added in v0.3.0
func (b *ToggleElement) Tooltip(s string) *ToggleElement
Tooltip shows s below the toggle after the pointer rests on it. Assistive technology reads it as the toggle's description, unless it has another.
func (*ToggleElement) Width ¶ added in v0.3.0
func (b *ToggleElement) Width(l Length) *ToggleElement
The sizing methods give the toggle's outer box a size. A toggle is as wide as its label by default, as a button is (see Sizing in docs/styling.md).
type ToggleGroupElement ¶ added in v0.3.0
type ToggleGroupElement[T comparable] struct { // contains filtered or unexported fields }
ToggleGroupElement is a row of joined toggles, one per option, of which one is selected, bound to a value. The selected option is the one whose value equals the signal's. It is a radio group for the keyboard and for assistive technology: the group is one Tab stop, at the selected option, and the arrow keys move to the next option and select it. Up and Left go back; Down and Right go on. They wrap around and skip disabled options. Space chooses the focused option; Enter goes on to the modal's default button or the form.
func ToggleGroup ¶ added in v0.3.0
func ToggleGroup[T comparable](value *Signal[T], options ...Option[T]) *ToggleGroupElement[T]
ToggleGroup creates a row of joined toggles that reads and writes value, one per option.
func (*ToggleGroupElement[T]) Disabled ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Disabled(d bool) *ToggleGroupElement[T]
Disabled shows every option but lets none of them be chosen.
func (*ToggleGroupElement[T]) FocusHandle ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) FocusHandle(h *FocusHandle) *ToggleGroupElement[T]
FocusHandle lets code focus the group's tab stop: the selected option, or the first enabled one (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*ToggleGroupElement[T]) GridSpan ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) GridSpan(cols, rows int) *ToggleGroupElement[T]
GridSpan sets how many columns and rows the toggle group covers in its parent's grid.
func (*ToggleGroupElement[T]) Grow ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Grow(f float32) *ToggleGroupElement[T]
Grow makes the toggle group take a share of the free space on its parent's main axis.
func (*ToggleGroupElement[T]) IconOnly ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) IconOnly() *ToggleGroupElement[T]
IconOnly draws the icon of each option without its label, as square items. The label stays the option's accessible name. An option with no icon still shows its label.
func (*ToggleGroupElement[T]) Key ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Key(k string) *ToggleGroupElement[T]
Key identifies the toggle group among its siblings (see DivElement.Key).
func (*ToggleGroupElement[T]) Label ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Label(s string) *ToggleGroupElement[T]
Label names the group for assistive technology, such as "Alignment". The group has no visible name of its own, so give it one.
func (*ToggleGroupElement[T]) LabelledBy ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) LabelledBy(keys ...string) *ToggleGroupElement[T]
LabelledBy names the group by the text of the elements with the given keys, such as a visible label beside it (see DivElement.LabelledBy).
func (*ToggleGroupElement[T]) Large ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Large() *ToggleGroupElement[T]
Large makes the group use the large control size, as Button.Large does. Small and Large replace each other.
func (*ToggleGroupElement[T]) MaxWidth ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) MaxWidth(l Length) *ToggleGroupElement[T]
MaxWidth sets the largest width of the toggle group.
func (*ToggleGroupElement[T]) MinWidth ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) MinWidth(l Length) *ToggleGroupElement[T]
MinWidth sets the smallest width of the toggle group.
func (*ToggleGroupElement[T]) OnChange ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) OnChange(fn func(T)) *ToggleGroupElement[T]
OnChange runs fn with the chosen value after the user selects an option, by a click, Space or the arrow keys. The signal is set first.
func (*ToggleGroupElement[T]) Small ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Small() *ToggleGroupElement[T]
Small makes the group use the small control size, as Button.Small does.
func (*ToggleGroupElement[T]) Styles ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Styles(st ToggleGroupStyle) *ToggleGroupElement[T]
Styles sets the look of the parts of the toggle group, for this instance only. Set fields win over the theme's ToggleGroup and the defaults; see ToggleGroupStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ToggleGroupElement[T]) Tooltip ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Tooltip(s string) *ToggleGroupElement[T]
Tooltip shows s below the group after the pointer rests on it. Assistive technology reads it as the group's description, unless it has another.
func (*ToggleGroupElement[T]) Validate ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Validate(rules ...Validator[T]) *ToggleGroupElement[T]
Validate sets the validators of the chosen value. The zero value is no choice, so Required[T] rejects it (see Field).
func (*ToggleGroupElement[T]) Width ¶ added in v0.3.0
func (g *ToggleGroupElement[T]) Width(l Length) *ToggleGroupElement[T]
The sizing methods give the group's outer box a size. A group is as wide as its items by default; see Sizing in docs/styling.md.
type ToggleGroupStyle ¶ added in v0.3.0
type ToggleGroupStyle struct {
Group Style // the row of items, with the outer border
GroupInvalid Style // the row when the group's value is not valid (see Field)
Item Style // each option: its size, padding, font and text color
ItemSelected Style // the selected option
ItemHover Style // an option under the pointer, if enabled and not selected
ItemPressed Style // an option while it is pressed
ItemFocusVisible Style // an option that has keyboard focus
ItemDisabled Style // an option that cannot be chosen
Label Style // the text of each option
Icon Style // the icon of each option
}
ToggleGroupStyle is the look of each part of a toggle group. A part's style merges over the built-in defaults, then over the theme's ToggleGroup, then over the Styles of the instance; see docs/styling.md. Group is the joined row of items, which draws the outer border. Each option is an Item, with its Icon and its Label; an item after the first draws the line between it and the one before it, and the first and last items round their outer corners to fit the Group. The states are parts of their own: ItemSelected for the selected item, ItemHover while the pointer is over an enabled item that is not selected, ItemPressed while an item is pressed, ItemFocusVisible while an item has keyboard focus, ItemDisabled for an item that cannot be chosen, and GroupInvalid when the group's value is not valid (see Field).
type ToggleStyle ¶ added in v0.3.0
type ToggleStyle struct {
Root Style // the button: its size, shape, fill, border, font and text color
RootChecked Style // the button while the toggle is on
RootHover Style // the button while the pointer is over it, if enabled
RootPressed Style // the button while it is pressed
RootDisabled Style // the button when it is disabled
RootFocusVisible Style // the button while it has keyboard focus
Label Style // the text of the label
Icon Style // the icon
}
ToggleStyle is the look of each part of a toggle. A part's style merges over the built-in defaults of its variant, then over the theme's Toggle, then over the Styles of the instance; see docs/styling.md. Root is the button, with the size, font and colors of a Button of the same variant. The states are parts of their own: RootChecked while the toggle is on, RootHover while the pointer is over an enabled toggle, RootPressed while it is pressed, RootDisabled when it cannot change, and RootFocusVisible while it has keyboard focus (its focus ring is added to the shadows of Root).
type ToolbarElement ¶ added in v0.3.0
type ToolbarElement struct {
// contains filtered or unexported fields
}
ToolbarElement is a row of controls, such as the formatting buttons above an editor. It follows the WAI-ARIA toolbar pattern: the toolbar is one Tab stop, and Left and Right move focus between its controls, wrapping at the ends, with Home and End to the first and the last. Tab enters it at the control that had focus last. A control that uses those keys itself keeps them, such as a text field or a slider inside the toolbar. Assistive technology sees a tool bar named by its label.
The controls keep their own looks: a toolbar does not restyle them. Buttons and toggles in a toolbar are usually Ghost and Small.
func Toolbar ¶ added in v0.3.0
func Toolbar(label string) *ToolbarElement
Toolbar creates a toolbar named label for assistive technology. A toolbar fills the width of its container by default, and lays its controls out in a row.
ui.Toolbar("Formatting").
Child(ui.Toggle("Bold", bold).Small()).
Child(ui.Toggle("Italic", italic).Small()).
Child(ui.ToolbarSeparator()).
Child(ui.Button("Undo").Ghost().Small().OnClick(undo))
func (*ToolbarElement) Child ¶ added in v0.3.0
func (b *ToolbarElement) Child(e Element) *ToolbarElement
Child appends a control, or a ToolbarSeparator.
func (*ToolbarElement) Children ¶ added in v0.3.0
func (b *ToolbarElement) Children(es ...Element) *ToolbarElement
Children appends several controls.
func (*ToolbarElement) GridSpan ¶ added in v0.3.0
func (b *ToolbarElement) GridSpan(cols, rows int) *ToolbarElement
GridSpan sets how many columns and rows the toolbar covers in its parent's grid.
func (*ToolbarElement) Grow ¶ added in v0.3.0
func (b *ToolbarElement) Grow(f float32) *ToolbarElement
Grow makes the toolbar take a share of the free space on its parent's main axis.
func (*ToolbarElement) Key ¶ added in v0.3.0
func (b *ToolbarElement) Key(k string) *ToolbarElement
Key identifies the toolbar among its siblings, so it keeps the control it remembers when the siblings around it change (see DivElement.Key).
func (*ToolbarElement) MaxWidth ¶ added in v0.3.0
func (b *ToolbarElement) MaxWidth(l Length) *ToolbarElement
MaxWidth sets the largest width of the toolbar.
func (*ToolbarElement) MinWidth ¶ added in v0.3.0
func (b *ToolbarElement) MinWidth(l Length) *ToolbarElement
MinWidth sets the smallest width of the toolbar.
func (*ToolbarElement) Styles ¶ added in v0.3.0
func (b *ToolbarElement) Styles(st ToolbarStyle) *ToolbarElement
Styles sets the look of the parts of the toolbar, for this instance only. Set fields win over the theme's Toolbar and the defaults; see ToolbarStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*ToolbarElement) Width ¶ added in v0.3.0
func (b *ToolbarElement) Width(l Length) *ToolbarElement
The sizing methods give the toolbar's outer box a size. See Sizing in docs/styling.md.
type ToolbarStyle ¶ added in v0.3.0
type ToolbarStyle struct {
Bar Style // the row of controls: its spacing, fill and border
Separator Style // the line between groups of controls
}
ToolbarStyle is the look of each part of a toolbar. A part's style merges over the built-in defaults, then over the theme's Toolbar, then over the Styles of the instance; see docs/styling.md. Bar is the row that holds the controls, and Separator the line that ToolbarSeparator draws between groups of them. The controls keep their own looks.
type TooltipStyle ¶
TooltipStyle is the look of each part of a tooltip. A part's style merges over the built-in defaults, then over the theme's Tooltip; a tooltip has no instance. Panel is the box that shows the text, and Text the text in it. See docs/styling.md.
type TopMenu ¶
type TopMenu struct {
// Label is the text of the menu in the menu bar.
Label string
// Items builds the items of the menu when it opens.
Items func() []MenuItem
}
TopMenu is one menu of a MenuBar: the label on the bar, and the function that builds the menu's items when the menu opens.
type TreeElement ¶
type TreeElement struct {
// contains filtered or unexported fields
}
TreeElement is a hierarchy of nodes that open and close, shown as a list of the rows that are visible. Only the rows near the viewport are built, so a tree of tens of thousands of nodes costs what its visible part costs. Size it with Style (Height, Grow or MaxHeight): a tree with no bounded height shows every row.
The tree is one focusable element, as a Windows tree view is, and its keys act on the selected node. Selection follows the keyboard: Up and Down select the previous and next visible node and scroll it into view. The keys follow the Windows TreeView conventions, and the WAI-ARIA tree view pattern (https://www.w3.org/WAI/ARIA/apg/patterns/treeview/):
- Down and Up move to the next and previous visible node, without wrapping.
- Home and End move to the first and last visible node.
- Right opens a closed node, and on an open node moves to its first child.
- Left closes an open node, and otherwise moves to the parent node.
- Enter and Space open and close a node that has children.
- * (asterisk) opens all the closed siblings of the selected node.
- Typing letters selects the next node whose label starts with them. A pause of a second starts a new search, as in a select.
A click selects a node, and a click on its chevron opens or closes it without selecting it. A double-click opens or closes it, as it does on Windows. Selection is single.
The open nodes are the tree's own state, unless Expanded gives the tree the keys of the open nodes in a signal, which the app can open and close.
func Tree ¶
func Tree(nodes []TreeNode, selected *Signal[string]) *TreeElement
Tree creates a tree of nodes, with the node whose key equals selected's value selected. The nodes shown first are the top level, and every node is closed until the user opens it.
With no size, the tree takes the height its parent leaves it, and shows the rows that fit in it, however many rows are open. A tree in a column that is not bounded shows every row.
func (*TreeElement) ContextMenu ¶ added in v0.4.0
func (tv *TreeElement) ContextMenu(build func(key string) []MenuItem) *TreeElement
ContextMenu opens a menu on a row, built by build with the row's key. A right click selects the row first, as File Explorer does, and Shift+F10 or the Menu key opens the menu of the selected row while the tree has focus. An empty result opens nothing.
func (*TreeElement) Expanded ¶ added in v0.4.0
func (tv *TreeElement) Expanded(keys *Signal[[]string]) *TreeElement
Expanded keeps the keys of the open nodes in keys: the tree sets it when a node is opened or closed, and a value the app sets in keys opens those nodes and closes the others. A nil keys keeps the open nodes inside the tree. The keys are kept in the order the nodes were opened; closing a node keeps the keys of the nodes below it, so opening it again shows them open.
func (*TreeElement) FocusHandle ¶
func (tv *TreeElement) FocusHandle(h *FocusHandle) *TreeElement
FocusHandle lets code focus the tree (see NewFocusHandle). A Field that wraps the control gives it its own handle, which takes precedence.
func (*TreeElement) GridSpan ¶
func (tv *TreeElement) GridSpan(cols, rows int) *TreeElement
GridSpan sets how many columns and rows the tree covers in its parent's grid.
func (*TreeElement) Grow ¶
func (tv *TreeElement) Grow(f float32) *TreeElement
Grow makes the tree take a share of the free space on its parent's main axis.
func (*TreeElement) Handle ¶ added in v0.4.0
func (tv *TreeElement) Handle(h *TreeHandle) *TreeElement
Handle connects h, so that code can open, close, reveal and select the nodes of the tree. See TreeHandle.
func (*TreeElement) Height ¶
func (tv *TreeElement) Height(l Length) *TreeElement
Height sets the height of the tree.
func (*TreeElement) Key ¶
func (tv *TreeElement) Key(k string) *TreeElement
Key gives the tree a stable identity among its siblings.
func (*TreeElement) Label ¶
func (tv *TreeElement) Label(name string) *TreeElement
Label names the tree for assistive technology, such as "Project files".
func (*TreeElement) MaxHeight ¶
func (tv *TreeElement) MaxHeight(l Length) *TreeElement
MaxHeight sets the largest height of the tree.
func (*TreeElement) MaxWidth ¶
func (tv *TreeElement) MaxWidth(l Length) *TreeElement
MaxWidth sets the largest width of the tree.
func (*TreeElement) MinHeight ¶
func (tv *TreeElement) MinHeight(l Length) *TreeElement
MinHeight sets the smallest height of the tree.
func (*TreeElement) MinWidth ¶
func (tv *TreeElement) MinWidth(l Length) *TreeElement
MinWidth sets the smallest width of the tree.
func (*TreeElement) OnChange ¶
func (tv *TreeElement) OnChange(fn func(key string)) *TreeElement
OnChange runs fn with the key of the node after the selection changes, by a click, the keys or a typed letter. The signal is set first.
func (*TreeElement) OnCollapse ¶ added in v0.4.0
func (tv *TreeElement) OnCollapse(fn func(key string)) *TreeElement
OnCollapse runs fn with the key of a node after it is closed, from the same sources as OnExpand. It does not run for the keys the app sets in Expanded.
func (*TreeElement) OnExpand ¶ added in v0.4.0
func (tv *TreeElement) OnExpand(fn func(key string)) *TreeElement
OnExpand runs fn with the key of a node after it is opened, by a click, the keys, the accessibility actions, a TreeHandle or Reveal. It does not run for the keys the app sets in Expanded.
func (*TreeElement) RenderLabel ¶
func (tv *TreeElement) RenderLabel(fn func(node TreeNode, state PartState) Element) *TreeElement
RenderLabel replaces the text of each row with what fn returns, keeping the row's icon, level, key, selection and accessible name. It is not called when RenderRow is set, which replaces the label too. The content is hidden from assistive technology.
func (*TreeElement) RenderRow ¶
func (tv *TreeElement) RenderRow(fn func(node TreeNode, state PartState) Element) *TreeElement
RenderRow replaces the icon and the label of each row with what fn returns. The row keeps its chevron, its level, key, selection, keys and accessible name, which is still the node's label. fn is called again when the row's pointer state changes, with the state in the PartState (Selected for the selected row). The content is hidden from assistive technology.
func (*TreeElement) RenderTrailing ¶ added in v0.4.0
func (tv *TreeElement) RenderTrailing(fn func(node TreeNode, state PartState) Element) *TreeElement
RenderTrailing puts what fn returns at the end of each row, after the label and the description, such as a count or a badge. The content is hidden from assistive technology, so the row's name and description still say what the node is. fn is called again when the row's pointer state changes, with the state in the PartState.
func (*TreeElement) Style ¶
func (tv *TreeElement) Style(s Style) *TreeElement
Style is merged into the scroll container: size it with Height, Grow or MaxHeight.
func (*TreeElement) Styles ¶
func (tv *TreeElement) Styles(st TreeStyle) *TreeElement
Styles sets the look of the parts of the tree, for this instance only. Set fields win over the theme's Tree and the defaults; see TreeStyle and docs/styling.md. Calling Styles again merges with the earlier values.
func (*TreeElement) Width ¶
func (tv *TreeElement) Width(l Length) *TreeElement
The sizing methods give the tree's outer box a size, over its Style. See Sizing in docs/styling.md.
type TreeHandle ¶ added in v0.4.0
type TreeHandle struct {
// contains filtered or unexported fields
}
TreeHandle opens, closes, reveals and selects the nodes of a Tree from code, by their keys. Create one with NewTreeHandle and pass it to Tree.Handle. A request takes effect when the tree is next built, on the next frame, in the order the requests were made. A key that names no visible node does nothing, except for Reveal and Select, which open the nodes above the key. Call it on the UI thread.
ExpandAll and Reveal call the children of the nodes they open, and so load every node below them: a tree that loads its children lazily loads them all.
func NewTreeHandle ¶ added in v0.4.0
func NewTreeHandle() *TreeHandle
NewTreeHandle creates a handle to pass to Tree.Handle.
func (*TreeHandle) Collapse ¶ added in v0.4.0
func (h *TreeHandle) Collapse(key string)
Collapse closes the node with the key, if it is shown and can have children. If the selected node was shown only below it, the selection moves to it, and OnChange runs.
func (*TreeHandle) CollapseAll ¶ added in v0.4.0
func (h *TreeHandle) CollapseAll()
CollapseAll closes every node. The selection moves to the top-level node that holds it, and OnChange runs.
func (*TreeHandle) Expand ¶ added in v0.4.0
func (h *TreeHandle) Expand(key string)
Expand opens the node with the key, if it is shown and can have children.
func (*TreeHandle) ExpandAll ¶ added in v0.4.0
func (h *TreeHandle) ExpandAll()
ExpandAll opens every node that can have children.
func (*TreeHandle) Reveal ¶ added in v0.4.0
func (h *TreeHandle) Reveal(key string)
Reveal opens the nodes above the node with the key, and scrolls it into view. It does nothing when the tree has no such node.
func (*TreeHandle) Select ¶ added in v0.4.0
func (h *TreeHandle) Select(key string)
Select reveals the node with the key and selects it. It does not run OnChange.
type TreeNode ¶
type TreeNode struct {
// Key identifies the node among its siblings.
Key string
// Label is the text of the node.
Label string
// Description is muted text after the label, such as a count or a path. Assistive
// technology reads it as the node's description.
Description string
// Icon is an icon shown before the label.
Icon *icons.Icon
// Children are the children of the node, shown when it is open.
Children func() []TreeNode
}
TreeNode is one node of a Tree. Key identifies the node in the whole tree: the keyboard focus, the selection and the open state are kept by it, so it must be unique and stable. Children is nil for a node that cannot have children. For any other node it returns the node's children, and it is called only while the node is open, so a large tree can load each part when it is shown.
type TreeStyle ¶
type TreeStyle struct {
Row Style // each visible row
RowHover Style // a row the pointer is over, if it is not selected
RowSelected Style // the selected row
Chevron Style // the click target of a node's chevron
Icon Style // the icon of a node
Label Style // the text of a node
Description Style // the text after a node's label (see TreeNode.Description)
TreeFocusVisible Style // the tree while it has keyboard focus
Indent float32 // the indent of each level below the top, in logical pixels
}
TreeStyle is the look of each part of a tree. A part's style merges over the built-in defaults, then over the theme's Tree, then over the Styles of the instance; see docs/styling.md. Row is each visible row, indented by its level by Indent pixels per level (a row's own left padding, when its Row style sets one, replaces the indent). Chevron is the click target that opens and closes a node, Icon the node's icon and Label its text. The states are parts of their own: RowHover while the pointer is over a row that is not selected, RowSelected for the selected row, and TreeFocusVisible for the tree while it has keyboard focus (the ring is drawn on the tree, as the rows are not focused themselves). Description is the muted text after a node's label, and a node's RenderTrailing content sits after it, at the end of the row.
type UniformListElement ¶
type UniformListElement struct {
// contains filtered or unexported fields
}
UniformListElement is a scrolling list that builds only the rows in view. Every row must have the same height: the list measures one row and positions the rest from that.
func UniformList ¶
func UniformList(count int, row func(i int) Element) *UniformListElement
UniformList creates a list of count rows. row(i) is called only for rows near the viewport, so count can be large:
ui.UniformList(len(events), func(i int) ui.Element { return eventRow(events[i]) }).
Style(ui.Style{Grow: 1})
func (*UniformListElement) GridSpan ¶
func (l *UniformListElement) GridSpan(cols, rows int) *UniformListElement
GridSpan sets how many columns and rows the uniform list covers in its parent's grid.
func (*UniformListElement) Grow ¶
func (l *UniformListElement) Grow(f float32) *UniformListElement
Grow makes the uniform list take a share of the free space on its parent's main axis.
func (*UniformListElement) Handle ¶
func (l *UniformListElement) Handle(h *ListHandle) *UniformListElement
Handle connects h so the list can be scrolled from code.
func (*UniformListElement) Height ¶
func (l *UniformListElement) Height(v Length) *UniformListElement
Height sets the height of the uniform list.
func (*UniformListElement) Key ¶
func (l *UniformListElement) Key(k string) *UniformListElement
Key gives the list a stable identity among its siblings.
func (*UniformListElement) Label ¶ added in v0.6.0
func (l *UniformListElement) Label(name string) *UniformListElement
Label names the list for assistive technology, such as "Search results", which reads it with the list's role and its number of items.
func (*UniformListElement) MaxHeight ¶
func (l *UniformListElement) MaxHeight(v Length) *UniformListElement
MaxHeight sets the largest height of the uniform list.
func (*UniformListElement) MaxWidth ¶
func (l *UniformListElement) MaxWidth(v Length) *UniformListElement
MaxWidth sets the largest width of the uniform list.
func (*UniformListElement) MinHeight ¶
func (l *UniformListElement) MinHeight(v Length) *UniformListElement
MinHeight sets the smallest height of the uniform list.
func (*UniformListElement) MinWidth ¶
func (l *UniformListElement) MinWidth(v Length) *UniformListElement
MinWidth sets the smallest width of the uniform list.
func (*UniformListElement) SelectionContainer ¶
func (l *UniformListElement) SelectionContainer() *UniformListElement
SelectionContainer makes the list the group that holds its rows as selection items, such as the notes in a sidebar. Rows that call AccessSelected are the items.
func (*UniformListElement) Style ¶
func (l *UniformListElement) Style(s Style) *UniformListElement
Style is merged into the scroll container: size it with Height, Grow or MaxHeight.
func (*UniformListElement) Width ¶
func (l *UniformListElement) Width(v Length) *UniformListElement
The sizing methods give the list's outer box a size, over its Style. See Sizing in docs/styling.md.
type Validator ¶
Validator checks the value of a form control. It returns nil when the value is valid, and an error whose text is the message the field shows. A control takes its validators with Validate (TextInput, TextArea, NumberInput, Select, RadioGroup and Checkbox); a Field takes a check of its own with Check.
The validators follow the value types of the controls:
- Required for any comparable value: the empty text (after trimming spaces), the zero number, false for a check box (so it is "must accept"), and the zero option of a Select or RadioGroup, which is the placeholder.
- MinLength, MaxLength and Pattern for text, which count runes. MinLength and Pattern pass the empty text, so Required decides whether a field must be filled in, and an optional field can use them.
- Range for numbers, from lo to hi inclusive.
- Custom for any value, from a function of your own.
func Custom ¶
Custom makes a validator from fn, which returns the error for a value it rejects, or nil.
func MinLength ¶
MinLength rejects text with fewer than n runes. The empty text passes, so that Required decides whether the field must be filled in.
func Pattern ¶
Pattern rejects text that re does not match, with the message msg. The empty text passes (see MinLength).
func Required ¶
func Required[T comparable]() Validator[T]
Required rejects the zero value of T: the empty text, zero, false and the zero option. A text value is trimmed first, so spaces alone are empty. A number does not need it, since a number input always holds a number; use Range to say which numbers are allowed.
type Window ¶
type Window interface {
// Minimize minimizes the window to the taskbar.
Minimize()
// ToggleMaximize maximizes the window, or restores it when it is maximized.
ToggleMaximize()
// Focus brings the window to the front and gives it keyboard focus.
Focus()
// Closed reports whether the window has closed, or failed to open.
Closed() bool
// Maximized reports whether the window is maximized. Read inside a
// component, it is reactive: the component re-renders when it changes.
Maximized() bool
// Close closes the window, as the app's own decision: OnClose is asked, and
// app.Window's CloseToTray does not apply.
Close()
// RequestClose asks the window to close as the user's close button does:
// OnClose is asked, and with app.Window's CloseToTray the window may hide to
// the notification area instead. A close button that the app draws itself
// calls it.
RequestClose()
// SetTitle sets the title that the title bar and the taskbar show.
SetTitle(title string)
// Focused reports whether the window has keyboard focus. Read inside a
// component, it is reactive.
Focused() bool
// Position returns the window's top-left corner on the screen, and Size
// the size of its content, in logical pixels as app.Window takes them.
Position() (x, y int)
// Size returns the size of the window's content in logical pixels; see Position.
Size() (width, height int)
// SetPosition moves the window and SetSize resizes its content, in logical
// pixels. A maximized or fullscreen window is restored first.
SetPosition(x, y int)
// SetSize resizes the window's content, in logical pixels; see SetPosition.
SetSize(width, height int)
// SetFullscreen makes the window cover its monitor without a frame, or puts
// it back where it was. Fullscreen reports which.
SetFullscreen(on bool)
// Fullscreen reports whether the window is fullscreen; see SetFullscreen.
Fullscreen() bool
// OpenFiles shows the system's file-open dialog, owned by this window. It
// returns at once; done runs on the UI thread when the dialog closes, with
// the files chosen or Canceled set. See the dialog package.
OpenFiles(o dialog.FileOptions, done func(dialog.FileResult))
// SaveFile shows the system's file-save dialog, owned by this window. done
// runs as for OpenFiles.
SaveFile(o dialog.FileOptions, done func(dialog.FileResult))
// PickFolder shows the system's folder dialog, owned by this window. done
// runs as for OpenFiles.
PickFolder(o dialog.FileOptions, done func(dialog.FileResult))
// Show shows a window that is hidden or minimized, and brings it to the front.
// Hide hides the window and its taskbar button, and the app keeps running; a
// hidden window draws nothing until Show. These are Windows operations, and
// see also app.Window.CloseToTray.
Show()
// Hide hides the window and its taskbar button; see Show.
Hide()
// Visible reports whether the window is shown: it has opened, is not hidden
// (by Hide, or by a close with app.Window.CloseToTray), and has not closed. A
// minimized window is visible.
Visible() bool
// SetTaskbarProgress sets the progress bar of the window's taskbar button.
SetTaskbarProgress(p TaskbarProgress)
// SetTaskbarBadge sets the badge drawn over the taskbar button's icon, or
// removes it when img is nil. The badge is drawn at the small icon size. Its
// description is what assistive technology reads, such as "3 unread", and it
// is required with an image: without one, the badge is not set.
SetTaskbarBadge(img image.Image, description string)
// MessageBox shows a message box, owned by this window, and runs done with
// the button chosen.
MessageBox(o dialog.MessageOptions, done func(dialog.Button))
}
Window is a window of the app: the one a component is shown in (Context.Window), or one opened with app.Open. Its methods may be called from any goroutine. An action runs on the UI thread: at once when it is called there, else in call order with the other posted work. A read from another goroutine waits for the UI thread to answer it. Methods may be added to Window in later versions, so an implementation should embed NopWindow, which has every method of Window.
type WindowArea ¶
type WindowArea uint8
WindowArea marks the part of a custom title bar an element is in. The platform gives each area its native behavior: dragging WindowAreaDrag moves the window (double-clicking maximizes it, and Aero Snap works), and releasing a button area performs its action. Windows that keep the operating system's title bar ignore areas.
const ( // WindowAreaNone is the client area: ordinary pointer events. WindowAreaNone WindowArea = iota // WindowAreaDrag moves the window when dragged. WindowAreaDrag // WindowAreaMinimize minimizes the window when released over it. WindowAreaMinimize // WindowAreaMaximize maximizes or restores the window when released over it. WindowAreaMaximize // WindowAreaClose closes the window when released over it, as the user's // close (see Window.RequestClose). WindowAreaClose )
Source Files
¶
- access.go
- access_text_model.go
- actions.go
- alert.go
- alertdialog.go
- animation.go
- avatar.go
- badge.go
- breadcrumbs.go
- calendar.go
- canvas.go
- card.go
- carousel.go
- checkbox.go
- collapsible.go
- color.go
- colorpicker.go
- combobox.go
- command.go
- commandpalette.go
- component.go
- computed.go
- copybutton.go
- datagrid.go
- datagrid_tree.go
- datefmt.go
- datepicker.go
- daterangepicker.go
- debug.go
- defaulttitlebar.go
- descriptionlist.go
- devstate.go
- dispatch.go
- display.go
- dock.go
- dock_layout.go
- drag.go
- drawer.go
- drawnstyle.go
- editor.go
- editoractions.go
- element.go
- element_input.go
- empty.go
- events.go
- field.go
- follow.go
- form.go
- format.go
- gif.go
- gradient.go
- groupbox.go
- highcontrast.go
- host.go
- hostlayer.go
- hovercard.go
- ime.go
- inputformat.go
- inspect.go
- kbd.go
- keycontext.go
- list.go
- listbox.go
- locale.go
- locale_other.go
- media.go
- menu.go
- menubar.go
- modal.go
- motion.go
- numberinput.go
- otpinput.go
- overlay.go
- pagination.go
- paint.go
- parts.go
- popover.go
- progress.go
- query.go
- radio.go
- rangeslider.go
- rating.go
- relative.go
- retain.go
- richtext.go
- runtime.go
- scrollbar.go
- select.go
- selecttext.go
- settings.go
- sidebar.go
- signal.go
- sizing.go
- skeleton.go
- slider.go
- split.go
- split_layout.go
- splitbutton.go
- statusbar.go
- stepper.go
- strings.go
- strings_it.go
- strings_zh.go
- style.go
- style_layers.go
- svg.go
- switch.go
- syntax.go
- tabs.go
- tag.go
- taskbar.go
- text.go
- textaccess.go
- theme.go
- theme_style.go
- themes.go
- themes_gen.go
- timeline.go
- timepicker.go
- timer.go
- titlebar.go
- toast.go
- toggle.go
- toolbar.go
- tree.go
- validate.go
- vlist.go
- widgets.go
- window.go
- word_other.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package uitest drives a jamb UI headlessly in tests: it renders a root component in a ui.Runtime of a given size, steps a clock of its own, finds elements by key, accessible name or role, acts on them as a user does, and reads what they show, their accessibility states and how they were drawn.
|
Package uitest drives a jamb UI headlessly in tests: it renders a root component in a ui.Runtime of a given size, steps a clock of its own, finds elements by key, accessible name or role, acts on them as a user does, and reads what they show, their accessibility states and how they were drawn. |