theme/material3/collapsible.go
Functions
func PaintHeader
func (p CollapsiblePainter) PaintHeader(canvas widget.Canvas, s collapsible.HeaderState) {
if s.Bounds.IsEmpty() {
return
}
// Resolve colors from theme or defaults.
bgColor, textColor, arrowColor, focusColor := p.resolveHeaderColors(s)
// Apply interaction state to background.
bgColor = m3ApplyCollapsibleState(bgColor, s.Hovered, s.Pressed)
// Draw header background with rounded corners.
canvas.DrawRoundRect(s.Bounds, bgColor, m3CollapsibleRadius)
// Draw arrow indicator.
m3DrawCollapsibleArrow(canvas, s.Bounds, arrowColor, s.ArrowProgress)
// Draw title text.
if s.Title != "" {
titleBounds := m3CollapsibleTitleBounds(s.Bounds)
canvas.DrawText(s.Title, titleBounds, m3CollapsibleFontSize, textColor, true, m3CollapsibleTextAlign)
}
// Focus ring.
if s.Focused {
ringBounds := s.Bounds.Expand(m3CollapsibleFocusRingOffset)
ringRadius := m3CollapsibleRadius + m3CollapsibleFocusRingOffset
canvas.StrokeRoundRect(ringBounds, focusColor, ringRadius, m3CollapsibleFocusRingStrokeWidth)
}
}
Structs
type CollapsiblePainter struct
CollapsiblePainter renders collapsible section headers using Material 3 design tokens.
It maps header states (expanded, hovered, pressed, focused) to the M3 color scheme
with surface colors for the header and on-surface colors for text.
If Theme is nil, CollapsiblePainter falls back to the default M3 purple palette.
type CollapsiblePainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
PaintHeader renders a collapsible header according to Material 3 specifications.