widgets

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Overview

Package widgets provides reusable widgets for terminal UIs.

Index

Examples

Constants

View Source
const (
	FlexColumn = runtime.Column
	FlexRow    = runtime.Row
)

FlexDirection constants.

Variables

This section is empty.

Functions

func DrawGauge

func DrawGauge(buf *runtime.Buffer, x, y, width int, ratio float64, style GaugeStyle)

DrawGauge renders a horizontal gauge bar with gradient fill. ratio: 0.0-1.0 fill percentage width: total width in characters Returns the rendered gauge string and styles for each character.

func DrawGaugeString

func DrawGaugeString(width int, ratio float64, style GaugeStyle) string

DrawGaugeString renders a gauge and returns it as a string (for inline use).

func FlexExpanded

func FlexExpanded(w runtime.Widget) runtime.FlexChild

func FlexFixed

func FlexFixed(w runtime.Widget) runtime.FlexChild

Flex child helpers - these delegate to runtime.

func FlexFixedSpace

func FlexFixedSpace(size int) runtime.FlexChild

func FlexFlexible

func FlexFlexible(w runtime.Widget, grow float64) runtime.FlexChild

func FlexSized

func FlexSized(w runtime.Widget, basis int) runtime.FlexChild

func FlexSpace

func FlexSpace() runtime.FlexChild

func HBox

func HBox(children ...runtime.FlexChild) *runtime.Flex

HBox creates a horizontal flex container.

func MustRegisterWidgetPlugin

func MustRegisterWidgetPlugin(plugin WidgetPlugin)

MustRegisterWidgetPlugin registers a plugin or panics.

func RegisterWidgetPlugin

func RegisterWidgetPlugin(plugin WidgetPlugin) error

RegisterWidgetPlugin registers a plugin globally.

func VBox

func VBox(children ...runtime.FlexChild) *runtime.Flex

VBox creates a vertical flex container.

Types

type Accordion

type Accordion struct {
	FocusableBase
	// contains filtered or unexported fields
}

Accordion groups collapsible sections.

func NewAccordion

func NewAccordion(sections ...*AccordionSection) *Accordion

NewAccordion creates an accordion.

func (*Accordion) AddSection

func (a *Accordion) AddSection(section *AccordionSection)

AddSection appends a section.

func (*Accordion) Bind

func (a *Accordion) Bind(services runtime.Services)

Bind attaches app services.

func (*Accordion) ChildWidgets

func (a *Accordion) ChildWidgets() []runtime.Widget

ChildWidgets returns section content widgets.

func (*Accordion) HandleMessage

func (a *Accordion) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles navigation and toggling.

func (*Accordion) Layout

func (a *Accordion) Layout(bounds runtime.Rect)

Layout positions headers and content.

func (*Accordion) Measure

func (a *Accordion) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Accordion) PathSegment

func (a *Accordion) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Accordion) Render

func (a *Accordion) Render(ctx runtime.RenderContext)

Render draws headers and visible content.

func (*Accordion) SetAllowMultiple

func (a *Accordion) SetAllowMultiple(allow bool)

SetAllowMultiple toggles multiple expansion.

func (*Accordion) SetLabel

func (a *Accordion) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Accordion) SetSections

func (a *Accordion) SetSections(sections ...*AccordionSection)

SetSections updates accordion sections.

func (*Accordion) SetSelected

func (a *Accordion) SetSelected(index int)

SetSelected moves selection to the provided index.

func (*Accordion) SetStyles

func (a *Accordion) SetStyles(base, header, selected, disabled backend.Style)

SetStyles updates styles.

func (*Accordion) StyleType

func (a *Accordion) StyleType() string

StyleType returns the selector type name.

func (*Accordion) ToggleSection

func (a *Accordion) ToggleSection(index int)

ToggleSection toggles a section by index.

func (*Accordion) Unbind

func (a *Accordion) Unbind()

Unbind releases app services.

type AccordionOption

type AccordionOption = Option[Accordion]

AccordionOption configures an accordion.

type AccordionSection

type AccordionSection struct {
	// contains filtered or unexported fields
}

AccordionSection is a single collapsible section.

func NewAccordionSection

func NewAccordionSection(title string, content runtime.Widget, opts ...AccordionSectionOption) *AccordionSection

NewAccordionSection creates a section.

func (*AccordionSection) Content

func (s *AccordionSection) Content() runtime.Widget

Content returns the section content widget.

func (*AccordionSection) Disabled

func (s *AccordionSection) Disabled() bool

Disabled reports whether the section is disabled.

func (*AccordionSection) Expanded

func (s *AccordionSection) Expanded() bool

Expanded reports whether the section is expanded.

func (*AccordionSection) SetContent

func (s *AccordionSection) SetContent(content runtime.Widget)

SetContent updates the section content widget.

func (*AccordionSection) SetDisabled

func (s *AccordionSection) SetDisabled(disabled bool)

SetDisabled updates the disabled state.

func (*AccordionSection) SetExpanded

func (s *AccordionSection) SetExpanded(expanded bool)

SetExpanded updates the expanded state.

func (*AccordionSection) SetTitle

func (s *AccordionSection) SetTitle(title string)

SetTitle updates the section title.

func (*AccordionSection) Title

func (s *AccordionSection) Title() string

Title returns the section title.

type AccordionSectionOption

type AccordionSectionOption = Option[AccordionSection]

AccordionSectionOption configures a section.

func WithSectionAnimation

func WithSectionAnimation(duration time.Duration, easing animation.EasingFunc) AccordionSectionOption

WithSectionAnimation sets animation configuration.

func WithSectionDisabled

func WithSectionDisabled(disabled bool) AccordionSectionOption

WithSectionDisabled sets initial disabled state.

func WithSectionExpanded

func WithSectionExpanded(expanded bool) AccordionSectionOption

WithSectionExpanded sets initial expanded state.

type Alert

type Alert struct {
	Base
	Variant AlertVariant
	Text    string
	// contains filtered or unexported fields
}

Alert renders an inline message.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	alert := widgets.NewAlert("All systems nominal", widgets.AlertSuccess)
	_ = alert
}

func NewAlert

func NewAlert(text string, variant AlertVariant) *Alert

NewAlert creates an alert.

func (*Alert) Bind

func (a *Alert) Bind(services runtime.Services)

Bind attaches app services.

func (*Alert) HandleMessage

func (a *Alert) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled.

func (*Alert) Measure

func (a *Alert) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Alert) Render

func (a *Alert) Render(ctx runtime.RenderContext)

Render draws the alert.

func (*Alert) SetStyle

func (a *Alert) SetStyle(style backend.Style)

SetStyle updates the alert style.

func (*Alert) StyleClasses

func (a *Alert) StyleClasses() []string

StyleClasses returns selector classes including the variant.

func (*Alert) StyleType

func (a *Alert) StyleType() string

StyleType returns the selector type name.

func (*Alert) Unbind

func (a *Alert) Unbind()

Unbind releases app services.

type AlertVariant

type AlertVariant string

AlertVariant describes alert styling.

const (
	AlertInfo    AlertVariant = "info"
	AlertSuccess AlertVariant = "success"
	AlertWarning AlertVariant = "warning"
	AlertError   AlertVariant = "error"
)

type Alignment

type Alignment int

Alignment specifies text alignment.

const (
	AlignLeft Alignment = iota
	AlignCenter
	AlignRight
)

type AnimatedGauge

type AnimatedGauge struct {
	CanvasWidget
	// contains filtered or unexported fields
}

AnimatedGauge renders a radial gauge with spring animation.

func NewAnimatedGauge

func NewAnimatedGauge(minValue, maxValue float64) *AnimatedGauge

NewAnimatedGauge creates a new animated gauge.

func (*AnimatedGauge) Bind

func (g *AnimatedGauge) Bind(services runtime.Services)

Bind attaches services and registers the spring.

func (*AnimatedGauge) SetValue

func (g *AnimatedGauge) SetValue(value float64)

SetValue updates the gauge target value. When reduced motion is enabled, the gauge snaps to the target immediately without spring animation.

func (*AnimatedGauge) StyleType

func (g *AnimatedGauge) StyleType() string

StyleType returns the selector type name.

func (*AnimatedGauge) Unbind

func (g *AnimatedGauge) Unbind()

Unbind releases services.

type AnimatedWidget

type AnimatedWidget struct {
	Component

	Opacity animation.Float64
	OffsetX animation.Float64
	OffsetY animation.Float64
	Scale   animation.Float64
}

AnimatedWidget is a base for widgets with animation support.

func NewAnimatedWidget

func NewAnimatedWidget() AnimatedWidget

NewAnimatedWidget creates an AnimatedWidget with defaults.

func (*AnimatedWidget) Animate

func (w *AnimatedWidget) Animate(property string, endValue animation.Animatable, cfg animation.TweenConfig)

Animate starts a property animation.

func (*AnimatedWidget) FadeIn

func (w *AnimatedWidget) FadeIn(duration time.Duration)

FadeIn animates opacity from 0 to 1.

func (*AnimatedWidget) FadeOut

func (w *AnimatedWidget) FadeOut(duration time.Duration, onComplete func())

FadeOut animates opacity to 0.

func (*AnimatedWidget) SlideIn

func (w *AnimatedWidget) SlideIn(from SlideDirection, distance int, duration time.Duration)

SlideIn animates the widget into place from a direction.

type AspectRatio

type AspectRatio struct {
	Base
	// contains filtered or unexported fields
}

AspectRatio constrains a child to a fixed width/height ratio.

func NewAspectRatio

func NewAspectRatio(child runtime.Widget, ratio float64) *AspectRatio

NewAspectRatio creates an aspect ratio container.

func (*AspectRatio) Bind

func (a *AspectRatio) Bind(services runtime.Services)

Bind attaches app services.

func (*AspectRatio) ChildWidgets

func (a *AspectRatio) ChildWidgets() []runtime.Widget

ChildWidgets returns the child widget.

func (*AspectRatio) HandleMessage

func (a *AspectRatio) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to the child.

func (*AspectRatio) Layout

func (a *AspectRatio) Layout(bounds runtime.Rect)

Layout assigns bounds and centers the child within the ratio box.

func (*AspectRatio) Measure

func (a *AspectRatio) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the constrained size preserving the ratio.

func (*AspectRatio) Render

func (a *AspectRatio) Render(ctx runtime.RenderContext)

Render draws the child.

func (*AspectRatio) SetLabel

func (a *AspectRatio) SetLabel(label string)

SetLabel updates the accessibility label.

func (*AspectRatio) SetRatio

func (a *AspectRatio) SetRatio(ratio float64)

SetRatio updates the aspect ratio (width / height).

func (*AspectRatio) Unbind

func (a *AspectRatio) Unbind()

Unbind releases app services.

type AsyncImage

type AsyncImage struct {
	Component
	// contains filtered or unexported fields
}

AsyncImage loads an image asynchronously and renders it when ready.

func NewAsyncImage

func NewAsyncImage(path string, opts ...AsyncImageOption) *AsyncImage

NewAsyncImage loads an image from disk asynchronously.

func NewAsyncImageWithLoader

func NewAsyncImageWithLoader(loader func() (image.Image, error), opts ...AsyncImageOption) *AsyncImage

NewAsyncImageWithLoader loads an image using a custom loader.

func (*AsyncImage) Bind

func (w *AsyncImage) Bind(services runtime.Services)

Bind attaches services and starts loading.

func (*AsyncImage) Error

func (w *AsyncImage) Error() error

Error returns the last load error, if any.

func (*AsyncImage) Layout

func (w *AsyncImage) Layout(bounds runtime.Rect)

Layout updates layout bounds and placeholder layout.

func (*AsyncImage) Measure

func (w *AsyncImage) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size for the image.

func (*AsyncImage) Render

func (w *AsyncImage) Render(ctx runtime.RenderContext)

Render draws the image or placeholder.

func (*AsyncImage) Unbind

func (w *AsyncImage) Unbind()

Unbind releases subscriptions.

type AsyncImageOption

type AsyncImageOption = Option[AsyncImage]

AsyncImageOption configures an async image widget.

func WithAsyncImageBlitter

func WithAsyncImageBlitter(blitter graphics.Blitter) AsyncImageOption

WithAsyncImageBlitter overrides the blitter used for rendering.

func WithAsyncImageCenter

func WithAsyncImageCenter(enabled bool) AsyncImageOption

WithAsyncImageCenter toggles centering within the widget bounds.

func WithAsyncImagePlaceholder

func WithAsyncImagePlaceholder(widget runtime.Widget) AsyncImageOption

WithAsyncImagePlaceholder sets a placeholder widget for loading/error states.

func WithAsyncImageScaleMode

func WithAsyncImageScaleMode(mode graphics.ScaleMode) AsyncImageOption

WithAsyncImageScaleMode sets the scaling interpolation mode.

func WithAsyncImageScaleToFit

func WithAsyncImageScaleToFit(enabled bool) AsyncImageOption

WithAsyncImageScaleToFit toggles scaling to fit the widget bounds.

type AutoComplete

type AutoComplete struct {
	FocusableBase
	// contains filtered or unexported fields
}

AutoComplete provides an input with suggestion list.

func NewAutoComplete

func NewAutoComplete() *AutoComplete

NewAutoComplete creates a new AutoComplete widget.

func (*AutoComplete) Bind

func (a *AutoComplete) Bind(services runtime.Services)

Bind attaches app services.

func (*AutoComplete) Blur

func (a *AutoComplete) Blur()

Blur clears focus.

func (*AutoComplete) ChildWidgets

func (a *AutoComplete) ChildWidgets() []runtime.Widget

ChildWidgets returns child widgets.

func (*AutoComplete) Focus

func (a *AutoComplete) Focus()

Focus forwards focus to the input.

func (*AutoComplete) HandleMessage

func (a *AutoComplete) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*AutoComplete) Input

func (a *AutoComplete) Input() *Input

Input returns the underlying input widget.

func (*AutoComplete) Layout

func (a *AutoComplete) Layout(bounds runtime.Rect)

Layout positions input and suggestion list.

func (*AutoComplete) Measure

func (a *AutoComplete) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*AutoComplete) Query

func (a *AutoComplete) Query() string

Query returns the current query text.

func (*AutoComplete) Render

func (a *AutoComplete) Render(ctx runtime.RenderContext)

Render draws the input and suggestions.

func (*AutoComplete) SetLabel

func (a *AutoComplete) SetLabel(label string)

SetLabel updates the accessibility label.

func (*AutoComplete) SetMaxSuggestions

func (a *AutoComplete) SetMaxSuggestions(limit int)

SetMaxSuggestions limits the number of suggestions shown.

func (*AutoComplete) SetOnSelect

func (a *AutoComplete) SetOnSelect(fn func(value string))

SetOnSelect registers a selection callback.

func (*AutoComplete) SetOptions

func (a *AutoComplete) SetOptions(options []string)

SetOptions sets the candidate options for filtering.

func (*AutoComplete) SetProvider

func (a *AutoComplete) SetProvider(fn func(query string) []string)

SetProvider sets a custom suggestion provider.

func (*AutoComplete) SetQuery

func (a *AutoComplete) SetQuery(query string)

SetQuery updates the query text and refreshes suggestions.

func (*AutoComplete) StyleType

func (a *AutoComplete) StyleType() string

StyleType returns the selector type name.

func (*AutoComplete) Unbind

func (a *AutoComplete) Unbind()

Unbind releases app services.

type Avatar

type Avatar struct {
	Base
	// contains filtered or unexported fields
}

Avatar displays user initials or a placeholder character in a styled block. The background color is deterministically derived from the name.

func NewAvatar

func NewAvatar(name string, opts ...AvatarOption) *Avatar

NewAvatar creates an avatar widget for the given name.

func (*Avatar) Bind

func (a *Avatar) Bind(services runtime.Services)

Bind attaches app services.

func (*Avatar) HandleMessage

func (a *Avatar) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled (non-interactive widget).

func (*Avatar) Initials

func (a *Avatar) Initials() string

Initials returns the displayed initials.

func (*Avatar) Layout

func (a *Avatar) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*Avatar) Measure

func (a *Avatar) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Avatar) Name

func (a *Avatar) Name() string

Name returns the avatar name.

func (*Avatar) Render

func (a *Avatar) Render(ctx runtime.RenderContext)

Render draws the avatar.

func (*Avatar) SetStyle

func (a *Avatar) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*Avatar) Size

func (a *Avatar) Size() AvatarSize

Size returns the avatar size.

func (*Avatar) StyleType

func (a *Avatar) StyleType() string

StyleType returns the selector type name.

func (*Avatar) Unbind

func (a *Avatar) Unbind()

Unbind releases app services.

type AvatarOption

type AvatarOption = Option[Avatar]

AvatarOption configures an Avatar widget.

func WithAvatarInitials

func WithAvatarInitials(initials string) AvatarOption

WithAvatarInitials overrides the computed initials.

func WithAvatarSize

func WithAvatarSize(size AvatarSize) AvatarOption

WithAvatarSize sets the display size.

type AvatarSize

type AvatarSize int

AvatarSize controls the avatar display dimensions.

const (
	// AvatarSmall renders as 3 wide x 1 tall.
	AvatarSmall AvatarSize = iota
	// AvatarMedium renders as 5 wide x 3 tall (with border).
	AvatarMedium
	// AvatarLarge renders as 7 wide x 3 tall (with border).
	AvatarLarge
)

type Axis

type Axis struct {
	Min  float64
	Max  float64
	Auto bool
}

Axis controls min/max scaling for chart values.

type Badge

type Badge struct {
	Base
	// contains filtered or unexported fields
}

Badge is a non-focusable colored label widget. It displays a short text like a status indicator or count.

func NewBadge

func NewBadge(text string) *Badge

NewBadge creates a badge with the given text.

func (*Badge) Bind

func (b *Badge) Bind(services runtime.Services)

Bind attaches app services.

func (*Badge) HandleMessage

func (b *Badge) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled (non-interactive widget).

func (*Badge) Layout

func (b *Badge) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*Badge) Measure

func (b *Badge) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Badge) Render

func (b *Badge) Render(ctx runtime.RenderContext)

Render draws the badge.

func (*Badge) SetStyle

func (b *Badge) SetStyle(style backend.Style)

SetStyle sets the badge style.

func (*Badge) SetText

func (b *Badge) SetText(text string)

SetText updates the badge text.

func (*Badge) StyleType

func (b *Badge) StyleType() string

StyleType returns the selector type name.

func (*Badge) Text

func (b *Badge) Text() string

Text returns the badge text.

func (*Badge) Unbind

func (b *Badge) Unbind()

Unbind releases app services.

type BarChart

type BarChart struct {
	Base
	Data       *state.Signal[[]BarData]
	ShowValues bool
	ShowLabels bool
	Style      backend.Style
	// contains filtered or unexported fields
}

BarChart renders horizontal bars.

Example
package main

import (
	"m31labs.dev/fluffyui/state"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	data := state.NewSignal([]widgets.BarData{
		{Label: "alpha", Value: 42},
		{Label: "beta", Value: 27},
	})
	chart := widgets.NewBarChart(data)
	_ = chart
}

func NewBarChart

func NewBarChart(data *state.Signal[[]BarData]) *BarChart

NewBarChart creates a bar chart.

func (*BarChart) Bind

func (b *BarChart) Bind(services runtime.Services)

Bind attaches app services.

func (*BarChart) HandleMessage

func (b *BarChart) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled.

func (*BarChart) Measure

func (b *BarChart) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*BarChart) Render

func (b *BarChart) Render(ctx runtime.RenderContext)

Render draws the bars.

func (*BarChart) StyleType

func (b *BarChart) StyleType() string

StyleType returns the selector type name.

func (*BarChart) Unbind

func (b *BarChart) Unbind()

Unbind releases app services.

type BarData

type BarData struct {
	Label string
	Value float64
}

BarData describes a bar entry.

type Base

type Base struct {
	accessibility.Base
	// contains filtered or unexported fields
}

Base provides common functionality for widgets. Base should be embedded in widget structs to get default implementations.

func (*Base) AddClass

func (b *Base) AddClass(class string)

AddClass adds a class if it does not already exist.

func (*Base) AddClasses

func (b *Base) AddClasses(classes ...string)

AddClasses adds multiple classes.

func (*Base) ApplyStyle

func (b *Base) ApplyStyle(s style.Style)

ApplyStyle stores the resolved style for layout.

func (*Base) Bind

func (b *Base) Bind(services runtime.Services)

Bind implements runtime.Bindable for Base. Widgets that define their own Bind will shadow this; the onMount hook is separately invoked by OnMountHook which BindTree calls after Bind.

func (*Base) Blur

func (b *Base) Blur()

Blur marks the widget as unfocused.

func (*Base) Bounds

func (b *Base) Bounds() runtime.Rect

Bounds returns the widget's assigned bounds.

func (*Base) CanFocus

func (b *Base) CanFocus() bool

CanFocus returns false by default.

func (*Base) ClearInvalidation

func (b *Base) ClearInvalidation()

ClearInvalidation clears the render-needed flag.

func (*Base) ContentBounds

func (b *Base) ContentBounds() runtime.Rect

ContentBounds returns the widget's content bounds.

func (*Base) Focus

func (b *Base) Focus()

Focus marks the widget as focused.

func (*Base) HandleMessage

func (b *Base) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns Unhandled by default.

func (*Base) ID

func (b *Base) ID() string

ID returns the optional explicit widget identifier.

func (*Base) Invalidate

func (b *Base) Invalidate()

Invalidate marks the widget as needing a render pass.

func (*Base) IsActive

func (b *Base) IsActive() bool

IsActive returns true if the widget is currently active (pressed).

func (*Base) IsFocused

func (b *Base) IsFocused() bool

IsFocused returns whether the widget is focused.

func (*Base) IsHovered

func (b *Base) IsHovered() bool

IsHovered returns true if the widget is currently hovered.

func (*Base) Key

func (b *Base) Key() string

Key returns the stable widget identity (defaults to ID).

func (*Base) Layout

func (b *Base) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*Base) LayoutStyle

func (b *Base) LayoutStyle() style.Style

LayoutStyle returns the resolved style used for layout.

func (*Base) NeedsRender

func (b *Base) NeedsRender() bool

NeedsRender reports whether the widget needs to re-render.

func (*Base) OnMount

func (b *Base) OnMount(fn func())

OnMount registers a callback that fires when the widget is bound (mounted into a screen). If the widget type defines its own Bind method, call b.Base.Bind(services) to trigger the hook.

func (*Base) OnMountHook

func (b *Base) OnMountHook()

OnMountHook implements runtime.MountHook. It invokes the onMount callback if one has been registered via OnMount. BindTree calls this automatically after Bind, so hooks fire even if a widget has its own Bind method.

func (*Base) OnUnmount

func (b *Base) OnUnmount(fn func())

OnUnmount registers a callback that fires when the widget is unbound (removed from a screen). If the widget type defines its own Unbind method, call b.Base.Unbind() to trigger the hook.

func (*Base) OnUnmountHook

func (b *Base) OnUnmountHook()

OnUnmountHook implements runtime.UnmountHook. It invokes the onUnmount callback if one has been registered via OnUnmount. UnbindTree calls this automatically before Unbind.

func (*Base) SetActive

func (b *Base) SetActive(active bool)

SetActive sets the active (pressed) state of the widget.

func (*Base) SetClasses

func (b *Base) SetClasses(classes ...string)

SetClasses replaces the widget classes.

func (*Base) SetHovered

func (b *Base) SetHovered(hovered bool)

SetHovered sets the hover state of the widget.

func (*Base) SetID

func (b *Base) SetID(id string)

SetID assigns an explicit widget identifier.

func (*Base) SetKey

func (b *Base) SetKey(key string)

SetKey assigns the stable widget identity (alias for SetID).

func (*Base) StyleClasses

func (b *Base) StyleClasses() []string

StyleClasses returns the style selector classes.

func (*Base) StyleID

func (b *Base) StyleID() string

StyleID returns the style selector ID.

func (*Base) StyleState

func (b *Base) StyleState() style.WidgetState

StyleState returns the default widget style state.

func (*Base) Unbind

func (b *Base) Unbind()

Unbind implements runtime.Unbindable for Base. Widgets that define their own Unbind will shadow this; the onUnmount hook is separately invoked by OnUnmountHook which UnbindTree calls before Unbind.

type Box

type Box struct {
	Base
	// contains filtered or unexported fields
}

Box is a simple container that fills its background.

Example
package main

import (
	"m31labs.dev/fluffyui/backend"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	box := widgets.NewBox(widgets.NewLabel("Status"))
	box.SetStyle(backend.DefaultStyle().Reverse(true))
	_ = box
}

func NewBox

func NewBox(child runtime.Widget, opts ...BoxOption) *Box

NewBox creates a new box widget.

func (*Box) Bind

func (b *Box) Bind(services runtime.Services)

Bind attaches app services.

func (*Box) ChildWidgets

func (b *Box) ChildWidgets() []runtime.Widget

ChildWidgets returns the box's child widget.

func (*Box) HandleMessage

func (b *Box) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage delegates to child.

func (*Box) Layout

func (b *Box) Layout(bounds runtime.Rect)

Layout assigns bounds to the box and child.

func (*Box) Measure

func (b *Box) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the child's size.

func (*Box) Render

func (b *Box) Render(ctx runtime.RenderContext)

Render draws the background and child.

func (*Box) SetStyle

func (b *Box) SetStyle(style backend.Style)

SetStyle sets the background style.

func (*Box) StyleType

func (b *Box) StyleType() string

StyleType returns the selector type name.

func (*Box) Unbind

func (b *Box) Unbind()

Unbind releases app services.

func (*Box) WithStyle deprecated

func (b *Box) WithStyle(style backend.Style) *Box

Deprecated: prefer WithBoxStyle during construction or SetStyle for mutation.

type BoxOption

type BoxOption = Option[Box]

BoxOption configures a Box widget.

func WithBoxStyle

func WithBoxStyle(style backend.Style) BoxOption

WithBoxStyle sets the box background style.

type Breadcrumb struct {
	FocusableBase
	Items []BreadcrumbItem
	// contains filtered or unexported fields
}

Breadcrumb renders a path of items with optional collapsing.

When the items exceed the available width, the breadcrumb automatically collapses middle items into an ellipsis ("..."), keeping the first item and the last N visible items (controlled by SetCollapseKeep, default 2). The collapse threshold can be configured with SetCollapseThreshold (minimum item count before collapsing, default 4).

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	breadcrumb := widgets.NewBreadcrumb(
		widgets.BreadcrumbItem{Label: "home"},
		widgets.BreadcrumbItem{Label: "docs"},
		widgets.BreadcrumbItem{Label: "readme.md"},
	)
	_ = breadcrumb
}

func NewBreadcrumb

func NewBreadcrumb(items ...BreadcrumbItem) *Breadcrumb

NewBreadcrumb creates a breadcrumb.

func (b *Breadcrumb) Bind(services runtime.Services)

Bind attaches app services.

func (b *Breadcrumb) CollapseKeep() int

CollapseKeep returns the number of trailing items kept visible.

func (b *Breadcrumb) CollapseThreshold() int

CollapseThreshold returns the minimum item count before collapsing.

func (b *Breadcrumb) Collapsible() bool

Collapsible reports whether automatic collapsing is enabled.

func (b *Breadcrumb) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles mouse clicks and keyboard navigation.

func (b *Breadcrumb) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (b *Breadcrumb) OnNavigate(fn func(index int))

OnNavigate sets the callback for navigation to a breadcrumb item.

Deprecated: Use SetOnNavigate instead. This method will be removed in v1.0.

func (b *Breadcrumb) Render(ctx runtime.RenderContext)

Render draws breadcrumb text.

func (b *Breadcrumb) Selected() int

Selected returns the currently selected item index.

func (b *Breadcrumb) SetCollapseKeep(n int)

SetCollapseKeep sets the number of trailing items kept visible when collapsed. Default is 2.

func (b *Breadcrumb) SetCollapseThreshold(n int)

SetCollapseThreshold sets the minimum number of items before collapsing activates. Default is 4.

func (b *Breadcrumb) SetCollapsible(enabled bool)

SetCollapsible enables or disables automatic collapsing when items overflow.

func (b *Breadcrumb) SetOnNavigate(fn func(index int))

SetOnNavigate sets the callback for navigation to a breadcrumb item.

func (b *Breadcrumb) SetSeparator(sep string)

SetSeparator sets the separator between items (default " > ").

func (b *Breadcrumb) StyleType() string

StyleType returns the selector type name for FSS stylesheet targeting.

func (b *Breadcrumb) Unbind()

Unbind releases app services.

type BreadcrumbItem struct {
	Label   string
	OnClick func()
}

BreadcrumbItem represents a path segment.

type Button

type Button struct {
	FocusableBase
	// contains filtered or unexported fields
}

Button is a clickable action widget.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	button := widgets.NewButton("Save", widgets.WithVariant(widgets.VariantPrimary))
	button.SetLabel("Save changes")
	_ = button
}

func NewButton

func NewButton(label string, opts ...ButtonOption) *Button

NewButton creates a clickable button with the given label. Use ButtonOption functions (WithOnClick, WithVariant, WithDisabled, WithLoading) to configure behavior.

func (*Button) Bind

func (b *Button) Bind(services runtime.Services)

Bind attaches app services.

func (*Button) Class deprecated

func (b *Button) Class(class string) *Button

Class adds a style class and returns the button for chaining.

Deprecated: Use WithClass during construction or AddClass for mutation. This method will be removed in v1.0.

func (*Button) Classes deprecated

func (b *Button) Classes(classes ...string) *Button

Classes adds style classes and returns the button for chaining.

Deprecated: Use WithClasses during construction or AddClasses for mutation. This method will be removed in v1.0.

func (*Button) Danger deprecated

func (b *Button) Danger() *Button

Danger applies the danger variant and returns the button for chaining.

Deprecated: Use WithVariant(VariantDanger) during construction or SetVariant for mutation. This method will be removed in v1.0.

func (*Button) Disabled deprecated

func (b *Button) Disabled(disabled *state.Signal[bool]) *Button

Disabled sets the disabled signal and returns the button for chaining.

Deprecated: Use WithDisabled during construction. This method will be removed in v1.0.

func (*Button) HandleMessage

func (b *Button) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles button activation.

func (*Button) Loading deprecated

func (b *Button) Loading(loading *state.Signal[bool]) *Button

Loading sets the loading signal and returns the button for chaining.

Deprecated: Use WithLoading during construction. This method will be removed in v1.0.

func (*Button) Measure

func (b *Button) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed by the button.

func (*Button) OnClick deprecated

func (b *Button) OnClick(fn func()) *Button

OnClick sets the click handler and returns the button for chaining.

Deprecated: Use SetOnClick for mutation or WithOnClick during construction. This method will be removed in v1.0.

func (*Button) Primary deprecated

func (b *Button) Primary() *Button

Primary applies the primary variant and returns the button for chaining.

Deprecated: Use WithVariant(VariantPrimary) during construction or SetVariant for mutation. This method will be removed in v1.0.

func (*Button) Render

func (b *Button) Render(ctx runtime.RenderContext)

Render draws the button.

func (*Button) Secondary deprecated

func (b *Button) Secondary() *Button

Secondary applies the secondary variant and returns the button for chaining.

Deprecated: Use WithVariant(VariantSecondary) during construction or SetVariant for mutation. This method will be removed in v1.0.

func (*Button) SetDisabledStyle

func (b *Button) SetDisabledStyle(style backend.Style)

SetDisabledStyle updates the disabled style.

func (*Button) SetFocusStyle

func (b *Button) SetFocusStyle(style backend.Style)

SetFocusStyle updates the focus style.

func (*Button) SetLabel

func (b *Button) SetLabel(label string)

SetLabel updates the button label.

func (*Button) SetOnClick

func (b *Button) SetOnClick(fn func())

SetOnClick sets the click handler.

func (*Button) SetStyle

func (b *Button) SetStyle(style backend.Style)

SetStyle updates the button style.

func (*Button) SetVariant

func (b *Button) SetVariant(variant Variant)

SetVariant updates the button variant.

func (*Button) StyleClasses

func (b *Button) StyleClasses() []string

StyleClasses returns selector classes including the variant.

func (*Button) StyleType

func (b *Button) StyleType() string

StyleType returns the selector type name.

func (*Button) Unbind

func (b *Button) Unbind()

Unbind releases app services.

type ButtonOption

type ButtonOption = Option[Button]

ButtonOption configures a button.

func WithClass

func WithClass(class string) ButtonOption

WithClass adds a style class.

func WithClasses

func WithClasses(classes ...string) ButtonOption

WithClasses adds multiple style classes.

func WithDisabled

func WithDisabled(disabled *state.Signal[bool]) ButtonOption

WithDisabled sets the disabled signal.

func WithLoading

func WithLoading(loading *state.Signal[bool]) ButtonOption

WithLoading sets the loading signal.

func WithOnClick

func WithOnClick(fn func()) ButtonOption

WithOnClick sets the click handler.

func WithVariant

func WithVariant(v Variant) ButtonOption

WithVariant sets the button variant.

type Calendar

type Calendar struct {
	FocusableBase
	// contains filtered or unexported fields
}

Calendar displays a month grid with selectable days.

func NewCalendar

func NewCalendar(opts ...CalendarOption) *Calendar

NewCalendar creates a new calendar widget.

func (*Calendar) Bind

func (c *Calendar) Bind(services runtime.Services)

Bind attaches app services.

func (*Calendar) DisplayedMonth

func (c *Calendar) DisplayedMonth() time.Time

DisplayedMonth returns the month being displayed.

func (*Calendar) DisplayedMonthSignal

func (c *Calendar) DisplayedMonthSignal() *state.Signal[time.Time]

DisplayedMonthSignal returns the displayed month signal.

func (*Calendar) HandleMessage

func (c *Calendar) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard navigation and mouse selection.

func (*Calendar) Measure

func (c *Calendar) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Calendar) OnRangeSelect deprecated

func (c *Calendar) OnRangeSelect(fn func(start, end time.Time))

OnRangeSelect registers a range selection callback.

Deprecated: Use SetOnRangeSelect instead. This method will be removed in v1.0.

func (*Calendar) OnSelect deprecated

func (c *Calendar) OnSelect(fn func(time.Time))

OnSelect registers a single-date selection callback.

Deprecated: Use SetOnSelect instead. This method will be removed in v1.0.

func (*Calendar) RangeEnd

func (c *Calendar) RangeEnd() *time.Time

RangeEnd returns the current range end date.

func (*Calendar) RangeEndSignal

func (c *Calendar) RangeEndSignal() *state.Signal[*time.Time]

RangeEndSignal returns the range end signal.

func (*Calendar) RangeStart

func (c *Calendar) RangeStart() *time.Time

RangeStart returns the current range start date.

func (*Calendar) RangeStartSignal

func (c *Calendar) RangeStartSignal() *state.Signal[*time.Time]

RangeStartSignal returns the range start signal.

func (*Calendar) Render

func (c *Calendar) Render(ctx runtime.RenderContext)

Render draws the calendar grid.

func (*Calendar) SelectedDate

func (c *Calendar) SelectedDate() time.Time

SelectedDate returns the selected date.

func (*Calendar) SelectedDateSignal

func (c *Calendar) SelectedDateSignal() *state.Signal[time.Time]

SelectedDateSignal returns the selected date signal.

func (*Calendar) SetDayRenderer

func (c *Calendar) SetDayRenderer(fn DayRenderFunc)

SetDayRenderer updates the day renderer.

func (*Calendar) SetDisplayedMonth

func (c *Calendar) SetDisplayedMonth(date time.Time)

SetDisplayedMonth changes the visible month.

func (*Calendar) SetHighlightDates

func (c *Calendar) SetHighlightDates(dates []time.Time)

SetHighlightDates sets highlighted dates.

func (*Calendar) SetMaxDate

func (c *Calendar) SetMaxDate(date *time.Time)

SetMaxDate sets the maximum selectable date (inclusive).

func (*Calendar) SetMinDate

func (c *Calendar) SetMinDate(date *time.Time)

SetMinDate sets the minimum selectable date (inclusive).

func (*Calendar) SetOnRangeSelect

func (c *Calendar) SetOnRangeSelect(fn func(start, end time.Time))

SetOnRangeSelect registers a range selection callback.

func (*Calendar) SetOnSelect

func (c *Calendar) SetOnSelect(fn func(time.Time))

SetOnSelect registers a single-date selection callback.

func (*Calendar) SetRange

func (c *Calendar) SetRange(start, end *time.Time)

SetRange updates the selected date range.

func (*Calendar) SetSelectedDate

func (c *Calendar) SetSelectedDate(date time.Time)

SetSelectedDate updates the selected date.

func (*Calendar) SetSelectionMode

func (c *Calendar) SetSelectionMode(mode CalendarSelectionMode)

SetSelectionMode updates selection mode.

func (*Calendar) SetShowWeekNumbers

func (c *Calendar) SetShowWeekNumbers(show bool)

SetShowWeekNumbers toggles week number display.

func (*Calendar) SetStyles

func (c *Calendar) SetStyles(base, header, weekday, selected, today, disabled, highlight, outside, rangeSty backend.Style)

SetStyles configures calendar styles.

func (*Calendar) SetWeekStart

func (c *Calendar) SetWeekStart(start time.Weekday)

SetWeekStart updates the week start day.

func (*Calendar) StyleType

func (c *Calendar) StyleType() string

StyleType returns the selector type name.

func (*Calendar) Unbind

func (c *Calendar) Unbind()

Unbind releases app services.

type CalendarDayState

type CalendarDayState struct {
	InMonth     bool
	Selected    bool
	Disabled    bool
	Today       bool
	Highlighted bool
	InRange     bool
	RangeStart  bool
	RangeEnd    bool
}

CalendarDayState describes rendering flags for a day.

type CalendarOption

type CalendarOption = Option[Calendar]

CalendarOption configures a calendar.

func WithDayRenderer

func WithDayRenderer(fn DayRenderFunc) CalendarOption

WithDayRenderer sets a custom day renderer.

func WithDisplayedMonthSignal

func WithDisplayedMonthSignal(sig *state.Signal[time.Time]) CalendarOption

WithDisplayedMonthSignal sets the displayed month signal.

func WithHighlightDatesSignal

func WithHighlightDatesSignal(sig *state.Signal[[]time.Time]) CalendarOption

WithHighlightDatesSignal sets the highlight dates signal.

func WithMaxDateSignal

func WithMaxDateSignal(sig *state.Signal[*time.Time]) CalendarOption

WithMaxDateSignal sets the max date signal.

func WithMinDateSignal

func WithMinDateSignal(sig *state.Signal[*time.Time]) CalendarOption

WithMinDateSignal sets the min date signal.

func WithNowFunc

func WithNowFunc(fn func() time.Time) CalendarOption

WithNowFunc overrides the clock (useful for tests).

func WithSelectedDateSignal

func WithSelectedDateSignal(sig *state.Signal[time.Time]) CalendarOption

WithSelectedDateSignal sets the selected date signal.

func WithSelectionMode

func WithSelectionMode(mode CalendarSelectionMode) CalendarOption

WithSelectionMode sets the selection mode.

func WithShowWeekNumbers

func WithShowWeekNumbers(show bool) CalendarOption

WithShowWeekNumbers toggles week number display.

func WithWeekStart

func WithWeekStart(start time.Weekday) CalendarOption

WithWeekStart sets the week start day.

type CalendarSelectionMode

type CalendarSelectionMode int

CalendarSelectionMode controls selection behavior.

const (
	CalendarSelectionSingle CalendarSelectionMode = iota
	CalendarSelectionRange
)

type CanvasOption

type CanvasOption = Option[CanvasWidget]

CanvasOption configures a CanvasWidget.

func WithCanvasBlitter

func WithCanvasBlitter(blitter graphics.Blitter) CanvasOption

WithCanvasBlitter sets the blitter used to render pixels to cells.

type CanvasWidget

type CanvasWidget struct {
	Component
	// contains filtered or unexported fields
}

CanvasWidget is a widget that draws using a Canvas.

func NewCanvasWidget

func NewCanvasWidget(draw func(canvas *graphics.Canvas), opts ...CanvasOption) *CanvasWidget

NewCanvasWidget creates a CanvasWidget with the draw callback.

func (*CanvasWidget) Layout

func (w *CanvasWidget) Layout(bounds runtime.Rect)

Layout updates layout bounds and canvas size.

func (*CanvasWidget) Measure

func (w *CanvasWidget) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size for the canvas widget.

func (*CanvasWidget) Render

func (w *CanvasWidget) Render(ctx runtime.RenderContext)

Render draws the canvas.

func (*CanvasWidget) SetBlitter

func (w *CanvasWidget) SetBlitter(blitter graphics.Blitter)

SetBlitter sets the blitter used to render pixels to cells.

func (*CanvasWidget) WithBlitter deprecated

func (w *CanvasWidget) WithBlitter(blitter graphics.Blitter) *CanvasWidget

Deprecated: prefer WithCanvasBlitter during construction or SetBlitter for mutation.

type Card

type Card struct {
	Base
	// contains filtered or unexported fields
}

Card is a non-focusable bordered container with optional header, body, and footer sections.

func NewCard

func NewCard(title string, body runtime.Widget) *Card

NewCard creates a card with a title and body widget.

func (*Card) Bind

func (c *Card) Bind(services runtime.Services)

Bind attaches app services.

func (*Card) ChildWidgets

func (c *Card) ChildWidgets() []runtime.Widget

ChildWidgets returns child widgets for tree traversal.

func (*Card) HandleMessage

func (c *Card) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to children.

func (*Card) Layout

func (c *Card) Layout(bounds runtime.Rect)

Layout positions child widgets within the card.

func (*Card) Measure

func (c *Card) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Card) Render

func (c *Card) Render(ctx runtime.RenderContext)

Render draws the card.

func (*Card) SetBody

func (c *Card) SetBody(body runtime.Widget)

SetBody sets the body widget.

func (*Card) SetBorder

func (c *Card) SetBorder(border bool)

SetBorder enables or disables the border.

func (*Card) SetFooter

func (c *Card) SetFooter(footer runtime.Widget)

SetFooter sets the footer widget.

func (*Card) SetHeader

func (c *Card) SetHeader(header runtime.Widget)

SetHeader sets the header widget.

func (*Card) SetStyle

func (c *Card) SetStyle(style backend.Style)

SetStyle sets the card style.

func (*Card) SetTitle

func (c *Card) SetTitle(title string)

SetTitle updates the card title.

func (*Card) StyleType

func (c *Card) StyleType() string

StyleType returns the selector type name.

func (*Card) Title

func (c *Card) Title() string

Title returns the card title.

func (*Card) Unbind

func (c *Card) Unbind()

Unbind releases app services.

type ChartSeries

type ChartSeries struct {
	Data   []float64
	Color  backend.Color
	Smooth bool
	Fill   bool
}

ChartSeries represents a line chart series.

type Checkbox

type Checkbox struct {
	FocusableBase
	// contains filtered or unexported fields
}

Checkbox is a toggle input widget.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	checked := true
	checkbox := widgets.NewCheckbox("Accept terms")
	checkbox.SetChecked(&checked)
	_ = checkbox
}

func NewCheckbox

func NewCheckbox(label string) *Checkbox

NewCheckbox creates a checkbox with a label.

func (*Checkbox) Bind

func (c *Checkbox) Bind(services runtime.Services)

Bind attaches app services.

func (*Checkbox) Checked

func (c *Checkbox) Checked() *bool

Checked returns the current value.

func (*Checkbox) HandleMessage

func (c *Checkbox) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage toggles the checkbox.

func (*Checkbox) Measure

func (c *Checkbox) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed.

func (*Checkbox) Render

func (c *Checkbox) Render(ctx runtime.RenderContext)

Render draws the checkbox.

func (*Checkbox) SetChecked

func (c *Checkbox) SetChecked(value *bool)

SetChecked updates the checkbox value (nil = indeterminate).

func (*Checkbox) SetFocusStyle

func (c *Checkbox) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*Checkbox) SetLabel

func (c *Checkbox) SetLabel(label string)

SetLabel updates the checkbox label.

func (*Checkbox) SetOnChange

func (c *Checkbox) SetOnChange(fn func(value *bool))

SetOnChange sets the change handler.

func (*Checkbox) SetStyle

func (c *Checkbox) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*Checkbox) StyleType

func (c *Checkbox) StyleType() string

StyleType returns the selector type name.

func (*Checkbox) Unbind

func (c *Checkbox) Unbind()

Unbind releases app services.

type Chip

type Chip struct {
	FocusableBase
	// contains filtered or unexported fields
}

Chip is a compact label widget, optionally dismissible. When dismissible, it becomes focusable and handles Enter/Space to dismiss.

func NewChip

func NewChip(label string, opts ...ChipOption) *Chip

NewChip creates a chip widget with the given label.

func (*Chip) Bind

func (c *Chip) Bind(services runtime.Services)

Bind attaches app services.

func (*Chip) CanFocus

func (c *Chip) CanFocus() bool

CanFocus returns true only if the chip is dismissible.

func (*Chip) Dismissible

func (c *Chip) Dismissible() bool

Dismissible returns true if the chip can be dismissed.

func (*Chip) HandleMessage

func (c *Chip) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input for dismissible chips.

func (*Chip) Label

func (c *Chip) Label() string

Label returns the chip label text.

func (*Chip) Measure

func (c *Chip) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Chip) Render

func (c *Chip) Render(ctx runtime.RenderContext)

Render draws the chip.

func (*Chip) RenderHTML

func (c *Chip) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML renders the chip as a static HTML button.

func (*Chip) SetLabel

func (c *Chip) SetLabel(label string)

SetLabel updates the chip label.

func (*Chip) SetStyle

func (c *Chip) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*Chip) StyleType

func (c *Chip) StyleType() string

StyleType returns the selector type name for FSS.

func (*Chip) Unbind

func (c *Chip) Unbind()

Unbind releases app services.

func (*Chip) Variant

func (c *Chip) Variant() ChipVariant

Variant returns the chip variant.

type ChipOption

type ChipOption = Option[Chip]

ChipOption configures a Chip widget.

func WithChipDismiss

func WithChipDismiss(fn func()) ChipOption

WithChipDismiss makes the chip dismissible with the given callback.

func WithChipVariant

func WithChipVariant(v ChipVariant) ChipOption

WithChipVariant sets the chip variant for visual styling.

type ChipVariant

type ChipVariant int

ChipVariant describes the visual style of a chip.

const (
	// ChipDefault is the default chip variant.
	ChipDefault ChipVariant = iota
	// ChipPrimary is the primary chip variant.
	ChipPrimary
	// ChipSuccess is the success chip variant.
	ChipSuccess
	// ChipWarning is the warning chip variant.
	ChipWarning
	// ChipError is the error chip variant.
	ChipError
)

type ColorPicker

type ColorPicker struct {
	FocusableBase
	// contains filtered or unexported fields
}

ColorPicker is a focusable color selection widget. It displays a grid of preset color swatches and allows keyboard navigation.

func NewColorPicker

func NewColorPicker(opts ...ColorPickerOption) *ColorPicker

NewColorPicker creates a color picker with the default palette.

func (*ColorPicker) Bind

func (cp *ColorPicker) Bind(services runtime.Services)

Bind attaches app services.

func (*ColorPicker) HandleMessage

func (cp *ColorPicker) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*ColorPicker) Measure

func (cp *ColorPicker) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*ColorPicker) Render

func (cp *ColorPicker) Render(ctx runtime.RenderContext)

Render draws the color picker.

func (*ColorPicker) Selected

func (cp *ColorPicker) Selected() backend.Color

Selected returns the currently selected color.

func (*ColorPicker) SelectedIndex

func (cp *ColorPicker) SelectedIndex() int

SelectedIndex returns the index of the selected color.

func (*ColorPicker) SetSelected

func (cp *ColorPicker) SetSelected(index int)

SetSelected sets the selected index.

func (*ColorPicker) SetStyle

func (cp *ColorPicker) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*ColorPicker) StyleType

func (cp *ColorPicker) StyleType() string

StyleType returns the selector type name.

func (*ColorPicker) Unbind

func (cp *ColorPicker) Unbind()

Unbind releases app services.

type ColorPickerOption

type ColorPickerOption = Option[ColorPicker]

ColorPickerOption configures a ColorPicker widget.

func WithColorPickerOnChange

func WithColorPickerOnChange(fn func(backend.Color)) ColorPickerOption

WithColorPickerOnChange sets the change handler.

func WithColorPickerPalette

func WithColorPickerPalette(colors []backend.Color, names []string) ColorPickerOption

WithColorPickerPalette sets custom palette colors.

type ColorScale

type ColorScale func(value float64) backend.Color

ColorScale maps a normalized value in [0,1] to a color.

func BlueRedScale

func BlueRedScale() ColorScale

BlueRedScale returns a color scale from blue (low) to red (high).

func GrayscaleScale

func GrayscaleScale() ColorScale

GrayscaleScale returns a color scale from black (low) to white (high).

func GreenRedScale

func GreenRedScale() ColorScale

GreenRedScale returns a color scale from green (low) to red (high).

type ColumnPin

type ColumnPin int

ColumnPin determines whether a column is pinned to the left or right edge.

const (
	// PinNone means the column scrolls normally with the middle area.
	PinNone ColumnPin = iota
	// PinLeft pins the column to the left edge.
	PinLeft
	// PinRight pins the column to the right edge.
	PinRight
)

type Combobox

type Combobox struct {
	FocusableBase
	// contains filtered or unexported fields
}

Combobox is a dropdown select that also accepts free-text input.

func NewCombobox

func NewCombobox(options ...string) *Combobox

NewCombobox creates a combobox with the given options.

func (*Combobox) Bind

func (c *Combobox) Bind(services runtime.Services)

Bind attaches app services.

func (*Combobox) HandleMessage

func (c *Combobox) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard input.

func (*Combobox) Measure

func (c *Combobox) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Combobox) Options

func (c *Combobox) Options() []string

Options returns the full option list.

func (*Combobox) Render

func (c *Combobox) Render(ctx runtime.RenderContext)

Render draws the combobox.

func (*Combobox) SetFocusStyle

func (c *Combobox) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*Combobox) SetOnChange

func (c *Combobox) SetOnChange(fn func(string))

SetOnChange sets the change handler.

func (*Combobox) SetOptions

func (c *Combobox) SetOptions(opts []string)

SetOptions replaces the option list and re-filters.

func (*Combobox) SetStyle

func (c *Combobox) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*Combobox) SetText

func (c *Combobox) SetText(s string)

SetText updates the text and filters options.

func (*Combobox) StyleType

func (c *Combobox) StyleType() string

StyleType returns the selector type name.

func (*Combobox) Text

func (c *Combobox) Text() string

Text returns the current text.

func (*Combobox) Unbind

func (c *Combobox) Unbind()

Unbind releases app services.

type CommandPalette

type CommandPalette struct {
	FocusableBase
	// contains filtered or unexported fields
}

CommandPalette is a focusable fuzzy-search command launcher (VS Code-style Ctrl+K/Ctrl+P). It displays a filterable list of commands with keyboard navigation.

func NewCommandPalette

func NewCommandPalette(commands ...PaletteCommand) *CommandPalette

NewCommandPalette creates a command palette with the given commands.

func (*CommandPalette) AddCommand

func (cp *CommandPalette) AddCommand(cmd PaletteCommand)

AddCommand appends a single command and refilters.

func (*CommandPalette) Bind

func (cp *CommandPalette) Bind(services runtime.Services)

Bind attaches app services.

func (*CommandPalette) FilteredCount

func (cp *CommandPalette) FilteredCount() int

FilteredCount returns the number of matching commands.

func (*CommandPalette) HandleMessage

func (cp *CommandPalette) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*CommandPalette) Hide

func (cp *CommandPalette) Hide()

Hide closes the palette.

func (*CommandPalette) Measure

func (cp *CommandPalette) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*CommandPalette) Open

func (cp *CommandPalette) Open() bool

Open returns whether the palette is visible.

func (*CommandPalette) Query

func (cp *CommandPalette) Query() string

Query returns the current search query.

func (*CommandPalette) Render

func (cp *CommandPalette) Render(ctx runtime.RenderContext)

Render draws the command palette.

func (*CommandPalette) SelectedIndex

func (cp *CommandPalette) SelectedIndex() int

SelectedIndex returns the index within the filtered results.

func (*CommandPalette) SetCommands

func (cp *CommandPalette) SetCommands(cmds []PaletteCommand)

SetCommands replaces the command list and refilters.

func (*CommandPalette) SetMaxResults

func (cp *CommandPalette) SetMaxResults(n int)

SetMaxResults sets the maximum number of results to display.

func (*CommandPalette) SetOnExecute

func (cp *CommandPalette) SetOnExecute(fn func(cmd PaletteCommand))

SetOnExecute sets a callback invoked after a command is executed.

func (*CommandPalette) SetOpen

func (cp *CommandPalette) SetOpen(open bool)

SetOpen sets the visibility of the palette.

func (*CommandPalette) SetStyle

func (cp *CommandPalette) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*CommandPalette) Show

func (cp *CommandPalette) Show()

Show makes the palette visible, resetting the query and selection.

func (*CommandPalette) StyleType

func (cp *CommandPalette) StyleType() string

StyleType returns the selector type name.

func (*CommandPalette) Toggle

func (cp *CommandPalette) Toggle()

Toggle switches the palette between visible and hidden.

func (*CommandPalette) Unbind

func (cp *CommandPalette) Unbind()

Unbind releases app services.

type CommandPaletteOption

type CommandPaletteOption = Option[CommandPalette]

CommandPaletteOption configures a CommandPalette widget.

func WithCommandPaletteOpen

func WithCommandPaletteOpen(open bool) CommandPaletteOption

WithCommandPaletteOpen sets the initial open/visible state.

type Component

type Component struct {
	Base
	Services runtime.Services
	Subs     state.Subscriptions
}

Component is a base widget with bound services and subscriptions.

func (*Component) Bind

func (c *Component) Bind(services runtime.Services)

Bind attaches app services to the component.

func (*Component) Invalidate

func (c *Component) Invalidate()

Invalidate requests a render pass.

func (*Component) Observe

func (c *Component) Observe(sub state.Subscribable, fn func())

Observe registers a subscription using the default scheduler.

func (*Component) Unbind

func (c *Component) Unbind()

Unbind releases app services and subscriptions.

type DataGrid

type DataGrid struct {
	FocusableBase
	// contains filtered or unexported fields
}

DataGrid is an advanced data grid widget with column resizing, cell renderers, column pinning, sorting, and virtual scrolling. It provides per-cell selection, inline editing, and ARIA grid semantics.

func NewDataGrid

func NewDataGrid(columns []DataGridColumn) *DataGrid

NewDataGrid creates a DataGrid with the given column definitions. MinWidth defaults to 3 for all columns. Width is clamped to [MinWidth, MaxWidth].

func (*DataGrid) AddRow

func (dg *DataGrid) AddRow(row []string)

AddRow appends a single row.

func (*DataGrid) Bind

func (dg *DataGrid) Bind(services runtime.Services)

Bind attaches app services.

func (*DataGrid) CancelEdit

func (dg *DataGrid) CancelEdit()

CancelEdit discards edits and exits edit mode.

func (*DataGrid) Cell

func (dg *DataGrid) Cell(row, col int) string

Cell returns the cell value at the given display row and column.

func (*DataGrid) ColumnCount

func (dg *DataGrid) ColumnCount() int

ColumnCount returns the number of columns.

func (*DataGrid) ColumnWidth

func (dg *DataGrid) ColumnWidth(col int) int

ColumnWidth returns the current width of a column.

func (*DataGrid) Columns

func (dg *DataGrid) Columns() []DataGridColumn

Columns returns a copy of the current column definitions.

func (*DataGrid) CommitEdit

func (dg *DataGrid) CommitEdit()

CommitEdit saves edits and exits edit mode.

func (*DataGrid) Editing

func (dg *DataGrid) Editing() bool

Editing reports whether the grid is in cell edit mode.

func (*DataGrid) HandleMessage

func (dg *DataGrid) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes key events for cell navigation, inline editing, and column resizing (Ctrl+Left/Right shrinks/grows the selected column).

func (*DataGrid) Measure

func (dg *DataGrid) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*DataGrid) PageBy

func (dg *DataGrid) PageBy(pages int)

PageBy scrolls by a number of pages.

func (*DataGrid) RemoveRow

func (dg *DataGrid) RemoveRow(index int)

RemoveRow removes the row at the given display index.

func (*DataGrid) Render

func (dg *DataGrid) Render(ctx runtime.RenderContext)

Render draws the data grid into the render context.

func (*DataGrid) RowCount

func (dg *DataGrid) RowCount() int

RowCount returns the number of visible rows.

func (*DataGrid) ScrollBy

func (dg *DataGrid) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta.

func (*DataGrid) ScrollTo

func (dg *DataGrid) ScrollTo(x, y int)

ScrollTo scrolls to an absolute position.

func (*DataGrid) ScrollToEnd

func (dg *DataGrid) ScrollToEnd()

ScrollToEnd scrolls to the last row.

func (*DataGrid) ScrollToStart

func (dg *DataGrid) ScrollToStart()

ScrollToStart scrolls to the first row.

func (*DataGrid) SelectedCell

func (dg *DataGrid) SelectedCell() (row, col int)

SelectedCell returns the currently selected row and column.

func (*DataGrid) SetCell

func (dg *DataGrid) SetCell(row, col int, value string)

SetCell updates a single cell value at the given display row and column.

func (*DataGrid) SetColumnPin

func (dg *DataGrid) SetColumnPin(col int, pin ColumnPin)

SetColumnPin sets the pin state for a column.

func (*DataGrid) SetColumnWidth

func (dg *DataGrid) SetColumnWidth(col, width int)

SetColumnWidth sets the width of a column, clamped to [MinWidth, MaxWidth].

func (*DataGrid) SetHeaderStyle

func (dg *DataGrid) SetHeaderStyle(s backend.Style)

SetHeaderStyle updates the header row style.

func (*DataGrid) SetLabel

func (dg *DataGrid) SetLabel(label string)

SetLabel updates the accessibility label.

func (*DataGrid) SetOnCellEdit

func (dg *DataGrid) SetOnCellEdit(fn func(row, col int, oldValue, newValue string))

SetOnCellEdit sets the callback invoked when a cell edit is committed.

func (*DataGrid) SetOverscan

func (dg *DataGrid) SetOverscan(count int)

SetOverscan sets the number of extra rows rendered beyond the viewport.

func (*DataGrid) SetRows

func (dg *DataGrid) SetRows(rows [][]string)

SetRows replaces all row data.

func (*DataGrid) SetSelectedCell

func (dg *DataGrid) SetSelectedCell(row, col int)

SetSelectedCell updates the selected cell position.

func (*DataGrid) SetSelectedStyle

func (dg *DataGrid) SetSelectedStyle(s backend.Style)

SetSelectedStyle updates the selected cell/row style.

func (*DataGrid) SetStyle

func (dg *DataGrid) SetStyle(s backend.Style)

SetStyle updates the base style.

func (*DataGrid) SetVirtualScroll

func (dg *DataGrid) SetVirtualScroll(enabled bool)

SetVirtualScroll enables or disables virtual scrolling for large datasets.

func (*DataGrid) Sort

func (dg *DataGrid) Sort(col int, dir SortDirection)

Sort sets the sort column and direction, then rebuilds the display order.

func (*DataGrid) SortState

func (dg *DataGrid) SortState() (col int, dir SortDirection)

SortState returns the current sort column and direction.

func (*DataGrid) StartEdit

func (dg *DataGrid) StartEdit()

StartEdit enters edit mode on the selected cell.

func (*DataGrid) StyleType

func (dg *DataGrid) StyleType() string

StyleType returns the selector type name.

func (*DataGrid) Unbind

func (dg *DataGrid) Unbind()

Unbind releases app services.

func (*DataGrid) VirtualScroll

func (dg *DataGrid) VirtualScroll() bool

VirtualScroll reports whether virtual scrolling is enabled.

func (*DataGrid) VisibleRange

func (dg *DataGrid) VisibleRange() (start, end int)

VisibleRange returns the [start, end) row range currently rendered.

type DataGridColumn

type DataGridColumn struct {
	Header    string                             // column header text
	Width     int                                // current width in cells
	MinWidth  int                                // minimum resize width (default 3)
	MaxWidth  int                                // maximum resize width (0 = unlimited)
	Resizable bool                               // can be resized via Ctrl+Left/Right
	Pinned    ColumnPin                          // pinned to left/right edge
	Sortable  bool                               // can be sorted
	Renderer  func(row int, value string) string // custom cell renderer (optional)
}

DataGridColumn defines a column in a DataGrid. Unlike TableColumn, it supports resizing constraints, pinning, sortability, and per-cell renderers.

type DatePicker

type DatePicker struct {
	Base
	// contains filtered or unexported fields
}

DatePicker combines a text input and calendar.

func NewDatePicker

func NewDatePicker() *DatePicker

NewDatePicker creates a date picker.

func (*DatePicker) Bind

func (d *DatePicker) Bind(services runtime.Services)

Bind attaches app services.

func (*DatePicker) Calendar

func (d *DatePicker) Calendar() *Calendar

Calendar returns the underlying calendar.

func (*DatePicker) ChildWidgets

func (d *DatePicker) ChildWidgets() []runtime.Widget

ChildWidgets returns child widgets.

func (*DatePicker) HandleMessage

func (d *DatePicker) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to children.

func (*DatePicker) Input

func (d *DatePicker) Input() *Input

Input returns the underlying input widget.

func (*DatePicker) Layout

func (d *DatePicker) Layout(bounds runtime.Rect)

Layout positions the input and calendar.

func (*DatePicker) Measure

func (d *DatePicker) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*DatePicker) PathSegment

func (d *DatePicker) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*DatePicker) Render

func (d *DatePicker) Render(ctx runtime.RenderContext)

Render draws the date picker.

func (*DatePicker) SelectedDate

func (d *DatePicker) SelectedDate() time.Time

SelectedDate returns the selected date.

func (*DatePicker) SetFormat

func (d *DatePicker) SetFormat(format string)

SetFormat updates the date format.

func (*DatePicker) SetHighlightDates

func (d *DatePicker) SetHighlightDates(dates []time.Time)

SetHighlightDates updates highlighted dates.

func (*DatePicker) SetLabel

func (d *DatePicker) SetLabel(label string)

SetLabel updates the accessibility label.

func (*DatePicker) SetMaxDate

func (d *DatePicker) SetMaxDate(date *time.Time)

SetMaxDate sets the maximum selectable date.

func (*DatePicker) SetMinDate

func (d *DatePicker) SetMinDate(date *time.Time)

SetMinDate sets the minimum selectable date.

func (*DatePicker) SetSelectedDate

func (d *DatePicker) SetSelectedDate(date time.Time)

SetSelectedDate updates the selected date.

func (*DatePicker) SetSelectionMode

func (d *DatePicker) SetSelectionMode(mode CalendarSelectionMode)

SetSelectionMode updates selection mode.

func (*DatePicker) SetShowWeekNumbers

func (d *DatePicker) SetShowWeekNumbers(show bool)

SetShowWeekNumbers toggles week numbers.

func (*DatePicker) SetWeekStart

func (d *DatePicker) SetWeekStart(start time.Weekday)

SetWeekStart updates the calendar week start.

func (*DatePicker) StyleType

func (d *DatePicker) StyleType() string

StyleType returns the selector type name.

func (*DatePicker) Unbind

func (d *DatePicker) Unbind()

Unbind releases app services.

type DateRangePicker

type DateRangePicker struct {
	Base
	// contains filtered or unexported fields
}

DateRangePicker combines two inputs with a range-select calendar.

func NewDateRangePicker

func NewDateRangePicker() *DateRangePicker

NewDateRangePicker creates a date range picker.

func (*DateRangePicker) Bind

func (d *DateRangePicker) Bind(services runtime.Services)

Bind attaches app services.

func (*DateRangePicker) Calendar

func (d *DateRangePicker) Calendar() *Calendar

Calendar returns the underlying calendar.

func (*DateRangePicker) ChildWidgets

func (d *DateRangePicker) ChildWidgets() []runtime.Widget

ChildWidgets returns child widgets for traversal.

func (*DateRangePicker) EndInput

func (d *DateRangePicker) EndInput() *Input

EndInput returns the end input widget.

func (*DateRangePicker) HandleMessage

func (d *DateRangePicker) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to child widgets.

func (*DateRangePicker) Layout

func (d *DateRangePicker) Layout(bounds runtime.Rect)

Layout positions the inputs and calendar.

func (*DateRangePicker) Measure

func (d *DateRangePicker) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*DateRangePicker) OnRangeSelect deprecated

func (d *DateRangePicker) OnRangeSelect(fn func(start, end time.Time))

OnRangeSelect registers a selection callback.

Deprecated: Use SetOnRangeSelect instead. This method will be removed in v1.0.

func (*DateRangePicker) Render

func (d *DateRangePicker) Render(ctx runtime.RenderContext)

Render draws inputs, separator, and calendar.

func (*DateRangePicker) SelectedRange

func (d *DateRangePicker) SelectedRange() (time.Time, time.Time, bool)

SelectedRange returns the selected range and a flag if both ends are set.

func (*DateRangePicker) SetFormat

func (d *DateRangePicker) SetFormat(format string)

SetFormat updates the date format.

func (*DateRangePicker) SetLabel

func (d *DateRangePicker) SetLabel(label string)

SetLabel updates the accessibility label.

func (*DateRangePicker) SetOnRangeSelect

func (d *DateRangePicker) SetOnRangeSelect(fn func(start, end time.Time))

SetOnRangeSelect registers a selection callback.

func (*DateRangePicker) SetRange

func (d *DateRangePicker) SetRange(start, end *time.Time)

SetRange updates the selected date range.

func (*DateRangePicker) StartInput

func (d *DateRangePicker) StartInput() *Input

StartInput returns the start input widget.

func (*DateRangePicker) StyleType

func (d *DateRangePicker) StyleType() string

StyleType returns the selector type name.

func (*DateRangePicker) Unbind

func (d *DateRangePicker) Unbind()

Unbind releases app services.

type DayRenderFunc

type DayRenderFunc func(ctx runtime.RenderContext, date time.Time, state CalendarDayState)

DayRenderFunc customizes day rendering.

type DebugOverlay

type DebugOverlay struct {
	Base
	// contains filtered or unexported fields
}

DebugOverlay draws widget bounds and labels for layout debugging.

func NewDebugOverlay

func NewDebugOverlay(root runtime.Widget, opts ...DebugOverlayOption) *DebugOverlay

NewDebugOverlay creates a debug overlay for the provided root widget.

func (*DebugOverlay) Bind

func (d *DebugOverlay) Bind(services runtime.Services)

Bind attaches app services.

func (*DebugOverlay) Layout

func (d *DebugOverlay) Layout(bounds runtime.Rect)

Layout stores bounds.

func (*DebugOverlay) Measure

func (d *DebugOverlay) Measure(constraints runtime.Constraints) runtime.Size

Measure takes all available space.

func (*DebugOverlay) Render

func (d *DebugOverlay) Render(ctx runtime.RenderContext)

Render draws bounding boxes for the widget tree.

func (*DebugOverlay) Unbind

func (d *DebugOverlay) Unbind()

Unbind releases app services.

type DebugOverlayOption

type DebugOverlayOption = Option[DebugOverlay]

DebugOverlayOption configures a debug overlay.

func WithDebugLabelStyle

func WithDebugLabelStyle(style backend.Style) DebugOverlayOption

WithDebugLabelStyle sets the label style.

func WithDebugLabels

func WithDebugLabels(enabled bool) DebugOverlayOption

WithDebugLabels toggles label rendering.

func WithDebugMaxDepth

func WithDebugMaxDepth(depth int) DebugOverlayOption

WithDebugMaxDepth limits traversal depth (0 = unlimited).

func WithDebugStyle

func WithDebugStyle(style backend.Style) DebugOverlayOption

WithDebugStyle sets the box style.

type Dialog

type Dialog struct {
	FocusableBase
	Title   string
	Body    string         // Text body (used if Content is nil)
	Content runtime.Widget // Custom content widget (takes precedence over Body)
	Buttons []DialogButton
	// contains filtered or unexported fields
}

Dialog is a modal message container with optional custom content. Dialog supports keyboard shortcuts, auto-dismiss timers, and dismiss callbacks.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	dialog := widgets.NewDialog("Confirm", "Delete the item?", widgets.DialogButton{Label: "OK"})
	_ = dialog
}

func NewDialog

func NewDialog(title, body string, buttons ...DialogButton) *Dialog

NewDialog creates a dialog with title, body text, and optional buttons. Use builder methods to add custom content, auto-dismiss, etc.

func (*Dialog) Apply

func (d *Dialog) Apply(opts ...DialogOption) *Dialog

Apply applies dialog options and returns the dialog for chaining.

func (*Dialog) Bind

func (d *Dialog) Bind(services runtime.Services)

Bind attaches app services and announces dialog content. It saves the currently focused widget so focus can be restored on close.

func (*Dialog) CenteredBounds

func (d *Dialog) CenteredBounds(parent runtime.Rect) runtime.Rect

CenteredBounds returns bounds to center dialog within parent rect.

func (*Dialog) ChildWidgets

func (d *Dialog) ChildWidgets() []runtime.Widget

ChildWidgets returns the content widget for proper widget tree traversal.

func (*Dialog) HandleMessage

func (d *Dialog) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles button selection and keyboard shortcuts.

func (*Dialog) IsPaused

func (d *Dialog) IsPaused() bool

IsPaused returns whether the auto-dismiss timer is paused.

func (*Dialog) Layout

func (d *Dialog) Layout(bounds runtime.Rect)

Layout positions the dialog and its content.

func (*Dialog) Measure

func (d *Dialog) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Dialog) OnDismiss deprecated

func (d *Dialog) OnDismiss(fn func()) *Dialog

OnDismiss sets the dismiss callback and returns the dialog for chaining.

Deprecated: Use SetOnDismiss for mutation or WithDialogOnDismiss during construction. This method will be removed in v1.0.

func (*Dialog) PathSegment

func (d *Dialog) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Dialog) PauseTimer

func (d *Dialog) PauseTimer()

PauseTimer pauses the auto-dismiss timer.

func (*Dialog) Render

func (d *Dialog) Render(ctx runtime.RenderContext)

Render draws the dialog.

func (*Dialog) ResumeTimer

func (d *Dialog) ResumeTimer()

ResumeTimer resumes the auto-dismiss timer.

func (*Dialog) SetAutoDismiss

func (d *Dialog) SetAutoDismiss(duration time.Duration)

SetAutoDismiss enables auto-dismiss after duration (0 = disabled).

func (*Dialog) SetButtons

func (d *Dialog) SetButtons(buttons ...DialogButton)

SetButtons updates dialog buttons.

func (*Dialog) SetContent

func (d *Dialog) SetContent(content runtime.Widget)

SetContent sets a custom widget as dialog body (replaces text Body).

func (*Dialog) SetDismissable

func (d *Dialog) SetDismissable(dismissable bool)

SetDismissable sets whether Escape closes the dialog (default true).

func (*Dialog) SetOnDismiss

func (d *Dialog) SetOnDismiss(fn func())

SetOnDismiss sets callback when dialog is dismissed via Escape.

func (*Dialog) SetStyle

func (d *Dialog) SetStyle(style backend.Style)

SetStyle updates the dialog style.

func (*Dialog) ShouldDismiss

func (d *Dialog) ShouldDismiss(now time.Time) bool

ShouldDismiss returns true if auto-dismiss time has elapsed.

func (*Dialog) StyleType

func (d *Dialog) StyleType() string

StyleType returns the selector type name.

func (*Dialog) TimerProgress

func (d *Dialog) TimerProgress(now time.Time) float64

TimerProgress returns 0.0-1.0 progress toward auto-dismiss.

func (*Dialog) Unbind

func (d *Dialog) Unbind()

Unbind releases app services and restores focus to the widget that was focused before the dialog opened.

func (*Dialog) WithAutoDismiss deprecated

func (d *Dialog) WithAutoDismiss(duration time.Duration) *Dialog

WithAutoDismiss enables auto-dismiss after duration and returns the dialog for chaining. Call ShouldDismiss() periodically to check if time has elapsed.

Deprecated: Use SetAutoDismiss for mutation or WithDialogAutoDismiss during construction. This method will be removed in v1.0.

func (*Dialog) WithContent deprecated

func (d *Dialog) WithContent(content runtime.Widget) *Dialog

WithContent sets a custom widget as dialog body and returns the dialog for chaining.

Deprecated: Use SetContent for mutation or WithDialogContent during construction. This method will be removed in v1.0.

func (*Dialog) WithDismissable deprecated

func (d *Dialog) WithDismissable(dismissable bool) *Dialog

WithDismissable sets whether Escape closes the dialog and returns it for chaining.

Deprecated: Use SetDismissable for mutation or WithDialogDismissable during construction. This method will be removed in v1.0.

type DialogButton

type DialogButton struct {
	Label   string
	Key     rune // Keyboard shortcut (e.g., 'Y' for Yes). 0 = no shortcut.
	OnClick func()
}

DialogButton represents an action in a dialog.

type DialogOption

type DialogOption = Option[Dialog]

DialogOption configures a Dialog widget.

func WithDialogAutoDismiss

func WithDialogAutoDismiss(duration time.Duration) DialogOption

WithDialogAutoDismiss enables auto-dismiss after duration.

func WithDialogButtons

func WithDialogButtons(buttons ...DialogButton) DialogOption

WithDialogButtons sets the dialog buttons.

func WithDialogContent

func WithDialogContent(content runtime.Widget) DialogOption

WithDialogContent sets a custom content widget.

func WithDialogDismissable

func WithDialogDismissable(dismissable bool) DialogOption

WithDialogDismissable sets whether Escape closes the dialog.

func WithDialogOnDismiss

func WithDialogOnDismiss(fn func()) DialogOption

WithDialogOnDismiss registers a dismiss callback.

func WithDialogStyle

func WithDialogStyle(style backend.Style) DialogOption

WithDialogStyle sets the dialog style.

type DirectoryEntry

type DirectoryEntry struct {
	Path     string
	Name     string
	IsDir    bool
	Expanded bool
	Depth    int
	Parent   *DirectoryEntry
	Children []*DirectoryEntry
	Loaded   bool // true if children have been loaded (for lazy loading)
}

DirectoryEntry represents a file or directory in the tree.

type DirectoryTree

type DirectoryTree struct {
	FocusableBase
	// contains filtered or unexported fields
}

DirectoryTree is a lazy-loading file browser with virtual scrolling.

func NewDirectoryTree

func NewDirectoryTree(root string, opts ...DirectoryTreeOption) *DirectoryTree

NewDirectoryTree creates a new directory tree widget.

func (*DirectoryTree) Bind

func (d *DirectoryTree) Bind(services runtime.Services)

Bind attaches app services.

func (*DirectoryTree) CollapseSelected

func (d *DirectoryTree) CollapseSelected()

CollapseSelected collapses the selected directory.

func (*DirectoryTree) ExpandSelected

func (d *DirectoryTree) ExpandSelected()

ExpandSelected expands the selected directory.

func (*DirectoryTree) HandleMessage

func (d *DirectoryTree) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles navigation and expansion input.

func (*DirectoryTree) Layout

func (d *DirectoryTree) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*DirectoryTree) LazyLoad

func (d *DirectoryTree) LazyLoad() bool

LazyLoad returns whether lazy loading is enabled.

func (*DirectoryTree) Measure

func (d *DirectoryTree) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*DirectoryTree) PageBy

func (d *DirectoryTree) PageBy(pages int)

PageBy scrolls by a number of pages.

func (*DirectoryTree) Refresh

func (d *DirectoryTree) Refresh()

Refresh reloads the directory tree.

func (*DirectoryTree) Render

func (d *DirectoryTree) Render(ctx runtime.RenderContext)

Render draws the directory tree.

func (*DirectoryTree) Root

func (d *DirectoryTree) Root() string

Root returns the current root directory.

func (*DirectoryTree) ScrollBy

func (d *DirectoryTree) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta rows.

func (*DirectoryTree) ScrollTo

func (d *DirectoryTree) ScrollTo(x, y int)

ScrollTo scrolls to an absolute row index.

func (*DirectoryTree) ScrollToEnd

func (d *DirectoryTree) ScrollToEnd()

ScrollToEnd scrolls to the last row.

func (*DirectoryTree) ScrollToStart

func (d *DirectoryTree) ScrollToStart()

ScrollToStart scrolls to the first row.

func (*DirectoryTree) SelectedEntry

func (d *DirectoryTree) SelectedEntry() *DirectoryEntry

SelectedEntry returns the currently selected entry.

func (*DirectoryTree) SelectedPath

func (d *DirectoryTree) SelectedPath() string

SelectedPath returns the currently selected path.

func (*DirectoryTree) SetFilter

func (d *DirectoryTree) SetFilter(filter func(os.DirEntry) bool)

SetFilter sets the filter function.

func (*DirectoryTree) SetLabel

func (d *DirectoryTree) SetLabel(label string)

SetLabel sets the accessibility label.

func (*DirectoryTree) SetLazyLoad

func (d *DirectoryTree) SetLazyLoad(lazy bool)

SetLazyLoad enables or disables lazy loading.

func (*DirectoryTree) SetOnSelect

func (d *DirectoryTree) SetOnSelect(fn func(path string))

SetOnSelect sets the selection callback.

func (*DirectoryTree) SetRoot

func (d *DirectoryTree) SetRoot(root string)

SetRoot changes the root directory.

func (*DirectoryTree) SetSelectedStyle

func (d *DirectoryTree) SetSelectedStyle(style backend.Style)

SetSelectedStyle sets the selected row style.

func (*DirectoryTree) SetShowHidden

func (d *DirectoryTree) SetShowHidden(show bool)

SetShowHidden enables or disables showing hidden files.

func (*DirectoryTree) SetStyle

func (d *DirectoryTree) SetStyle(style backend.Style)

SetStyle sets the base style.

func (*DirectoryTree) ShowHidden

func (d *DirectoryTree) ShowHidden() bool

ShowHidden returns whether hidden files are shown.

func (*DirectoryTree) StyleType

func (d *DirectoryTree) StyleType() string

StyleType returns the selector type name.

func (*DirectoryTree) ToggleSelected

func (d *DirectoryTree) ToggleSelected()

ToggleSelected toggles expand/collapse on the selected directory.

func (*DirectoryTree) Unbind

func (d *DirectoryTree) Unbind()

Unbind releases app services.

type DirectoryTreeOption

type DirectoryTreeOption func(*DirectoryTree)

DirectoryTreeOption is a functional option for DirectoryTree.

func WithDirectoryFilter

func WithDirectoryFilter(filter func(os.DirEntry) bool) DirectoryTreeOption

WithDirectoryFilter sets a filter function for entries.

func WithDirectoryIcons

func WithDirectoryIcons(dir, file, expanded, collapsed string) DirectoryTreeOption

WithDirectoryIcons sets custom icons.

func WithDirectorySelectedStyle

func WithDirectorySelectedStyle(s backend.Style) DirectoryTreeOption

WithDirectorySelectedStyle sets the selected row style.

func WithDirectoryStyle

func WithDirectoryStyle(s backend.Style) DirectoryTreeOption

WithDirectoryStyle sets the base style.

func WithLazyLoad

func WithLazyLoad(lazy bool) DirectoryTreeOption

WithLazyLoad enables lazy loading of children.

func WithOnSelect

func WithOnSelect(fn func(path string)) DirectoryTreeOption

WithOnSelect sets the selection callback.

func WithShowHidden

func WithShowHidden(show bool) DirectoryTreeOption

WithShowHidden enables showing hidden files (starting with .).

type Disclosure

type Disclosure struct {
	FocusableBase
	// contains filtered or unexported fields
}

Disclosure is a single expandable section with a toggle header.

func NewDisclosure

func NewDisclosure(title string, content runtime.Widget) *Disclosure

NewDisclosure creates a disclosure widget with the given title and content.

func (*Disclosure) Bind

func (d *Disclosure) Bind(services runtime.Services)

Bind attaches app services.

func (*Disclosure) ChildWidgets

func (d *Disclosure) ChildWidgets() []runtime.Widget

ChildWidgets returns the content widget when expanded.

func (*Disclosure) Expanded

func (d *Disclosure) Expanded() bool

Expanded reports whether the disclosure is expanded.

func (*Disclosure) HandleMessage

func (d *Disclosure) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard toggling.

func (*Disclosure) Layout

func (d *Disclosure) Layout(bounds runtime.Rect)

Layout positions the header and content.

func (*Disclosure) Measure

func (d *Disclosure) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Disclosure) Render

func (d *Disclosure) Render(ctx runtime.RenderContext)

Render draws the disclosure header and optional content.

func (*Disclosure) SetExpanded

func (d *Disclosure) SetExpanded(expanded bool)

SetExpanded sets the expanded state.

func (*Disclosure) SetFocusStyle

func (d *Disclosure) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*Disclosure) SetOnChange

func (d *Disclosure) SetOnChange(fn func(expanded bool))

SetOnChange sets the change handler.

func (*Disclosure) SetStyle

func (d *Disclosure) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*Disclosure) StyleType

func (d *Disclosure) StyleType() string

StyleType returns the selector type name.

func (*Disclosure) Toggle

func (d *Disclosure) Toggle()

Toggle toggles the expanded state.

func (*Disclosure) Unbind

func (d *Disclosure) Unbind()

Unbind releases app services.

type Drawer

type Drawer struct {
	Base
	// contains filtered or unexported fields
}

Drawer is a slide-out panel that overlays from a screen edge. When closed, it takes no space. When open, it renders its child content at the specified edge with the specified width or height.

func NewDrawer

func NewDrawer(child runtime.Widget, open *state.Signal[bool], opts ...DrawerOption) *Drawer

NewDrawer creates a drawer containing the given child widget. The open signal controls whether the drawer is visible.

func (*Drawer) Bind

func (d *Drawer) Bind(services runtime.Services)

Bind attaches app services.

func (*Drawer) ChildWidgets

func (d *Drawer) ChildWidgets() []runtime.Widget

ChildWidgets returns the child widget when the drawer is open.

func (*Drawer) HandleMessage

func (d *Drawer) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes input for the drawer. Escape closes the drawer when it is open.

func (*Drawer) IsOpen

func (d *Drawer) IsOpen() bool

IsOpen returns whether the drawer is currently open.

func (*Drawer) Layout

func (d *Drawer) Layout(bounds runtime.Rect)

Layout positions the drawer and its child.

func (*Drawer) Measure

func (d *Drawer) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size. When closed, returns zero size. When open, returns the drawer dimensions.

func (*Drawer) Render

func (d *Drawer) Render(ctx runtime.RenderContext)

Render draws the drawer and its child content when open.

func (*Drawer) SetOpen

func (d *Drawer) SetOpen(value bool)

SetOpen updates the open state and announces the change.

func (*Drawer) SetStyle

func (d *Drawer) SetStyle(style backend.Style)

SetStyle sets the drawer background style.

func (*Drawer) StyleType

func (d *Drawer) StyleType() string

StyleType returns the selector type name for FSS.

func (*Drawer) Unbind

func (d *Drawer) Unbind()

Unbind releases app services.

type DrawerOption

type DrawerOption = Option[Drawer]

DrawerOption configures a Drawer widget.

func WithDrawerHeight

func WithDrawerHeight(height int) DrawerOption

WithDrawerHeight sets the height for bottom drawers.

func WithDrawerSide

func WithDrawerSide(side DrawerSide) DrawerOption

WithDrawerSide sets which edge the drawer opens from.

func WithDrawerWidth

func WithDrawerWidth(width int) DrawerOption

WithDrawerWidth sets the width for left/right drawers.

type DrawerSide

type DrawerSide int

DrawerSide specifies which edge the drawer slides out from.

const (
	// DrawerLeft opens from the left edge.
	DrawerLeft DrawerSide = iota
	// DrawerRight opens from the right edge.
	DrawerRight
	// DrawerBottom opens from the bottom edge.
	DrawerBottom
)

type EnhancedPalette

type EnhancedPalette struct {
	Widget *PaletteWidget
	// contains filtered or unexported fields
}

EnhancedPalette wraps a command registry with palette UI.

Example
package main

import (
	"m31labs.dev/fluffyui/keybind"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	registry := keybind.NewRegistry()
	registry.Register(keybind.Command{
		ID:          "app.quit",
		Title:       "Quit",
		Description: "Exit the app",
	})
	palette := widgets.NewEnhancedPalette(registry)
	_ = palette
}

func NewEnhancedPalette

func NewEnhancedPalette(registry *keybind.CommandRegistry) *EnhancedPalette

NewEnhancedPalette creates a palette from a registry.

func (*EnhancedPalette) Pin

func (p *EnhancedPalette) Pin(id string)

Pin adds a command to pinned list.

func (*EnhancedPalette) Record

func (p *EnhancedPalette) Record(id string)

Record marks a command as recently used.

func (*EnhancedPalette) Refresh

func (p *EnhancedPalette) Refresh()

Refresh rebuilds palette items from the registry.

func (*EnhancedPalette) SetKeymapStack

func (p *EnhancedPalette) SetKeymapStack(stack *keybind.KeymapStack)

SetKeymapStack supplies keymaps from a stack.

func (*EnhancedPalette) SetKeymaps

func (p *EnhancedPalette) SetKeymaps(keymaps ...*keybind.Keymap)

SetKeymaps supplies keymaps for shortcut display.

func (*EnhancedPalette) Unpin

func (p *EnhancedPalette) Unpin(id string)

Unpin removes a command from pinned list.

type FilePicker

type FilePicker struct {
	FocusableBase
	// contains filtered or unexported fields
}

FilePicker is a focusable file/directory browser for selecting files.

func NewFilePicker

func NewFilePicker(dir string, opts ...FilePickerOption) *FilePicker

NewFilePicker creates a file picker for the given directory.

func (*FilePicker) Bind

func (fp *FilePicker) Bind(services runtime.Services)

Bind attaches app services.

func (*FilePicker) CurrentDir

func (fp *FilePicker) CurrentDir() string

CurrentDir returns the current directory path.

func (*FilePicker) EntryCount

func (fp *FilePicker) EntryCount() int

EntryCount returns the number of visible entries (including "..").

func (*FilePicker) HandleMessage

func (fp *FilePicker) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*FilePicker) Measure

func (fp *FilePicker) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*FilePicker) Render

func (fp *FilePicker) Render(ctx runtime.RenderContext)

Render draws the file picker.

func (*FilePicker) SelectedIndex

func (fp *FilePicker) SelectedIndex() int

SelectedIndex returns the currently selected entry index.

func (*FilePicker) SetStyle

func (fp *FilePicker) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*FilePicker) StyleType

func (fp *FilePicker) StyleType() string

StyleType returns the selector type name.

func (*FilePicker) Unbind

func (fp *FilePicker) Unbind()

Unbind releases app services.

type FilePickerOption

type FilePickerOption = Option[FilePicker]

FilePickerOption configures a FilePicker widget.

func WithFileFilter

func WithFileFilter(pattern string) FilePickerOption

WithFileFilter sets the file extension filter (e.g. "*.go").

func WithFilePickerShowHidden

func WithFilePickerShowHidden(show bool) FilePickerOption

WithFilePickerShowHidden controls whether hidden files are shown.

func WithOnFileSelect

func WithOnFileSelect(fn func(string)) FilePickerOption

WithOnFileSelect sets the file selection callback.

func WithStartDir

func WithStartDir(dir string) FilePickerOption

WithStartDir sets the starting directory.

type FixedSpacer

type FixedSpacer struct {
	Base
	// contains filtered or unexported fields
}

FixedSpacer is an empty widget with a fixed size, useful for adding precise spacing between widgets in a layout. Unlike runtime.FixedSpace which is a flex child helper, FixedSpacer is a full widget that can participate in the accessibility tree and stylesheet system.

func NewFixedSpacer

func NewFixedSpacer(width, height int) *FixedSpacer

NewFixedSpacer creates a fixed-size empty widget. The spacer occupies exactly the given width and height and renders nothing.

func (*FixedSpacer) HandleMessage

func (s *FixedSpacer) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled; spacers do not process input.

func (*FixedSpacer) Measure

func (s *FixedSpacer) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the fixed size, clamped to the given constraints.

func (*FixedSpacer) Render

func (s *FixedSpacer) Render(ctx runtime.RenderContext)

Render is a no-op; the spacer is invisible.

func (*FixedSpacer) StyleType

func (s *FixedSpacer) StyleType() string

StyleType returns the selector type name for stylesheets.

type Flex

type Flex = runtime.Flex

Flex re-exports runtime flex layout types for widget-level usage.

type FlexChild

type FlexChild = runtime.FlexChild

FlexChild defines a child item for flex layouts.

type FlexDirection

type FlexDirection = runtime.FlexDirection

FlexDirection defines the layout axis for flex containers.

type FocusTrap

type FocusTrap struct {
	Base
	// contains filtered or unexported fields
}

FocusTrap wraps a child widget and constrains Tab/Shift+Tab navigation within the child subtree. This is critical for modal dialogs, drawers, and overlays that must not let keyboard focus escape.

When active, Tab and Shift+Tab cycle only through focusable descendants. When inactive, focus navigation passes through normally.

func NewFocusTrap

func NewFocusTrap(child runtime.Widget) *FocusTrap

NewFocusTrap creates a FocusTrap wrapping the given child widget. The trap starts active by default.

func (*FocusTrap) Active

func (f *FocusTrap) Active() bool

Active reports whether the focus trap is currently active.

func (*FocusTrap) Bind

func (f *FocusTrap) Bind(services runtime.Services)

Bind attaches app services and announces the focus trap.

func (*FocusTrap) Child

func (f *FocusTrap) Child() runtime.Widget

Child returns the wrapped child widget.

func (*FocusTrap) ChildWidgets

func (f *FocusTrap) ChildWidgets() []runtime.Widget

ChildWidgets returns the child widget for tree traversal.

func (*FocusTrap) HandleMessage

func (f *FocusTrap) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage intercepts Tab/Shift+Tab when the trap is active to cycle focus within the child subtree.

func (*FocusTrap) Layout

func (f *FocusTrap) Layout(bounds runtime.Rect)

Layout positions the child within the given bounds.

func (*FocusTrap) Measure

func (f *FocusTrap) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size, delegating to the child.

func (*FocusTrap) PathSegment

func (f *FocusTrap) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment.

func (*FocusTrap) Render

func (f *FocusTrap) Render(ctx runtime.RenderContext)

Render draws the child widget.

func (*FocusTrap) Scope

func (f *FocusTrap) Scope() *runtime.FocusScope

Scope returns the internal focus scope for testing and inspection.

func (*FocusTrap) SetActive

func (f *FocusTrap) SetActive(active bool)

SetActive enables or disables the focus trap. When activated, focus is announced and trapped within children. When deactivated, Tab/Shift+Tab pass through to the parent scope.

func (*FocusTrap) SetChild

func (f *FocusTrap) SetChild(child runtime.Widget)

SetChild replaces the child widget.

func (*FocusTrap) SetLabel

func (f *FocusTrap) SetLabel(label string)

SetLabel sets the accessible label for announcements.

func (*FocusTrap) StyleType

func (f *FocusTrap) StyleType() string

StyleType returns the selector type name.

func (*FocusTrap) Unbind

func (f *FocusTrap) Unbind()

Unbind releases app services.

type FocusableBase

type FocusableBase struct {
	Base
	// contains filtered or unexported fields
}

FocusableBase extends Base for focusable widgets.

func (*FocusableBase) Blur

func (f *FocusableBase) Blur()

Blur marks the widget as unfocused and invokes the onBlur hook.

func (*FocusableBase) CanFocus

func (f *FocusableBase) CanFocus() bool

CanFocus returns true for focusable widgets.

func (*FocusableBase) Focus

func (f *FocusableBase) Focus()

Focus marks the widget as focused and invokes the onFocus hook.

func (*FocusableBase) OnBlur

func (f *FocusableBase) OnBlur(fn func())

OnBlur registers a callback that fires when the widget loses focus.

func (*FocusableBase) OnFocus

func (f *FocusableBase) OnFocus(fn func())

OnFocus registers a callback that fires when the widget gains focus.

type Form

type Form struct {
	Component
	// contains filtered or unexported fields
}

Form is a container widget that manages a set of labeled input fields with validation, error display, and submit handling.

func NewForm

func NewForm(fields ...FormFieldDef) *Form

NewForm creates a new form with the given field definitions.

func (*Form) Bind

func (f *Form) Bind(services runtime.Services)

Bind attaches app services to the form and its children.

func (*Form) ChildWidgets

func (f *Form) ChildWidgets() []runtime.Widget

ChildWidgets returns all child widgets for focus traversal and binding.

func (*Form) Errors

func (f *Form) Errors() map[int]string

Errors returns a map of field index to error message for fields with errors.

func (*Form) FieldCount

func (f *Form) FieldCount() int

FieldCount returns the number of fields in the form.

func (*Form) HandleMessage

func (f *Form) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input for the form.

func (*Form) Layout

func (f *Form) Layout(bounds runtime.Rect)

Layout positions the form and all its child widgets.

func (*Form) Measure

func (f *Form) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed for the form.

func (*Form) PathSegment

func (f *Form) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Form) Render

func (f *Form) Render(ctx runtime.RenderContext)

Render draws the form to the buffer.

func (*Form) SetCancelLabel

func (f *Form) SetCancelLabel(label string)

SetCancelLabel sets the label for the cancel button.

func (*Form) SetLabel

func (f *Form) SetLabel(label string)

SetLabel sets the accessibility label for the form.

func (*Form) SetOnCancel

func (f *Form) SetOnCancel(fn func())

SetOnCancel sets the callback invoked when the form is cancelled.

func (*Form) SetOnSubmit

func (f *Form) SetOnSubmit(fn func(map[string]string))

SetOnSubmit sets the callback invoked when the form is submitted. The callback receives a map of label -> text value for each field.

func (*Form) SetSubmitLabel

func (f *Form) SetSubmitLabel(label string)

SetSubmitLabel sets the label for the submit button.

func (*Form) StyleType

func (f *Form) StyleType() string

StyleType returns the selector type name for FSS styling.

func (*Form) Unbind

func (f *Form) Unbind()

Unbind releases app services from the form and its children.

func (*Form) Validate

func (f *Form) Validate() bool

Validate runs validators on all fields and returns true if all pass.

type FormFieldDef

type FormFieldDef struct {
	Label  string
	Widget runtime.Widget
}

FormFieldDef defines a labeled form field.

func FormField

func FormField(label string, widget runtime.Widget) FormFieldDef

FormField creates a form field definition.

type GPUCanvasOption

type GPUCanvasOption = Option[GPUCanvasWidget]

GPUCanvasOption configures a GPUCanvasWidget.

func WithGPUCanvasBackend

func WithGPUCanvasBackend(backend gpu.Backend) GPUCanvasOption

WithGPUCanvasBackend sets the GPU backend used by the canvas.

func WithGPUCanvasDriver

func WithGPUCanvasDriver(driver gpu.Driver) GPUCanvasOption

WithGPUCanvasDriver sets a specific driver instance.

func WithGPUCanvasEncoder

func WithGPUCanvasEncoder(encoder graphics.TerminalEncoder) GPUCanvasOption

WithGPUCanvasEncoder sets a specific terminal encoder.

type GPUCanvasWidget

type GPUCanvasWidget struct {
	Component
	// contains filtered or unexported fields
}

GPUCanvasWidget draws using a GPU canvas and image protocols.

func NewGPUCanvasWidget

func NewGPUCanvasWidget(draw func(canvas *gpu.GPUCanvas), opts ...GPUCanvasOption) *GPUCanvasWidget

NewGPUCanvasWidget creates a GPUCanvasWidget with the draw callback.

func (*GPUCanvasWidget) Layout

func (w *GPUCanvasWidget) Layout(bounds runtime.Rect)

Layout updates layout bounds and canvas size.

func (*GPUCanvasWidget) Measure

func (w *GPUCanvasWidget) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size for the widget.

func (*GPUCanvasWidget) Render

func (w *GPUCanvasWidget) Render(ctx runtime.RenderContext)

Render draws the GPU canvas.

func (*GPUCanvasWidget) SetBackend

func (w *GPUCanvasWidget) SetBackend(backend gpu.Backend)

SetBackend sets the GPU backend used by the canvas.

func (*GPUCanvasWidget) SetDriver

func (w *GPUCanvasWidget) SetDriver(driver gpu.Driver)

SetDriver sets a specific driver instance.

func (*GPUCanvasWidget) SetEncoder

func (w *GPUCanvasWidget) SetEncoder(encoder graphics.TerminalEncoder)

SetEncoder sets a specific terminal encoder.

func (*GPUCanvasWidget) Unbind

func (w *GPUCanvasWidget) Unbind()

Unbind releases GPU resources.

func (*GPUCanvasWidget) WithBackend deprecated

func (w *GPUCanvasWidget) WithBackend(backend gpu.Backend) *GPUCanvasWidget

Deprecated: prefer WithGPUCanvasBackend during construction or SetBackend for mutation.

func (*GPUCanvasWidget) WithDriver deprecated

func (w *GPUCanvasWidget) WithDriver(driver gpu.Driver) *GPUCanvasWidget

Deprecated: prefer WithGPUCanvasDriver during construction or SetDriver for mutation.

func (*GPUCanvasWidget) WithEncoder deprecated

func (w *GPUCanvasWidget) WithEncoder(encoder graphics.TerminalEncoder) *GPUCanvasWidget

Deprecated: prefer WithGPUCanvasEncoder during construction or SetEncoder for mutation.

type GaugeColors

type GaugeColors struct {
	Background backend.Color
	Fill       backend.Color
	Glow       backend.Color
}

GaugeColors defines the colors used for the animated gauge.

type GaugeSpan

type GaugeSpan struct {
	Text  string
	Style backend.Style
}

GaugeSpan represents a styled segment for composite rendering.

func DrawGaugeSpans

func DrawGaugeSpans(width int, ratio float64, style GaugeStyle) []GaugeSpan

DrawGaugeSpans returns gauge as styled spans for scrollback integration.

type GaugeStyle

type GaugeStyle struct {
	// Fill characters
	FillChar  rune // Filled portion (default '█')
	EmptyChar rune // Empty portion (default '░')

	// Gradient thresholds and styles (ascending order)
	// Each threshold defines the ratio at which a new color begins
	Thresholds []GaugeThreshold

	// EmptyStyle for unfilled portion
	EmptyStyle backend.Style

	// EdgeStyle for the leading edge (optional glow effect)
	EdgeStyle backend.Style
}

GaugeStyle defines the visual appearance of a gauge.

func DefaultGaugeStyle

func DefaultGaugeStyle(green, amber, coral, edge, empty backend.Style) GaugeStyle

DefaultGaugeStyle returns a green→amber→coral gradient gauge.

type GaugeThreshold

type GaugeThreshold struct {
	Ratio float64       // Start ratio for this color (0.0-1.0)
	Style backend.Style // Style for this segment
}

GaugeThreshold defines a color breakpoint in the gradient.

type Grid

type Grid struct {
	Base
	// Legacy: fixed uniform grid
	Rows int
	Cols int

	// Enhanced: track-based sizing (CSS Grid-like)
	ColTracks []TrackSize
	RowTracks []TrackSize

	Gap      int
	Children []GridChild
	// contains filtered or unexported fields
}

Grid lays out children in rows and columns.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	grid := widgets.NewGrid(2, 2)
	grid.Gap = 1
	grid.Add(widgets.NewLabel("Top"), 0, 0, 1, 2)
	grid.Add(widgets.NewLabel("Left"), 1, 0, 1, 1)
	grid.Add(widgets.NewLabel("Right"), 1, 1, 1, 1)
	_ = grid
}

func NewGrid

func NewGrid(rows, cols int) *Grid

NewGrid creates a grid with the given dimensions.

func NewTrackGrid

func NewTrackGrid(cols []TrackSize, rows []TrackSize) *Grid

NewTrackGrid creates a grid with explicit column and row track definitions.

func (*Grid) Add

func (g *Grid) Add(child runtime.Widget, row, col, rowSpan, colSpan int)

Add adds a child at the given cell.

func (*Grid) Bind

func (g *Grid) Bind(services runtime.Services)

Bind attaches app services.

func (*Grid) ChildWidgets

func (g *Grid) ChildWidgets() []runtime.Widget

ChildWidgets returns grid children.

func (*Grid) HandleMessage

func (g *Grid) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to children.

func (*Grid) Layout

func (g *Grid) Layout(bounds runtime.Rect)

Layout positions children within the grid.

func (*Grid) Measure

func (g *Grid) Measure(constraints runtime.Constraints) runtime.Size

Measure estimates the grid size.

func (*Grid) PathSegment

func (g *Grid) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Grid) Render

func (g *Grid) Render(ctx runtime.RenderContext)

Render draws all children.

func (*Grid) SetLabel

func (g *Grid) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Grid) Unbind

func (g *Grid) Unbind()

Unbind releases app services.

type GridBuilder

type GridBuilder struct {
	// contains filtered or unexported fields
}

GridBuilder provides a declarative API for constructing grids.

Usage:

grid := BuildGrid().
    Columns(3).
    Gap(1).
    Row(nameInput, emailInput, phoneInput).
    Row(addressInput, cityInput, zipInput).
    Build()

func BuildGrid

func BuildGrid() *GridBuilder

BuildGrid starts a new grid builder with a default of 1 column.

func (*GridBuilder) Build

func (b *GridBuilder) Build() *Grid

Build constructs the Grid widget from the builder configuration.

func (*GridBuilder) Columns

func (b *GridBuilder) Columns(n int) *GridBuilder

Columns sets the number of columns in the grid.

func (*GridBuilder) Gap

func (b *GridBuilder) Gap(gap int) *GridBuilder

Gap sets the gap (in cells) between grid children.

func (*GridBuilder) Row

func (b *GridBuilder) Row(children ...runtime.Widget) *GridBuilder

Row adds a row of widgets placed left-to-right into columns. If fewer widgets than columns are provided, the remaining cells are empty. If more widgets than columns are provided, excess widgets are ignored.

func (*GridBuilder) SpanRow

func (b *GridBuilder) SpanRow(child runtime.Widget) *GridBuilder

SpanRow adds a single widget that spans all columns in the row.

type GridChild

type GridChild struct {
	Widget  runtime.Widget
	Row     int
	Col     int
	RowSpan int
	ColSpan int
}

GridChild positions a widget in the grid.

type HTMLItemRenderer

type HTMLItemRenderer[T any] func(item T, index int) runtime.HTML

HTMLItemRenderer renders a list item as HTML.

type HeatMap

type HeatMap struct {
	Base
	Data       *state.Signal[[][]float64]
	RowLabels  []string
	ColLabels  []string
	ColorScale ColorScale
	CellWidth  int  // width per cell (default 3)
	ShowValues bool // show numeric values in cells
	// contains filtered or unexported fields
}

HeatMap displays a 2D grid of values as color-coded cells.

func NewHeatMap

func NewHeatMap(data *state.Signal[[][]float64]) *HeatMap

NewHeatMap creates a heat map widget.

func (*HeatMap) Bind

func (hm *HeatMap) Bind(services runtime.Services)

Bind attaches app services.

func (*HeatMap) HandleMessage

func (hm *HeatMap) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled.

func (*HeatMap) Measure

func (hm *HeatMap) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*HeatMap) Render

func (hm *HeatMap) Render(ctx runtime.RenderContext)

Render draws the heat map.

func (*HeatMap) SetLabel

func (hm *HeatMap) SetLabel(label string)

SetLabel sets the accessible label.

func (*HeatMap) StyleType

func (hm *HeatMap) StyleType() string

StyleType returns the selector type name.

func (*HeatMap) Unbind

func (hm *HeatMap) Unbind()

Unbind releases app services.

type Image

type Image struct {
	Base
	// contains filtered or unexported fields
}

Image displays an image in the terminal.

func NewImage

func NewImage(src image.Image) *Image

NewImage creates an Image widget from the given Go image.

func NewImageFromFile

func NewImageFromFile(path string) (*Image, error)

NewImageFromFile creates an Image widget by loading an image from a file.

func (*Image) Bind

func (w *Image) Bind(services runtime.Services)

Bind attaches app services.

func (*Image) Fit

func (w *Image) Fit() ImageFit

Fit returns the current fit mode.

func (*Image) HandleMessage

func (w *Image) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled (non-interactive widget).

func (*Image) Label

func (w *Image) Label() string

Label returns the accessible label.

func (*Image) Layout

func (w *Image) Layout(bounds runtime.Rect)

Layout stores the assigned bounds and prepares the canvas.

func (*Image) Measure

func (w *Image) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size based on the image aspect ratio and the selected terminal transport's pixel density.

func (*Image) Protocol

func (w *Image) Protocol() ImageProtocol

Protocol returns the current protocol setting.

func (*Image) Render

func (w *Image) Render(ctx runtime.RenderContext)

Render draws the image through the selected terminal protocol or text fallback.

func (*Image) SetFit

func (w *Image) SetFit(fit ImageFit)

SetFit sets the image fit mode.

func (*Image) SetImage

func (w *Image) SetImage(img image.Image)

SetImage replaces the displayed image.

func (*Image) SetLabel

func (w *Image) SetLabel(label string)

SetLabel sets the accessible label for the image.

func (*Image) SetProtocol

func (w *Image) SetProtocol(proto ImageProtocol)

SetProtocol sets the image rendering protocol.

func (*Image) StyleType

func (w *Image) StyleType() string

StyleType returns the selector type name.

func (*Image) Unbind

func (w *Image) Unbind()

Unbind releases app services.

type ImageFit

type ImageFit int

ImageFit controls how images are sized within their bounds.

const (
	// ImageFitContain fits the image within bounds, preserving aspect ratio.
	ImageFitContain ImageFit = iota
	// ImageFitCover fills the bounds, cropping any excess.
	ImageFitCover
	// ImageFitFill stretches the image to fill the bounds exactly.
	ImageFitFill
	// ImageFitScaleDown behaves like Contain but never upscales.
	ImageFitScaleDown
)

type ImageProtocol

type ImageProtocol int

ImageProtocol selects the terminal image protocol.

const (
	// ImageProtocolAuto detects the best available protocol.
	ImageProtocolAuto ImageProtocol = iota
	// ImageProtocolKitty uses the Kitty image protocol.
	ImageProtocolKitty
	// ImageProtocolSixel uses the Sixel graphics protocol.
	ImageProtocolSixel
	// ImageProtocolITerm2 uses the iTerm2 inline image protocol.
	ImageProtocolITerm2
	// ImageProtocolHalfBlock uses Unicode half-block character fallback.
	ImageProtocolHalfBlock
)

type Input

type Input struct {
	FocusableBase
	// contains filtered or unexported fields
}

Input is a text input widget with cursor support.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	input := widgets.NewInput()
	input.SetPlaceholder("Search...")
	input.SetText("fluffy")
	input.SetOnSubmit(func(text string) {})
	_ = input
}

func NewInput

func NewInput() *Input

NewInput creates a single-line text input with cursor, selection, and undo/redo. Configure with SetPlaceholder, SetOnSubmit, and SetOnChange.

func (*Input) Bind

func (i *Input) Bind(services runtime.Services)

Bind attaches app services.

func (*Input) CanRedo

func (i *Input) CanRedo() bool

CanRedo returns true if redo is available.

func (*Input) CanUndo

func (i *Input) CanUndo() bool

CanUndo returns true if undo is available.

func (*Input) Clear

func (i *Input) Clear()

Clear clears the input text.

func (*Input) ClearHistory

func (i *Input) ClearHistory()

ClearHistory resets the undo/redo history.

func (*Input) ClipboardCopy

func (i *Input) ClipboardCopy() (string, bool)

ClipboardCopy returns selected text, or all text if no selection.

func (*Input) ClipboardCut

func (i *Input) ClipboardCut() (string, bool)

ClipboardCut returns selected text and deletes it, or all text if no selection.

func (*Input) ClipboardPaste

func (i *Input) ClipboardPaste(text string) bool

ClipboardPaste inserts text at the cursor.

func (*Input) CursorOffset

func (i *Input) CursorOffset() int

CursorOffset returns the current cursor offset (alias for CursorPos).

func (*Input) CursorPos

func (i *Input) CursorPos() int

CursorPos returns the current cursor position.

func (*Input) CursorPosition

func (i *Input) CursorPosition() (x, y int)

CursorPosition returns the cursor coordinates within the input.

func (*Input) CursorWordLeft

func (i *Input) CursorWordLeft()

CursorWordLeft moves the cursor to the previous word boundary.

func (*Input) CursorWordRight

func (i *Input) CursorWordRight()

CursorWordRight moves the cursor to the next word boundary.

func (*Input) Errors

func (i *Input) Errors() []string

Errors returns the latest validation error messages.

func (*Input) GetSelectedText

func (i *Input) GetSelectedText() string

GetSelectedText returns the currently selected text.

func (*Input) GetSelection

func (i *Input) GetSelection() Selection

GetSelection returns the current selection range.

func (*Input) HandleMessage

func (i *Input) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*Input) HasSelection

func (i *Input) HasSelection() bool

HasSelection returns true if text is selected.

func (*Input) Measure

func (i *Input) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed for the input.

func (*Input) OnChange deprecated

func (i *Input) OnChange(fn func(text string))

OnChange sets the callback for when the input text changes.

Deprecated: Use SetOnChange instead. This method will be removed in v1.0.

func (*Input) OnSubmit deprecated

func (i *Input) OnSubmit(fn func(text string))

OnSubmit sets the callback for when Enter is pressed.

Deprecated: Use SetOnSubmit instead. This method will be removed in v1.0.

func (*Input) Redo

func (i *Input) Redo() bool

Redo reapplies a previously undone state. Returns true if redo was successful.

func (*Input) Render

func (i *Input) Render(ctx runtime.RenderContext)

Render draws the input field.

func (*Input) SelectAll

func (i *Input) SelectAll()

SelectAll selects all text.

func (*Input) SelectLine

func (i *Input) SelectLine()

SelectLine selects the entire line (all text for single-line input).

func (*Input) SelectNone

func (i *Input) SelectNone()

SelectNone clears the selection.

func (*Input) SelectWord

func (i *Input) SelectWord()

SelectWord selects the word at the cursor position.

func (*Input) SetCursorOffset

func (i *Input) SetCursorOffset(offset int)

SetCursorOffset moves the cursor to the given offset.

func (*Input) SetCursorPosition

func (i *Input) SetCursorPosition(x, y int)

SetCursorPosition moves the cursor to the given coordinates.

func (*Input) SetFocusStyle

func (i *Input) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*Input) SetHistoryEnabled

func (i *Input) SetHistoryEnabled(enabled bool)

SetHistoryEnabled enables or disables undo/redo support.

func (*Input) SetHistoryOptions

func (i *Input) SetHistoryOptions(opts ...state.HistoryOption)

SetHistoryOptions reconfigures the history with new options.

func (*Input) SetLabel

func (i *Input) SetLabel(label string)

SetLabel sets the accessibility label for the input.

func (*Input) SetOnChange

func (i *Input) SetOnChange(fn func(text string))

SetOnChange sets the callback for when text changes.

func (*Input) SetOnSubmit

func (i *Input) SetOnSubmit(fn func(text string))

SetOnSubmit sets the callback for when Enter is pressed.

func (*Input) SetPlaceholder

func (i *Input) SetPlaceholder(text string)

SetPlaceholder sets the placeholder text shown when empty.

func (*Input) SetSelection

func (i *Input) SetSelection(sel Selection)

SetSelection sets the selection range.

func (*Input) SetStyle

func (i *Input) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*Input) SetText

func (i *Input) SetText(text string)

SetText sets the input text and moves cursor to end.

func (*Input) SetValidators

func (i *Input) SetValidators(validators ...forms.Validator)

SetValidators updates validation rules for the input.

func (*Input) StyleType

func (i *Input) StyleType() string

StyleType returns the selector type name.

func (*Input) Text

func (i *Input) Text() string

Text returns the current input text.

func (*Input) Unbind

func (i *Input) Unbind()

Unbind releases app services.

func (*Input) Undo

func (i *Input) Undo() bool

Undo reverts to the previous state. Returns true if undo was successful.

func (*Input) Valid

func (i *Input) Valid() bool

Valid reports whether validation passes.

func (*Input) Validate

func (i *Input) Validate() []forms.ValidationError

Validate runs validation rules and returns validation errors.

type Inspector

type Inspector struct {
	FocusableBase
	// contains filtered or unexported fields
}

Inspector displays a two-column overlay showing the widget tree and properties of the selected widget. It can inspect any widget tree provided via SetRoot.

func NewInspector

func NewInspector(root runtime.Widget, opts ...InspectorOption) *Inspector

NewInspector creates a new Inspector widget. If root is non-nil the tree is built immediately.

func (*Inspector) Bind

func (ins *Inspector) Bind(services runtime.Services)

Bind attaches app services.

func (*Inspector) Entries

func (ins *Inspector) Entries() int

Entries returns the number of entries in the flattened tree.

func (*Inspector) HandleMessage

func (ins *Inspector) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*Inspector) Layout

func (ins *Inspector) Layout(bounds runtime.Rect)

Layout stores bounds.

func (*Inspector) Measure

func (ins *Inspector) Measure(constraints runtime.Constraints) runtime.Size

Measure takes all available space.

func (*Inspector) Refresh

func (ins *Inspector) Refresh()

Refresh rebuilds the tree from the current root.

func (*Inspector) Render

func (ins *Inspector) Render(ctx runtime.RenderContext)

Render draws the two-column inspector overlay.

func (*Inspector) Selected

func (ins *Inspector) Selected() int

Selected returns the index of the currently selected entry.

func (*Inspector) SelectedEntry

func (ins *Inspector) SelectedEntry() inspectorEntry

SelectedEntry returns the inspectorEntry at the current selection, or a zero value if out of range.

func (*Inspector) SetRoot

func (ins *Inspector) SetRoot(w runtime.Widget)

SetRoot sets the root widget to inspect and rebuilds the tree.

func (*Inspector) Toggle

func (ins *Inspector) Toggle()

Toggle flips visibility.

func (*Inspector) Unbind

func (ins *Inspector) Unbind()

Unbind releases app services.

func (*Inspector) Visible

func (ins *Inspector) Visible() bool

Visible reports whether the inspector is visible.

type InspectorOption

type InspectorOption = Option[Inspector]

InspectorOption configures an Inspector.

type Label

type Label struct {
	Base
	// contains filtered or unexported fields
}

Label is a single-line text widget often used for headers/labels.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	label := widgets.NewLabel("Title")
	label.SetAlignment(widgets.AlignCenter)
	_ = label
}

func NewLabel

func NewLabel(text string, opts ...LabelOption) *Label

NewLabel creates a new label widget.

func (*Label) Bind

func (l *Label) Bind(services runtime.Services)

Bind attaches app services.

func (*Label) Direction

func (l *Label) Direction() i18n.Direction

Direction returns the effective text direction. If a direction was explicitly set, it returns that. Otherwise, it auto-detects from the text content.

func (*Label) Measure

func (l *Label) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed for the label.

func (*Label) Render

func (l *Label) Render(ctx runtime.RenderContext)

Render draws the label.

func (*Label) RenderHTML

func (l *Label) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML returns a static HTML representation of the label.

func (*Label) SetA11yLabel

func (l *Label) SetA11yLabel(label string)

SetA11yLabel overrides the accessibility label without changing visible text.

func (*Label) SetAlignment

func (l *Label) SetAlignment(align Alignment)

SetAlignment sets text alignment.

func (*Label) SetDirection

func (l *Label) SetDirection(dir i18n.Direction)

SetDirection sets an explicit text direction override. Pass DirectionRTL for right-to-left or DirectionLTR for left-to-right. When set, auto-detection is bypassed.

func (*Label) SetStyle

func (l *Label) SetStyle(style backend.Style)

SetStyle sets the label style.

func (*Label) SetText

func (l *Label) SetText(text string)

SetText updates the label text.

func (*Label) StyleType

func (l *Label) StyleType() string

StyleType returns the selector type name.

func (*Label) Unbind

func (l *Label) Unbind()

Unbind releases app services.

func (*Label) WithAlignment deprecated

func (l *Label) WithAlignment(align Alignment) *Label

Deprecated: prefer WithLabelAlignment during construction or SetAlignment for mutation.

func (*Label) WithStyle deprecated

func (l *Label) WithStyle(style backend.Style) *Label

Deprecated: prefer WithLabelStyle during construction or SetStyle for mutation.

type LabelOption

type LabelOption = Option[Label]

LabelOption configures a Label widget.

func WithLabelA11yLabel

func WithLabelA11yLabel(label string) LabelOption

WithLabelA11yLabel sets an accessibility label override.

func WithLabelAlignment

func WithLabelAlignment(align Alignment) LabelOption

WithLabelAlignment sets the label alignment.

func WithLabelDirection

func WithLabelDirection(dir i18n.Direction) LabelOption

WithLabelDirection sets an explicit text direction (DirectionLTR or DirectionRTL). When set, auto-detection is bypassed for rendering.

func WithLabelStyle

func WithLabelStyle(style backend.Style) LabelOption

WithLabelStyle sets the label style.

type LazyLoadable

type LazyLoadable interface {
	SetLazyLoad(fn func(start, end, total int))
	SetLazyLoadThreshold(threshold int)
}

LazyLoadable represents widgets that can request more data as users scroll.

type LineChart

type LineChart struct {
	CanvasWidget
	// contains filtered or unexported fields
}

LineChart renders one or more series using a CanvasWidget.

func NewLineChart

func NewLineChart() *LineChart

NewLineChart creates an empty line chart.

func (*LineChart) AddSeries

func (c *LineChart) AddSeries(series ChartSeries)

AddSeries appends a new series.

func (*LineChart) AutoYAxis

func (c *LineChart) AutoYAxis()

AutoYAxis enables auto-scaling on the Y axis.

func (*LineChart) Bind

func (c *LineChart) Bind(services runtime.Services)

Bind attaches app services.

func (*LineChart) HandleMessage

func (c *LineChart) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled for all messages.

func (*LineChart) Layout

func (c *LineChart) Layout(bounds runtime.Rect)

Layout updates the bounds and prepares the canvas for rendering.

func (*LineChart) Measure

func (c *LineChart) Measure(constraints runtime.Constraints) runtime.Size

Measure keeps the chart flexible within constraints.

func (*LineChart) Render

func (c *LineChart) Render(ctx runtime.RenderContext)

Render draws the line chart to the buffer.

func (*LineChart) SetSeries

func (c *LineChart) SetSeries(series []ChartSeries)

SetSeries replaces the chart series.

func (*LineChart) SetYAxis

func (c *LineChart) SetYAxis(minValue, maxValue float64)

SetYAxis fixes the Y axis range.

func (*LineChart) StyleType

func (c *LineChart) StyleType() string

StyleType returns the selector type name.

func (*LineChart) Unbind

func (c *LineChart) Unbind()

Unbind releases app services.

type Link struct {
	FocusableBase
	// contains filtered or unexported fields
}

Link is a focusable text widget that renders as an OSC-8 hyperlink. In terminals that support OSC-8, the text becomes clickable.

func NewLink(label, url string) *Link

NewLink creates a new hyperlink widget.

func (*Link) Bind

func (l *Link) Bind(services runtime.Services)

Bind attaches app services.

func (*Link) HandleMessage

func (l *Link) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes input events.

func (*Link) Measure

func (l *Link) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed to display the link text.

func (*Link) Render

func (l *Link) Render(ctx runtime.RenderContext)

Render draws the link text with underline styling.

func (*Link) RenderHTML

func (l *Link) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML returns a static HTML representation of the link.

func (*Link) SetFocusStyle

func (l *Link) SetFocusStyle(s backend.Style)

SetFocusStyle sets the focused style.

func (*Link) SetLabel

func (l *Link) SetLabel(label string)

SetLabel updates the link text.

func (*Link) SetOnActivate

func (l *Link) SetOnActivate(fn func(url string))

SetOnActivate sets the callback when the link is activated (Enter key).

func (*Link) SetStyle

func (l *Link) SetStyle(s backend.Style)

SetStyle sets the normal style.

func (*Link) SetURL

func (l *Link) SetURL(url string)

SetURL updates the link URL.

func (*Link) URL

func (l *Link) URL() string

URL returns the link URL.

func (*Link) Unbind

func (l *Link) Unbind()

Unbind releases app services.

type List

type List[T any] struct {
	FocusableBase
	// contains filtered or unexported fields
}

List renders a list of items.

Example
package main

import (
	"m31labs.dev/fluffyui/backend"
	"m31labs.dev/fluffyui/runtime"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	items := []string{"alpha", "beta", "gamma"}
	adapter := widgets.NewSliceAdapter(items, func(item string, index int, selected bool, ctx runtime.RenderContext) {
		prefix := "  "
		if selected {
			prefix = "> "
		}
		ctx.Buffer.SetString(ctx.Bounds.X, ctx.Bounds.Y, prefix+item, backend.DefaultStyle())
	})
	list := widgets.NewList(adapter)
	list.SetSelected(1)
	_ = list
}

func NewList

func NewList[T any](adapter ListAdapter[T]) *List[T]

NewList creates a list widget.

func (*List[T]) Bind

func (l *List[T]) Bind(services runtime.Services)

Bind attaches app services.

func (*List[T]) CanDrop

func (l *List[T]) CanDrop(data runtime.DragData) bool

CanDrop returns true if this list accepts the given drag data.

func (*List[T]) DragOrigin

func (l *List[T]) DragOrigin() int

DragOrigin returns the index of the item being dragged, or -1 if no drag is active.

func (*List[T]) DropIndex

func (l *List[T]) DropIndex() int

DropIndex returns the current drop target index, or -1 if no drag is active.

func (*List[T]) HandleMessage

func (l *List[T]) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles navigation and drag-and-drop.

func (*List[T]) IsDraggable

func (l *List[T]) IsDraggable() bool

IsDraggable reports whether drag-and-drop reordering is enabled.

func (*List[T]) IsDragging

func (l *List[T]) IsDragging() bool

IsDragging reports whether a drag operation is currently in progress.

func (*List[T]) Measure

func (l *List[T]) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*List[T]) OnDrop

func (l *List[T]) OnDrop(data runtime.DragData) bool

OnDrop handles an external drop onto this list.

func (*List[T]) OnSelect deprecated

func (l *List[T]) OnSelect(fn func(index int, item T))

OnSelect registers a selection handler on the list.

Deprecated: Use SetOnSelect instead. This method will be removed in v1.0.

func (*List[T]) PageBy

func (l *List[T]) PageBy(pages int)

PageBy scrolls by a number of pages.

func (*List[T]) Render

func (l *List[T]) Render(ctx runtime.RenderContext)

Render draws list items.

func (*List[T]) RenderHTML

func (l *List[T]) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML renders the list as a static HTML unordered list.

func (*List[T]) ScrollBy

func (l *List[T]) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta.

func (*List[T]) ScrollTo

func (l *List[T]) ScrollTo(x, y int)

ScrollTo scrolls to an absolute index.

func (*List[T]) ScrollToEnd

func (l *List[T]) ScrollToEnd()

ScrollToEnd scrolls to the last item.

func (*List[T]) ScrollToStart

func (l *List[T]) ScrollToStart()

ScrollToStart scrolls to the first item.

func (*List[T]) SelectedIndex

func (l *List[T]) SelectedIndex() int

SelectedIndex returns the current selection index.

func (*List[T]) SelectedItem

func (l *List[T]) SelectedItem() (T, bool)

SelectedItem returns the selected item.

func (*List[T]) SetDragStyle

func (l *List[T]) SetDragStyle(style backend.Style)

SetDragStyle updates the style used for the item being dragged.

func (*List[T]) SetDraggable

func (l *List[T]) SetDraggable(enabled bool)

SetDraggable enables or disables drag-and-drop reordering. When enabled, the user can press Ctrl+G to grab a selected item, use arrow keys to move the drop indicator, Enter to drop (reorder), or Escape to cancel.

func (*List[T]) SetHTMLItemRenderer

func (l *List[T]) SetHTMLItemRenderer(r HTMLItemRenderer[T])

SetHTMLItemRenderer sets a custom HTML renderer for list items.

func (*List[T]) SetLabel

func (l *List[T]) SetLabel(label string)

SetLabel updates the accessibility label.

func (*List[T]) SetOnDrop

func (l *List[T]) SetOnDrop(fn ListOnDrop[T])

SetOnDrop registers a handler called when a drop completes.

func (*List[T]) SetOnSelect

func (l *List[T]) SetOnSelect(fn func(index int, item T))

SetOnSelect registers a selection handler.

func (*List[T]) SetSelected

func (l *List[T]) SetSelected(index int)

SetSelected updates the selected index.

func (*List[T]) SetSelectedStyle

func (l *List[T]) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected row style.

func (*List[T]) SetStyle

func (l *List[T]) SetStyle(style backend.Style)

SetStyle updates the list base style.

func (*List[T]) StyleType

func (l *List[T]) StyleType() string

StyleType returns the selector type name.

func (*List[T]) Unbind

func (l *List[T]) Unbind()

Unbind releases app services.

type ListAdapter

type ListAdapter[T any] interface {
	Count() int
	Item(index int) T
	Render(item T, index int, selected bool, ctx runtime.RenderContext)
}

ListAdapter provides data for list widgets.

func NewSignalAdapter

func NewSignalAdapter[T any](items *state.Signal[[]T], render RenderFunc[T]) ListAdapter[T]

NewSignalAdapter creates a signal adapter.

func NewSliceAdapter

func NewSliceAdapter[T any](items []T, render RenderFunc[T]) ListAdapter[T]

NewSliceAdapter creates a slice adapter.

type ListOnDrop

type ListOnDrop[T any] func(fromIndex, toIndex int, item T)

ListOnDrop is called when a drop completes on a list. It receives the source index, destination index, and the item that was moved.

type Log

type Log struct {
	FocusableBase
	// contains filtered or unexported fields
}

Log is an auto-scrolling log viewer widget with filtering and level-based coloring.

func NewLog

func NewLog(opts ...LogOption) *Log

NewLog creates a new log viewer widget.

func (*Log) AddEntry

func (l *Log) AddEntry(entry LogEntry)

AddEntry adds a log entry to the ring buffer.

func (*Log) AutoScroll

func (l *Log) AutoScroll() bool

AutoScroll returns whether auto-scrolling is enabled.

func (*Log) Bind

func (l *Log) Bind(services runtime.Services)

Bind attaches app services.

func (*Log) Clear

func (l *Log) Clear()

Clear removes all entries from the log.

func (*Log) ClipboardCopy

func (l *Log) ClipboardCopy() (string, bool)

ClipboardCopy returns visible log entries for copying.

func (*Log) Debug

func (l *Log) Debug(message string, fields ...map[string]any)

Debug adds a debug-level entry.

func (*Log) Entries

func (l *Log) Entries() []LogEntry

Entries returns a copy of all entries.

func (*Log) EntryCount

func (l *Log) EntryCount() int

EntryCount returns the number of entries in the log.

func (*Log) Error

func (l *Log) Error(message string, fields ...map[string]any)

Error adds an error-level entry.

func (*Log) FilteredEntries

func (l *Log) FilteredEntries() []LogEntry

FilteredEntries returns entries that pass the current filter.

func (*Log) HandleMessage

func (l *Log) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard input.

func (*Log) Info

func (l *Log) Info(message string, fields ...map[string]any)

Info adds an info-level entry.

func (*Log) Layout

func (l *Log) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*Log) Log

func (l *Log) Log(level LogLevel, message string, fields ...map[string]any)

Log adds a new entry to the log.

func (*Log) Measure

func (l *Log) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Log) MinLevel

func (l *Log) MinLevel() LogLevel

MinLevel returns the minimum level.

func (*Log) PageBy

func (l *Log) PageBy(pages int)

PageBy scrolls by pages.

func (*Log) Render

func (l *Log) Render(ctx runtime.RenderContext)

Render draws the log viewer.

func (*Log) ScrollBy

func (l *Log) ScrollBy(dx, dy int)

ScrollBy scrolls by delta rows.

func (*Log) ScrollTo

func (l *Log) ScrollTo(x, y int)

ScrollTo scrolls to an absolute row.

func (*Log) ScrollToEnd

func (l *Log) ScrollToEnd()

ScrollToEnd scrolls to the newest entries.

func (*Log) ScrollToStart

func (l *Log) ScrollToStart()

ScrollToStart scrolls to the oldest entries.

func (*Log) SetAutoScroll

func (l *Log) SetAutoScroll(auto bool)

SetAutoScroll enables or disables auto-scrolling.

func (*Log) SetFilter

func (l *Log) SetFilter(filter func(LogEntry) bool)

SetFilter sets the filter function.

func (*Log) SetLabel

func (l *Log) SetLabel(label string)

SetLabel sets the accessibility label.

func (*Log) SetLevelStyle

func (l *Log) SetLevelStyle(level LogLevel, style backend.Style)

SetLevelStyle sets the style for a specific level.

func (*Log) SetMinLevel

func (l *Log) SetMinLevel(level LogLevel)

SetMinLevel sets the minimum level to display.

func (*Log) SetShowTime

func (l *Log) SetShowTime(show bool)

SetShowTime enables or disables timestamp display.

func (*Log) SetStyle

func (l *Log) SetStyle(style backend.Style)

SetStyle sets the base style.

func (*Log) ShowTime

func (l *Log) ShowTime() bool

ShowTime returns whether timestamps are shown.

func (*Log) StyleType

func (l *Log) StyleType() string

StyleType returns the selector type name.

func (*Log) Unbind

func (l *Log) Unbind()

Unbind releases app services.

func (*Log) Warn

func (l *Log) Warn(message string, fields ...map[string]any)

Warn adds a warning-level entry.

func (*Log) Write

func (l *Log) Write(p []byte) (n int, err error)

Write implements io.Writer, parsing lines as log entries.

type LogEntry

type LogEntry struct {
	Time    time.Time
	Level   LogLevel
	Message string
	Fields  map[string]any
}

LogEntry represents a single log message.

func (LogEntry) Format

func (e LogEntry) Format(showTime bool) string

Format returns a formatted string representation of the entry.

type LogLevel

type LogLevel int

LogLevel represents the severity of a log entry.

const (
	// LogDebug is for debug-level messages.
	LogDebug LogLevel = iota
	// LogInfo is for informational messages.
	LogInfo
	// LogWarn is for warning messages.
	LogWarn
	// LogError is for error messages.
	LogError
)

func (LogLevel) String

func (l LogLevel) String() string

String returns a string representation of the log level.

type LogOption

type LogOption func(*Log)

LogOption is a functional option for Log.

func WithAutoScroll

func WithAutoScroll(auto bool) LogOption

WithAutoScroll enables or disables auto-scrolling.

func WithLevelColors

func WithLevelColors(colors map[LogLevel]backend.Style) LogOption

WithLevelColors sets custom level-based colors.

func WithLogFilter

func WithLogFilter(filter func(LogEntry) bool) LogOption

WithLogFilter sets a custom filter function.

func WithLogStyle

func WithLogStyle(s backend.Style) LogOption

WithLogStyle sets the base style.

func WithMaxLines

func WithMaxLines(max int) LogOption

WithMaxLines sets the maximum number of lines to keep.

func WithMinLevel

func WithMinLevel(level LogLevel) LogOption

WithMinLevel sets the minimum level to display.

func WithShowTime

func WithShowTime(show bool) LogOption

WithShowTime enables or disables timestamp display.

type MarkdownViewer

type MarkdownViewer struct {
	FocusableBase
	// contains filtered or unexported fields
}

MarkdownViewer renders markdown content as styled terminal text. Supports headings, bold, italic, code blocks, links, lists, tables, and blockquotes. Content is scrollable when it exceeds the available height.

func NewMarkdownViewer

func NewMarkdownViewer(content string, opts ...MarkdownViewerOption) *MarkdownViewer

NewMarkdownViewer creates a new MarkdownViewer widget.

func (*MarkdownViewer) Content

func (m *MarkdownViewer) Content() string

Content returns the raw markdown content.

func (*MarkdownViewer) HandleMessage

func (m *MarkdownViewer) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles scroll input.

func (*MarkdownViewer) Layout

func (m *MarkdownViewer) Layout(bounds runtime.Rect)

Layout stores bounds and updates wrapping.

func (*MarkdownViewer) Measure

func (m *MarkdownViewer) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the required size.

func (*MarkdownViewer) PageBy

func (m *MarkdownViewer) PageBy(pages int)

PageBy scrolls by pages.

func (*MarkdownViewer) Render

func (m *MarkdownViewer) Render(ctx runtime.RenderContext)

Render draws the visible lines.

func (*MarkdownViewer) RenderHTML

func (m *MarkdownViewer) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML renders the markdown content as static HTML.

func (*MarkdownViewer) ScrollBy

func (m *MarkdownViewer) ScrollBy(dx, dy int)

ScrollBy scrolls the content by delta.

func (*MarkdownViewer) ScrollTo

func (m *MarkdownViewer) ScrollTo(x, y int)

ScrollTo scrolls to an absolute offset.

func (*MarkdownViewer) ScrollToEnd

func (m *MarkdownViewer) ScrollToEnd()

ScrollToEnd scrolls to the bottom.

func (*MarkdownViewer) ScrollToStart

func (m *MarkdownViewer) ScrollToStart()

ScrollToStart scrolls to the top.

func (*MarkdownViewer) SetContent

func (m *MarkdownViewer) SetContent(content string)

SetContent updates the markdown content.

func (*MarkdownViewer) StyleType

func (m *MarkdownViewer) StyleType() string

StyleType returns the selector type name.

type MarkdownViewerOption

type MarkdownViewerOption = Option[MarkdownViewer]

MarkdownViewerOption configures a MarkdownViewer widget.

func WithMarkdownMaxWidth

func WithMarkdownMaxWidth(width int) MarkdownViewerOption

WithMarkdownMaxWidth sets a maximum content width for readability. Lines will be wrapped at this width even if more space is available. A value of 0 disables the limit (uses full available width).

func WithMarkdownTheme

func WithMarkdownTheme(t *theme.Theme) MarkdownViewerOption

WithMarkdownTheme sets a custom theme for markdown rendering.

func WithWordWrap

func WithWordWrap(enabled bool) MarkdownViewerOption

WithWordWrap enables or disables word wrapping.

type MaskedInput

type MaskedInput struct {
	FocusableBase
	// contains filtered or unexported fields
}

MaskedInput is a text input widget with a format mask. The mask defines the expected format for input using special characters:

  • # = digit (0-9)
  • A = letter (a-zA-Z)
  • * = alphanumeric (letter or digit)
  • ? = any character
  • \ = escape next character as literal

Any other character in the mask is treated as a literal that is automatically inserted and cannot be edited.

func NewMaskedInput

func NewMaskedInput(mask string, opts ...MaskedInputOption) *MaskedInput

NewMaskedInput creates a new masked input widget.

func (*MaskedInput) Bind

func (m *MaskedInput) Bind(services runtime.Services)

Bind attaches app services.

func (*MaskedInput) Blur

func (m *MaskedInput) Blur()

Blur removes focus and announces validation errors if any.

func (*MaskedInput) ClipboardCopy

func (m *MaskedInput) ClipboardCopy() (string, bool)

ClipboardCopy returns the masked value for copying.

func (*MaskedInput) ClipboardCut

func (m *MaskedInput) ClipboardCut() (string, bool)

ClipboardCut returns the masked value and clears the input.

func (*MaskedInput) ClipboardPaste

func (m *MaskedInput) ClipboardPaste(text string) bool

ClipboardPaste inserts text, extracting valid characters.

func (*MaskedInput) CursorPos

func (m *MaskedInput) CursorPos() int

CursorPos returns the current cursor position in the masked display.

func (*MaskedInput) Errors

func (m *MaskedInput) Errors() []string

Errors returns the latest validation error messages.

func (*MaskedInput) HandleMessage

func (m *MaskedInput) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*MaskedInput) Layout

func (m *MaskedInput) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*MaskedInput) Mask

func (m *MaskedInput) Mask() string

Mask returns the current mask pattern.

func (*MaskedInput) MaskedValue

func (m *MaskedInput) MaskedValue() string

MaskedValue returns the formatted value with mask characters included.

func (*MaskedInput) Measure

func (m *MaskedInput) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed for the input.

func (*MaskedInput) Placeholder

func (m *MaskedInput) Placeholder() rune

Placeholder returns the placeholder character.

func (*MaskedInput) Render

func (m *MaskedInput) Render(ctx runtime.RenderContext)

Render draws the masked input field.

func (*MaskedInput) SetFocusStyle

func (m *MaskedInput) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*MaskedInput) SetLabel

func (m *MaskedInput) SetLabel(label string)

SetLabel sets the accessibility label.

func (*MaskedInput) SetMask

func (m *MaskedInput) SetMask(mask string)

SetMask updates the mask pattern.

func (*MaskedInput) SetOnChange

func (m *MaskedInput) SetOnChange(fn func(value string))

SetOnChange sets the callback for when value changes.

func (*MaskedInput) SetOnSubmit

func (m *MaskedInput) SetOnSubmit(fn func(value string))

SetOnSubmit sets the callback for when Enter is pressed.

func (*MaskedInput) SetPlaceholder

func (m *MaskedInput) SetPlaceholder(r rune)

SetPlaceholder sets the placeholder character.

func (*MaskedInput) SetStyle

func (m *MaskedInput) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*MaskedInput) SetValidators

func (m *MaskedInput) SetValidators(validators ...forms.Validator)

SetValidators updates validation rules.

func (*MaskedInput) SetValue

func (m *MaskedInput) SetValue(value string)

SetValue sets the raw value (without mask characters).

func (*MaskedInput) StyleType

func (m *MaskedInput) StyleType() string

StyleType returns the selector type name.

func (*MaskedInput) Unbind

func (m *MaskedInput) Unbind()

Unbind releases app services.

func (*MaskedInput) Valid

func (m *MaskedInput) Valid() bool

Valid reports whether validation passes.

func (*MaskedInput) Validate

func (m *MaskedInput) Validate() []forms.ValidationError

Validate runs validation rules and returns validation errors.

func (*MaskedInput) Value

func (m *MaskedInput) Value() string

Value returns the raw input value without mask characters.

type MaskedInputOption

type MaskedInputOption func(*MaskedInput)

MaskedInputOption is a functional option for MaskedInput.

func WithMaskedFocusStyle

func WithMaskedFocusStyle(s backend.Style) MaskedInputOption

WithMaskedFocusStyle sets the focused style.

func WithMaskedLabel

func WithMaskedLabel(label string) MaskedInputOption

WithMaskedLabel sets the accessibility label.

func WithMaskedStyle

func WithMaskedStyle(s backend.Style) MaskedInputOption

WithMaskedStyle sets the normal style.

func WithPlaceholder

func WithPlaceholder(r rune) MaskedInputOption

WithPlaceholder sets the placeholder character for unfilled positions.

type Menu struct {
	FocusableBase
	Items []*MenuItem
	// contains filtered or unexported fields
}

Menu renders a vertical menu.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	menu := widgets.NewMenu(
		&widgets.MenuItem{Title: "Open", Shortcut: "Ctrl+O"},
		&widgets.MenuItem{Title: "Save", Shortcut: "Ctrl+S"},
	)
	_ = menu
}

func NewMenu

func NewMenu(items ...*MenuItem) *Menu

NewMenu creates a new menu.

func (m *Menu) Bind(services runtime.Services)

Bind attaches app services.

func (m *Menu) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles navigation and selection.

func (m *Menu) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (m *Menu) PageBy(pages int)

PageBy scrolls by a number of pages.

func (m *Menu) Render(ctx runtime.RenderContext)

Render draws the menu.

func (m *Menu) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta.

func (m *Menu) ScrollTo(x, y int)

ScrollTo scrolls to an absolute row index.

func (m *Menu) ScrollToEnd()

ScrollToEnd scrolls to the last row.

func (m *Menu) ScrollToStart()

ScrollToStart scrolls to the first row.

func (m *Menu) SetItems(items ...*MenuItem)

SetItems replaces the menu items and clears cached rows.

func (m *Menu) SetLabel(label string)

SetLabel updates the accessibility label.

func (m *Menu) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected row style.

func (m *Menu) SetStyle(style backend.Style)

SetStyle updates the menu base style.

func (m *Menu) StyleType() string

StyleType returns the selector type name.

func (m *Menu) Unbind()

Unbind releases app services.

type MenuItem struct {
	ID       string
	Title    string
	Shortcut string
	Children []*MenuItem
	Expanded bool
	Disabled bool
	OnSelect func()
}

MenuItem describes a menu entry.

type MultiSelect

type MultiSelect struct {
	FocusableBase
	// contains filtered or unexported fields
}

MultiSelect renders a list of options with multiple selection.

func NewMultiSelect

func NewMultiSelect(options ...MultiSelectOption) *MultiSelect

NewMultiSelect creates a new multi-select list.

func (*MultiSelect) Bind

func (m *MultiSelect) Bind(services runtime.Services)

Bind attaches app services.

func (*MultiSelect) HandleMessage

func (m *MultiSelect) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes navigation and toggling.

func (*MultiSelect) Measure

func (m *MultiSelect) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*MultiSelect) Render

func (m *MultiSelect) Render(ctx runtime.RenderContext)

Render draws the options list.

func (*MultiSelect) SelectedOptions

func (m *MultiSelect) SelectedOptions() []MultiSelectOption

SelectedOptions returns the currently selected options.

func (*MultiSelect) SetLabel

func (m *MultiSelect) SetLabel(label string)

SetLabel updates the accessibility label.

func (*MultiSelect) SetOnChange

func (m *MultiSelect) SetOnChange(fn func(selected []MultiSelectOption))

SetOnChange registers a change callback.

func (*MultiSelect) SetOptions

func (m *MultiSelect) SetOptions(options []MultiSelectOption)

SetOptions updates the list of options.

func (*MultiSelect) StyleType

func (m *MultiSelect) StyleType() string

StyleType returns the selector type name.

func (*MultiSelect) Unbind

func (m *MultiSelect) Unbind()

Unbind releases app services.

type MultiSelectOption

type MultiSelectOption struct {
	Label    string
	Value    any
	Disabled bool
}

MultiSelectOption represents an option in a multi-select list.

type MultilineInput

type MultilineInput struct {
	FocusableBase
	// contains filtered or unexported fields
}

MultilineInput is a text input that supports multiple lines.

func NewMultilineInput

func NewMultilineInput() *MultilineInput

NewMultilineInput creates a new multiline input widget.

func (*MultilineInput) Bind

func (m *MultilineInput) Bind(services runtime.Services)

Bind attaches app services.

func (*MultilineInput) Clear

func (m *MultilineInput) Clear()

Clear clears all content.

func (*MultilineInput) ClipboardCopy

func (m *MultilineInput) ClipboardCopy() (string, bool)

ClipboardCopy returns selected text, or all text if no selection.

func (*MultilineInput) ClipboardCut

func (m *MultilineInput) ClipboardCut() (string, bool)

ClipboardCut returns selected text and deletes it, or all text if no selection.

func (*MultilineInput) ClipboardPaste

func (m *MultilineInput) ClipboardPaste(text string) bool

ClipboardPaste inserts text at the cursor.

func (*MultilineInput) CursorOffset

func (m *MultilineInput) CursorOffset() int

CursorOffset returns the cursor offset in the full text.

func (*MultilineInput) CursorPosition

func (m *MultilineInput) CursorPosition() (x, y int)

CursorPosition returns the cursor coordinates within the input.

func (*MultilineInput) CursorWordLeft

func (m *MultilineInput) CursorWordLeft()

CursorWordLeft moves the cursor to the previous word boundary.

func (*MultilineInput) CursorWordRight

func (m *MultilineInput) CursorWordRight()

CursorWordRight moves the cursor to the next word boundary.

func (*MultilineInput) Errors

func (m *MultilineInput) Errors() []string

Errors returns the latest validation error messages.

func (*MultilineInput) GetSelectedText

func (m *MultilineInput) GetSelectedText() string

GetSelectedText returns the currently selected text.

func (*MultilineInput) GetSelection

func (m *MultilineInput) GetSelection() Selection

GetSelection returns the current selection range (character offsets).

func (*MultilineInput) HandleMessage

func (m *MultilineInput) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes input for multiline editing.

func (*MultilineInput) HasSelection

func (m *MultilineInput) HasSelection() bool

HasSelection returns true if text is selected.

func (*MultilineInput) Measure

func (m *MultilineInput) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the preferred size.

func (*MultilineInput) OnChange deprecated

func (m *MultilineInput) OnChange(fn func(text string))

OnChange sets the callback for when the multiline input text changes.

Deprecated: Use SetOnChange instead. This method will be removed in v1.0.

func (*MultilineInput) OnSubmit deprecated

func (m *MultilineInput) OnSubmit(fn func(text string))

OnSubmit sets the callback for when Ctrl+Enter is pressed.

Deprecated: Use SetOnSubmit instead. This method will be removed in v1.0.

func (*MultilineInput) Render

func (m *MultilineInput) Render(ctx runtime.RenderContext)

Render draws the multiline input.

func (*MultilineInput) SelectAll

func (m *MultilineInput) SelectAll()

SelectAll selects all text.

func (*MultilineInput) SelectLine

func (m *MultilineInput) SelectLine()

SelectLine selects the current line.

func (*MultilineInput) SelectNone

func (m *MultilineInput) SelectNone()

SelectNone clears the selection.

func (*MultilineInput) SelectWord

func (m *MultilineInput) SelectWord()

SelectWord selects the word at the cursor position.

func (*MultilineInput) SetCursorOffset

func (m *MultilineInput) SetCursorOffset(offset int)

SetCursorOffset moves the cursor to the given offset.

func (*MultilineInput) SetCursorPosition

func (m *MultilineInput) SetCursorPosition(x, y int)

SetCursorPosition moves the cursor to the given coordinates.

func (*MultilineInput) SetFocusStyle

func (m *MultilineInput) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*MultilineInput) SetLabel

func (m *MultilineInput) SetLabel(label string)

SetLabel sets the accessibility label.

func (*MultilineInput) SetOnChange

func (m *MultilineInput) SetOnChange(fn func(text string))

SetOnChange sets the callback for when text changes.

func (*MultilineInput) SetOnSubmit

func (m *MultilineInput) SetOnSubmit(fn func(text string))

SetOnSubmit sets the callback (Ctrl+Enter to submit).

func (*MultilineInput) SetSelection

func (m *MultilineInput) SetSelection(sel Selection)

SetSelection sets the selection range (character offsets).

func (*MultilineInput) SetStyle

func (m *MultilineInput) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*MultilineInput) SetText

func (m *MultilineInput) SetText(text string)

SetText sets the content.

func (*MultilineInput) SetValidators

func (m *MultilineInput) SetValidators(validators ...forms.Validator)

SetValidators updates validation rules for the multiline input.

func (*MultilineInput) StyleType

func (m *MultilineInput) StyleType() string

StyleType returns the selector type name.

func (*MultilineInput) Text

func (m *MultilineInput) Text() string

Text returns the full text content.

func (*MultilineInput) Unbind

func (m *MultilineInput) Unbind()

Unbind releases app services.

func (*MultilineInput) Valid

func (m *MultilineInput) Valid() bool

Valid reports whether validation passes.

func (*MultilineInput) Validate

func (m *MultilineInput) Validate() []forms.ValidationError

Validate runs validation rules and returns validation errors.

type MutableListAdapter

type MutableListAdapter[T any] interface {
	ListAdapter[T]
	// Move moves the item at fromIndex to toIndex, shifting other items as needed.
	Move(fromIndex, toIndex int)
}

MutableListAdapter extends ListAdapter with mutation support for drag-and-drop reordering.

type MutableSliceAdapter

type MutableSliceAdapter[T any] struct {
	SliceAdapter[T]
}

MutableSliceAdapter adapts a mutable slice to a MutableListAdapter.

func NewMutableSliceAdapter

func NewMutableSliceAdapter[T any](items []T, render RenderFunc[T]) *MutableSliceAdapter[T]

NewMutableSliceAdapter creates a mutable slice adapter.

func (*MutableSliceAdapter[T]) Items

func (m *MutableSliceAdapter[T]) Items() []T

Items returns the current slice (useful for reading back after reorder).

func (*MutableSliceAdapter[T]) Move

func (m *MutableSliceAdapter[T]) Move(fromIndex, toIndex int)

Move moves an item from one index to another.

type Notification

type Notification struct {
	ID      string
	Title   string
	Body    string
	Level   NotificationLevel
	Time    time.Time
	Read    bool
	Actions []NotificationAction
}

Notification represents a persistent notification entry.

type NotificationAction

type NotificationAction struct {
	Label   string
	OnClick func()
}

NotificationAction represents an optional action button on a notification.

type NotificationCenter

type NotificationCenter struct {
	FocusableBase
	// contains filtered or unexported fields
}

NotificationCenter is a persistent, dismissible notification panel. When collapsed it shows an unread count badge; when expanded it shows a navigable list of notifications.

func NewNotificationCenter

func NewNotificationCenter() *NotificationCenter

NewNotificationCenter creates a new notification center widget.

func (*NotificationCenter) Add

func (nc *NotificationCenter) Add(n Notification)

Add adds a notification. It announces new notifications via the a11y announcer.

func (*NotificationCenter) AddSimple

func (nc *NotificationCenter) AddSimple(level NotificationLevel, title, body string)

AddSimple is a convenience helper that creates a notification with an auto-generated ID.

func (*NotificationCenter) Bind

func (nc *NotificationCenter) Bind(services runtime.Services)

Bind attaches app services.

func (*NotificationCenter) Dismiss

func (nc *NotificationCenter) Dismiss(id string)

Dismiss removes a notification by ID.

func (*NotificationCenter) DismissAll

func (nc *NotificationCenter) DismissAll()

DismissAll clears all notifications.

func (*NotificationCenter) Expanded

func (nc *NotificationCenter) Expanded() bool

Expanded returns whether the panel is currently open.

func (*NotificationCenter) HandleMessage

func (nc *NotificationCenter) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard input for navigation and actions.

func (*NotificationCenter) MarkAllRead

func (nc *NotificationCenter) MarkAllRead()

MarkAllRead marks all notifications as read.

func (*NotificationCenter) MarkRead

func (nc *NotificationCenter) MarkRead(id string)

MarkRead marks a notification as read by ID.

func (*NotificationCenter) Measure

func (nc *NotificationCenter) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*NotificationCenter) Notifications

func (nc *NotificationCenter) Notifications() []Notification

Notifications returns a copy of all notifications.

func (*NotificationCenter) Render

func (nc *NotificationCenter) Render(ctx runtime.RenderContext)

Render draws the notification center.

func (*NotificationCenter) Selected

func (nc *NotificationCenter) Selected() int

Selected returns the currently selected index.

func (*NotificationCenter) SetExpanded

func (nc *NotificationCenter) SetExpanded(expanded bool)

SetExpanded opens or closes the notification panel.

func (*NotificationCenter) SetHeaderStyle

func (nc *NotificationCenter) SetHeaderStyle(style backend.Style)

SetHeaderStyle sets the style for the header line.

func (*NotificationCenter) SetLabel

func (nc *NotificationCenter) SetLabel(label string)

SetLabel sets the accessibility label.

func (*NotificationCenter) SetMaxItems

func (nc *NotificationCenter) SetMaxItems(max int)

SetMaxItems sets the maximum number of notifications to retain. Older notifications are dropped when the cap is exceeded.

func (*NotificationCenter) SetOnDismiss

func (nc *NotificationCenter) SetOnDismiss(fn func(id string))

SetOnDismiss registers a callback invoked when a notification is dismissed.

func (*NotificationCenter) SetSelectedStyle

func (nc *NotificationCenter) SetSelectedStyle(style backend.Style)

SetSelectedStyle sets the style for the selected notification row.

func (*NotificationCenter) SetStyle

func (nc *NotificationCenter) SetStyle(style backend.Style)

SetStyle sets the base rendering style.

func (*NotificationCenter) StyleType

func (nc *NotificationCenter) StyleType() string

StyleType returns the selector type name.

func (*NotificationCenter) Unbind

func (nc *NotificationCenter) Unbind()

Unbind releases app services.

func (*NotificationCenter) UnreadCount

func (nc *NotificationCenter) UnreadCount() int

UnreadCount returns the number of unread notifications.

type NotificationLevel

type NotificationLevel int

NotificationLevel indicates notification severity.

const (
	// NotificationInfo is for informational notifications.
	NotificationInfo NotificationLevel = iota
	// NotificationSuccess is for success notifications.
	NotificationSuccess
	// NotificationWarning is for warning notifications.
	NotificationWarning
	// NotificationError is for error notifications.
	NotificationError
)

func (NotificationLevel) String

func (l NotificationLevel) String() string

String returns a string representation of the notification level.

type NumberInput

type NumberInput struct {
	FocusableBase
	// contains filtered or unexported fields
}

NumberInput is a focusable numeric input with increment/decrement controls. It renders as [v] 42 [^] and supports keyboard-driven value changes.

func NewNumberInput

func NewNumberInput(value *state.Signal[float64], opts ...NumberInputOption) *NumberInput

NewNumberInput creates a numeric input bound to the given signal.

func (*NumberInput) Bind

func (n *NumberInput) Bind(services runtime.Services)

Bind attaches app services.

func (*NumberInput) HandleMessage

func (n *NumberInput) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input for the number input.

func (*NumberInput) Max

func (n *NumberInput) Max() float64

Max returns the maximum allowed value.

func (*NumberInput) Measure

func (n *NumberInput) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*NumberInput) Min

func (n *NumberInput) Min() float64

Min returns the minimum allowed value.

func (*NumberInput) Render

func (n *NumberInput) Render(ctx runtime.RenderContext)

Render draws the number input widget.

func (*NumberInput) SetStyle

func (n *NumberInput) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*NumberInput) SetValue

func (n *NumberInput) SetValue(v float64)

SetValue updates the current value, clamping to the min/max range.

func (*NumberInput) Step

func (n *NumberInput) Step() float64

Step returns the increment/decrement step size.

func (*NumberInput) StyleType

func (n *NumberInput) StyleType() string

StyleType returns the selector type name for FSS.

func (*NumberInput) Unbind

func (n *NumberInput) Unbind()

Unbind releases app services.

func (*NumberInput) Value

func (n *NumberInput) Value() float64

Value returns the current numeric value.

type NumberInputOption

type NumberInputOption = Option[NumberInput]

NumberInputOption configures a NumberInput widget.

func WithNumberOnChange

func WithNumberOnChange(fn func(float64)) NumberInputOption

WithNumberOnChange sets the value change handler.

func WithNumberRange

func WithNumberRange(min, max float64) NumberInputOption

WithNumberRange sets the minimum and maximum allowed values.

func WithNumberStep

func WithNumberStep(step float64) NumberInputOption

WithNumberStep sets the increment/decrement step size.

type Option

type Option[T any] func(*T)

Option defines a configurable option for a widget.

type Orientation

type Orientation int

Orientation describes slider orientation.

const (
	Horizontal Orientation = iota
	Vertical
)

type Pagination

type Pagination struct {
	FocusableBase
	// contains filtered or unexported fields
}

Pagination is a focusable page navigation widget. It renders a page indicator like: < 1 2 [3] 4 5 ... 10 >

func NewPagination

func NewPagination(total, pageSize int) *Pagination

NewPagination creates a pagination widget.

func (*Pagination) Bind

func (p *Pagination) Bind(services runtime.Services)

Bind attaches app services.

func (*Pagination) HandleMessage

func (p *Pagination) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*Pagination) Measure

func (p *Pagination) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Pagination) Page

func (p *Pagination) Page() int

Page returns the current page (1-based).

func (*Pagination) Render

func (p *Pagination) Render(ctx runtime.RenderContext)

Render draws the pagination widget.

func (*Pagination) SetOnChange

func (p *Pagination) SetOnChange(fn func(page int))

SetOnChange sets the page change handler.

func (*Pagination) SetPage

func (p *Pagination) SetPage(page int)

SetPage sets the current page (1-based).

func (*Pagination) SetStyle

func (p *Pagination) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*Pagination) StyleType

func (p *Pagination) StyleType() string

StyleType returns the selector type name.

func (*Pagination) TotalPages

func (p *Pagination) TotalPages() int

TotalPages returns the total number of pages.

func (*Pagination) Unbind

func (p *Pagination) Unbind()

Unbind releases app services.

type PaletteCommand

type PaletteCommand struct {
	ID          string
	Label       string
	Description string
	Shortcut    string // display only, e.g. "Ctrl+S"
	Category    string // for grouping
	OnExecute   func()
}

PaletteCommand describes an executable action in the command palette.

type PaletteItem

type PaletteItem struct {
	ID          string // Unique identifier
	Category    string // Optional category for grouping (e.g., "Recent", "Files", "Actions")
	Label       string // Display text
	Description string // Optional secondary text
	Shortcut    string // Optional keyboard shortcut hint
	Data        any    // Custom data for the action
}

PaletteItem represents a single item in the palette.

type PaletteWidget

type PaletteWidget struct {
	FocusableBase
	// contains filtered or unexported fields
}

PaletteWidget provides a fuzzy-filtering command palette overlay.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	palette := widgets.NewPaletteWidget("Commands")
	palette.SetItems([]widgets.PaletteItem{
		{ID: "new", Category: "File", Label: "New file", Shortcut: "Ctrl+N"},
		{ID: "open", Category: "File", Label: "Open file", Shortcut: "Ctrl+O"},
	})
	_ = palette
}

func NewPaletteWidget

func NewPaletteWidget(title string) *PaletteWidget

NewPaletteWidget creates a new palette widget.

func (*PaletteWidget) Bind

func (p *PaletteWidget) Bind(services runtime.Services)

Bind attaches app services.

func (*PaletteWidget) HandleMessage

func (p *PaletteWidget) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*PaletteWidget) Layout

func (p *PaletteWidget) Layout(bounds runtime.Rect)

Layout positions the widget (centered overlay).

func (*PaletteWidget) Measure

func (p *PaletteWidget) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the preferred size.

func (*PaletteWidget) Query

func (p *PaletteWidget) Query() string

Query returns the current query string.

func (*PaletteWidget) Render

func (p *PaletteWidget) Render(ctx runtime.RenderContext)

Render draws the palette.

func (*PaletteWidget) SelectedItem

func (p *PaletteWidget) SelectedItem() *PaletteItem

SelectedItem returns the currently selected item, or nil if none.

func (*PaletteWidget) SetFilterFn

func (p *PaletteWidget) SetFilterFn(fn func(item PaletteItem, query string) bool)

SetFilterFn sets a custom filter function.

func (*PaletteWidget) SetItems

func (p *PaletteWidget) SetItems(items []PaletteItem)

SetItems sets the palette items.

func (*PaletteWidget) SetMaxVisible

func (p *PaletteWidget) SetMaxVisible(max int)

SetMaxVisible sets the maximum visible items.

func (*PaletteWidget) SetOnSelect

func (p *PaletteWidget) SetOnSelect(fn func(item PaletteItem))

SetOnSelect sets the callback for item selection.

func (*PaletteWidget) SetPlaceholder

func (p *PaletteWidget) SetPlaceholder(placeholder string)

SetPlaceholder sets the query placeholder text.

func (*PaletteWidget) SetScoreFn

func (p *PaletteWidget) SetScoreFn(fn func(item PaletteItem, query string) int)

SetScoreFn sets a custom scoring function.

func (*PaletteWidget) SetStyles

func (p *PaletteWidget) SetStyles(bg, border, title, query, item, selected, category backend.Style)

SetStyles configures the palette appearance.

func (*PaletteWidget) StyleType

func (p *PaletteWidget) StyleType() string

StyleType returns the selector type name.

func (*PaletteWidget) Unbind

func (p *PaletteWidget) Unbind()

Unbind releases app services.

type Panel

type Panel struct {
	Base
	// contains filtered or unexported fields
}

Panel is a container widget with optional border and background.

Example
package main

import (
	"m31labs.dev/fluffyui/backend"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	panel := widgets.NewPanel(widgets.NewLabel("Details")).WithBorder(backend.DefaultStyle())
	panel.SetTitle("Summary")
	_ = panel
}

func NewPanel

func NewPanel(child runtime.Widget, opts ...PanelOption) *Panel

NewPanel creates a new panel widget.

func (*Panel) Bind

func (p *Panel) Bind(services runtime.Services)

Bind attaches app services.

func (*Panel) ChildWidgets

func (p *Panel) ChildWidgets() []runtime.Widget

ChildWidgets returns the panel's child widget.

func (*Panel) HandleMessage

func (p *Panel) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage delegates to child.

func (*Panel) Layout

func (p *Panel) Layout(bounds runtime.Rect)

Layout positions the panel and its child.

func (*Panel) Measure

func (p *Panel) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed for the panel.

func (*Panel) Render

func (p *Panel) Render(ctx runtime.RenderContext)

Render draws the panel.

func (*Panel) SetBorder

func (p *Panel) SetBorder(enabled bool)

SetBorder enables or disables the border.

func (*Panel) SetBorderStyle

func (p *Panel) SetBorderStyle(style backend.Style)

SetBorderStyle sets the border style and enables the border.

func (*Panel) SetStyle

func (p *Panel) SetStyle(style backend.Style)

SetStyle sets the panel background style.

func (*Panel) SetTitle

func (p *Panel) SetTitle(title string)

SetTitle sets the panel title (shown in border).

func (*Panel) StyleType

func (p *Panel) StyleType() string

StyleType returns the selector type name.

func (*Panel) Unbind

func (p *Panel) Unbind()

Unbind releases app services.

func (*Panel) WithBorder deprecated

func (p *Panel) WithBorder(style backend.Style) *Panel

Deprecated: prefer WithPanelBorder during construction or SetBorderStyle for mutation.

func (*Panel) WithStyle deprecated

func (p *Panel) WithStyle(style backend.Style) *Panel

Deprecated: prefer WithPanelStyle during construction or SetStyle for mutation.

func (*Panel) WithTitle deprecated

func (p *Panel) WithTitle(title string) *Panel

Deprecated: prefer WithPanelTitle during construction or SetTitle for mutation.

type PanelOption

type PanelOption = Option[Panel]

PanelOption configures a Panel widget.

func WithPanelBorder

func WithPanelBorder(style backend.Style) PanelOption

WithPanelBorder enables a border with the given style.

func WithPanelStyle

func WithPanelStyle(style backend.Style) PanelOption

WithPanelStyle sets the panel background style.

func WithPanelTitle

func WithPanelTitle(title string) PanelOption

WithPanelTitle sets the panel title.

type PerformanceDashboard

type PerformanceDashboard struct {
	Component
	// contains filtered or unexported fields
}

PerformanceDashboard renders render-loop performance metrics.

func NewPerformanceDashboard

func NewPerformanceDashboard(sampler *runtime.RenderSampler, opts ...PerformanceDashboardOption) *PerformanceDashboard

NewPerformanceDashboard creates a dashboard wired to a render sampler.

func (*PerformanceDashboard) Bind

func (d *PerformanceDashboard) Bind(services runtime.Services)

Bind attaches app services and schedules refreshes.

func (*PerformanceDashboard) Measure

func (d *PerformanceDashboard) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*PerformanceDashboard) Render

Render draws the dashboard summary.

func (*PerformanceDashboard) SetRefreshInterval

func (d *PerformanceDashboard) SetRefreshInterval(interval time.Duration)

SetRefreshInterval updates the auto-refresh interval.

func (*PerformanceDashboard) SetSampler

func (d *PerformanceDashboard) SetSampler(sampler *runtime.RenderSampler)

SetSampler updates the render sampler.

func (*PerformanceDashboard) StyleType

func (d *PerformanceDashboard) StyleType() string

StyleType returns the selector type name.

func (*PerformanceDashboard) Unbind

func (d *PerformanceDashboard) Unbind()

Unbind releases subscriptions.

type PerformanceDashboardOption

type PerformanceDashboardOption = Option[PerformanceDashboard]

PerformanceDashboardOption configures the dashboard.

func WithPerformanceHeaderStyle

func WithPerformanceHeaderStyle(style backend.Style) PerformanceDashboardOption

WithPerformanceHeaderStyle overrides the header style.

func WithPerformanceLabel

func WithPerformanceLabel(label string) PerformanceDashboardOption

WithPerformanceLabel sets the accessibility label.

func WithPerformanceMutedStyle

func WithPerformanceMutedStyle(style backend.Style) PerformanceDashboardOption

WithPerformanceMutedStyle overrides the muted style.

func WithPerformanceRefresh

func WithPerformanceRefresh(interval time.Duration) PerformanceDashboardOption

WithPerformanceRefresh sets the refresh interval (0 disables auto refresh).

func WithPerformanceStyle

func WithPerformanceStyle(style backend.Style) PerformanceDashboardOption

WithPerformanceStyle overrides the base style.

type Popover

type Popover struct {
	Base

	Child                runtime.Widget
	Anchor               runtime.Rect
	Placement            PopoverPlacement
	Gap                  int
	MatchAnchorWidth     bool
	DismissOnOutside     bool
	DismissOnMoveOutside bool
	DismissOnEscape      bool
	// contains filtered or unexported fields
}

Popover positions a child widget relative to an anchor rect.

func NewPopover

func NewPopover(anchor runtime.Rect, child runtime.Widget, opts ...PopoverOption) *Popover

NewPopover creates a popover anchored to the given rect.

func (*Popover) Bind

func (p *Popover) Bind(services runtime.Services)

Bind attaches app services. It saves the currently focused widget so focus can be restored on close.

func (*Popover) ChildWidgets

func (p *Popover) ChildWidgets() []runtime.Widget

ChildWidgets returns the popover content.

func (*Popover) HandleMessage

func (p *Popover) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards input to the child and optionally dismisses.

func (*Popover) HitSelf

func (p *Popover) HitSelf() bool

HitSelf ensures the popover receives mouse events for its bounds.

func (*Popover) Layout

func (p *Popover) Layout(bounds runtime.Rect)

Layout positions the child relative to the anchor.

func (*Popover) Measure

func (p *Popover) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the full available size.

func (*Popover) Mount

func (p *Popover) Mount()

Mount marks the popover as active.

func (*Popover) Render

func (p *Popover) Render(ctx runtime.RenderContext)

Render draws the child widget.

func (*Popover) Unbind

func (p *Popover) Unbind()

Unbind releases app services and restores focus to the widget that was focused before the popover opened.

func (*Popover) Unmount

func (p *Popover) Unmount()

Unmount closes the popover.

type PopoverOption

type PopoverOption = Option[Popover]

PopoverOption configures a popover.

func WithPopoverDismissOnEscape

func WithPopoverDismissOnEscape(enabled bool) PopoverOption

WithPopoverDismissOnEscape sets whether to dismiss on Escape.

func WithPopoverDismissOnMoveOutside

func WithPopoverDismissOnMoveOutside(enabled bool) PopoverOption

WithPopoverDismissOnMoveOutside sets whether to dismiss on mouse move outside.

func WithPopoverDismissOnOutside

func WithPopoverDismissOnOutside(enabled bool) PopoverOption

WithPopoverDismissOnOutside sets whether to dismiss on outside clicks.

func WithPopoverGap

func WithPopoverGap(gap int) PopoverOption

WithPopoverGap sets the gap between anchor and popover.

func WithPopoverMatchAnchorWidth

func WithPopoverMatchAnchorWidth(enabled bool) PopoverOption

WithPopoverMatchAnchorWidth sets whether the popover should match anchor width.

func WithPopoverOnClose

func WithPopoverOnClose(fn func()) PopoverOption

WithPopoverOnClose registers a callback invoked when the popover closes.

func WithPopoverPlacement

func WithPopoverPlacement(placement PopoverPlacement) PopoverOption

WithPopoverPlacement sets the placement behavior.

type PopoverPlacement

type PopoverPlacement int

PopoverPlacement controls where the popover appears relative to the anchor.

const (
	PopoverAuto PopoverPlacement = iota
	PopoverBelow
	PopoverAbove
)

type Progress

type Progress struct {
	Base
	Value       float64
	Max         float64
	Label       string
	ShowPercent bool
	Style       GaugeStyle
	// contains filtered or unexported fields
}

Progress displays a determinate progress bar.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	progress := widgets.NewProgress()
	progress.Value = 65
	_ = progress
}

func NewProgress

func NewProgress() *Progress

NewProgress creates a progress widget.

func (*Progress) Bind

func (p *Progress) Bind(services runtime.Services)

Bind attaches app services.

func (*Progress) HandleMessage

func (p *Progress) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled.

func (*Progress) Measure

func (p *Progress) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Progress) Render

func (p *Progress) Render(ctx runtime.RenderContext)

Render draws the progress bar.

func (*Progress) StyleType

func (p *Progress) StyleType() string

StyleType returns the selector type name.

func (*Progress) Unbind

func (p *Progress) Unbind()

Unbind releases app services.

type Radio

type Radio struct {
	FocusableBase
	// contains filtered or unexported fields
}

Radio is a single radio option.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	group := widgets.NewRadioGroup()
	first := widgets.NewRadio("First", group)
	second := widgets.NewRadio("Second", group)
	group.SetSelected(1)
	_ = first
	_ = second
}

func NewRadio

func NewRadio(label string, group *RadioGroup) *Radio

NewRadio creates a radio option and registers it with the group.

func (*Radio) Bind

func (r *Radio) Bind(services runtime.Services)

Bind attaches app services.

func (*Radio) HandleMessage

func (r *Radio) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles selection.

func (*Radio) Measure

func (r *Radio) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Radio) Render

func (r *Radio) Render(ctx runtime.RenderContext)

Render draws the radio.

func (*Radio) SetDisabled

func (r *Radio) SetDisabled(disabled bool)

SetDisabled updates disabled state.

func (*Radio) SetFocusStyle

func (r *Radio) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*Radio) SetLabel

func (r *Radio) SetLabel(label string)

SetLabel updates the radio label.

func (*Radio) SetStyle

func (r *Radio) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*Radio) StyleType

func (r *Radio) StyleType() string

StyleType returns the selector type name.

func (*Radio) Unbind

func (r *Radio) Unbind()

Unbind releases app services.

type RadioGroup

type RadioGroup struct {
	// contains filtered or unexported fields
}

RadioGroup manages a set of radio buttons.

func NewRadioGroup

func NewRadioGroup() *RadioGroup

NewRadioGroup creates an empty group.

func (*RadioGroup) OnChange deprecated

func (g *RadioGroup) OnChange(fn func(index int))

OnChange registers a selection callback on the radio group.

Deprecated: Use SetOnChange instead. This method will be removed in v1.0.

func (*RadioGroup) Selected

func (g *RadioGroup) Selected() int

Selected returns the selected index.

func (*RadioGroup) SetOnChange

func (g *RadioGroup) SetOnChange(fn func(index int))

SetOnChange registers a selection callback.

func (*RadioGroup) SetSelected

func (g *RadioGroup) SetSelected(index int)

SetSelected updates the selected index.

type RangeSlider

type RangeSlider struct {
	FocusableBase
	// contains filtered or unexported fields
}

RangeSlider is a dual-handle slider.

func NewRangeSlider

func NewRangeSlider(minValue, maxValue *state.Signal[float64], opts ...RangeSliderOption) *RangeSlider

NewRangeSlider creates a range slider.

func (*RangeSlider) Bind

func (r *RangeSlider) Bind(services runtime.Services)

Bind attaches app services.

func (*RangeSlider) HandleMessage

func (r *RangeSlider) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage updates value on input.

func (*RangeSlider) Measure

func (r *RangeSlider) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*RangeSlider) Render

func (r *RangeSlider) Render(ctx runtime.RenderContext)

Render draws the range slider.

func (*RangeSlider) SetLabel

func (r *RangeSlider) SetLabel(label string)

SetLabel updates the accessibility label.

func (*RangeSlider) SetRange

func (r *RangeSlider) SetRange(min, max, step float64)

SetRange updates min/max/step.

func (*RangeSlider) SetStyles

func (r *RangeSlider) SetStyles(base, track, thumb, fill backend.Style)

SetStyles updates slider styles.

func (*RangeSlider) SetValues

func (r *RangeSlider) SetValues(minValue, maxValue float64)

SetValues updates the min/max values.

func (*RangeSlider) StyleType

func (r *RangeSlider) StyleType() string

StyleType returns the selector type name.

func (*RangeSlider) Unbind

func (r *RangeSlider) Unbind()

Unbind releases app services.

func (*RangeSlider) Values

func (r *RangeSlider) Values() (float64, float64)

Values returns the current min/max values.

type RangeSliderOption

type RangeSliderOption = Option[RangeSlider]

RangeSliderOption configures range slider behavior.

func WithRangeSliderOrientation

func WithRangeSliderOrientation(orientation Orientation) RangeSliderOption

WithRangeSliderOrientation sets orientation.

func WithRangeSliderRange

func WithRangeSliderRange(min, max, step float64) RangeSliderOption

WithRangeSliderRange configures min, max, and step.

func WithRangeSliderShowValue

func WithRangeSliderShowValue(show bool) RangeSliderOption

WithRangeSliderShowValue toggles value label.

func WithRangeSliderStyles

func WithRangeSliderStyles(track, thumb, fill backend.Style) RangeSliderOption

WithRangeSliderStyles configures styles.

func WithRangeSliderValueFormat

func WithRangeSliderValueFormat(format string) RangeSliderOption

WithRangeSliderValueFormat sets format string.

type Rating

type Rating struct {
	FocusableBase
	// contains filtered or unexported fields
}

Rating is a focusable star rating widget. It renders filled and empty stars based on the current value.

func NewRating

func NewRating(maxStars int) *Rating

NewRating creates a rating widget with the given max stars.

func (*Rating) Bind

func (r *Rating) Bind(services runtime.Services)

Bind attaches app services.

func (*Rating) HandleMessage

func (r *Rating) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*Rating) Max

func (r *Rating) Max() int

Max returns the maximum rating value.

func (*Rating) Measure

func (r *Rating) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Rating) Render

func (r *Rating) Render(ctx runtime.RenderContext)

Render draws the rating widget.

func (*Rating) SetOnChange

func (r *Rating) SetOnChange(fn func(int))

SetOnChange sets the value change handler.

func (*Rating) SetStyle

func (r *Rating) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*Rating) SetValue

func (r *Rating) SetValue(value int)

SetValue sets the current rating value.

func (*Rating) StyleType

func (r *Rating) StyleType() string

StyleType returns the selector type name.

func (*Rating) Unbind

func (r *Rating) Unbind()

Unbind releases app services.

func (*Rating) Value

func (r *Rating) Value() int

Value returns the current rating value.

type RenderFunc

type RenderFunc[T any] func(item T, index int, selected bool, ctx runtime.RenderContext)

RenderFunc renders an item.

type RichText

type RichText struct {
	FocusableBase
	// contains filtered or unexported fields
}

RichText renders markdown content with scrolling.

func NewRichText

func NewRichText(content string, opts ...RichTextOption) *RichText

NewRichText creates a new RichText widget.

func (*RichText) Bind

func (r *RichText) Bind(services runtime.Services)

Bind attaches app services.

func (*RichText) HandleMessage

func (r *RichText) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles scroll input.

func (*RichText) Layout

func (r *RichText) Layout(bounds runtime.Rect)

Layout stores bounds and updates wrapping.

func (*RichText) Measure

func (r *RichText) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the required size.

func (*RichText) PageBy

func (r *RichText) PageBy(pages int)

PageBy scrolls by pages.

func (*RichText) Render

func (r *RichText) Render(ctx runtime.RenderContext)

Render draws the visible lines.

func (*RichText) ScrollBy

func (r *RichText) ScrollBy(dx, dy int)

ScrollBy scrolls the content by delta.

func (*RichText) ScrollTo

func (r *RichText) ScrollTo(x, y int)

ScrollTo scrolls to an absolute offset.

func (*RichText) ScrollToAnchor

func (r *RichText) ScrollToAnchor(anchor string)

ScrollToAnchor scrolls to a heading anchor if available.

func (*RichText) ScrollToEnd

func (r *RichText) ScrollToEnd()

ScrollToEnd scrolls to the bottom.

func (*RichText) ScrollToStart

func (r *RichText) ScrollToStart()

ScrollToStart scrolls to the top.

func (*RichText) SetContent

func (r *RichText) SetContent(content string)

SetContent updates the markdown content.

func (*RichText) SetLabel

func (r *RichText) SetLabel(label string)

SetLabel updates the accessibility label.

func (*RichText) SetLines

func (r *RichText) SetLines(lines []markdown.StyledLine)

SetLines sets pre-rendered styled lines.

func (*RichText) SetRenderer

func (r *RichText) SetRenderer(renderer *markdown.Renderer)

SetRenderer replaces the markdown renderer.

func (*RichText) SetShowScrollbar

func (r *RichText) SetShowScrollbar(show bool)

SetShowScrollbar toggles the scrollbar.

func (*RichText) SetSource

func (r *RichText) SetSource(source string)

SetSource sets the markdown source style key.

func (*RichText) SetStyle

func (r *RichText) SetStyle(style backend.Style)

SetStyle updates the base style.

func (*RichText) StyleType

func (r *RichText) StyleType() string

StyleType returns the selector type name.

func (*RichText) Unbind

func (r *RichText) Unbind()

Unbind releases app services.

type RichTextOption

type RichTextOption = Option[RichText]

RichTextOption configures a RichText widget.

func WithRichTextLabel

func WithRichTextLabel(label string) RichTextOption

WithRichTextLabel sets the accessibility label.

func WithRichTextRenderer

func WithRichTextRenderer(renderer *markdown.Renderer) RichTextOption

WithRichTextRenderer uses a custom markdown renderer.

func WithRichTextScrollbar

func WithRichTextScrollbar(show bool) RichTextOption

WithRichTextScrollbar toggles the scrollbar.

func WithRichTextSource

func WithRichTextSource(source string) RichTextOption

WithRichTextSource sets the markdown source style key.

func WithRichTextStyle

func WithRichTextStyle(style backend.Style) RichTextOption

WithRichTextStyle sets the base style.

type ScrollView

type ScrollView struct {
	FocusableBase
	// contains filtered or unexported fields
}

ScrollView provides a scrollable container.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	content := widgets.NewText("Line 1\nLine 2\nLine 3")
	scroll := widgets.NewScrollView(content)
	scroll.ScrollBy(0, 1)
	_ = scroll
}

func NewScrollView

func NewScrollView(content runtime.Widget) *ScrollView

NewScrollView creates a scroll view for content.

func (*ScrollView) Bind

func (s *ScrollView) Bind(services runtime.Services)

Bind attaches app services.

func (*ScrollView) ChildWidgets

func (s *ScrollView) ChildWidgets() []runtime.Widget

ChildWidgets returns the content widget.

func (*ScrollView) ContentSize

func (s *ScrollView) ContentSize() runtime.Size

ContentSize returns the current scrollable content size.

func (*ScrollView) HandleMessage

func (s *ScrollView) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles scrolling input.

func (*ScrollView) Layout

func (s *ScrollView) Layout(bounds runtime.Rect)

Layout positions the content.

func (*ScrollView) Measure

func (s *ScrollView) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*ScrollView) PageBy

func (s *ScrollView) PageBy(pages int)

PageBy scrolls by page count.

func (*ScrollView) Render

func (s *ScrollView) Render(ctx runtime.RenderContext)

Render draws the visible portion of content.

func (*ScrollView) ScrollBy

func (s *ScrollView) ScrollBy(dx, dy int)

ScrollBy scrolls the view by delta.

func (*ScrollView) ScrollTo

func (s *ScrollView) ScrollTo(x, y int)

ScrollTo scrolls to the specified offset.

func (*ScrollView) ScrollToEnd

func (s *ScrollView) ScrollToEnd()

ScrollToEnd scrolls to the bottom-right.

func (*ScrollView) ScrollToStart

func (s *ScrollView) ScrollToStart()

ScrollToStart scrolls to the top-left.

func (*ScrollView) SetBehavior

func (s *ScrollView) SetBehavior(behavior scroll.ScrollBehavior)

SetBehavior updates scroll behavior.

func (*ScrollView) SetContent

func (s *ScrollView) SetContent(content runtime.Widget)

SetContent updates the scroll content.

func (*ScrollView) SetLabel

func (s *ScrollView) SetLabel(label string)

SetLabel updates the accessibility label.

func (*ScrollView) SetStyle

func (s *ScrollView) SetStyle(style backend.Style)

SetStyle updates the scroll view background style.

func (*ScrollView) Unbind

func (s *ScrollView) Unbind()

Unbind releases app services.

type SearchWidget

type SearchWidget struct {
	FocusableBase
	// contains filtered or unexported fields
}

SearchWidget provides a search input overlay for the chat view.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	search := widgets.NewSearchWidget()
	search.SetOnSearch(func(query string) {})
	search.SetMatchInfo(1, 4)
	_ = search
}

func NewSearchWidget

func NewSearchWidget() *SearchWidget

NewSearchWidget creates a new search widget.

func (*SearchWidget) Bind

func (s *SearchWidget) Bind(services runtime.Services)

Bind attaches app services.

func (*SearchWidget) HandleMessage

func (s *SearchWidget) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*SearchWidget) Layout

func (s *SearchWidget) Layout(bounds runtime.Rect)

Layout positions at the bottom of the screen.

func (*SearchWidget) Measure

func (s *SearchWidget) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the preferred size (fixed height bar).

func (*SearchWidget) Query

func (s *SearchWidget) Query() string

Query returns the current search query.

func (*SearchWidget) Render

func (s *SearchWidget) Render(ctx runtime.RenderContext)

Render draws the search bar.

func (*SearchWidget) RenderHTML

func (s *SearchWidget) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML renders the search widget as a static HTML search input.

func (*SearchWidget) SetLabel

func (s *SearchWidget) SetLabel(label string)

SetLabel updates the accessibility label.

func (*SearchWidget) SetMatchInfo

func (s *SearchWidget) SetMatchInfo(current, total int)

SetMatchInfo updates the match count display.

func (*SearchWidget) SetOnClose

func (s *SearchWidget) SetOnClose(fn func())

SetOnClose sets the close callback.

func (*SearchWidget) SetOnNavigate

func (s *SearchWidget) SetOnNavigate(next, prev func())

SetOnNavigate sets callbacks for navigating search matches.

func (*SearchWidget) SetOnSearch

func (s *SearchWidget) SetOnSearch(fn func(query string))

SetOnSearch sets the search callback.

func (*SearchWidget) SetQuery

func (s *SearchWidget) SetQuery(query string)

SetQuery updates the search query and triggers search callback.

func (*SearchWidget) SetStyles

func (s *SearchWidget) SetStyles(bg, border, text, match backend.Style)

SetStyles configures appearance.

func (*SearchWidget) StyleType

func (s *SearchWidget) StyleType() string

StyleType returns the selector type name.

func (*SearchWidget) Unbind

func (s *SearchWidget) Unbind()

Unbind releases app services.

type Searchable

type Searchable interface {
	SetQuery(query string)
	Query() string
}

Searchable represents widgets that expose a searchable query.

type Section

type Section struct {
	FocusableBase
	// contains filtered or unexported fields
}

Section represents a collapsible section in the sidebar.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	section := widgets.NewSection("Pipeline")
	section.SetItems([]widgets.SectionItem{
		{Icon: '>', Text: "Build", Active: true},
		{Icon: 'o', Text: "Test"},
		{Icon: 'x', Text: "Deploy"},
	})
	section.SetMaxItems(3)
	_ = section
}

func NewSection

func NewSection(title string) *Section

NewSection creates a new collapsible section.

func (*Section) Bind

func (s *Section) Bind(services runtime.Services)

Bind attaches app services.

func (*Section) ContentHeight

func (s *Section) ContentHeight() int

ContentHeight returns the height needed for content (items).

func (*Section) HandleMessage

func (s *Section) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes input.

func (*Section) IsExpanded

func (s *Section) IsExpanded() bool

IsExpanded returns the expanded state.

func (*Section) Layout

func (s *Section) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*Section) Measure

func (s *Section) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the preferred size.

func (*Section) Render

func (s *Section) Render(ctx runtime.RenderContext)

Render draws the section.

func (*Section) SetExpanded

func (s *Section) SetExpanded(expanded bool)

SetExpanded sets the expanded state.

func (*Section) SetIconStyle

func (s *Section) SetIconStyle(style backend.Style)

SetIconStyle configures the default icon style.

func (*Section) SetItems

func (s *Section) SetItems(items []SectionItem)

SetItems updates the section items.

func (*Section) SetMaxItems

func (s *Section) SetMaxItems(max int)

SetMaxItems sets the maximum items to show when expanded.

func (*Section) SetStyles

func (s *Section) SetStyles(header, item, active, completed, pending, activeIcon backend.Style)

SetStyles configures the section appearance.

func (*Section) SetTitle

func (s *Section) SetTitle(title string)

SetTitle updates the section title.

func (*Section) StyleType

func (s *Section) StyleType() string

StyleType returns the selector type name.

func (*Section) Toggle

func (s *Section) Toggle()

Toggle toggles the expanded state.

func (*Section) Unbind

func (s *Section) Unbind()

Unbind releases app services.

type SectionItem

type SectionItem struct {
	Icon    rune   // Status icon (✓, →, ○, ⟳)
	Text    string // Item text
	Active  bool   // Whether this item is currently active/in-progress
	SubText string // Optional secondary text (e.g., spinner detail)
}

SectionItem represents a single item in a collapsible section.

type SegmentedControl

type SegmentedControl struct {
	FocusableBase
	// contains filtered or unexported fields
}

SegmentedControl is a horizontal row of mutually exclusive options.

func NewSegmentedControl

func NewSegmentedControl(options ...string) *SegmentedControl

NewSegmentedControl creates a segmented control with the given options.

func (*SegmentedControl) Bind

func (s *SegmentedControl) Bind(services runtime.Services)

Bind attaches app services.

func (*SegmentedControl) HandleMessage

func (s *SegmentedControl) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard navigation.

func (*SegmentedControl) Measure

func (s *SegmentedControl) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*SegmentedControl) Render

func (s *SegmentedControl) Render(ctx runtime.RenderContext)

Render draws the segmented control as [Option A | Option B | Option C].

func (*SegmentedControl) Selected

func (s *SegmentedControl) Selected() int

Selected returns the currently selected index.

func (*SegmentedControl) SetOnChange

func (s *SegmentedControl) SetOnChange(fn func(index int, label string))

SetOnChange sets the change handler.

func (*SegmentedControl) SetSelected

func (s *SegmentedControl) SetSelected(index int)

SetSelected updates the selected index.

func (*SegmentedControl) SetSelectedStyle

func (s *SegmentedControl) SetSelectedStyle(style backend.Style)

SetSelectedStyle sets the selected segment style.

func (*SegmentedControl) SetStyle

func (s *SegmentedControl) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*SegmentedControl) StyleType

func (s *SegmentedControl) StyleType() string

StyleType returns the selector type name.

func (*SegmentedControl) Unbind

func (s *SegmentedControl) Unbind()

Unbind releases app services.

type Select

type Select struct {
	FocusableBase
	// contains filtered or unexported fields
}

Select is a dropdown-like selector (inline).

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	selector := widgets.NewSelect(
		widgets.SelectOption{Label: "Small", Value: "S"},
		widgets.SelectOption{Label: "Medium", Value: "M"},
		widgets.SelectOption{Label: "Large", Value: "L"},
	)
	selector.SetSelected(1)
	_ = selector
}

func NewSelect

func NewSelect(options ...SelectOption) *Select

NewSelect creates a single-selection picker from the given options. Use SetOnChange to handle selection. Apply WithDropdownMode for overlay rendering.

func (*Select) Apply

func (s *Select) Apply(opts ...SelectModeOption) *Select

Apply configures the select with mode options.

func (*Select) Bind

func (s *Select) Bind(services runtime.Services)

Bind attaches app services.

func (*Select) HandleMessage

func (s *Select) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage changes selection.

func (*Select) Measure

func (s *Select) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Select) Render

func (s *Select) Render(ctx runtime.RenderContext)

Render draws the select.

func (*Select) Selected

func (s *Select) Selected() int

Selected returns the current selection index.

func (*Select) SelectedOption

func (s *Select) SelectedOption() (SelectOption, bool)

SelectedOption returns the current option.

func (*Select) SetFocusStyle

func (s *Select) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*Select) SetLabel

func (s *Select) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Select) SetMode

func (s *Select) SetMode(mode SelectMode)

SetMode updates the select rendering mode.

func (*Select) SetOnChange

func (s *Select) SetOnChange(fn func(option SelectOption))

SetOnChange sets the change handler.

func (*Select) SetSelected

func (s *Select) SetSelected(index int)

SetSelected updates the selected index.

func (*Select) SetStyle

func (s *Select) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*Select) StyleType

func (s *Select) StyleType() string

StyleType returns the selector type name.

func (*Select) Unbind

func (s *Select) Unbind()

Unbind releases app services.

type SelectMode

type SelectMode int

SelectMode controls how the select renders.

const (
	SelectInline SelectMode = iota
	SelectDropdown
)

type SelectModeOption

type SelectModeOption = Option[Select]

SelectModeOption configures select behavior.

func WithDropdownMode

func WithDropdownMode() SelectModeOption

WithDropdownMode enables dropdown overlay rendering.

func WithInlineMode

func WithInlineMode() SelectModeOption

WithInlineMode forces inline rendering.

type SelectOption

type SelectOption struct {
	Label    string
	Value    any
	Disabled bool
}

SelectOption represents a selectable option.

type Selectable

type Selectable interface {
	// GetSelection returns the current selection range.
	GetSelection() Selection

	// SetSelection sets the selection range.
	SetSelection(sel Selection)

	// SelectAll selects all text.
	SelectAll()

	// SelectNone clears the selection.
	SelectNone()

	// SelectWord selects the word at the cursor position.
	SelectWord()

	// SelectLine selects the current line.
	SelectLine()

	// HasSelection returns true if text is selected.
	HasSelection() bool

	// GetSelectedText returns the currently selected text.
	GetSelectedText() string
}

Selectable is implemented by widgets that support text selection.

type Selection

type Selection struct {
	Start int
	End   int
}

Selection represents a text selection range.

func (Selection) IsEmpty

func (s Selection) IsEmpty() bool

IsEmpty returns true if no text is selected.

func (Selection) Length

func (s Selection) Length() int

Length returns the length of the selection.

func (Selection) Normalize

func (s Selection) Normalize() Selection

Normalize returns a Selection with Start <= End.

type Sidebar struct {
	FocusableBase
	// contains filtered or unexported fields
}

Sidebar renders a vertical navigation panel with keyboard support.

Items can be nested via Children. Nested items are expanded/collapsed with Left/Right or Enter keys. Up/Down moves selection. Enter activates the OnSelect callback of the focused item.

func NewSidebar

func NewSidebar(items ...SidebarItem) *Sidebar

NewSidebar creates a new sidebar navigation widget.

func (*Sidebar) Bind

func (s *Sidebar) Bind(services runtime.Services)

Bind attaches app services.

func (*Sidebar) Expanded

func (s *Sidebar) Expanded() bool

Expanded reports whether the sidebar is expanded.

func (*Sidebar) GetItems

func (s *Sidebar) GetItems() []SidebarItem

Items returns the current sidebar items.

func (*Sidebar) HandleMessage

func (s *Sidebar) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard navigation.

func (*Sidebar) Measure

func (s *Sidebar) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Sidebar) PageBy

func (s *Sidebar) PageBy(pages int)

PageBy scrolls by a number of pages.

func (*Sidebar) Render

func (s *Sidebar) Render(ctx runtime.RenderContext)

Render draws the sidebar.

func (*Sidebar) ScrollBy

func (s *Sidebar) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta.

func (*Sidebar) ScrollTo

func (s *Sidebar) ScrollTo(x, y int)

ScrollTo scrolls to an absolute row index.

func (*Sidebar) ScrollToEnd

func (s *Sidebar) ScrollToEnd()

ScrollToEnd scrolls to the last row.

func (*Sidebar) ScrollToStart

func (s *Sidebar) ScrollToStart()

ScrollToStart scrolls to the first row.

func (*Sidebar) Selected

func (s *Sidebar) Selected() int

Selected returns the currently selected flat index.

func (*Sidebar) SelectedItem

func (s *Sidebar) SelectedItem() *SidebarItem

SelectedItem returns the currently selected SidebarItem, or nil.

func (*Sidebar) SetExpanded

func (s *Sidebar) SetExpanded(expanded bool)

SetExpanded controls whether the sidebar is expanded (visible) or collapsed.

func (*Sidebar) SetItems

func (s *Sidebar) SetItems(items ...SidebarItem)

SetItems replaces the sidebar items.

func (*Sidebar) SetLabel

func (s *Sidebar) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Sidebar) SetSelectedStyle

func (s *Sidebar) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected row style.

func (*Sidebar) SetStyle

func (s *Sidebar) SetStyle(style backend.Style)

SetStyle updates the sidebar base style.

func (*Sidebar) SetWidth

func (s *Sidebar) SetWidth(w int)

SetWidth sets the desired fixed width. 0 means fill available width.

func (*Sidebar) StyleType

func (s *Sidebar) StyleType() string

StyleType returns the selector type name for FSS stylesheet targeting.

func (*Sidebar) Unbind

func (s *Sidebar) Unbind()

Unbind releases app services.

func (*Sidebar) Width

func (s *Sidebar) Width() int

Width returns the desired fixed width.

type SidebarItem

type SidebarItem struct {
	Label    string
	Icon     string // optional single-char icon prefix
	OnSelect func()
	Badge    string        // optional badge text drawn right-aligned
	Children []SidebarItem // for nested navigation
	Expanded bool
}

SidebarItem represents a single entry in a Sidebar navigation.

type SignalAdapter

type SignalAdapter[T any] struct {
	// contains filtered or unexported fields
}

SignalAdapter adapts a signal slice to a ListAdapter.

func (*SignalAdapter[T]) Count

func (s *SignalAdapter[T]) Count() int

Count returns the item count.

func (*SignalAdapter[T]) Item

func (s *SignalAdapter[T]) Item(index int) T

Item returns an item.

func (*SignalAdapter[T]) Render

func (s *SignalAdapter[T]) Render(item T, index int, selected bool, ctx runtime.RenderContext)

Render draws an item.

type SignalLabel

type SignalLabel struct {
	Base
	// contains filtered or unexported fields
}

SignalLabel is a tiny label bound to a signal. SignalLabel demonstrates managing subscriptions in Mount/Unmount with a state.Scheduler.

Example
package main

import (
	"m31labs.dev/fluffyui/state"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	signal := state.NewSignal("Ready")
	label := widgets.NewSignalLabel(signal, state.DirectScheduler)
	_ = label
}

func NewSignalLabel

func NewSignalLabel(source state.Readable[string], scheduler state.Scheduler) *SignalLabel

NewSignalLabel creates a new signal-backed label.

func (*SignalLabel) Bind

func (s *SignalLabel) Bind(services runtime.Services)

Bind attaches app services.

func (*SignalLabel) Measure

func (s *SignalLabel) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed for the label.

func (*SignalLabel) Mount

func (s *SignalLabel) Mount()

Mount subscribes to signal changes.

func (*SignalLabel) Render

func (s *SignalLabel) Render(ctx runtime.RenderContext)

Render draws the label.

func (*SignalLabel) SetA11yLabel

func (s *SignalLabel) SetA11yLabel(label string)

SetA11yLabel overrides the accessibility label without changing visible text.

func (*SignalLabel) SetAlignment

func (s *SignalLabel) SetAlignment(align Alignment)

SetAlignment sets text alignment.

func (*SignalLabel) SetStyle

func (s *SignalLabel) SetStyle(style backend.Style)

SetStyle sets the label style.

func (*SignalLabel) StyleType

func (s *SignalLabel) StyleType() string

StyleType returns the selector type name.

func (*SignalLabel) Text

func (s *SignalLabel) Text() string

Text returns the current label text.

func (*SignalLabel) Unbind

func (s *SignalLabel) Unbind()

Unbind releases app services.

func (*SignalLabel) Unmount

func (s *SignalLabel) Unmount()

Unmount unsubscribes from signal changes.

type SimpleWidget

type SimpleWidget struct {
	Base

	MeasureFunc       func(runtime.Constraints) runtime.Size
	LayoutFunc        func(runtime.Rect)
	RenderFunc        func(runtime.RenderContext)
	HandleMessageFunc func(runtime.Message) runtime.HandleResult
	HTMLRenderFunc    func(runtime.HTMLContext) runtime.HTML
	// contains filtered or unexported fields
}

SimpleWidget provides function hooks for quick widgets with Base styling.

func NewSimpleWidget

func NewSimpleWidget() *SimpleWidget

NewSimpleWidget creates a SimpleWidget.

func (*SimpleWidget) Bind

func (s *SimpleWidget) Bind(services runtime.Services)

Bind attaches app services.

func (*SimpleWidget) HandleMessage

func (s *SimpleWidget) HandleMessage(msg runtime.Message) runtime.HandleResult

func (*SimpleWidget) Layout

func (s *SimpleWidget) Layout(bounds runtime.Rect)

func (*SimpleWidget) Measure

func (s *SimpleWidget) Measure(constraints runtime.Constraints) runtime.Size

func (*SimpleWidget) Render

func (s *SimpleWidget) Render(ctx runtime.RenderContext)

func (*SimpleWidget) RenderHTML

func (s *SimpleWidget) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML returns a static HTML representation of the widget.

func (*SimpleWidget) Unbind

func (s *SimpleWidget) Unbind()

Unbind releases app services.

type Skeleton

type Skeleton struct {
	Component
	// contains filtered or unexported fields
}

Skeleton is an animated placeholder widget that indicates loading state. It renders alternating block characters that shift with each tick.

func NewSkeleton

func NewSkeleton(width, height int) *Skeleton

NewSkeleton creates a skeleton placeholder with the given dimensions.

func (*Skeleton) Frame

func (s *Skeleton) Frame() int

Frame returns the current animation frame.

func (*Skeleton) HandleMessage

func (s *Skeleton) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage advances animation on ticks. Skips frame advancement when reduced motion is active.

func (*Skeleton) IsAnimating

func (s *Skeleton) IsAnimating() bool

IsAnimating returns whether animation is enabled.

func (*Skeleton) Measure

func (s *Skeleton) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Skeleton) Render

func (s *Skeleton) Render(ctx runtime.RenderContext)

Render draws the skeleton placeholder. When reduced motion is enabled, a uniform static pattern is shown instead of the shimmering animation.

func (*Skeleton) SetAnimate

func (s *Skeleton) SetAnimate(animate bool)

SetAnimate enables or disables animation.

func (*Skeleton) SetStyle

func (s *Skeleton) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*Skeleton) StyleType

func (s *Skeleton) StyleType() string

StyleType returns the selector type name.

type SkipNav

type SkipNav struct {
	FocusableBase
	// contains filtered or unexported fields
}

SkipNav is a skip-navigation landmark widget that lets keyboard users jump past navigation elements directly to main content. This is an essential accessibility pattern for screen reader and keyboard-only users.

SkipNav is only visible when focused (zero height when unfocused). When the user presses Enter, focus transfers to the target widget.

func NewSkipNav

func NewSkipNav(label string, target runtime.Widget) *SkipNav

NewSkipNav creates a skip-navigation widget with the given label and target. The label is displayed when focused (e.g., "Skip to main content"). The target is the widget that receives focus when the skip nav is activated.

func (*SkipNav) Bind

func (s *SkipNav) Bind(services runtime.Services)

Bind attaches app services.

func (*SkipNav) FocusAffectsLayout

func (s *SkipNav) FocusAffectsLayout() bool

FocusAffectsLayout returns true because the skip nav appears/disappears based on focus state, which changes the layout.

func (*SkipNav) HandleMessage

func (s *SkipNav) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input. Enter activates the skip nav and transfers focus to the target widget.

func (*SkipNav) Label

func (s *SkipNav) Label() string

Label returns the skip nav label text.

func (*SkipNav) Measure

func (s *SkipNav) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size. When unfocused, the widget has zero height so it takes no visual space. When focused, it renders as a single line.

func (*SkipNav) Render

func (s *SkipNav) Render(ctx runtime.RenderContext)

Render draws the skip nav label when focused.

func (*SkipNav) SetLabel

func (s *SkipNav) SetLabel(label string)

SetLabel updates the skip nav label text.

func (*SkipNav) SetStyle

func (s *SkipNav) SetStyle(style backend.Style)

SetStyle sets the display style used when the skip nav is visible.

func (*SkipNav) SetTarget

func (s *SkipNav) SetTarget(target runtime.Widget)

SetTarget updates the focus target widget.

func (*SkipNav) StyleType

func (s *SkipNav) StyleType() string

StyleType returns the selector type name.

func (*SkipNav) Target

func (s *SkipNav) Target() runtime.Widget

Target returns the focus target widget.

func (*SkipNav) Unbind

func (s *SkipNav) Unbind()

Unbind releases app services.

type SliceAdapter

type SliceAdapter[T any] struct {
	// contains filtered or unexported fields
}

SliceAdapter adapts a slice to a ListAdapter.

func (*SliceAdapter[T]) Count

func (s *SliceAdapter[T]) Count() int

Count returns the item count.

func (*SliceAdapter[T]) Item

func (s *SliceAdapter[T]) Item(index int) T

Item returns the item at index.

func (*SliceAdapter[T]) Render

func (s *SliceAdapter[T]) Render(item T, index int, selected bool, ctx runtime.RenderContext)

Render renders the item.

type SlideDirection

type SlideDirection int

SlideDirection indicates a slide direction.

const (
	DirectionLeft SlideDirection = iota
	DirectionRight
	DirectionUp
	DirectionDown
)

type Slider

type Slider struct {
	FocusableBase
	// contains filtered or unexported fields
}

Slider is a focusable value slider.

func NewSlider

func NewSlider(value *state.Signal[float64], opts ...SliderOption) *Slider

NewSlider creates a draggable value slider bound to the given signal. The signal's value is clamped to the slider's min/max range (default 0-100). Configure with SliderOption functions like WithSliderRange and WithSliderStep.

func (*Slider) Bind

func (s *Slider) Bind(services runtime.Services)

Bind attaches app services.

func (*Slider) HandleMessage

func (s *Slider) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage updates value on input.

func (*Slider) Measure

func (s *Slider) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Slider) Render

func (s *Slider) Render(ctx runtime.RenderContext)

Render draws the slider.

func (*Slider) SetLabel

func (s *Slider) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Slider) SetRange

func (s *Slider) SetRange(min, max, step float64)

SetRange updates min/max/step.

func (*Slider) SetStyles

func (s *Slider) SetStyles(base, track, thumb, fill backend.Style)

SetStyles updates slider styles.

func (*Slider) SetValue

func (s *Slider) SetValue(value float64)

SetValue updates the slider value.

func (*Slider) StyleType

func (s *Slider) StyleType() string

StyleType returns the selector type name.

func (*Slider) Unbind

func (s *Slider) Unbind()

Unbind releases app services.

func (*Slider) Value

func (s *Slider) Value() float64

Value returns the current value.

type SliderOption

type SliderOption = Option[Slider]

SliderOption configures slider behavior.

func WithSliderOrientation

func WithSliderOrientation(orientation Orientation) SliderOption

WithSliderOrientation sets orientation.

func WithSliderRange

func WithSliderRange(min, max, step float64) SliderOption

WithSliderRange configures min, max, and step.

func WithSliderShowValue

func WithSliderShowValue(show bool) SliderOption

WithSliderShowValue toggles value label.

func WithSliderStyles

func WithSliderStyles(track, thumb, fill backend.Style) SliderOption

WithSliderStyles configures styles.

func WithSliderValueFormat

func WithSliderValueFormat(format string) SliderOption

WithSliderValueFormat sets format string.

type SortDirection

type SortDirection int

SortDirection indicates the direction of column sorting.

const (
	// SortNone means no sorting is applied.
	SortNone SortDirection = iota
	// SortAsc sorts in ascending order.
	SortAsc
	// SortDesc sorts in descending order.
	SortDesc
)

type Sparkline

type Sparkline struct {
	Base
	Data  *state.Signal[[]float64]
	Width int
	Style backend.Style
	// contains filtered or unexported fields
}

Sparkline renders a compact single-line chart.

Example
package main

import (
	"m31labs.dev/fluffyui/state"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	data := state.NewSignal([]float64{1, 2, 3, 2, 4})
	spark := widgets.NewSparkline(data)
	_ = spark
}

func NewSparkline

func NewSparkline(data *state.Signal[[]float64]) *Sparkline

NewSparkline creates a sparkline.

func (*Sparkline) Bind

func (s *Sparkline) Bind(services runtime.Services)

Bind attaches app services.

func (*Sparkline) HandleMessage

func (s *Sparkline) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled.

func (*Sparkline) Measure

func (s *Sparkline) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Sparkline) Render

func (s *Sparkline) Render(ctx runtime.RenderContext)

Render draws the sparkline.

func (*Sparkline) StyleType

func (s *Sparkline) StyleType() string

StyleType returns the selector type name.

func (*Sparkline) Unbind

func (s *Sparkline) Unbind()

Unbind releases app services.

type Spinner

type Spinner struct {
	Base
	Frames []string
	// contains filtered or unexported fields
}

Spinner is an animated loading indicator.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	spinner := widgets.NewSpinner()
	spinner.Advance()
	_ = spinner
}

func NewSpinner

func NewSpinner() *Spinner

NewSpinner creates an animated loading indicator that cycles through frames on each tick. Shows a static indicator when reduced motion is enabled.

func (*Spinner) Advance

func (s *Spinner) Advance()

Advance moves to the next frame.

func (*Spinner) Bind

func (s *Spinner) Bind(services runtime.Services)

Bind attaches app services.

func (*Spinner) HandleMessage

func (s *Spinner) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage advances on ticks. Skips frame advancement when reduced motion is active.

func (*Spinner) Measure

func (s *Spinner) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Spinner) Render

func (s *Spinner) Render(ctx runtime.RenderContext)

Render draws the spinner frame, or a static indicator when reduced motion is enabled.

func (*Spinner) SetStyle

func (s *Spinner) SetStyle(style backend.Style)

SetStyle updates the spinner style.

func (*Spinner) StyleType

func (s *Spinner) StyleType() string

StyleType returns the selector type name.

func (*Spinner) Unbind

func (s *Spinner) Unbind()

Unbind releases app services.

type Splitter

type Splitter struct {
	Base
	First       runtime.Widget
	Second      runtime.Widget
	Orientation SplitterOrientation
	Ratio       float64
	DividerSize int
	// contains filtered or unexported fields
}

Splitter divides space between two panes.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	left := widgets.NewText("Logs")
	right := widgets.NewText("Details")
	split := widgets.NewSplitter(left, right)
	split.Orientation = widgets.SplitHorizontal
	split.Ratio = 0.65
	_ = split
}

func NewSplitter

func NewSplitter(first, second runtime.Widget) *Splitter

NewSplitter creates a splitter with two panes.

func (*Splitter) Bind

func (s *Splitter) Bind(services runtime.Services)

Bind attaches app services.

func (*Splitter) ChildWidgets

func (s *Splitter) ChildWidgets() []runtime.Widget

ChildWidgets returns the panes.

func (*Splitter) HandleMessage

func (s *Splitter) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to child panes.

func (*Splitter) Layout

func (s *Splitter) Layout(bounds runtime.Rect)

Layout positions the panes.

func (*Splitter) Measure

func (s *Splitter) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the max child size.

func (*Splitter) PathSegment

func (s *Splitter) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Splitter) Render

func (s *Splitter) Render(ctx runtime.RenderContext)

Render draws both panes.

func (*Splitter) RenderHTML

func (s *Splitter) RenderHTML(ctx runtime.HTMLContext) runtime.HTML

RenderHTML renders the splitter as a static HTML flexbox layout.

func (*Splitter) SetLabel

func (s *Splitter) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Splitter) Unbind

func (s *Splitter) Unbind()

Unbind releases app services.

type SplitterOrientation

type SplitterOrientation int

SplitterOrientation describes the split direction.

const (
	SplitHorizontal SplitterOrientation = iota // Left/right
	SplitVertical                              // Top/bottom
)

type Stack

type Stack struct {
	Base
	Children []runtime.Widget
	// contains filtered or unexported fields
}

Stack overlays child widgets.

Example
package main

import (
	"m31labs.dev/fluffyui/backend"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	base := widgets.NewBox(widgets.NewLabel("Base"))
	overlay := widgets.NewPanel(widgets.NewLabel("Overlay")).WithBorder(backend.DefaultStyle())
	stack := widgets.NewStack(base, overlay)
	_ = stack
}

func NewStack

func NewStack(children ...runtime.Widget) *Stack

NewStack creates a stack container.

func (*Stack) Bind

func (s *Stack) Bind(services runtime.Services)

Bind attaches app services.

func (*Stack) ChildWidgets

func (s *Stack) ChildWidgets() []runtime.Widget

ChildWidgets returns stacked children.

func (*Stack) HandleMessage

func (s *Stack) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to children from top to bottom.

func (*Stack) Layout

func (s *Stack) Layout(bounds runtime.Rect)

Layout assigns bounds to children.

func (*Stack) Measure

func (s *Stack) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the max size of children.

func (*Stack) PathSegment

func (s *Stack) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Stack) Render

func (s *Stack) Render(ctx runtime.RenderContext)

Render draws children in order.

func (*Stack) SetLabel

func (s *Stack) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Stack) Unbind

func (s *Stack) Unbind()

Unbind releases app services.

type StatusBar

type StatusBar struct {
	FocusableBase
	// contains filtered or unexported fields
}

StatusBar is a VS Code-style bottom status bar with left, center, and right sections.

func NewStatusBar

func NewStatusBar(items ...StatusBarItem) *StatusBar

NewStatusBar creates a status bar with the given items.

func (*StatusBar) AddItem

func (sb *StatusBar) AddItem(item StatusBarItem)

AddItem appends an item to the status bar.

func (*StatusBar) Bind

func (sb *StatusBar) Bind(services runtime.Services)

Bind attaches app services.

func (*StatusBar) HandleMessage

func (sb *StatusBar) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles keyboard navigation and mouse clicks.

func (*StatusBar) Items

func (sb *StatusBar) Items() []StatusBarItem

Items returns a copy of all items.

func (*StatusBar) Layout

func (sb *StatusBar) Layout(bounds runtime.Rect)

Layout stores the assigned bounds.

func (*StatusBar) Measure

func (sb *StatusBar) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size (full width, one line tall).

func (*StatusBar) RemoveItem

func (sb *StatusBar) RemoveItem(key string)

RemoveItem removes the item with the given key.

func (*StatusBar) Render

func (sb *StatusBar) Render(ctx runtime.RenderContext)

Render draws the status bar.

func (*StatusBar) Selected

func (sb *StatusBar) Selected() int

Selected returns the currently selected visible item index.

func (*StatusBar) SetBackground

func (sb *StatusBar) SetBackground(style backend.Style)

SetBackground sets the bar background style.

func (*StatusBar) SetItemVisible

func (sb *StatusBar) SetItemVisible(key string, visible bool)

SetItemVisible sets the visibility of an item identified by key.

func (*StatusBar) StyleType

func (sb *StatusBar) StyleType() string

StyleType returns the selector type name.

func (*StatusBar) Unbind

func (sb *StatusBar) Unbind()

Unbind releases app services.

func (*StatusBar) UpdateItem

func (sb *StatusBar) UpdateItem(key string, text string)

UpdateItem updates the text of an item identified by key.

type StatusBarAlignment

type StatusBarAlignment int

StatusBarAlignment controls where an item is placed within the bar.

const (
	// StatusBarLeft packs items to the left edge.
	StatusBarLeft StatusBarAlignment = iota
	// StatusBarCenter places items in the center.
	StatusBarCenter
	// StatusBarRight packs items to the right edge.
	StatusBarRight
)

type StatusBarItem

type StatusBarItem struct {
	Key       string             // unique identifier
	Text      string             // display text
	Alignment StatusBarAlignment // placement within the bar
	Style     backend.Style      // optional custom style
	OnClick   func()             // optional click handler
	Tooltip   string             // tooltip description
	Priority  int                // higher priority = kept when space is limited
	Visible   bool               // whether this item is shown
}

StatusBarItem represents a single section in a status bar.

type Step

type Step struct {
	Title string
	State StepState
}

Step describes a step in a stepper.

type StepState

type StepState int

StepState describes the state of a step.

const (
	StepPending StepState = iota
	StepActive
	StepCompleted
	StepError
)

type Stepper

type Stepper struct {
	Base
	Steps []Step
	// contains filtered or unexported fields
}

Stepper renders a sequence of steps.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	stepper := widgets.NewStepper(
		widgets.Step{Title: "Fetch", State: widgets.StepCompleted},
		widgets.Step{Title: "Build", State: widgets.StepActive},
		widgets.Step{Title: "Ship", State: widgets.StepPending},
	)
	_ = stepper
}

func NewStepper

func NewStepper(steps ...Step) *Stepper

NewStepper creates a stepper.

func (*Stepper) Bind

func (s *Stepper) Bind(services runtime.Services)

Bind attaches app services.

func (*Stepper) HandleMessage

func (s *Stepper) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage returns unhandled.

func (*Stepper) Measure

func (s *Stepper) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Stepper) Render

func (s *Stepper) Render(ctx runtime.RenderContext)

Render draws the stepper.

func (*Stepper) SetStyle

func (s *Stepper) SetStyle(style backend.Style)

SetStyle updates the stepper style.

func (*Stepper) StyleType

func (s *Stepper) StyleType() string

StyleType returns the selector type name.

func (*Stepper) Unbind

func (s *Stepper) Unbind()

Unbind releases app services.

type Tab

type Tab struct {
	Title   string
	Content runtime.Widget
}

Tab represents a single tab.

type Table

type Table struct {
	FocusableBase
	Columns []TableColumn
	Rows    [][]string
	// contains filtered or unexported fields
}

Table is a simple data grid widget.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	table := widgets.NewTable(
		widgets.TableColumn{Title: "Name", Width: 12},
		widgets.TableColumn{Title: "Status", Width: 8},
	)
	table.SetRows([][]string{
		{"alpha", "ok"},
		{"beta", "warn"},
	})
	_ = table
}

func NewTable

func NewTable(columns ...TableColumn) *Table

NewTable creates a data table with the given column definitions. Populate rows with SetRows or SetDataSource. Supports keyboard navigation, sorting, filtering, and virtual scrolling for large datasets.

func (*Table) Bind

func (t *Table) Bind(services runtime.Services)

Bind attaches app services.

func (*Table) CancelEdit

func (t *Table) CancelEdit()

CancelEdit discards the current edit and exits edit mode.

func (*Table) ClearFilter

func (t *Table) ClearFilter()

ClearFilter removes any active filter.

func (*Table) ColumnCount

func (t *Table) ColumnCount() int

ColumnCount returns the number of columns.

func (*Table) CommitEdit

func (t *Table) CommitEdit()

CommitEdit saves the current edit and exits edit mode. If the data source implements TabularEditable, SetCell is called. Otherwise, for static Rows, the cell is updated directly. The onCellEdit callback (if set) is invoked with old and new values.

func (*Table) DataSource

func (t *Table) DataSource() TabularDataSource

DataSource returns the active data source.

func (*Table) EditBuffer

func (t *Table) EditBuffer() string

EditBuffer returns the current edit buffer contents.

func (*Table) EditCol

func (t *Table) EditCol() int

EditCol returns the column index being edited.

func (*Table) EditCursorPos

func (t *Table) EditCursorPos() int

EditCursorPos returns the cursor position within the edit buffer.

func (*Table) EditRow

func (t *Table) EditRow() int

EditRow returns the row index being edited (display index).

func (*Table) Editing

func (t *Table) Editing() bool

Editing reports whether the table is currently in cell edit mode.

func (*Table) GetCell

func (t *Table) GetCell(row, col int) string

GetCell returns the cell value at the given row and column. When sorting or filtering is active, row refers to the display index.

func (*Table) HandleMessage

func (t *Table) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles row navigation and inline cell editing.

func (*Table) Measure

func (t *Table) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Table) PageBy

func (t *Table) PageBy(pages int)

PageBy scrolls by a number of pages.

func (*Table) Render

func (t *Table) Render(ctx runtime.RenderContext)

Render draws the table.

func (*Table) RowCount

func (t *Table) RowCount() int

RowCount returns the number of rows.

func (*Table) ScrollBy

func (t *Table) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta.

func (*Table) ScrollTo

func (t *Table) ScrollTo(x, y int)

ScrollTo scrolls to an absolute row index.

func (*Table) ScrollToEnd

func (t *Table) ScrollToEnd()

ScrollToEnd scrolls to the last row.

func (*Table) ScrollToStart

func (t *Table) ScrollToStart()

ScrollToStart scrolls to the first row.

func (*Table) SelectedCol

func (t *Table) SelectedCol() int

SelectedCol returns the currently selected column index.

func (*Table) SelectedIndex

func (t *Table) SelectedIndex() int

SelectedIndex returns the currently selected row index.

func (*Table) SelectedRow

func (t *Table) SelectedRow() []string

SelectedRow returns the currently selected row data, or nil if no selection.

func (*Table) SetCell

func (t *Table) SetCell(row, col int, value string)

SetCell updates a cell value at the given row and column. When sorting or filtering is active, row refers to the display index.

func (*Table) SetDataSource

func (t *Table) SetDataSource(source TabularDataSource)

SetDataSource sets a virtualized data source for large datasets.

func (*Table) SetFilter

func (t *Table) SetFilter(fn func(row []string) bool)

SetFilter sets a filter function. Only rows for which fn returns true will be displayed. Pass nil to remove the filter. Filtering only applies to static Rows data, not to a TabularDataSource.

func (*Table) SetHeaderStyle

func (t *Table) SetHeaderStyle(style backend.Style)

SetHeaderStyle updates the header style.

func (*Table) SetLabel

func (t *Table) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Table) SetOnCellEdit

func (t *Table) SetOnCellEdit(fn func(row, col int, oldValue, newValue string))

SetOnCellEdit sets the callback invoked when a cell edit is committed. The callback receives the display row, column, old value, and new value.

func (*Table) SetRows

func (t *Table) SetRows(rows [][]string)

SetRows updates table rows.

func (*Table) SetSelected

func (t *Table) SetSelected(index int)

SetSelected updates the selected row index.

func (*Table) SetSelectedCol

func (t *Table) SetSelectedCol(col int)

SetSelectedCol updates the selected column index.

func (*Table) SetSelectedStyle

func (t *Table) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected row style.

func (*Table) SetSortColumn

func (t *Table) SetSortColumn(col int, dir SortDirection)

SetSortColumn sets the sort column and direction, then rebuilds the view.

func (*Table) SetStyle

func (t *Table) SetStyle(style backend.Style)

SetStyle updates the base table style.

func (*Table) SetVirtualOverscan

func (t *Table) SetVirtualOverscan(count int)

SetVirtualOverscan sets the number of extra rows to render above and below the visible area when virtual scrolling is enabled. Default is 2.

func (*Table) SetVirtualScroll

func (t *Table) SetVirtualScroll(enabled bool)

SetVirtualScroll enables or disables virtual scrolling for large datasets. When enabled, only visible rows (plus overscan) are rendered each frame, which dramatically improves performance for tables with thousands of rows.

func (*Table) Sort

func (t *Table) Sort() TableSortState

Sort returns the current sort state.

func (*Table) StartEdit

func (t *Table) StartEdit()

StartEdit enters edit mode on the currently selected cell. The edit buffer is populated with the current cell value.

func (*Table) StyleType

func (t *Table) StyleType() string

StyleType returns the selector type name.

func (*Table) Unbind

func (t *Table) Unbind()

Unbind releases app services.

func (*Table) VirtualScroll

func (t *Table) VirtualScroll() bool

VirtualScroll reports whether virtual scrolling is enabled.

func (*Table) VisibleRange

func (t *Table) VisibleRange() (start, end int)

VisibleRange returns the [start, end) row indices currently rendered. When virtual scrolling is disabled, start is the scroll offset and end is offset+viewportRows. When enabled, it returns the virtualized range.

type TableColumn

type TableColumn struct {
	Title string
	Width int
}

TableColumn defines a column in a table.

type TableSortState

type TableSortState struct {
	Column    int
	Direction SortDirection
}

TableSortState holds the current sort column and direction.

type Tabs

type Tabs struct {
	FocusableBase
	Tabs []Tab
	// contains filtered or unexported fields
}

Tabs is a tabbed container widget.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	tabs := widgets.NewTabs(
		widgets.Tab{Title: "Home", Content: widgets.NewText("Welcome")},
		widgets.Tab{Title: "Logs", Content: widgets.NewText("...")},
	)
	_ = tabs
}

func NewTabs

func NewTabs(tabs ...Tab) *Tabs

NewTabs creates a tabbed container that shows one tab's content at a time. Navigate tabs with arrow keys when focused.

func (*Tabs) Bind

func (t *Tabs) Bind(services runtime.Services)

Bind attaches app services.

func (*Tabs) ChildWidgets

func (t *Tabs) ChildWidgets() []runtime.Widget

ChildWidgets returns the selected tab content.

func (*Tabs) HandleMessage

func (t *Tabs) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage switches tabs.

func (*Tabs) Layout

func (t *Tabs) Layout(bounds runtime.Rect)

Layout positions the selected tab content.

func (*Tabs) Measure

func (t *Tabs) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size of the selected tab.

func (*Tabs) Mount

func (t *Tabs) Mount()

Mount marks the tab container as mounted.

func (*Tabs) PathSegment

func (t *Tabs) PathSegment(child runtime.Widget) string

PathSegment returns a debug path segment for the given child.

func (*Tabs) Render

func (t *Tabs) Render(ctx runtime.RenderContext)

Render draws tab titles and content.

func (*Tabs) SelectedIndex

func (t *Tabs) SelectedIndex() int

SelectedIndex returns the current tab index.

func (*Tabs) SetLabel

func (t *Tabs) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Tabs) SetSelected

func (t *Tabs) SetSelected(index int)

SetSelected updates the active tab index.

func (*Tabs) SetSelectedStyle

func (t *Tabs) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected tab style.

func (*Tabs) SetStyle

func (t *Tabs) SetStyle(style backend.Style)

SetStyle updates the base tab style.

func (*Tabs) StyleType

func (t *Tabs) StyleType() string

StyleType returns the selector type name.

func (*Tabs) Unbind

func (t *Tabs) Unbind()

Unbind releases app services.

func (*Tabs) Unmount

func (t *Tabs) Unmount()

Unmount marks the tab container as unmounted.

type TabularDataSource

type TabularDataSource interface {
	RowCount() int
	Cell(row, col int) string
}

TabularDataSource provides virtualized tabular data.

type TabularEditable

type TabularEditable interface {
	TabularDataSource
	SetCell(row, col int, value string)
}

TabularEditable allows editing tabular data.

type TabularRowProvider

type TabularRowProvider interface {
	TabularDataSource
	Row(row int) []string
}

TabularRowProvider optionally provides full row slices.

type TagInput

type TagInput struct {
	FocusableBase
	// contains filtered or unexported fields
}

TagInput is a focusable widget for entering and managing tags. Tags are displayed as [tag1] [tag2] followed by an input area.

func NewTagInput

func NewTagInput() *TagInput

NewTagInput creates a tag input widget.

func (*TagInput) AddTag

func (t *TagInput) AddTag(tag string) bool

AddTag adds a tag if not duplicate and under max limit.

func (*TagInput) Bind

func (t *TagInput) Bind(services runtime.Services)

Bind attaches app services.

func (*TagInput) HandleMessage

func (t *TagInput) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*TagInput) InputBuffer

func (t *TagInput) InputBuffer() string

InputBuffer returns the current input text.

func (*TagInput) Measure

func (t *TagInput) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*TagInput) RemoveTag

func (t *TagInput) RemoveTag(tag string) bool

RemoveTag removes a tag by value.

func (*TagInput) Render

func (t *TagInput) Render(ctx runtime.RenderContext)

Render draws the tag input widget.

func (*TagInput) SetMaxTags

func (t *TagInput) SetMaxTags(max int)

SetMaxTags sets the maximum number of tags allowed (0 = unlimited).

func (*TagInput) SetOnChange

func (t *TagInput) SetOnChange(fn func(tags []string))

SetOnChange sets the change handler.

func (*TagInput) SetStyle

func (t *TagInput) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*TagInput) SetTags

func (t *TagInput) SetTags(tags []string)

SetTags replaces the current tags.

func (*TagInput) StyleType

func (t *TagInput) StyleType() string

StyleType returns the selector type name.

func (*TagInput) Tags

func (t *TagInput) Tags() []string

Tags returns a copy of the current tags.

func (*TagInput) Unbind

func (t *TagInput) Unbind()

Unbind releases app services.

type Text

type Text struct {
	Base
	// contains filtered or unexported fields
}

Text is a simple text display widget.

Example
package main

import (
	"m31labs.dev/fluffyui/backend"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	text := widgets.NewText("Hello\nWorld")
	text.SetStyle(backend.DefaultStyle().Bold(true))
	_ = text
}

func NewText

func NewText(text string, opts ...TextOption) *Text

NewText creates a new text widget.

func (*Text) Bind

func (t *Text) Bind(services runtime.Services)

Bind attaches app services.

func (*Text) Direction

func (t *Text) Direction() i18n.Direction

Direction returns the effective text direction. If a direction was explicitly set, it returns that. Otherwise, it auto-detects from the text content.

func (*Text) Measure

func (t *Text) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the size needed to display the text.

func (*Text) Render

func (t *Text) Render(ctx runtime.RenderContext)

Render draws the text.

func (*Text) SetA11yLabel

func (t *Text) SetA11yLabel(label string)

SetA11yLabel overrides the accessibility label without changing visible text.

func (*Text) SetDirection

func (t *Text) SetDirection(dir i18n.Direction)

SetDirection sets an explicit text direction override. Pass DirectionRTL for right-to-left or DirectionLTR for left-to-right. When set, auto-detection is bypassed.

func (*Text) SetStyle

func (t *Text) SetStyle(style backend.Style)

SetStyle sets the text style.

func (*Text) SetText

func (t *Text) SetText(text string)

SetText updates the displayed text.

func (*Text) StyleType

func (t *Text) StyleType() string

StyleType returns the selector type name.

func (*Text) Text

func (t *Text) Text() string

Text returns the current text.

func (*Text) Unbind

func (t *Text) Unbind()

Unbind releases app services.

func (*Text) WithStyle deprecated

func (t *Text) WithStyle(style backend.Style) *Text

Deprecated: prefer WithTextStyle during construction or SetStyle for mutation.

type TextArea

type TextArea struct {
	FocusableBase
	// contains filtered or unexported fields
}

TextArea is a multi-line text input widget.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	area := widgets.NewTextArea()
	area.SetText("First line\nSecond line")
	area.SetOnChange(func(text string) {})
	_ = area
}

func NewTextArea

func NewTextArea() *TextArea

NewTextArea creates a multi-line text editor with line wrapping, selection, clipboard support, and undo/redo history.

func (*TextArea) Bind

func (t *TextArea) Bind(services runtime.Services)

Bind attaches app services.

func (*TextArea) Blur

func (t *TextArea) Blur()

Blur removes focus and announces validation errors if any.

func (*TextArea) CanRedo

func (t *TextArea) CanRedo() bool

CanRedo returns true if redo is available.

func (*TextArea) CanUndo

func (t *TextArea) CanUndo() bool

CanUndo returns true if undo is available.

func (*TextArea) ClearHighlights

func (t *TextArea) ClearHighlights()

ClearHighlights removes all highlight ranges.

func (*TextArea) ClearHistory

func (t *TextArea) ClearHistory()

ClearHistory resets the undo/redo history.

func (*TextArea) ClipboardCopy

func (t *TextArea) ClipboardCopy() (string, bool)

ClipboardCopy returns selected text, or all text if no selection.

func (*TextArea) ClipboardCut

func (t *TextArea) ClipboardCut() (string, bool)

ClipboardCut cuts selected text, or all text if no selection.

func (*TextArea) ClipboardPaste

func (t *TextArea) ClipboardPaste(text string) bool

ClipboardPaste inserts text at the cursor, replacing any selection.

func (*TextArea) CursorOffset

func (t *TextArea) CursorOffset() int

CursorOffset returns the cursor offset in the text.

func (*TextArea) CursorPosition

func (t *TextArea) CursorPosition() (x, y int)

CursorPosition returns the cursor coordinates within the text area.

func (*TextArea) CursorWordLeft

func (t *TextArea) CursorWordLeft()

CursorWordLeft moves the cursor to the previous word boundary.

func (*TextArea) CursorWordRight

func (t *TextArea) CursorWordRight()

CursorWordRight moves the cursor to the next word boundary.

func (*TextArea) Errors

func (t *TextArea) Errors() []string

Errors returns the latest validation error messages.

func (*TextArea) GetSelectedText

func (t *TextArea) GetSelectedText() string

GetSelectedText returns the currently selected text.

func (*TextArea) GetSelection

func (t *TextArea) GetSelection() Selection

GetSelection returns the current selection range.

func (*TextArea) HandleMessage

func (t *TextArea) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard and mouse input.

func (*TextArea) HasSelection

func (t *TextArea) HasSelection() bool

HasSelection returns true if text is selected.

func (*TextArea) Measure

func (t *TextArea) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size. TextArea returns minimal preferred size (1x1) to work correctly in flex layouts. When flex containers measure children with unbounded constraints (maxInt), returning maxInt would cause the flex shrink algorithm to shrink this widget to 0.

func (*TextArea) OnChange deprecated

func (t *TextArea) OnChange(fn func(text string))

OnChange registers a callback for text changes.

Deprecated: Use SetOnChange instead. This method will be removed in v1.0.

func (*TextArea) Redo

func (t *TextArea) Redo() bool

Redo reapplies a previously undone state. Returns true if redo was successful.

func (*TextArea) Render

func (t *TextArea) Render(ctx runtime.RenderContext)

Render draws the text area.

func (*TextArea) SelectAll

func (t *TextArea) SelectAll()

SelectAll selects all text.

func (*TextArea) SelectLine

func (t *TextArea) SelectLine()

SelectLine selects the current line.

func (*TextArea) SelectNone

func (t *TextArea) SelectNone()

SelectNone clears the selection.

func (*TextArea) SelectWord

func (t *TextArea) SelectWord()

SelectWord selects the word at the cursor position.

func (*TextArea) SetCursorOffset

func (t *TextArea) SetCursorOffset(offset int)

SetCursorOffset moves the cursor to the given offset.

func (*TextArea) SetCursorPosition

func (t *TextArea) SetCursorPosition(x, y int)

SetCursorPosition moves the cursor to the given coordinates.

func (*TextArea) SetFocusStyle

func (t *TextArea) SetFocusStyle(style backend.Style)

SetFocusStyle sets the focused style.

func (*TextArea) SetGutterStyle

func (t *TextArea) SetGutterStyle(style backend.Style)

SetGutterStyle sets the style for the line number gutter.

func (*TextArea) SetHighlights

func (t *TextArea) SetHighlights(highlights []TextAreaHighlight)

SetHighlights replaces the highlight ranges. Ranges must be sorted by Start. The TextArea does not sort them — the caller is responsible for ordering.

func (*TextArea) SetLabel

func (t *TextArea) SetLabel(label string)

SetLabel updates the accessibility label.

func (*TextArea) SetOnChange

func (t *TextArea) SetOnChange(fn func(text string))

SetOnChange registers a callback for text changes.

func (*TextArea) SetSelection

func (t *TextArea) SetSelection(sel Selection)

SetSelection sets the selection range, clamping to valid bounds.

func (*TextArea) SetShowLineNumbers

func (t *TextArea) SetShowLineNumbers(show bool)

SetShowLineNumbers enables or disables the line number gutter.

func (*TextArea) SetStyle

func (t *TextArea) SetStyle(style backend.Style)

SetStyle sets the normal style.

func (*TextArea) SetTabMode

func (t *TextArea) SetTabMode(useTabs bool)

SetTabMode controls whether Tab inserts a literal '\t' (true) or spaces (false).

func (*TextArea) SetTabSize

func (t *TextArea) SetTabSize(n int)

SetTabSize sets the number of spaces for a tab. Default is 4.

func (*TextArea) SetText

func (t *TextArea) SetText(text string)

SetText sets the text and moves the cursor to the end.

func (*TextArea) SetValidators

func (t *TextArea) SetValidators(validators ...forms.Validator)

SetValidators updates validation rules for the text area.

func (*TextArea) SetVisibleLines

func (t *TextArea) SetVisibleLines(lines []int)

SetVisibleLines limits the rendered/interactive display to the provided logical line indices. Passing nil or an empty slice restores all lines.

func (*TextArea) SetWordWrap

func (t *TextArea) SetWordWrap(enabled bool)

SetWordWrap enables or disables soft wrapping for long lines.

func (*TextArea) StyleType

func (t *TextArea) StyleType() string

StyleType returns the selector type name.

func (*TextArea) Text

func (t *TextArea) Text() string

Text returns the current text.

func (*TextArea) Unbind

func (t *TextArea) Unbind()

Unbind releases app services.

func (*TextArea) Undo

func (t *TextArea) Undo() bool

Undo reverts to the previous state. Returns true if undo was successful.

func (*TextArea) Valid

func (t *TextArea) Valid() bool

Valid reports whether validation passes.

func (*TextArea) Validate

func (t *TextArea) Validate() []forms.ValidationError

Validate runs validation rules and returns validation errors.

func (*TextArea) VisibleLines

func (t *TextArea) VisibleLines() []int

VisibleLines returns the active logical line filter. Nil means all lines are visible.

func (*TextArea) WordWrap

func (t *TextArea) WordWrap() bool

WordWrap reports whether soft wrapping is enabled.

type TextAreaHighlight

type TextAreaHighlight struct {
	Start int           // rune offset, inclusive
	End   int           // rune offset, exclusive
	Style backend.Style // override style (typically just foreground color)
}

TextAreaHighlight defines a styled range within the TextArea content. Ranges are in rune offsets (not byte offsets) to match TextArea's internal []rune storage.

type TextOption

type TextOption = Option[Text]

TextOption configures a Text widget.

func WithTextA11yLabel

func WithTextA11yLabel(label string) TextOption

WithTextA11yLabel sets an accessibility label override.

func WithTextDirection

func WithTextDirection(dir i18n.Direction) TextOption

WithTextDirection sets an explicit text direction (DirectionLTR or DirectionRTL). When set, auto-detection is bypassed for rendering.

func WithTextStyle

func WithTextStyle(style backend.Style) TextOption

WithTextStyle sets the text style.

type TimePicker

type TimePicker struct {
	FocusableBase
	// contains filtered or unexported fields
}

TimePicker allows selecting a time of day.

func NewTimePicker

func NewTimePicker() *TimePicker

NewTimePicker creates a new time picker.

func (*TimePicker) Bind

func (t *TimePicker) Bind(services runtime.Services)

Bind attaches app services.

func (*TimePicker) HandleMessage

func (t *TimePicker) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input.

func (*TimePicker) Measure

func (t *TimePicker) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*TimePicker) Render

func (t *TimePicker) Render(ctx runtime.RenderContext)

Render draws the time.

func (*TimePicker) SetLabel

func (t *TimePicker) SetLabel(label string)

SetLabel updates the accessibility label.

func (*TimePicker) SetOnChange

func (t *TimePicker) SetOnChange(fn func(time.Time))

SetOnChange registers a change callback.

func (*TimePicker) SetOnSubmit

func (t *TimePicker) SetOnSubmit(fn func(time.Time))

SetOnSubmit registers a submit callback.

func (*TimePicker) SetShowSeconds

func (t *TimePicker) SetShowSeconds(show bool)

SetShowSeconds toggles second display.

func (*TimePicker) SetTime

func (t *TimePicker) SetTime(value time.Time)

SetTime updates the selected time.

func (*TimePicker) StyleType

func (t *TimePicker) StyleType() string

StyleType returns the selector type name.

func (*TimePicker) Time

func (t *TimePicker) Time() time.Time

Time returns the current time selection.

func (*TimePicker) Unbind

func (t *TimePicker) Unbind()

Unbind releases app services.

type ToastStack

type ToastStack struct {
	Base
	// contains filtered or unexported fields
}

ToastStack renders toast notifications.

Example
package main

import (
	"m31labs.dev/fluffyui/toast"
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	manager := toast.NewToastManager()
	stack := widgets.NewToastStack()
	manager.SetOnChange(stack.SetToasts)
	_ = stack
}

func NewToastStack

func NewToastStack() *ToastStack

NewToastStack creates a new toast stack widget.

func (*ToastStack) Bind

func (t *ToastStack) Bind(services runtime.Services)

Bind attaches app services.

func (*ToastStack) HandleMessage

func (t *ToastStack) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles dismiss clicks.

func (*ToastStack) HasActiveAnimations

func (t *ToastStack) HasActiveAnimations(now time.Time) bool

HasActiveAnimations returns true when any toast is animating.

func (*ToastStack) Measure

func (t *ToastStack) Measure(constraints runtime.Constraints) runtime.Size

Measure fills the available space.

func (*ToastStack) Render

func (t *ToastStack) Render(ctx runtime.RenderContext)

Render draws the toast stack.

func (*ToastStack) SetAnimationsEnabled

func (t *ToastStack) SetAnimationsEnabled(enabled bool)

SetAnimationsEnabled toggles toast animations.

func (*ToastStack) SetLabel

func (t *ToastStack) SetLabel(label string)

SetLabel updates the accessibility label.

func (*ToastStack) SetNow

func (t *ToastStack) SetNow(now time.Time)

SetNow updates the animation timestamp.

func (*ToastStack) SetOnDismiss

func (t *ToastStack) SetOnDismiss(fn func(id string))

SetOnDismiss registers a handler for dismiss actions.

func (*ToastStack) SetStyles

func (t *ToastStack) SetStyles(bg, text, info, success, warn, err backend.Style)

SetStyles configures the toast styles by level.

func (*ToastStack) SetToasts

func (t *ToastStack) SetToasts(toasts []*toast.Toast)

SetToasts updates the toast list.

func (*ToastStack) StyleType

func (t *ToastStack) StyleType() string

StyleType returns the selector type name.

func (*ToastStack) ToastAt

func (t *ToastStack) ToastAt(x, y int) (*toast.Toast, bool)

ToastAt returns the toast under the given point.

func (*ToastStack) Unbind

func (t *ToastStack) Unbind()

Unbind releases app services.

type Toggle

type Toggle struct {
	FocusableBase
	// contains filtered or unexported fields
}

Toggle is a focusable on/off switch widget. It is visually distinct from a checkbox, rendering as a sliding toggle.

func NewToggle

func NewToggle(on *state.Signal[bool], opts ...ToggleOption) *Toggle

NewToggle creates a toggle switch bound to the given signal.

func (*Toggle) Bind

func (t *Toggle) Bind(services runtime.Services)

Bind attaches app services.

func (*Toggle) HandleMessage

func (t *Toggle) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage processes keyboard input for the toggle.

func (*Toggle) Label

func (t *Toggle) Label() string

Label returns the current label text.

func (*Toggle) Measure

func (t *Toggle) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*Toggle) On

func (t *Toggle) On() bool

On returns the current toggle state.

func (*Toggle) Render

func (t *Toggle) Render(ctx runtime.RenderContext)

Render draws the toggle switch.

func (*Toggle) SetOn

func (t *Toggle) SetOn(value bool)

SetOn updates the toggle state.

func (*Toggle) SetStyle

func (t *Toggle) SetStyle(style backend.Style)

SetStyle sets the widget style.

func (*Toggle) StyleType

func (t *Toggle) StyleType() string

StyleType returns the selector type name for FSS.

func (*Toggle) Unbind

func (t *Toggle) Unbind()

Unbind releases app services.

type ToggleOption

type ToggleOption = Option[Toggle]

ToggleOption configures a Toggle widget.

func WithToggleLabel

func WithToggleLabel(label *state.Signal[string]) ToggleOption

WithToggleLabel sets the label displayed next to the toggle.

func WithToggleOnChange

func WithToggleOnChange(fn func(bool)) ToggleOption

WithToggleOnChange sets the callback invoked when the toggle state changes.

type Tooltip

type Tooltip struct {
	Base
	// contains filtered or unexported fields
}

Tooltip displays content anchored to a target widget.

func NewTooltip

func NewTooltip(target runtime.Widget, content runtime.Widget, opts ...TooltipOption) *Tooltip

NewTooltip creates a tooltip wrapper.

func (*Tooltip) Bind

func (t *Tooltip) Bind(services runtime.Services)

Bind attaches app services.

func (*Tooltip) ChildWidgets

func (t *Tooltip) ChildWidgets() []runtime.Widget

ChildWidgets returns the tooltip target.

func (*Tooltip) HandleMessage

func (t *Tooltip) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage forwards messages to the target and manages tooltip state.

func (*Tooltip) HitSelf

func (t *Tooltip) HitSelf() bool

HitSelf ensures the tooltip receives mouse events for its bounds.

func (*Tooltip) Layout

func (t *Tooltip) Layout(bounds runtime.Rect)

Layout assigns bounds to the target.

func (*Tooltip) Measure

func (t *Tooltip) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the target size within constraints.

func (*Tooltip) Render

func (t *Tooltip) Render(ctx runtime.RenderContext)

Render draws the target.

func (*Tooltip) Unbind

func (t *Tooltip) Unbind()

Unbind releases app services.

type TooltipOption

type TooltipOption = Option[Tooltip]

TooltipOption configures a tooltip.

func WithTooltipGap

func WithTooltipGap(gap int) TooltipOption

WithTooltipGap sets the gap between target and tooltip.

func WithTooltipPlacement

func WithTooltipPlacement(placement PopoverPlacement) TooltipOption

WithTooltipPlacement sets the popover placement.

func WithTooltipTrigger

func WithTooltipTrigger(trigger TooltipTrigger) TooltipOption

WithTooltipTrigger sets the activation trigger.

type TooltipTrigger

type TooltipTrigger int

TooltipTrigger describes how a tooltip is activated.

const (
	TooltipHover TooltipTrigger = iota
	TooltipFocus
	TooltipClick
)

type TrackGridBuilder

type TrackGridBuilder struct {
	// contains filtered or unexported fields
}

TrackGridBuilder provides a fluent API for constructing track-based grids with CSS Grid-like column and row definitions.

func NewTrackGridBuilder

func NewTrackGridBuilder() *TrackGridBuilder

NewTrackGridBuilder creates a new TrackGridBuilder.

func (*TrackGridBuilder) Add

func (b *TrackGridBuilder) Add(w runtime.Widget, row, col int) *TrackGridBuilder

Add adds a widget at the given row and column with span 1x1.

func (*TrackGridBuilder) AddSpan

func (b *TrackGridBuilder) AddSpan(w runtime.Widget, row, col, rowSpan, colSpan int) *TrackGridBuilder

AddSpan adds a widget at the given row and column with the specified spans.

func (*TrackGridBuilder) Build

func (b *TrackGridBuilder) Build() *Grid

Build constructs the Grid from the builder configuration.

func (*TrackGridBuilder) Columns

func (b *TrackGridBuilder) Columns(cols ...TrackSize) *TrackGridBuilder

Columns sets the column track definitions.

func (*TrackGridBuilder) GapSize

func (b *TrackGridBuilder) GapSize(gap int) *TrackGridBuilder

GapSize sets the gap between grid cells.

func (*TrackGridBuilder) Rows

func (b *TrackGridBuilder) Rows(rows ...TrackSize) *TrackGridBuilder

Rows sets the row track definitions.

type TrackSize

type TrackSize struct {
	Mode  TrackSizeMode
	Value float64
}

TrackSize defines the size of a grid column or row.

func AutoTrack

func AutoTrack() TrackSize

AutoTrack creates a track that sizes to its content.

func Fr

func Fr(n float64) TrackSize

Fr creates a fractional track size (like CSS 1fr, 2fr).

func Px

func Px(n int) TrackSize

Px creates a fixed pixel track size.

type TrackSizeMode

type TrackSizeMode int

TrackSizeMode defines how a grid track is sized.

const (
	TrackFixed TrackSizeMode = iota // Fixed pixel size
	TrackFr                         // Fractional unit (CSS fr)
	TrackAuto                       // Size to content
)

type Tree

type Tree struct {
	FocusableBase
	Root *TreeNode
	// contains filtered or unexported fields
}

Tree renders a hierarchical tree.

Example
package main

import (
	"m31labs.dev/fluffyui/widgets"
)

func main() {
	root := &widgets.TreeNode{
		Label:    "root",
		Expanded: true,
		Children: []*widgets.TreeNode{
			{Label: "configs"},
			{
				Label:    "data",
				Expanded: true,
				Children: []*widgets.TreeNode{
					{Label: "2024"},
				},
			},
		},
	}
	tree := widgets.NewTree(root)
	_ = tree
}

func NewTree

func NewTree(root *TreeNode) *Tree

NewTree creates a hierarchical tree view rooted at the given node. Nodes can be expanded/collapsed with Enter and navigated with arrow keys.

func (*Tree) Bind

func (t *Tree) Bind(services runtime.Services)

Bind attaches app services.

func (*Tree) CanDrop

func (t *Tree) CanDrop(data runtime.DragData) bool

CanDrop implements runtime.DropTarget. It accepts drops of kind "tree-node".

func (*Tree) DeselectAll

func (t *Tree) DeselectAll()

DeselectAll clears all multi-selections.

func (*Tree) DeselectNode

func (t *Tree) DeselectNode(path string)

DeselectNode deselects the node at the given path.

func (*Tree) DragOrigin

func (t *Tree) DragOrigin() int

DragOrigin returns the flat index of the drag origin, or -1 if not dragging.

func (*Tree) DropIndex

func (t *Tree) DropIndex() int

DropIndex returns the current drop target flat index, or -1 if not dragging.

func (*Tree) HandleMessage

func (t *Tree) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles navigation and expansion.

func (*Tree) IsDraggable

func (t *Tree) IsDraggable() bool

IsDraggable reports whether drag-and-drop is enabled.

func (*Tree) IsDragging

func (t *Tree) IsDragging() bool

IsDragging reports whether a drag operation is in progress.

func (*Tree) Measure

func (t *Tree) Measure(constraints runtime.Constraints) runtime.Size

Measure returns desired size.

func (*Tree) MultiSelect

func (t *Tree) MultiSelect() bool

MultiSelect reports whether multi-selection is enabled.

func (*Tree) OnDrop

func (t *Tree) OnDrop(data runtime.DragData) bool

OnDrop implements runtime.DropTarget. It accepts the drop.

func (*Tree) PageBy

func (t *Tree) PageBy(pages int)

PageBy scrolls by a number of pages.

func (*Tree) Render

func (t *Tree) Render(ctx runtime.RenderContext)

Render draws the tree.

func (*Tree) ScrollBy

func (t *Tree) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta.

func (*Tree) ScrollTo

func (t *Tree) ScrollTo(x, y int)

ScrollTo scrolls to an absolute row index.

func (*Tree) ScrollToEnd

func (t *Tree) ScrollToEnd()

ScrollToEnd scrolls to the last row.

func (*Tree) ScrollToStart

func (t *Tree) ScrollToStart()

ScrollToStart scrolls to the first row.

func (*Tree) SelectAll

func (t *Tree) SelectAll()

SelectAll selects all visible (flattened) nodes.

func (*Tree) SelectNode

func (t *Tree) SelectNode(path string)

SelectNode selects the node at the given path.

func (*Tree) SelectedNodes

func (t *Tree) SelectedNodes() []string

SelectedNodes returns the paths of all currently selected nodes, sorted by their position in the flattened tree (i.e. visual order).

func (*Tree) SetDragStyle

func (t *Tree) SetDragStyle(style backend.Style)

SetDragStyle sets the style used for the drop indicator during drag.

func (*Tree) SetDraggable

func (t *Tree) SetDraggable(enabled bool)

SetDraggable enables or disables drag-and-drop for tree nodes.

func (*Tree) SetLabel

func (t *Tree) SetLabel(label string)

SetLabel updates the accessibility label.

func (*Tree) SetMultiSelect

func (t *Tree) SetMultiSelect(enabled bool)

SetMultiSelect enables or disables multi-selection.

func (*Tree) SetOnNodeDrop

func (t *Tree) SetOnNodeDrop(fn func(sourcePaths []string, targetPath string))

SetOnNodeDrop sets the callback invoked when nodes are dropped. sourcePaths are the paths of the dragged nodes; targetPath is the drop target.

func (*Tree) SetRoot

func (t *Tree) SetRoot(root *TreeNode)

SetRoot updates the tree root and clears cached rows.

func (*Tree) SetSelectedStyle

func (t *Tree) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected row style.

func (*Tree) SetStyle

func (t *Tree) SetStyle(style backend.Style)

SetStyle updates the base tree style.

func (*Tree) SetVirtualOverscan

func (t *Tree) SetVirtualOverscan(count int)

SetVirtualOverscan sets the number of extra rows to render above and below the visible area when virtual scrolling is enabled. Default is 2.

func (*Tree) SetVirtualScroll

func (t *Tree) SetVirtualScroll(enabled bool)

SetVirtualScroll enables or disables virtual scrolling for large trees. When enabled, only visible rows (plus overscan) are rendered each frame, which dramatically improves performance for trees with thousands of nodes.

func (*Tree) StyleType

func (t *Tree) StyleType() string

StyleType returns the selector type name.

func (*Tree) Unbind

func (t *Tree) Unbind()

Unbind releases app services.

func (*Tree) VirtualScroll

func (t *Tree) VirtualScroll() bool

VirtualScroll reports whether virtual scrolling is enabled.

func (*Tree) VisibleRange

func (t *Tree) VisibleRange() (start, end int)

VisibleRange returns the [start, end) flattened node indices currently rendered.

type TreeNode

type TreeNode struct {
	Label    string
	Children []*TreeNode
	Expanded bool
}

TreeNode represents a node in a tree.

type Validatable

type Validatable interface {
	SetValidators(validators ...forms.Validator)
	Validate() []forms.ValidationError
	Errors() []string
	Valid() bool
}

Validatable represents widgets that can be validated with form validators.

type Variant

type Variant string

Variant controls button styling.

const (
	VariantPrimary   Variant = "primary"
	VariantSecondary Variant = "secondary"
	VariantDanger    Variant = "danger"
)

type VideoPlayer

type VideoPlayer struct {
	Component
	// contains filtered or unexported fields
}

VideoPlayer renders video frames onto a canvas.

func NewVideoPlayer

func NewVideoPlayer(path string, opts ...VideoPlayerOption) (*VideoPlayer, error)

NewVideoPlayer creates a player and starts decoding frames.

func (*VideoPlayer) DroppedFrames

func (v *VideoPlayer) DroppedFrames() int64

DroppedFrames returns the count of frames dropped during loading.

func (*VideoPlayer) HandleMessage

func (v *VideoPlayer) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage advances playback on ticks and toggles play on spacebar.

func (*VideoPlayer) IsPlaying

func (v *VideoPlayer) IsPlaying() bool

IsPlaying reports whether the player is currently playing.

func (*VideoPlayer) Layout

func (v *VideoPlayer) Layout(bounds runtime.Rect)

Layout updates layout bounds and canvas size.

func (*VideoPlayer) Measure

func (v *VideoPlayer) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size for the video player.

func (*VideoPlayer) Pause

func (v *VideoPlayer) Pause()

Pause stops playback.

func (*VideoPlayer) Play

func (v *VideoPlayer) Play()

Play starts playback.

func (*VideoPlayer) Render

func (v *VideoPlayer) Render(ctx runtime.RenderContext)

Render draws the current video frame.

func (*VideoPlayer) Seek

func (v *VideoPlayer) Seek(pos time.Duration)

Seek moves the playhead to the given position.

func (*VideoPlayer) SetBlitter

func (v *VideoPlayer) SetBlitter(blitter graphics.Blitter)

SetBlitter configures the blitter used for rendering frames.

func (*VideoPlayer) SetOnEnd

func (v *VideoPlayer) SetOnEnd(fn func())

SetOnEnd registers a callback for when playback completes.

func (*VideoPlayer) StyleType

func (v *VideoPlayer) StyleType() string

StyleType returns the selector type name.

func (*VideoPlayer) WithBlitter deprecated

func (v *VideoPlayer) WithBlitter(blitter graphics.Blitter) *VideoPlayer

Deprecated: prefer WithVideoPlayerBlitter during construction or SetBlitter for mutation.

type VideoPlayerOption

type VideoPlayerOption = Option[VideoPlayer]

VideoPlayerOption configures a VideoPlayer.

func WithVideoPlayerBlitter

func WithVideoPlayerBlitter(blitter graphics.Blitter) VideoPlayerOption

WithVideoPlayerBlitter configures the blitter used for rendering frames.

func WithVideoPlayerOnEnd

func WithVideoPlayerOnEnd(fn func()) VideoPlayerOption

WithVideoPlayerOnEnd registers a callback for when playback completes.

type VirtualList

type VirtualList[T any] struct {
	FocusableBase
	// contains filtered or unexported fields
}

VirtualList renders large datasets efficiently using virtualization.

func NewVirtualList

func NewVirtualList[T any](adapter VirtualListAdapter[T]) *VirtualList[T]

NewVirtualList creates a virtual list widget.

func (*VirtualList[T]) Bind

func (v *VirtualList[T]) Bind(services runtime.Services)

Bind attaches app services.

func (*VirtualList[T]) HandleMessage

func (v *VirtualList[T]) HandleMessage(msg runtime.Message) runtime.HandleResult

HandleMessage handles navigation input.

func (*VirtualList[T]) Layout

func (v *VirtualList[T]) Layout(bounds runtime.Rect)

Layout stores bounds and updates viewport height.

func (*VirtualList[T]) Measure

func (v *VirtualList[T]) Measure(constraints runtime.Constraints) runtime.Size

Measure returns the desired size.

func (*VirtualList[T]) Offset

func (v *VirtualList[T]) Offset() int

Offset returns the current scroll offset.

func (*VirtualList[T]) OnSelect deprecated

func (v *VirtualList[T]) OnSelect(fn func(index int, item T))

OnSelect registers a selection handler on the virtual list.

Deprecated: Use SetOnSelect instead. This method will be removed in v1.0.

func (*VirtualList[T]) PageBy

func (v *VirtualList[T]) PageBy(pages int)

PageBy scrolls selection by a number of pages.

func (*VirtualList[T]) Render

func (v *VirtualList[T]) Render(ctx runtime.RenderContext)

Render draws the list items.

func (*VirtualList[T]) ScrollBy

func (v *VirtualList[T]) ScrollBy(dx, dy int)

ScrollBy scrolls selection by delta rows.

func (*VirtualList[T]) ScrollTo

func (v *VirtualList[T]) ScrollTo(x, y int)

ScrollTo scrolls to an absolute index.

func (*VirtualList[T]) ScrollToEnd

func (v *VirtualList[T]) ScrollToEnd()

ScrollToEnd selects the last item.

func (*VirtualList[T]) ScrollToIndex

func (v *VirtualList[T]) ScrollToIndex(index int)

ScrollToIndex scrolls to the specified index.

func (*VirtualList[T]) ScrollToOffset

func (v *VirtualList[T]) ScrollToOffset(offset int)

ScrollToOffset scrolls to the specified offset in rows/pixels.

func (*VirtualList[T]) ScrollToStart

func (v *VirtualList[T]) ScrollToStart()

ScrollToStart selects the first item.

func (*VirtualList[T]) SelectedIndex

func (v *VirtualList[T]) SelectedIndex() int

SelectedIndex returns the current selection.

func (*VirtualList[T]) SelectedItem

func (v *VirtualList[T]) SelectedItem() (T, bool)

SelectedItem returns the selected item.

func (*VirtualList[T]) SetAdapter

func (v *VirtualList[T]) SetAdapter(adapter VirtualListAdapter[T])

SetAdapter replaces the data adapter.

func (*VirtualList[T]) SetBehavior

func (v *VirtualList[T]) SetBehavior(behavior scroll.ScrollBehavior)

SetBehavior updates scroll behavior.

func (*VirtualList[T]) SetItemHeight

func (v *VirtualList[T]) SetItemHeight(height int)

SetItemHeight sets a fixed item height for faster indexing.

func (*VirtualList[T]) SetItemHeightFunc

func (v *VirtualList[T]) SetItemHeightFunc(fn func(index int) int)

SetItemHeightFunc sets a variable height function.

func (*VirtualList[T]) SetLabel

func (v *VirtualList[T]) SetLabel(label string)

SetLabel updates the accessibility label.

func (*VirtualList[T]) SetLazyLoad

func (v *VirtualList[T]) SetLazyLoad(fn func(start, end, total int))

SetLazyLoad registers a lazy-load callback for visible ranges.

func (*VirtualList[T]) SetLazyLoadThreshold

func (v *VirtualList[T]) SetLazyLoadThreshold(threshold int)

SetLazyLoadThreshold sets the item count threshold for triggering lazy loads.

func (*VirtualList[T]) SetOnSelect

func (v *VirtualList[T]) SetOnSelect(fn func(index int, item T))

SetOnSelect registers a selection handler.

func (*VirtualList[T]) SetOverscan

func (v *VirtualList[T]) SetOverscan(count int)

SetOverscan updates the number of extra items to render.

func (*VirtualList[T]) SetSelected

func (v *VirtualList[T]) SetSelected(index int)

SetSelected updates the selected index.

func (*VirtualList[T]) SetSelectedStyle

func (v *VirtualList[T]) SetSelectedStyle(style backend.Style)

SetSelectedStyle updates the selected row style.

func (*VirtualList[T]) SetStyle

func (v *VirtualList[T]) SetStyle(style backend.Style)

SetStyle updates the list base style.

func (*VirtualList[T]) SetWidgetPoolMax

func (v *VirtualList[T]) SetWidgetPoolMax(max int)

SetWidgetPoolMax limits the pooled widget count when using widget factories.

func (*VirtualList[T]) StyleType

func (v *VirtualList[T]) StyleType() string

StyleType returns the selector type name.

func (*VirtualList[T]) Unbind

func (v *VirtualList[T]) Unbind()

Unbind releases app services.

func (*VirtualList[T]) UseAdapterHeights

func (v *VirtualList[T]) UseAdapterHeights()

UseAdapterHeights reverts to adapter-provided heights when available.

type VirtualListAdapter

type VirtualListAdapter[T any] interface {
	Count() int
	Item(index int) T
	Render(item T, index int, selected bool, ctx runtime.RenderContext)
}

VirtualListAdapter provides data for a virtual list.

type VirtualListFixedHeightProvider

type VirtualListFixedHeightProvider interface {
	FixedItemHeight() int
}

VirtualListFixedHeightProvider optionally provides a fixed item height.

type VirtualListHeightProvider

type VirtualListHeightProvider interface {
	ItemHeight(index int) int
}

VirtualListHeightProvider optionally provides variable item heights.

type VirtualListWidgetFactory

type VirtualListWidgetFactory[T any] interface {
	NewWidget() runtime.Widget
	UpdateWidget(widget runtime.Widget, item T, index int, selected bool)
}

VirtualListWidgetFactory provides pooled widget rendering.

type VirtualListWidgetResetter

type VirtualListWidgetResetter interface {
	ResetWidget(widget runtime.Widget)
}

VirtualListWidgetResetter resets widgets before reusing them.

type WidgetPlugin

type WidgetPlugin struct {
	ID          string
	Name        string
	Version     string
	Description string
	Categories  []string
	New         func() runtime.Widget
}

WidgetPlugin describes a third-party widget plugin.

func WidgetPluginByID

func WidgetPluginByID(id string) (WidgetPlugin, bool)

WidgetPluginByID fetches a plugin by ID.

func WidgetPlugins

func WidgetPlugins() []WidgetPlugin

WidgetPlugins returns all registered plugins sorted by ID.

func (WidgetPlugin) Validate

func (p WidgetPlugin) Validate() error

Validate returns an error if the plugin metadata is incomplete.

Jump to

Keyboard shortcuts

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