core/textfield/painter.go

Functions Structs Interfaces

Functions

func PaintTextField

PaintTextField renders a minimal text field with gray outline.

If the state has a non-zero ColorScheme (via the M3 painter), use those colors.

func (p DefaultPainter) PaintTextField(canvas widget.Canvas, st PaintState) {
	if st.Bounds.IsEmpty() {
		return
	}

	paintBackground(canvas, st)
	paintBorder(canvas, st)
	paintContent(canvas, st)
	paintCursor(canvas, st)
}

Structs

type PaintState struct

PaintState provides the current text field state to the painter.

type PaintState struct {
	Text		string
	Placeholder	string
	Focused		bool
	Hovered		bool
	Disabled	bool
	HasError	bool
	ErrorMsg	string
	CursorPos	int
	SelectStart	int
	SelectEnd	int
	InputType	InputType
	Bounds		geometry.Rect
}

type TextFieldColorScheme struct

TextFieldColorScheme provides theme-derived colors for text field painting.

Zero value means the painter should use its built-in defaults.

type TextFieldColorScheme struct {
	Background	widget.Color
	Border		widget.Color
	FocusBorder	widget.Color
	ErrorBorder	widget.Color
	TextColor	widget.Color
	Placeholder	widget.Color
	CursorColor	widget.Color
	DisabledBg	widget.Color
	DisabledFg	widget.Color
	SelectionBg	widget.Color
	ErrorText	widget.Color
}

type DefaultPainter struct

DefaultPainter provides a minimal fallback painter with no design system styling.

It draws a simple outlined text field suitable for testing and prototyping.

type DefaultPainter struct{}

Interfaces

type Painter interface

Painter draws the visual representation of a text field.

Each design system (Material 3, Fluent, Cupertino) provides its own

Painter implementation to render the text field in its visual style.

 

If no Painter is set, the text field uses [DefaultPainter].

type Painter interface {
	PaintTextField(canvas widget.Canvas, state PaintState)
}