Documentation
¶
Index ¶
- Constants
- Variables
- func Announce(text string, p access.Politeness)
- func FormatDate(t time.Time) string
- func FormatMonthYear(t time.Time) string
- func FormatTime(t time.Time) string
- func RegisterDefaultBindings(bs ...Binding)
- 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 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) 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) Key(k string) *ButtonElement
- func (b *ButtonElement) Label(s string) *ButtonElement
- func (b *ButtonElement) Large() *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 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 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 ComponentElement
- type Composite
- type Composition
- type Computed
- type Context
- 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) 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) Window() Window
- func (c *Context) WindowSize() (w, h float32)
- func (c *Context) Zoom() float32
- type Corners
- type Crumb
- type Cursor
- type DataColumn
- type DataGridDensity
- type DataGridElement
- func (g *DataGridElement[T]) Density(d DataGridDensity) *DataGridElement[T]
- func (g *DataGridElement[T]) Empty(el Element) *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]) 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]) Loading(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]) OnActivate(fn func(row T)) *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]) 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 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 Direction
- type DivElement
- func (d *DivElement) Absolute() *DivElement
- func (d *DivElement) AccessChecked(on bool) *DivElement
- func (d *DivElement) AccessExpanded(open bool) *DivElement
- func (d *DivElement) AccessHidden() *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) 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) 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) PaddingEdges(e Edges) *DivElement
- func (d *DivElement) PaddingX(px float32) *DivElement
- func (d *DivElement) PaddingY(px float32) *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) 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 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) 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) 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 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 Highlight
- 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 KeyEvent
- type Length
- type LineCap
- type LineJoin
- 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) 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) CloseOnBackdrop() *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) OnClose(fn func()) *ModalElement
- func (m *ModalElement) Styles(st ModalStyle) *ModalElement
- func (m *ModalElement) Width(l Length) *ModalElement
- type ModalStyle
- type Motion
- 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 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 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) 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 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 Rect
- 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) Find(key string) (Rect, bool)
- func (rt *Runtime) FocusedHandle() *FocusHandle
- func (rt *Runtime) Frame(now time.Time)
- func (rt *Runtime) HighContrast() 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) SetAccessWarnings(on bool)
- func (rt *Runtime) SetBindings(layer string, bs []Binding)
- 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) 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 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 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) 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]) RenderTab(fn func(tab Tab[T], state PartState) Element) *TabsElement[T]
- func (t *TabsElement[T]) Styles(s TabsStyle) *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) 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) 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) Bold() *TextElement
- func (t *TextElement) Font(family string) *TextElement
- func (t *TextElement) FontSize(px float32) *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) 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) Style(s Style) *TextElement
- func (t *TextElement) TextColor(c Color) *TextElement
- func (t *TextElement) Truncate() *TextElement
- func (t *TextElement) Weight(w FontWeight) *TextElement
- func (t *TextElement) Width(l Length) *TextElement
- type TextFormat
- type TextInputElement
- func (ti *TextInputElement) AutoFocus() *TextInputElement
- func (ti *TextInputElement) Borderless() *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) 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) 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) 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) 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 Toast
- type ToastPlacement
- type ToastStyle
- type ToastVariant
- type ToastVariants
- type ToasterElement
- type TooltipStyle
- type TopMenu
- type 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) 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) RenderLabel(fn func(node TreeNode, state PartState) Element) *TreeElement
- func (tv *TreeElement) RenderRow(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 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) 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 )
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 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 FormatTime ¶
FormatTime returns the time of day of t, to the minute, in the user's locale's clock.
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 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 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 )
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)
})
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 only: loop forever
}
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) 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) 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) 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
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, 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 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 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 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 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 (*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) 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) 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) 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 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. Cell func(row T) Element // 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 // 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. 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.
- 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. 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), 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. 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.
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.
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.
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]) 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]) 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]) 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]) 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]) 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]) 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]) 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]) 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 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
}
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.
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 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".
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) 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) 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) 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.
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; 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) 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) 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) PaddingEdges ¶
func (d *DivElement) PaddingEdges(e Edges) *DivElement
PaddingEdges sets each side's 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) 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) 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"`
}
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 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, 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) 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) 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
// 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 sized like Windows 11's (46×32 logical pixels each) and 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.
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
}
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. 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 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 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 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 Length ¶
Length is a size: Px(240), Percent(100) or Auto.
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 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".
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) 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) CloseOnBackdrop ¶
func (m *ModalElement) CloseOnBackdrop() *ModalElement
CloseOnBackdrop makes a press on the backdrop, outside the panel, close the modal (see OnClose).
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) 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
Title Style // the title, at the top of the dialog
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.
type Motion ¶
type Motion struct {
// contains filtered or unexported fields
}
Motion is a paint-only state an element enters from or exits to: an opacity, an offset and a scale. Build one with Fade, Slide and Grow, and combine them with the methods of the same names:
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 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 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 }
Option is one choice of a RadioGroup or a Select: 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 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.
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) 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 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 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 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) 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) HighContrast ¶
HighContrast reports whether the high contrast theme is in use.
func (*Runtime) KeyDown ¶
KeyDown handles a key press. Bindings and element handlers run in this order, which docs/input.md describes:
- 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.
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) 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) 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 and nothing animates toward an end. 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 Accent color (when no Color is set) and underlines while the pointer is over it.
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.
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) 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 instead.
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
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 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: always (SplitGripShown, the default), only while the pointer is over the divider or it is dragged or focused (SplitGripOnHover), 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 ( // SplitGripShown always shows the grip. It is the default. SplitGripShown SplitGrip = iota // 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. SplitGripOnHover // 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 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
// The labels of the controls that jamb draws.
LoadingEllipsis string
// LoadingSuggestions is the text shown while suggestions load.
LoadingSuggestions 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
}
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 {
// Layout
Direction Direction
// 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
// 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
// Gap is the space between the children, in logical pixels.
Gap float32
// Wrap flows children onto more lines when a row (or column) is full.
Wrap bool
// 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
// Basis is the starting main size before growing/shrinking (Auto = content).
Basis Length
// 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
// Inset holds the offsets of an Absolute element from the edges of its parent.
Inset Edges
// 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
// ZIndex orders overlapping siblings; a higher value is drawn on top.
ZIndex 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
// ColSpan and RowSpan are the number of grid columns and rows that the item covers; zero means one.
ColSpan, RowSpan int
// Visuals
Background Color
Gradient Gradient // replaces Background when set (see LinearGradient)
// BorderColor is the color of the border.
BorderColor Color
// BorderWidth is the width of the border on every side, in logical pixels.
BorderWidth float32
// BorderEdges, when not zero, gives each side its own width (top, right,
// bottom, left) in place of BorderWidth. See BorderEdges.
BorderEdges Edges
// Radius is the radius of the rounded corners, in logical pixels.
Radius float32
// Corners sets a radius for each corner, in place of Radius.
Corners Corners
// Shadows are the drop shadows of the element, drawn in order.
Shadows []Shadow
Opacity float32 // 0 = unset (opaque)
// Cursor is the mouse cursor shown over the element.
Cursor Cursor
// 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
// Text, inherited by descendants.
TextColor Color
// FontSize is the font size in logical pixels, inherited by the descendants.
FontSize float32
// FontWeight is the weight of the text, inherited by the descendants.
FontWeight FontWeight
// FontFamily is the name of the font family, inherited by the descendants.
FontFamily string
// LineHeight is the distance between lines of text, in logical pixels.
LineHeight float32
// TextAlign is the horizontal alignment of the text.
TextAlign Alignment
// Transition eases colors, opacity, offset and scale (hover, press, theme,
// and changes made by a new render) over this duration.
Transition time.Duration
// 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
// 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.
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.
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) 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
}
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.
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 capture in a code editor: its color, and whether its text is italic or bold. Theme.Syntax is keyed by the tree-sitter capture name, such as "keyword" or "string.escape". A capture that is not in the map 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 // Panel builds the content of the tab, which is shown while the tab is selected. Panel 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.
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]) 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]) 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]) 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 {
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
}
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. 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, the selected one // filled with Accent. It is the look of a segmented control. 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) 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) 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) 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) 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) 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 Weight.
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) 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 ¶
func (t *TextElement) Weight(w FontWeight) *TextElement
Weight sets the font weight.
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) 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) 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) 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) 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) 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) 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
// Syntax is the look of each syntax capture of a code editor, keyed by the
// tree-sitter capture 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
// 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
// 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
// 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
// Popover is the look of the panel of every popover.
Popover PopoverStyle
// 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
// 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
// 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
// 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
// ColorPicker is the look of every color picker: its trigger, its panel and the
// sliders of the panel.
ColorPicker ColorPickerStyle
// 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.
func Themes ¶
func Themes() []ThemeInfo
Themes returns the predefined themes in a stable order: Dark and Light first, then the themes converted from gpui-component, in the order of their upstream files and of the variants in each file. The themes are described, not built; NewTheme returns a copy of one.
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 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) 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
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), 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 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.
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.
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) 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) 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) 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 TreeNode ¶
type TreeNode struct {
// Key identifies the node among its siblings.
Key string
// Label is the text of the node.
Label 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
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).
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) 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
- animation.go
- avatar.go
- badge.go
- breadcrumbs.go
- calendar.go
- canvas.go
- checkbox.go
- collapsible.go
- color.go
- colorpicker.go
- combobox.go
- component.go
- computed.go
- datagrid.go
- datefmt.go
- datepicker.go
- daterangepicker.go
- debug.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
- events.go
- field.go
- form.go
- format.go
- gif.go
- gradient.go
- highcontrast.go
- host.go
- ime.go
- inspect.go
- keycontext.go
- list.go
- locale.go
- locale_other.go
- media.go
- menu.go
- menubar.go
- modal.go
- motion.go
- numberinput.go
- overlay.go
- pagination.go
- paint.go
- parts.go
- popover.go
- progress.go
- radio.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
- 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
- timepicker.go
- timer.go
- toast.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. |