theme/material3/radio.go

Functions Structs

Functions

func PaintRadio

PaintRadio renders a radio item according to Material 3 specifications.

func (p RadioPainter) PaintRadio(canvas widget.Canvas, state radio.PaintState) {
	if state.Bounds.IsEmpty() {
		return
	}

	// Determine the color scheme to use.
	colors := state.ColorScheme
	if colors == (radio.RadioColorScheme{}) {
		colors = p.resolveColors()
	}

	disabled := state.Disabled
	center, radius := m3RadioCircleGeometry(state.Bounds)

	if state.Selected {
		m3PaintSelectedRadio(canvas, center, radius, state, disabled, colors)
	} else {
		m3PaintUnselectedRadio(canvas, center, radius, state, disabled, colors)
	}

	// Draw label if present.
	if state.Label != "" {
		fg := colors.LabelColor
		if disabled {
			fg = colors.DisabledFg
		}
		labelBounds := m3RadioLabelBounds(state.Bounds)
		canvas.DrawText(state.Label, labelBounds, m3RadioFontSize, fg, false, m3RadioTextAlignLeft)
	}

	// Draw focus ring when focused.
	if state.Focused && !disabled {
		m3DrawRadioFocusIndicator(canvas, center, radius, colors)
	}
}

Structs

type RadioPainter struct

RadioPainter renders radio items using Material 3 design tokens.

It maps radio states (selected, unselected) to the M3 color scheme

and applies appropriate interaction feedback.

 

If Theme is nil, RadioPainter falls back to the default M3 purple palette.

type RadioPainter struct {
	Theme *Theme	// nil uses default M3 purple fallback
}