theme/material3/tabview.go

Functions Structs

Functions

func PaintTabBar

PaintTabBar renders a tab bar according to Material 3 specifications.

func (p TabViewPainter) PaintTabBar(canvas widget.Canvas, ps tabview.PaintState) {
	if ps.Bounds.IsEmpty() {
		return
	}

	// Determine the color scheme to use.
	colors := ps.ColorScheme
	if colors == (tabview.TabColorScheme{}) {
		colors = p.resolveColors()
	}

	// Tab bar background.
	canvas.DrawRect(ps.Bounds, colors.Background)

	// Draw each tab.
	for i := range ps.Tabs {
		ts := &ps.Tabs[i]
		m3PaintTab(canvas, ts, colors)
	}

	// Draw indicator under/over selected tab.
	if ps.SelectedIdx >= 0 && ps.SelectedIdx < len(ps.Tabs) {
		selected := &ps.Tabs[ps.SelectedIdx]
		m3PaintIndicator(canvas, selected.Bounds, ps.Position, colors.Indicator)
	}

	// Focus ring.
	if ps.Focused {
		ringBounds := ps.Bounds.Expand(m3TabFocusRingOffset)
		canvas.StrokeRoundRect(ringBounds, colors.FocusRing, m3TabFocusRadius, m3TabFocusRingStroke)
	}
}

Structs

type TabViewPainter struct

TabViewPainter renders tab bars using Material 3 design tokens.

It maps tab states to the M3 color scheme and applies appropriate

interaction feedback including an animated indicator.

 

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

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