Documentation
¶
Overview ¶
Package material3 provides a Google Material Design 3 (Material You) theme.
Material 3 uses a seed color to generate a complete, harmonious color scheme using HCT (Hue, Chroma, Tone) color science. From one color, the system derives primary, secondary, tertiary, and neutral palettes with proper contrast ratios for accessibility.
Creating a Theme ¶
Create a theme from a seed color:
theme := material3.New(widget.Hex(0x6750A4)) primary := theme.Colors.Primary fontSize := theme.Typography.BodyMedium.FontSize radius := theme.Shape.Medium
Light and Dark Schemes ¶
Light and dark color schemes are available:
lightColors := material3.Light(seedColor) darkColors := material3.Dark(seedColor)
Or create a complete dark theme:
darkTheme := material3.NewDark(seedColor)
Color Roles ¶
The color scheme includes the following role groups:
- Primary: key brand color and its container variant
- Secondary: accent color for less prominent elements
- Tertiary: complementary color for contrast and balance
- Error: error states and destructive actions
- Surface: neutral backgrounds at various elevation levels
- Outline: borders and dividers
Each color role has a corresponding "on" color for text/icons placed on top.
Typography ¶
The type scale provides 15 text styles organized into 5 categories:
- Display: large, impactful text
- Headline: section headers
- Title: component titles
- Body: primary reading text
- Label: UI labels and buttons
Shape ¶
The shape scale provides corner radius values from None (0dp) to Full (pill).
Component Painters ¶
The package provides painter implementations that render UI components according to Material 3 design specifications. Painters implement the interfaces defined in core packages and can be injected into widgets:
- ButtonPainter implements button.Painter for Material 3 button rendering
Example:
btn := button.New(
button.Text("Submit"),
button.PainterOpt(material3.ButtonPainter{}),
)
Index ¶
- type ButtonPainter
- type CheckboxPainter
- type CollapsiblePainter
- type ColorScheme
- type DataTablePainter
- func (p DataTablePainter) PaintCell(canvas widget.Canvas, cps datatable.CellPaintState)
- func (p DataTablePainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
- func (p DataTablePainter) PaintHeader(canvas widget.Canvas, bounds geometry.Rect, hps datatable.HeaderPaintState)
- func (p DataTablePainter) PaintHeaderCell(canvas widget.Canvas, bounds geometry.Rect, hcs datatable.HeaderCellPaintState)
- func (p DataTablePainter) PaintRow(canvas widget.Canvas, rps datatable.RowPaintState)
- type DialogPainter
- type DockingPainter
- type DropdownPainter
- type GridViewPainter
- type LineChartPainter
- type ListViewPainter
- func (p ListViewPainter) PaintDivider(canvas widget.Canvas, ds listview.DividerState)
- func (p ListViewPainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
- func (p ListViewPainter) PaintItemBackground(canvas widget.Canvas, ips listview.ItemPaintState)
- func (p ListViewPainter) PaintSelection(canvas widget.Canvas, ips listview.ItemPaintState)
- type MenuPainter
- type PopoverPainter
- type ProgressBarPainter
- type ProgressPainter
- type RadioPainter
- type ScrollbarPainter
- type ShapeScale
- type SliderPainter
- type SplitViewPainter
- type TabViewPainter
- type TextFieldPainter
- type TextStyle
- type Theme
- type ToolbarPainter
- type TreeViewPainter
- func (p TreeViewPainter) PaintConnectorLines(canvas widget.Canvas, s treeview.ConnectorState)
- func (p TreeViewPainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
- func (p TreeViewPainter) PaintExpandIcon(canvas widget.Canvas, s treeview.ExpandIconState)
- func (p TreeViewPainter) PaintLabel(canvas widget.Canvas, s treeview.LabelState)
- func (p TreeViewPainter) PaintRowBackground(canvas widget.Canvas, s treeview.RowPaintState)
- func (p TreeViewPainter) PaintSelection(canvas widget.Canvas, s treeview.RowPaintState)
- type TypeScale
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ButtonPainter ¶
type ButtonPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
ButtonPainter renders buttons using Material 3 design tokens. It maps button variants (Filled, Outlined, TextOnly, Tonal) to the M3 color scheme and applies appropriate interaction feedback.
If Theme is nil, ButtonPainter falls back to the default M3 purple palette.
func (ButtonPainter) PaintButton ¶
func (p ButtonPainter) PaintButton(canvas widget.Canvas, state button.PaintState)
PaintButton renders a button according to Material 3 specifications.
type CheckboxPainter ¶
type CheckboxPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
CheckboxPainter renders checkboxes using Material 3 design tokens. It maps checkbox states (checked, unchecked, indeterminate) to the M3 color scheme and applies appropriate interaction feedback.
If Theme is nil, CheckboxPainter falls back to the default M3 purple palette.
func (CheckboxPainter) PaintCheckbox ¶
func (p CheckboxPainter) PaintCheckbox(canvas widget.Canvas, state checkbox.PaintState)
PaintCheckbox renders a checkbox according to Material 3 specifications.
type CollapsiblePainter ¶
type CollapsiblePainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
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.
func (CollapsiblePainter) PaintHeader ¶
func (p CollapsiblePainter) PaintHeader(canvas widget.Canvas, s collapsible.HeaderState)
PaintHeader renders a collapsible header according to Material 3 specifications.
type ColorScheme ¶
type ColorScheme struct {
// Primary group: key brand color and its variants.
Primary widget.Color
OnPrimary widget.Color
PrimaryContainer widget.Color
OnPrimaryContainer widget.Color
// Secondary group: accent color for less prominent elements.
Secondary widget.Color
OnSecondary widget.Color
SecondaryContainer widget.Color
OnSecondaryContainer widget.Color
// Tertiary group: complementary color for contrast and balance.
Tertiary widget.Color
OnTertiary widget.Color
TertiaryContainer widget.Color
OnTertiaryContainer widget.Color
// Error group: error states and destructive actions.
Error widget.Color
OnError widget.Color
ErrorContainer widget.Color
OnErrorContainer widget.Color
// Surface group: neutral backgrounds at various elevation levels.
Surface widget.Color
OnSurface widget.Color
SurfaceVariant widget.Color
OnSurfaceVariant widget.Color
SurfaceContainerLowest widget.Color
SurfaceContainerLow widget.Color
SurfaceContainer widget.Color
SurfaceContainerHigh widget.Color
SurfaceContainerHighest widget.Color
// Background colors.
Background widget.Color
OnBackground widget.Color
// Outline colors for borders and dividers.
Outline widget.Color
OutlineVariant widget.Color
// Inverse colors for elements that appear on inverse surfaces.
InverseSurface widget.Color
InverseOnSurface widget.Color
InversePrimary widget.Color
}
ColorScheme holds all Material 3 color roles.
Material 3 defines a comprehensive set of color roles organized in primary/secondary/tertiary/error groups, each with container variants and corresponding "on" colors for content placed on top. Surface colors provide a neutral backdrop with multiple elevation levels.
func Dark ¶
func Dark(seed widget.Color) ColorScheme
Dark generates a dark color scheme from a seed color.
The seed color is used to derive a full set of harmonious colors following Material 3 tonal mapping rules for dark themes.
func Light ¶
func Light(seed widget.Color) ColorScheme
Light generates a light color scheme from a seed color.
The seed color is used to derive a full set of harmonious colors following Material 3 tonal mapping rules for light themes.
type DataTablePainter ¶
type DataTablePainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
DataTablePainter renders data tables using Material 3 design tokens. It maps M3 color roles to table elements: surface-container for header, on-surface for text, surface-variant for zebra striping, and primary for selection.
If Theme is nil, DataTablePainter falls back to the default M3 purple palette.
func (DataTablePainter) PaintCell ¶
func (p DataTablePainter) PaintCell(canvas widget.Canvas, cps datatable.CellPaintState)
PaintCell draws a single data cell with M3 on-surface text color.
func (DataTablePainter) PaintEmptyState ¶
func (p DataTablePainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
PaintEmptyState draws a centered "No data" message with M3 on-surface-variant color.
func (DataTablePainter) PaintHeader ¶
func (p DataTablePainter) PaintHeader(canvas widget.Canvas, bounds geometry.Rect, hps datatable.HeaderPaintState)
PaintHeader draws the table header background with M3 surface-container color.
func (DataTablePainter) PaintHeaderCell ¶
func (p DataTablePainter) PaintHeaderCell(canvas widget.Canvas, bounds geometry.Rect, hcs datatable.HeaderCellPaintState)
PaintHeaderCell draws a column header with title and sort indicator.
func (DataTablePainter) PaintRow ¶
func (p DataTablePainter) PaintRow(canvas widget.Canvas, rps datatable.RowPaintState)
PaintRow draws the row background with zebra striping and M3 selection/hover highlights.
type DialogPainter ¶
type DialogPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
DialogPainter renders dialogs using Material 3 design tokens. It applies the M3 dialog specification: surface tint, headline small typography, and text action buttons.
If Theme is nil, DialogPainter falls back to the default M3 purple palette.
func (DialogPainter) PaintDialog ¶
func (p DialogPainter) PaintDialog(canvas widget.Canvas, ps dialog.PaintState)
PaintDialog renders a dialog according to Material 3 specifications.
type DockingPainter ¶
type DockingPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
DockingPainter renders docking zones and tab bars using Material 3 design tokens. It maps M3 color roles to docking elements: surface for zones, outline for borders, and surface-variant for the tab bar background.
If Theme is nil, DockingPainter falls back to the default M3 purple palette.
func (DockingPainter) PaintZoneBorder ¶
func (p DockingPainter) PaintZoneBorder(canvas widget.Canvas, borderRect geometry.Rect, _ docking.Zone)
PaintZoneBorder renders the border between a zone and the center using M3 outline-variant.
func (DockingPainter) PaintZoneTabs ¶
func (p DockingPainter) PaintZoneTabs(canvas widget.Canvas, ps docking.ZoneTabsPaintState)
PaintZoneTabs renders the tab header bar using M3 surface-variant and primary accent.
type DropdownPainter ¶
type DropdownPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
DropdownPainter renders dropdowns using Material 3 design tokens. It implements the outlined dropdown variant with theme-derived colors.
If Theme is nil, DropdownPainter falls back to the default M3 purple palette.
func (DropdownPainter) PaintMenu ¶
func (p DropdownPainter) PaintMenu(canvas widget.Canvas, st *dropdown.MenuPaintState)
PaintMenu renders a dropdown menu according to Material 3 specifications.
func (DropdownPainter) PaintTrigger ¶
func (p DropdownPainter) PaintTrigger(canvas widget.Canvas, st *dropdown.TriggerPaintState)
PaintTrigger renders a dropdown trigger according to Material 3 specifications.
type GridViewPainter ¶
type GridViewPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
GridViewPainter renders grid view elements using Material 3 design tokens. It maps cell states (selected, hovered, focused) to the M3 color scheme with primary for selection, secondary-container for hover, and surface for cells.
If Theme is nil, GridViewPainter falls back to the default M3 purple palette.
func (GridViewPainter) PaintCellBackground ¶
func (p GridViewPainter) PaintCellBackground(canvas widget.Canvas, cps gridview.CellPaintState)
PaintCellBackground draws the background for a grid cell. This is called before the cell widget's own Draw method.
func (GridViewPainter) PaintEmptyState ¶
func (p GridViewPainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
PaintEmptyState draws a centered empty state message.
func (GridViewPainter) PaintSelection ¶
func (p GridViewPainter) PaintSelection(canvas widget.Canvas, cps gridview.CellPaintState)
PaintSelection draws the selection highlight for a selected cell. This is called before the cell widget's own Draw method.
type LineChartPainter ¶
type LineChartPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
LineChartPainter renders line charts using Material 3 design tokens. It maps M3 color roles to chart elements: primary for data lines, surface for background, and on-surface-variant for grid/labels.
If Theme is nil, LineChartPainter falls back to the default M3 purple palette.
func (LineChartPainter) PaintChart ¶
func (p LineChartPainter) PaintChart(canvas widget.Canvas, bounds geometry.Rect, state linechart.PaintState)
PaintChart renders a line chart according to Material 3 specifications.
type ListViewPainter ¶
type ListViewPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
ListViewPainter renders list view elements using Material 3 design tokens. It maps list states (divider, empty, hover, selection) to the M3 color scheme and applies appropriate visual feedback.
If Theme is nil, ListViewPainter falls back to the default M3 purple palette.
func (ListViewPainter) PaintDivider ¶
func (p ListViewPainter) PaintDivider(canvas widget.Canvas, ds listview.DividerState)
PaintDivider draws a M3-styled divider between list items.
func (ListViewPainter) PaintEmptyState ¶
func (p ListViewPainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
PaintEmptyState draws a M3-styled empty state message.
func (ListViewPainter) PaintItemBackground ¶
func (p ListViewPainter) PaintItemBackground(canvas widget.Canvas, ips listview.ItemPaintState)
PaintItemBackground draws the M3 item background with hover state.
func (ListViewPainter) PaintSelection ¶
func (p ListViewPainter) PaintSelection(canvas widget.Canvas, ips listview.ItemPaintState)
PaintSelection draws the M3 selection highlight.
type MenuPainter ¶
type MenuPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
MenuPainter renders menus and menu bars using Material 3 design tokens. It maps M3 color roles to menu elements: surface for containers, elevation shadow for depth, on-surface for text, and primary for highlight states.
If Theme is nil, MenuPainter falls back to the default M3 purple palette.
func (MenuPainter) PaintMenu ¶
func (p MenuPainter) PaintMenu(canvas widget.Canvas, st *menu.MenuPaintState)
PaintMenu renders a popup menu panel with M3 surface and elevation styling.
func (MenuPainter) PaintMenuBar ¶
func (p MenuPainter) PaintMenuBar(canvas widget.Canvas, st *menu.MenuBarPaintState)
PaintMenuBar renders a menu bar with M3 surface and elevation styling.
type PopoverPainter ¶
type PopoverPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
PopoverPainter renders popovers and tooltips using Material 3 design tokens. It applies M3 surface container elevation, outline-variant borders, and inverse-surface tooltip styling.
If Theme is nil, PopoverPainter falls back to the default M3 purple palette.
func (PopoverPainter) PaintPopover ¶
func (p PopoverPainter) PaintPopover(canvas widget.Canvas, st *popover.PopoverPaintState)
PaintPopover renders a popover background with shadow according to M3 specifications.
func (PopoverPainter) PaintTooltip ¶
func (p PopoverPainter) PaintTooltip(canvas widget.Canvas, st *popover.TooltipPaintState)
PaintTooltip renders a tooltip background and text according to M3 specifications.
type ProgressBarPainter ¶
type ProgressBarPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
ProgressBarPainter renders progress bars using Material 3 design tokens. It maps progress bar states (normal, disabled) to the M3 color scheme with primary color for the filled bar and surface variant for the track.
If Theme is nil, ProgressBarPainter falls back to the default M3 purple palette.
func (ProgressBarPainter) PaintProgressBar ¶
func (p ProgressBarPainter) PaintProgressBar(canvas widget.Canvas, ps progressbar.PaintState)
PaintProgressBar renders a progress bar according to Material 3 specifications.
type ProgressPainter ¶
type ProgressPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
ProgressPainter renders circular progress indicators using Material 3 design tokens. It maps progress states (determinate, indeterminate, disabled) to the M3 color scheme with primary color for the arc and surface variant for the track.
If Theme is nil, ProgressPainter falls back to the default M3 purple palette.
func (ProgressPainter) PaintProgress ¶
func (p ProgressPainter) PaintProgress(canvas widget.Canvas, ps progress.PaintState)
PaintProgress renders a circular progress indicator according to Material 3 specifications.
type RadioPainter ¶
type RadioPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
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.
func (RadioPainter) PaintRadio ¶
func (p RadioPainter) PaintRadio(canvas widget.Canvas, state radio.PaintState)
PaintRadio renders a radio item according to Material 3 specifications.
type ScrollbarPainter ¶
type ScrollbarPainter struct {
Theme *Theme // nil uses default M3 fallback
}
ScrollbarPainter renders scrollbars using Material 3 design tokens. It maps scrollbar states (normal, hover, dragging) to the M3 color scheme.
If Theme is nil, ScrollbarPainter falls back to the default M3 scrollbar palette.
func (ScrollbarPainter) PaintScrollbar ¶
func (p ScrollbarPainter) PaintScrollbar(canvas widget.Canvas, ps scrollview.PaintState)
PaintScrollbar renders scrollbars according to Material 3 specifications.
type ShapeScale ¶
type ShapeScale struct {
// None is no rounding (sharp corners): 0dp.
None float32
// ExtraSmall is subtle rounding: 4dp.
// Used for small components like chips and text fields.
ExtraSmall float32
// Small is moderate rounding: 8dp.
// Used for buttons and small cards.
Small float32
// Medium is standard rounding: 12dp.
// Used for cards, dialogs, and menus.
Medium float32
// Large is generous rounding: 16dp.
// Used for large cards and sheets.
Large float32
// ExtraLarge is very generous rounding: 28dp.
// Used for floating action buttons and large containers.
ExtraLarge float32
// Full is fully rounded: 9999dp.
// Creates circular or pill shapes regardless of element size.
Full float32
}
ShapeScale holds Material 3 corner radius values.
Material 3 defines a shape scale that ranges from no rounding (None) to fully circular (Full). These values are used for consistent corner rounding across UI components.
Reference: https://m3.material.io/styles/shape/overview
func DefaultShapeScale ¶
func DefaultShapeScale() ShapeScale
DefaultShapeScale returns the standard Material 3 shape scale.
Values follow the M3 specification:
None: 0dp ExtraSmall: 4dp Small: 8dp Medium: 12dp Large: 16dp ExtraLarge: 28dp Full: 9999dp (fully rounded)
type SliderPainter ¶
type SliderPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
SliderPainter renders sliders using Material 3 design tokens. It maps slider states (normal, hover, dragging, disabled) to the M3 color scheme and applies appropriate interaction feedback.
If Theme is nil, SliderPainter falls back to the default M3 purple palette.
func (SliderPainter) PaintSlider ¶
func (p SliderPainter) PaintSlider(canvas widget.Canvas, ps slider.PaintState)
PaintSlider renders a slider according to Material 3 specifications.
type SplitViewPainter ¶
type SplitViewPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
SplitViewPainter renders split view dividers using Material 3 design tokens. It maps divider states (normal, hovered, dragging) to the M3 color scheme with outline-variant for the divider and primary color for the handle.
If Theme is nil, SplitViewPainter falls back to the default M3 purple palette.
func (SplitViewPainter) PaintDivider ¶
func (p SplitViewPainter) PaintDivider(canvas widget.Canvas, ps splitview.PaintState)
PaintDivider renders a split view divider according to Material 3 specifications.
type TabViewPainter ¶
type TabViewPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
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.
func (TabViewPainter) PaintTabBar ¶
func (p TabViewPainter) PaintTabBar(canvas widget.Canvas, ps tabview.PaintState)
PaintTabBar renders a tab bar according to Material 3 specifications.
type TextFieldPainter ¶
type TextFieldPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
TextFieldPainter renders text fields using Material 3 design tokens. It implements the outlined text field variant with theme-derived colors.
If Theme is nil, TextFieldPainter falls back to the default M3 purple palette.
func (TextFieldPainter) PaintTextField ¶
func (p TextFieldPainter) PaintTextField(canvas widget.Canvas, st textfield.PaintState)
PaintTextField renders a text field according to Material 3 specifications.
type TextStyle ¶
type TextStyle struct {
// FontSize is the font size in logical pixels (sp).
FontSize float32
// LineHeight is the line height in logical pixels.
LineHeight float32
// Bold indicates whether the text should be rendered in bold weight.
// In Material 3, "bold" typically maps to Medium (500) weight.
Bold bool
}
TextStyle defines font properties for a typography role.
This is a simplified text style containing the essential properties needed for M3 typography: font size, line height, and weight indicator.
type Theme ¶
type Theme struct {
// Colors holds the Material 3 color scheme derived from the seed color.
Colors ColorScheme
// Typography holds the Material 3 type scale.
Typography TypeScale
// Shape holds the Material 3 corner radius scale.
Shape ShapeScale
// contains filtered or unexported fields
}
Theme provides Material 3 (Material You) design tokens.
A Theme contains the complete set of design tokens needed to style a Material 3 application: colors, typography, and shape. It is generated from a single seed color, which is used to derive a full harmonious color scheme.
Create a theme with New:
theme := material3.New(widget.Hex(0x6750A4)) primary := theme.Colors.Primary fontSize := theme.Typography.BodyMedium.FontSize radius := theme.Shape.Medium
func New ¶
New creates a Material 3 theme from a seed color.
The seed color drives the entire color scheme. Material 3 derives primary, secondary, tertiary, neutral, and error palettes from this single seed using HCT (Hue, Chroma, Tone) color science.
By default, the theme uses a light color scheme. Use NewDark for a dark scheme, or access Light and Dark functions to generate color schemes independently.
func NewDark ¶
NewDark creates a Material 3 theme with a dark color scheme from a seed color.
This is equivalent to New but uses dark mode tonal mappings.
func (*Theme) AsTheme ¶ added in v0.1.14
AsTheme converts the Material 3 theme to a theme.Theme for use with the generic theme system. This maps M3 color roles to the shared theme.ColorPalette structure, preserving background, surface, and on-color relationships.
Use this when you need to pass an M3 theme to APIs that accept *theme.Theme, such as [app.WithTheme] or [app.App.SetTheme]:
m3 := material3.New(widget.Hex(0x6750A4)) uiApp := app.New(app.WithTheme(m3.AsTheme()))
type ToolbarPainter ¶
type ToolbarPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
ToolbarPainter renders toolbars using Material 3 design tokens. It maps M3 color roles to toolbar elements: surface for background, on-surface for icons, and primary-container for hover highlights.
If Theme is nil, ToolbarPainter falls back to the default M3 purple palette.
func (ToolbarPainter) PaintButtonItem ¶
func (p ToolbarPainter) PaintButtonItem(canvas widget.Canvas, state toolbar.PaintButtonState)
PaintButtonItem renders a button item with icon and optional label using M3 colors.
func (ToolbarPainter) PaintSeparator ¶
func (p ToolbarPainter) PaintSeparator(canvas widget.Canvas, bounds geometry.Rect)
PaintSeparator renders a vertical separator line using M3 outline-variant.
func (ToolbarPainter) PaintToolbar ¶
func (p ToolbarPainter) PaintToolbar(canvas widget.Canvas, state toolbar.PaintToolbarState)
PaintToolbar renders the toolbar background using M3 surface color.
type TreeViewPainter ¶
type TreeViewPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
TreeViewPainter renders tree views using Material 3 design tokens. It maps M3 color roles to tree elements: primary for selection, surface for background, outline for connector lines, and on-surface for text.
If Theme is nil, TreeViewPainter falls back to the default M3 purple palette.
func (TreeViewPainter) PaintConnectorLines ¶
func (p TreeViewPainter) PaintConnectorLines(canvas widget.Canvas, s treeview.ConnectorState)
PaintConnectorLines draws L-shaped connector lines using M3 outline color.
func (TreeViewPainter) PaintEmptyState ¶
func (p TreeViewPainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect)
PaintEmptyState draws a centered placeholder message using M3 on-surface-variant.
func (TreeViewPainter) PaintExpandIcon ¶
func (p TreeViewPainter) PaintExpandIcon(canvas widget.Canvas, s treeview.ExpandIconState)
PaintExpandIcon draws the expand/collapse indicator using M3 on-surface-variant.
func (TreeViewPainter) PaintLabel ¶
func (p TreeViewPainter) PaintLabel(canvas widget.Canvas, s treeview.LabelState)
PaintLabel draws the node label text using M3 on-surface color.
func (TreeViewPainter) PaintRowBackground ¶
func (p TreeViewPainter) PaintRowBackground(canvas widget.Canvas, s treeview.RowPaintState)
PaintRowBackground draws the hover highlight for a tree row using M3 colors.
func (TreeViewPainter) PaintSelection ¶
func (p TreeViewPainter) PaintSelection(canvas widget.Canvas, s treeview.RowPaintState)
PaintSelection draws the selection highlight using M3 primary color.
type TypeScale ¶
type TypeScale struct {
DisplayLarge TextStyle
DisplayMedium TextStyle
DisplaySmall TextStyle
HeadlineLarge TextStyle
HeadlineMedium TextStyle
HeadlineSmall TextStyle
TitleLarge TextStyle
TitleMedium TextStyle
TitleSmall TextStyle
BodyLarge TextStyle
BodyMedium TextStyle
BodySmall TextStyle
LabelLarge TextStyle
LabelMedium TextStyle
LabelSmall TextStyle
}
TypeScale holds the 15 Material 3 typography roles.
Material 3 organizes typography into five categories (Display, Headline, Title, Body, Label), each with three sizes (Large, Medium, Small). This provides a complete type scale for building consistent UIs.
func DefaultTypeScale ¶
func DefaultTypeScale() TypeScale
DefaultTypeScale returns the standard Material 3 type scale.
Font sizes and line heights follow the M3 specification: https://m3.material.io/styles/typography/type-scale-tokens
Source Files
¶
- button.go
- checkbox.go
- collapsible.go
- color.go
- datatable.go
- dialog.go
- doc.go
- docking.go
- dropdown.go
- gridview.go
- hct.go
- linechart.go
- listview.go
- material3.go
- menu.go
- palette.go
- popover.go
- progress.go
- progressbar.go
- radio.go
- scrollbar.go
- shape.go
- slider.go
- splitview.go
- tabview.go
- textfield.go
- theme.go
- toolbar.go
- treeview.go
- typography.go