Documentation
¶
Overview ¶
Package md3e is a pure-Go Material Design 3 Expressive component library for MyGo's native GPU UI toolkit (github.com/egoist/mygo/ui). It draws every component itself, with no HTML, WebView or cgo, and runs on desktops (macOS, Windows, Linux) and in browsers (GOOS=js GOARCH=wasm).
The library is layered:
- github.com/imicola/mygo-md3e/tokens holds the MD3E design tokens: HCT color science, tonal palettes, dynamic color schemes, typography, shape and elevation.
- github.com/imicola/mygo-md3e/motion maps the MD3E spring specifications onto MyGo's physics, converting damping ratios to physical damping coefficients.
- github.com/imicola/mygo-md3e/shape builds the 35 Material Expressive shapes and morphs between them as closed cubic Bézier loops.
- github.com/imicola/mygo-md3e/symbols provides 252 zero-bloat rounded 24x24 vector icons whose (*Symbol).Draw method values plug directly into IconDraw.
- package md3e itself holds the core components, from buttons and selection controls to search/select/combobox/token inputs, disclosures, responsive forms, numeric steppers, inline editable text, color pickers/wells, command palettes, find bars, popovers, adaptive side sheets, concurrent toast stacks, confirmation/prompt dialogs, desktop shells, sidebars, routers, document tabs, overlays, virtualized tables/grids/ outline tables, typed/file drop zones, and local/SVG images.
- github.com/imicola/mygo-md3e/media, github.com/imicola/mygo-md3e/charts, github.com/imicola/mygo-md3e/docview, and github.com/imicola/mygo-md3e/codeview are opt-in extension subpackages for network images/lightbox/video/audio players, real-time/statistical charts over ui/chart, Markdown/streaming documents/outline over ui/markdown, and editor theme/font bridging over ui/editor, isolated from root md3e for zero-bloat DCE.
Components follow MyGo's value API: an element and its context live for one build pass only, state is held by the caller through pointers, and a component's key is given to the context before the component is built.
Index ¶
- Constants
- Variables
- func Accordion(c *ui.Context, sections []AccordionSection, opts ...AccordionOptions) ui.Element
- func ActionTile(c *ui.Context, title string, opts ...ActionTileOptions) ui.Element
- func ActionToolbar(c *ui.Context, actions []ToolbarAction, opts ...ToolbarOptions) ui.Element
- func AdaptiveScaffold(c *ui.Context, destinations []NavigationDestination, content func(), ...) ui.Element
- func AlertDialog(c *ui.Context, open *bool, opts ...AlertDialogOptions) ui.Element
- func AnimatedContent[K comparable](c *ui.Context, key K, build func(), opts ...TransitionOptions) ui.Element
- func AnimatedThemeScope(c *ui.Context, target *Theme, fn func(), opts ...ThemeTransitionOptions) ui.Element
- func AppShell(c *ui.Context, content func(), opts ...AppShellOptions) ui.Element
- func ApplyDataTableMenuActions(m *ui.Menu, actions []DataTableMenuAction)
- func ApplyElevationShadows(t *Theme, el ui.Element, level tokens.ElevationLevel) ui.Element
- func ApplyTonalElevation(t *Theme, base ui.Color, level tokens.ElevationLevel) ui.Color
- func ApplyTypeStyle(c *ui.Context, el ui.Element, role tokens.TypeRole, emphasized ...bool) ui.Element
- func AssistChip(c *ui.Context, label string, opts ...ChipOptions) ui.Element
- func AttachRipple(c *ui.Context, el ui.Element, opts ...StateLayerOptions) ui.Element
- func AttachStateLayer(c *ui.Context, el ui.Element, opts ...StateLayerOptions) ui.Element
- func Autocomplete(c *ui.Context, value *string, suggestions []string, opts ...CompletionOptions) ui.Element
- func Avatar(c *ui.Context, opts ...AvatarOptions) ui.Element
- func Badge(c *ui.Context, text string, opts ...BadgeOptions) ui.Element
- func BadgedBox(c *ui.Context, content func(), badge func() ui.Element, ...) ui.Element
- func Banner(c *ui.Context, message string, opts ...BannerOptions) ui.Element
- func BentoGrid(c *ui.Context, content func(), opts ...BentoGridOptions) ui.Element
- func BentoSpan(el ui.Element, cols, rows int) ui.Element
- func BodyText(c *ui.Context, s string, opts ...TextOptions) ui.Element
- func BottomSheet(c *ui.Context, open *bool, opts ...BottomSheetOptions) ui.Element
- func Breadcrumb(c *ui.Context, items []BreadcrumbItem, opts ...BreadcrumbOptions) ui.Element
- func Button(c *ui.Context, label string, opts ...ButtonOptions) ui.Element
- func ButtonGroup(c *ui.Context, selected *int, items []ButtonGroupItem, ...) ui.Element
- func ButtonGroupActions(c *ui.Context, items []ButtonGroupItem, onAction func(i int), ...) ui.Element
- func ButtonGroupMulti(c *ui.Context, selected *[]bool, items []ButtonGroupItem, ...) ui.Element
- func Card(c *ui.Context, content func(), opts ...CardOptions) ui.Element
- func Carousel(c *ui.Context, items []CarouselItem, opts ...CarouselOptions) ui.Element
- func Checkbox(c *ui.Context, checked *bool, opts ...CheckboxOptions) ui.Element
- func CheckboxState(c *ui.Context, state *ui.CheckState, opts ...CheckboxOptions) ui.Element
- func ChipGroup(c *ui.Context, fn func(), opts ...ChipGroupOptions) ui.Element
- func CircularProgress(c *ui.Context, value float64, opts ...ProgressOptions) ui.Element
- func CircularWavyProgress(c *ui.Context, value float64, opts ...ProgressOptions) ui.Element
- func Collapsible(c *ui.Context, label string, open *bool, body func(), ...) ui.Element
- func ColorPicker(c *ui.Context, color *ui.Color, opts ...ColorPickerOptions) ui.Element
- func ColorWell(c *ui.Context, color *ui.Color, opts ...ColorWellOptions) ui.Element
- func Combobox(c *ui.Context, selected *string, choices []string, opts ...CompletionOptions) ui.Element
- func CommandPalette(c *ui.Context, open *bool, commands []Command, opts ...PaletteOptions) ui.Element
- func ConfirmDialog(c *ui.Context, open *bool, opts ...ConfirmDialogOptions) ui.Element
- func ContextMenu(c *ui.Context, target ui.Element, items []MenuItem, opts ...MenuOptions) ui.Element
- func DataTable(c *ui.Context, columns []DataTableColumn, count int, cell func(row, col int), ...) ui.Element
- func DataTableCellText(c *ui.Context, text string, opts ...DataTableCellOptions) ui.Element
- func DatePicker(c *ui.Context, value *time.Time, opts ...DatePickerOptions) ui.Element
- func DateRangePicker(c *ui.Context, start, end *time.Time, opts ...DatePickerOptions) ui.Element
- func DefaultLoadingPolygons() []*shape.RoundedPolygon
- func DisplayText(c *ui.Context, s string, opts ...TextOptions) ui.Element
- func Divider(c *ui.Context, opts ...DividerOptions) ui.Element
- func DropZone[T any](c *ui.Context, content func(active bool), opts ...DropZoneOptions[T]) ui.Element
- func DropdownMenu(c *ui.Context, label string, items []MenuItem, opts ...MenuOptions) ui.Element
- func EditableText(c *ui.Context, value *string, opts ...EditableTextOptions) ui.Element
- func ElevatedCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
- func EmptyState(c *ui.Context, title string, opts ...EmptyStateOptions) ui.Element
- func ExtendedFAB(c *ui.Context, label string, icon IconDraw, opts ...ExtendedFABOptions) ui.Element
- func FAB(c *ui.Context, label string, icon IconDraw, opts ...FABOptions) ui.Element
- func FABMenu(c *ui.Context, items []FABMenuItem, opts ...FABMenuOptions) ui.Element
- func FileDropZone(c *ui.Context, content func(active bool), opts ...FileDropZoneOptions) ui.Element
- func FilledCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
- func FilterChip(c *ui.Context, selected *bool, label string, opts ...FilterChipOptions) ui.Element
- func FindBar(c *ui.Context, open *bool, query *string, matches int, current *int, ...) ui.Element
- func FloatingToolbar(c *ui.Context, items []FloatingToolbarItem, opts ...FloatingToolbarOptions) ui.Element
- func Form(c *ui.Context, body func(), opts ...FormOptions) ui.Element
- func FormField(c *ui.Context, label string, control func(), opts ...FieldOptions) ui.Element
- func FormatKeyChord(chord KeyChord) string
- func FullScreenDialog(c *ui.Context, open *bool, opts ...FullScreenDialogOptions) ui.Element
- func GridView(c *ui.Context, count int, minWidth, height float32, item func(i int), ...) ui.Element
- func HeadlineText(c *ui.Context, s string, opts ...TextOptions) ui.Element
- func HistoryButtons(c *ui.Context, r *ui.Router, opts ...HistoryOptions) ui.Element
- func IconBadge(c *ui.Context, icon IconDraw, opts ...IconBadgeOptions) ui.Element
- func IconButton(c *ui.Context, label string, icon IconDraw, opts ...IconButtonOptions) ui.Element
- func Image(c *ui.Context, src ui.ImageSource, opts ...ImageOptions) ui.Element
- func InputChip(c *ui.Context, label string, opts ...InputChipOptions) ui.Element
- func Kbd(c *ui.Context, chord KeyChord, opts ...KbdOptions) ui.Element
- func LabelText(c *ui.Context, s string, opts ...TextOptions) ui.Element
- func LinearProgress(c *ui.Context, value float64, opts ...ProgressOptions) ui.Element
- func LinearWavyProgress(c *ui.Context, value float64, opts ...ProgressOptions) ui.Element
- func Link(c *ui.Context, text, target string, opts ...LinkOptions) ui.Element
- func List(c *ui.Context, items []ListItem, opts ...ListOptions) ui.Element
- func ListDetailPane(c *ui.Context, list func(), detail func(), opts ...ListDetailPaneOptions) ui.Element
- func LoadingIndicator(c *ui.Context, opts ...LoadingOptions) ui.Element
- func MenuButton(c *ui.Context, label string, icon IconDraw, items []MenuItem, ...) ui.Element
- func MorphIconButton(c *ui.Context, on *bool, label string, icon IconDraw, ...) ui.Element
- func NavigationBar(c *ui.Context, destinations []NavigationDestination, ...) ui.Element
- func NavigationDrawer(c *ui.Context, items []NavigationDrawerItem, opts ...NavigationDrawerOptions) ui.Element
- func NavigationRail(c *ui.Context, destinations []NavigationDestination, ...) ui.Element
- func NavigationSidebar(c *ui.Context, selected *string, groups []NavGroup, opts ...SidebarOptions) ui.Element
- func NumberInput(c *ui.Context, value *float64, lo, hi, step float64, ...) ui.Element
- func OutlineTable[K comparable](c *ui.Context, state *ui.OutlineState[K], columns []DataTableColumn, roots []K, ...) ui.Element
- func OutlinedCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
- func PageTransition(c *ui.Context, key any, build func(), opts ...TransitionOptions) ui.Element
- func Pagination(c *ui.Context, page *int, totalPages int, opts ...PaginationOptions) ui.Element
- func PaintDropInsertionLine(p *ui.Painter, r ui.Rect, th *Theme, vertical bool)
- func PaintTopSpecular(p *ui.Painter, r ui.Rect, radius float32, th *Theme, ...)
- func PillTabs(c *ui.Context, tabs []TabItem, opts ...PillTabsOptions) ui.Element
- func PlainTooltip(c *ui.Context, anchor ui.Element, text string, opts ...PlainTooltipOptions) ui.Element
- func Popover(c *ui.Context, trigger ui.Element, open *bool, body func(), ...) ui.Element
- func PostSnackbar(c *ui.Context, message SnackbarOptions) string
- func PrimaryTabs(c *ui.Context, tabs []TabItem, opts ...TabsOptions) ui.Element
- func PromptDialog(c *ui.Context, open *bool, value *string, opts ...PromptDialogOptions) ui.Element
- func Radio[T comparable](c *ui.Context, selected *T, value T, label string, opts ...RadioOptions) ui.Element
- func RadioGroup(c *ui.Context, fn func(), opts ...RadioGroupOptions) ui.Element
- func RangeSlider(c *ui.Context, low, high *float64, lo, hi float64, opts ...RangeSliderOptions) ui.Element
- func RichTooltip(c *ui.Context, anchor ui.Element, opts ...RichTooltipOptions) ui.Element
- func RouterView(c *ui.Context, r *ui.Router, page func(*ui.Route), opts ...RouterViewOptions) ui.Element
- func SearchAppBar(c *ui.Context, query *string, opts ...SearchAppBarOptions) ui.Element
- func SearchBar(c *ui.Context, query *string, opts ...SearchOptions) ui.Element
- func SearchField(c *ui.Context, query *string, opts ...SearchOptions) ui.Element
- func SecondaryTabs(c *ui.Context, tabs []TabItem, opts ...TabsOptions) ui.Element
- func SegmentedTabs(c *ui.Context, tabs []TabItem, opts ...PillTabsOptions) ui.Element
- func Select[T comparable](c *ui.Context, value *T, choices []SelectChoice[T], opts ...SelectOptions[T]) ui.Element
- func SettingsGroup(c *ui.Context, title string, body func(), opts ...SettingsGroupOptions) ui.Element
- func ShapeButton(c *ui.Context, label string, icon IconDraw, opts ...ShapeButtonOptions) ui.Element
- func SideSheet(c *ui.Context, open *bool, main, detail func(), opts ...SideSheetOptions) ui.Element
- func Skeleton(c *ui.Context, opts ...SkeletonOptions) ui.Element
- func Slider(c *ui.Context, value *float64, lo, hi float64, opts ...SliderOptions) ui.Element
- func SmallBadge(c *ui.Context, opts ...BadgeOptions) ui.Element
- func SnackbarHost(c *ui.Context, state *SnackbarState) ui.Element
- func SplitButton(c *ui.Context, label string, opts ...SplitButtonOptions) (group, action, arrow ui.Element, open *bool)
- func StatusBar(c *ui.Context, leading func(), opts ...StatusBarOptions) ui.Element
- func StatusPill(c *ui.Context, text string, opts ...StatusPillOptions) ui.Element
- func Stepper(c *ui.Context, value *float64, lo, hi, step float64, opts ...StepperOptions) ui.Element
- func SuggestionChip(c *ui.Context, label string, opts ...ChipOptions) ui.Element
- func SupportingPane(c *ui.Context, main func(), supporting func(), opts ...SupportingPaneOptions) ui.Element
- func Surface(c *ui.Context, opts ...SurfaceOptions) ui.Element
- func SurfaceColorForElevation(t *Theme, level tokens.ElevationLevel) ui.Color
- func Switch(c *ui.Context, on *bool, opts ...SwitchOptions) ui.Element
- func SwitchCard(c *ui.Context, title string, on *bool, opts ...SwitchCardOptions) ui.Element
- func TabStrip(c *ui.Context, active *string, tabs []DocumentTab, opts ...TabStripOptions) ui.Element
- func TabularNums(el ui.Element) ui.Element
- func Tag(c *ui.Context, text string, opts ...TagOptions) ui.Element
- func Text(c *ui.Context, s string, role tokens.TypeRole, emphasized ...bool) ui.Element
- func TextArea(c *ui.Context, value *string, opts ...TextFieldOptions) ui.Element
- func TextField(c *ui.Context, value *string, opts ...TextFieldOptions) ui.Element
- func TextWith(c *ui.Context, s string, opts ...TextOptions) ui.Element
- func ThemeScope(c *ui.Context, t *Theme, content func()) ui.Element
- func TimePicker(c *ui.Context, value *time.Time, opts ...TimePickerOptions) ui.Element
- func TitleText(c *ui.Context, s string, opts ...TextOptions) ui.Element
- func ToastStack(c *ui.Context, opts ...ToastStackOptions) ui.Element
- func ToggleIconButton(c *ui.Context, on *bool, label string, icon IconDraw, ...) ui.Element
- func TokenField(c *ui.Context, values *[]string, suggestions []string, ...) ui.Element
- func TopAppBar(c *ui.Context, title string, opts ...TopAppBarOptions) ui.Element
- func TreeView(c *ui.Context, nodes []TreeNode, opts ...TreeViewOptions) ui.Element
- func VirtualList(c *ui.Context, count int, row func(r ui.ListRow), opts ...VirtualListOptions) ui.Element
- func WindowTitleBar(c *ui.Context, opts ...WindowTitleBarOptions) ui.Element
- type AccordionOptions
- type AccordionSection
- type ActionTileOptions
- type AdaptiveScaffoldOptions
- type AlertDialogOptions
- type AppBarAction
- type AppShellOptions
- type AvatarOptions
- type AvatarStatus
- type BadgeOptions
- type BadgedBoxOptions
- type BannerAction
- type BannerOptions
- type BentoGridOptions
- type BottomSheetOptions
- type BreadcrumbItem
- type BreadcrumbOptions
- type ButtonGroupItem
- type ButtonGroupKind
- type ButtonGroupOptions
- type ButtonOptions
- type ButtonShape
- type ButtonVariant
- type CardOptions
- type CardVariant
- type CarouselItem
- type CarouselLayout
- type CarouselOptions
- type CheckboxOptions
- type ChipGroupOptions
- type ChipOptions
- type ColorPickerOptions
- type ColorWellOptions
- type Command
- type CompletionOptions
- type ConfirmDialogOptions
- type DataTableCellOptions
- type DataTableColumn
- type DataTableMenuAction
- type DataTableOptions
- type DatePickerMode
- type DatePickerOptions
- type DialogAction
- type DisclosureOptions
- type DividerOptions
- type DocumentTab
- type DropZoneOptions
- type EditableTextOptions
- type ElasticIndicatorMotion
- type EmptyStateOptions
- type ExtendedFABOptions
- type FABColorScheme
- type FABMenuItem
- type FABMenuOptions
- type FABOptions
- type FABSize
- type FieldOptions
- type FileDropZoneOptions
- type FilterChipOptions
- type FindOptions
- type FloatingToolbarFab
- type FloatingToolbarItem
- type FloatingToolbarOptions
- type FloatingToolbarTone
- type FocusRingStyle
- type FormOptions
- type FullScreenDialogOptions
- type GridViewOptions
- type HistoryOptions
- type IconBadgeOptions
- type IconBadgeVariant
- type IconButtonOptions
- type IconButtonVariant
- type IconButtonWidth
- type IconDraw
- type ImageOptions
- type InputChipOptions
- type KbdOptions
- type KeyChord
- type LinkOptions
- type ListDetailPaneOptions
- type ListItem
- type ListOptions
- type LoadingOptions
- type LoadingStyle
- type MenuItem
- type MenuOptions
- type MorphIconButtonOptions
- type NavGroup
- type NavItem
- type NavigationBarOptions
- type NavigationDestination
- type NavigationDrawerItem
- type NavigationDrawerOptions
- type NavigationLabelMode
- type NavigationRailIndicatorStyle
- type NavigationRailOptions
- type NumberInputOptions
- type OutlineTableOptions
- type PaginationOptions
- type PaletteOptions
- type PillTabsOptions
- type PillTabsTone
- type PlainTooltipOptions
- type PopoverOptions
- type PopoverPlacement
- type ProgressOptions
- type PromptDialogOptions
- type RadioGroupOptions
- type RadioOptions
- type RangeSliderOptions
- type RichTooltipAction
- type RichTooltipOptions
- type RouterViewOptions
- type SearchAppBarOptions
- type SearchOptions
- type SelectChoice
- type SelectOptions
- type SemanticTone
- type SettingsGroupOptions
- type ShapeButtonOptions
- type ShapeButtonVariant
- type ShapeScale
- type ShellLayout
- type SideSheetMode
- type SideSheetOptions
- type SidebarOptions
- type SkeletonOptions
- type SkeletonShape
- type SliderOptions
- type SnackbarOptions
- type SnackbarState
- type SplitButtonOptions
- type StateLayerOptions
- type StatusBarOptions
- type StatusPillOptions
- type StepperOptions
- type SupportingPaneOptions
- type SurfaceOptions
- type SwitchCardOptions
- type SwitchOptions
- type TabItem
- type TabStripOptions
- type TabsOptions
- type TagOptions
- type TagVariant
- type TextFieldOptions
- type TextFieldVariant
- type TextOptions
- type Theme
- func (t *Theme) Animation(token motion.Token) ui.Animation
- func (t *Theme) Clone() *Theme
- func (t *Theme) ContentColorFor(bg ui.Color) ui.Color
- func (t *Theme) EffectiveTextScale() float32
- func (t *Theme) ToUITheme() *ui.Theme
- func (t *Theme) TypeStyle(role tokens.TypeRole, emphasized ...bool) tokens.TypeStyle
- func (t *Theme) UITheme() *ui.Theme
- func (t *Theme) WithPreferences(p ui.Preferences) *Theme
- type ThemeOptions
- type ThemeTransitionOptions
- type TimePickerMode
- type TimePickerOptions
- type ToastStackOptions
- type ToggleIconButtonOptions
- type TokenFieldOptions
- type ToolbarAction
- type ToolbarOptions
- type ToolbarOrientation
- type TopAppBarOptions
- type TopAppBarVariant
- type TransitionMode
- type TransitionOptions
- type TreeNode
- type TreeViewOptions
- type TruncateMode
- type TypeStyleMetrics
- type VirtualListOptions
- type WindowController
- type WindowSizeClass
- type WindowTitleBarOptions
Constants ¶
const Version = "0.2.0"
Version is the semantic version of this release.
Variables ¶
var DefaultSeedColor = ui.RGBA(0x67, 0x50, 0xA4, 1)
DefaultSeedColor is the baseline Material Design 3 primary seed (#6750A4) used when no custom seed color or system accent preference is provided.
Functions ¶
func Accordion ¶ added in v0.2.0
func Accordion(c *ui.Context, sections []AccordionSection, opts ...AccordionOptions) ui.Element
Accordion builds a vertical stack of collapsible sections with Up/Down/Home/End header navigation (skipping disabled sections) and optional SingleOpen exclusivity.
With SingleOpen enabled, both initial/external multi-true conflicts (clamped first-wins) and opening a single new section cleanly collapse sibling sections.
md3e.Accordion(c.Key("prefs"), []md3e.AccordionSection{
{ID: "net", Title: "Network", Open: &app.netOpen, Body: renderNetwork},
{ID: "tls", Title: "TLS", Open: &app.tlsOpen, Body: renderTLS},
}, md3e.AccordionOptions{Label: "Preferences", SingleOpen: true})
func ActionTile ¶
ActionTile builds a single-row clickable card tile on top of ui.ButtonBase with optional leading icon badge, title/subtitle, trailing metadata/badge, RTL-adaptive chevron (ChevronRight in LTR, ChevronLeft in RTL), full keyboard activation (Enter/Space), and MD3E StateLayer/Ripple feedback.
func ActionToolbar ¶ added in v0.2.0
func ActionToolbar(c *ui.Context, actions []ToolbarAction, opts ...ToolbarOptions) ui.Element
ActionToolbar builds an MD3E desktop command toolbar over upstream ui.Toolbar with named buttons, Horizontal roving focus (Left/Right/Home/End), and an automatic trailing overflow menu when horizontal space runs out.
md3e.ActionToolbar(c, []md3e.ToolbarAction{
{ID: "new", Label: "New", Icon: addIcon, Run: app.create},
{ID: "save", Label: "Save", Icon: saveIcon, Run: app.save},
}, md3e.ToolbarOptions{Label: "Document actions"})
func AdaptiveScaffold ¶
func AdaptiveScaffold(c *ui.Context, destinations []NavigationDestination, content func(), opts ...AdaptiveScaffoldOptions) ui.Element
AdaptiveScaffold builds an M3 Adaptive application layout shell that switches seamlessly between bottom NavigationBar (WindowCompact), collapsed NavigationRail (WindowMedium), and expanded NavigationRail (WindowExpanded), while keeping the body content under a stable keyed container so local state and focus survive breakpoint transitions.
The content slot builds with the width the rail actually leaves beside it, so nested BentoGrid and SupportingPane resolve their own breakpoints from that content width (see ContentSizeClassOf) instead of the whole window's.
func AlertDialog ¶
AlertDialog builds a Material Design 3 Expressive alert over the window while *open is true: an optional centered icon, a headline, supporting text, an optional scrollable middle area and Confirm and Dismiss buttons, on a large cornered SurfaceContainerHigh panel with a Level3 shadow. It scales and fades in with DefaultSpatial / DefaultEffects and exits monotonically over 160ms Curve I, returning keyboard focus immediately on logical close. Focus is locked inside and the window behind is inert; Escape runs Dismiss and closes, and a scrim press closes only with DismissOnScrim.
alert := false
md3e.AlertDialog(c, &alert, md3e.AlertDialogOptions{
Headline: "Delete “Notes”?", SupportingText: "You can't undo this.",
Dismiss: &md3e.DialogAction{Label: "Cancel"},
Confirm: &md3e.DialogAction{Label: "Delete", OnClick: app.delete},
})
func AnimatedContent ¶
func AnimatedContent[K comparable](c *ui.Context, key K, build func(), opts ...TransitionOptions) ui.Element
AnimatedContent is a type-safe generic wrapper around PageTransition for comparable keys.
func AnimatedThemeScope ¶
func AnimatedThemeScope(c *ui.Context, target *Theme, fn func(), opts ...ThemeTransitionOptions) ui.Element
AnimatedThemeScope wraps ThemeScope and smoothly animates colors and TextScale whenever target's visual signature changes (such as Light <-> Dark, seed color, or contrast switches). Descendants and ui.Overlay popups inherit the interpolated theme frame by frame until the spring settles cleanly. When ReduceMotion is enabled on either target or c.Preferences(), changes jump immediately to target with zero pending animation frames.
func AppShell ¶ added in v0.2.0
func AppShell(c *ui.Context, content func(), opts ...AppShellOptions) ui.Element
AppShell builds an integrated desktop application shell coordinating TitleBar, Navigation, Content, and Status regions. Across TopBarAcross, SidebarToTop, and WindowCompact breakpoints, Content always remains mounted under the same keyed Grid slot so editors, scroll positions, and focus stay intact.
When c.Vibrancy() is true, AppShell sets the window root transparent so the native material shines through the navigation chrome while keeping Content backed by an opaque surface; when c.Vibrancy() is false, AppShell provides an opaque tonal fallback.
md3e.AppShell(c.Key("workspace"), func() {
app.buildContent(c)
}, md3e.AppShellOptions{
Layout: md3e.SidebarToTop,
Zoom: app.zoom,
TitleBar: func() {
md3e.WindowTitleBar(c, md3e.WindowTitleBarOptions{Title: "Workspace"})
},
Navigation: func() {
md3e.NavigationSidebar(c, &app.dest, app.groups)
},
Status: func() {
md3e.StatusBar(c, func() { ui.Text(c, app.status) })
},
})
func ApplyDataTableMenuActions ¶
func ApplyDataTableMenuActions(m *ui.Menu, actions []DataTableMenuAction)
ApplyDataTableMenuActions populates a native ui.Menu from declarative DataTableMenuAction entries, handling separators, check/radio marks, danger styling, shortcuts, submenus, and click dispatch.
func ApplyElevationShadows ¶
ApplyElevationShadows appends MD3E Key and Ambient shadows for level to el when level > Level0.
func ApplyTonalElevation ¶
ApplyTonalElevation mixes t.Colors.SurfaceTint onto base using level's MD3E TintRatio (0% at Level0 up to 14% at Level5).
func ApplyTypeStyle ¶
func ApplyTypeStyle(c *ui.Context, el ui.Element, role tokens.TypeRole, emphasized ...bool) ui.Element
ApplyTypeStyle applies the MD3E typographic scale tokens for role (size, weight, fixed DIP line height, letter spacing, and optional font family) to el without altering el's foreground TextColor so parent Surface inheritance works.
func AssistChip ¶
AssistChip builds a Material Design 3 Expressive assist chip that performs an action, as "Add to calendar": a ui.ButtonBase with the 32 DIP chip container, an optional leading icon in Primary, the label in LabelLarge, MD3E state layer and ripple, and either an OutlineVariant border or the elevated SurfaceContainerLow fill. The whole box is the hit target.
md3e.AssistChip(c, "Add", md3e.ChipOptions{
LeadingIcon: addIcon,
OnClick: app.add,
})
func AttachRipple ¶
AttachRipple attaches both MD3E StateLayer and ExpressiveRipple wave feedback onto el. All hover/press visual state reads happen strictly inside DrawOver to avoid rebuilding the UI tree on pointer hover, and animations respect c.Preferences().ReduceMotion and stop cleanly once settled.
func AttachStateLayer ¶
AttachStateLayer attaches an MD3E StateLayer overlay (Hover 8%, Focus 10%, Pressed 10%, Dragged 16%) onto el without triggering view rebuilds on hover.
func Autocomplete ¶ added in v0.2.0
func Autocomplete(c *ui.Context, value *string, suggestions []string, opts ...CompletionOptions) ui.Element
Autocomplete builds a Material Design 3 Expressive free-text input with ranked completion suggestions using ui.TextInputBase and ui.PopoverBase.
Unlike Combobox, typing never auto-highlights item 0 so Enter with no highlighted suggestion keeps and submits the typed free text, while Down/Up + Enter or pointer click adopts a suggestion. Escape dismisses an open suggestion popup (or yields to an active IME composition without closing enclosing dialogs).
md3e.Autocomplete(c.Key("city"), &app.city, []string{"Paris", "Parma", "Lyon"}, md3e.CompletionOptions{
Label: "Destination",
Placeholder: "Type a city",
})
func Avatar ¶
func Avatar(c *ui.Context, opts ...AvatarOptions) ui.Element
Avatar builds an MD3E user/entity avatar supporting initials text, bitmap/SVG ui.ImageSource (painted with ui.Cover), circular or custom *shape.RoundedPolygon clipping, and an optional RTL-aware online/busy/away/offline status dot.
func Badge ¶
Badge builds a large Material Design 3 badge: a pill at least 16 DIP high and wide in the Error color, holding a count or a short text. A numeric count above MaxCount reads "999+" by default; zero hides it unless ShowZero is set, and Visible can hide any badge. It carries its text as its accessible name:
md3e.Badge(c, "3", md3e.BadgeOptions{Label: "3 unread messages"})
func BadgedBox ¶
func BadgedBox(c *ui.Context, content func(), badge func() ui.Element, opts ...BadgedBoxOptions) ui.Element
BadgedBox anchors badge on the top-end corner of content: the top right in a left-to-right layout and the top left right to left, as Material Design 3 places a badge on an icon. The badge keeps its own accessible name, and an optional Label describes the pair:
md3e.BadgedBox(c, func() { md3e.IconButton(c, "Inbox", mailIcon) }, func() ui.Element {
return md3e.Badge(c, "3", md3e.BadgeOptions{Label: "3 unread"})
}, md3e.BadgedBoxOptions{Label: "Inbox"})
func Banner ¶
Banner builds an MD3E non-modal notification banner supporting semantic color roles, optional leading icon and title, 1–2 inline action buttons, optional dismiss button, and *bool visibility binding with smooth 200ms Curve S expand and 180ms Curve I collapse choreography. Error and Warning banners use ui.RoleAlert; other tones use ui.RoleStatus.
func BentoGrid ¶
func BentoGrid(c *ui.Context, content func(), opts ...BentoGridOptions) ui.Element
BentoGrid builds a responsive Material Design 3 Expressive Bento card grid over upstream ui.Grid, automatically adapting column count to WindowSizeClass and track gap to Theme.Density. When resolving to a single column without explicit Tracks (for example under WindowCompact), BentoGrid lays children out in a vertical ui.Column so multi-column BentoSpan hints collapse cleanly into a single full-width stack without creating implicit overflow columns.
Without WidthOverride the column count follows the content area BentoGrid is built in (ContentSizeClassOf): inside an AdaptiveScaffold, a wide window whose expanded rail leaves less than 840 DIP of content gets Medium columns instead of squeezing four columns into the remainder.
func BentoSpan ¶
BentoSpan configures el to span cols columns and rows rows inside a BentoGrid. Negative values span to the last track (matching ui.Element.ColumnSpan and ui.Element.RowSpan semantics); 0 or 1 leaves that axis at a single cell.
func BodyText ¶ added in v0.2.0
BodyText builds a ui.Text element styled for body copy, defaulting to tokens.BodyMedium when opts is omitted or leaves TextOptions.Role unset (0), so TextOptions{Color: ..., TabularNums: true} never falls into DisplayLarge.
func BottomSheet ¶
BottomSheet builds a Material Design 3 Expressive bottom sheet. A modal one sits in a ui.Overlay over a scrim that fades with the sheet, takes the focus, closes with Escape, a scrim press or a downward pull of its handle past the threshold, and gives the focus back when the exit animation ends. The handle springs the sheet to its nearest detent on release, and the body scrolls its own content without the pull ever fighting it. A standard sheet lays out inline at its parent's bottom.
md3e.BottomSheet(c, &app.share, md3e.BottomSheetOptions{
Modal: true, Detents: []float32{0.5, 1}, Detent: &app.shareDetent,
Label: "Share", Content: app.shareOptions,
})
func Breadcrumb ¶
func Breadcrumb(c *ui.Context, items []BreadcrumbItem, opts ...BreadcrumbOptions) ui.Element
Breadcrumb builds a Material Design 3 Expressive responsive navigation trail as a ui.RoleNavigation landmark. Ancestor segments act as interactive MD3E buttons, the final segment renders as a static highlighted current-page pill (ui.CurrentPage), and intermediate segments collapse into a MoreHoriz overflow dropdown menu (ui.MenuBase) when MaxVisible is exceeded or available layout width shrinks. Separators and menu placement adapt automatically to ui.RightToLeft and Theme.Density.
func Button ¶
Button builds a Material Design 3 Expressive button: a ui.ButtonBase with the variant's container, border, elevation and content colors, the size tier's exact height, padding, icon geometry and typography, an MD3E StateLayer with Expressive Ripple, and a Fast Spatial corner morph toward the tier's pressed radius that springs back on release. Pressing also lifts the Elevated variant from Level1 to Level2 shadows.
Clicked reports pointer clicks and Enter or Space while the button has the focus, as ButtonBase's do; assistive technology sees a button named by the label:
save := md3e.Button(c, "Save", md3e.ButtonOptions{LeadingIcon: saveIcon})
if save.Clicked() {
app.save()
}
The corner morph reads Pressed in the build pass, as the radius is an element attribute; hover and focus feedbacks stay in DrawOver inside AttachRipple, so hovering never rebuilds the view. That Focus state layer is the button's focus cue: ui's default focus ring is turned off so it cannot overdraw the morphing corner.
func ButtonGroup ¶
func ButtonGroup(c *ui.Context, selected *int, items []ButtonGroupItem, opts ...ButtonGroupOptions) ui.Element
ButtonGroup builds a single-select Material Design 3 Expressive button group: a row of buttons, one of which *selected indexes, with the arrow keys moving the focus among them and Enter or Space choosing. A value outside the items chooses none.
A Standard group keeps its buttons apart and widens the pressed one with the Fast Spatial spring while its neighbors give way; a Connected group joins them with small inner corners, its outer ends keeping the large radius, and morphs the chosen button into a full pill. Round groups mirror right to left:
md3e.ButtonGroup(c, &app.view, []md3e.ButtonGroupItem{
{Label: "Day"}, {Label: "Week"}, {Label: "Month"},
}, md3e.ButtonGroupOptions{Kind: md3e.ButtonGroupConnected})
func ButtonGroupActions ¶
func ButtonGroupActions(c *ui.Context, items []ButtonGroupItem, onAction func(i int), opts ...ButtonGroupOptions) ui.Element
ButtonGroupActions builds an action group: its buttons are commands rather than choices, and a click calls onAction with its index.
func ButtonGroupMulti ¶
func ButtonGroupMulti(c *ui.Context, selected *[]bool, items []ButtonGroupItem, opts ...ButtonGroupOptions) ui.Element
ButtonGroupMulti builds a multi-select button group: each button toggles its slot of *selected, which grows to the number of items.
func Card ¶
func Card(c *ui.Context, content func(), opts ...CardOptions) ui.Element
Card builds a Material Design 3 Expressive card: an elevated, filled or outlined container around content. A clickable card (Clickable or OnClick) is a ui.ButtonBase with a StateLayer and Expressive Ripple, and its corners and elevation change with the Fast Spatial spring while it is pressed. A plain card is a non-focusable container with no feedback. Both support Disabled, and a disabled ancestor disables a clickable card too.
Hover feedback stays in the ripple's DrawOver pass, so hovering never rebuilds the view; only the press, which changes element attributes, is read in the build pass.
md3e.Card(c, func() {
md3e.Text(c, "Photos", tokens.TitleMedium)
}, md3e.CardOptions{Variant: md3e.CardFilled, OnClick: app.openPhotos})
func Carousel ¶
func Carousel(c *ui.Context, items []CarouselItem, opts ...CarouselOptions) ui.Element
Carousel builds a Material Design 3 Expressive carousel: a horizontal strip of ui.RoleButton slides whose widths follow their distance from the focused one and the chosen layout, clip their content to rounded corners with ClipInset, and glide to their new sizes with the Default Spatial spring. A click, Enter or Space focuses a slide, a pointer drag pans the strip and snaps it to the nearest slide, the wheel pages through it, and Index may be set by the app. The focused slide stays aligned with the strip's start, also right to left, and reduced motion settles every width at once:
md3e.Carousel(c, []md3e.CarouselItem{
{Label: "Mountain", Content: func() ui.Element { return photo(c, "mountain") }},
{Label: "Lake", Content: func() ui.Element { return photo(c, "lake") }},
}, md3e.CarouselOptions{Index: &app.slide, Layout: md3e.CarouselHero})
func Checkbox ¶
Checkbox builds a Material Design 3 Expressive check box over *checked: a ui.CheckboxBase row whose key is the caller's c.Key, a centered 18 DIP box with 2 DIP corners, the optional visible label, and MD3E hover, focus and press layers. Checking springs the box to Primary with an OnPrimary check mark drawn along its path, from 0 to its full length; unchecking trims it back, both with the Fast Spatial spring. Error paints the error palette and marks the box invalid for assistive technology.
A click, or Space while it has the keyboard focus, toggles *checked:
md3e.Checkbox(c, &app.sync, md3e.CheckboxOptions{Label: "Sync across devices"})
func CheckboxState ¶
func CheckboxState(c *ui.Context, state *ui.CheckState, opts ...CheckboxOptions) ui.Element
CheckboxState builds a check box that can be mixed, as the "select all" box of a table's header, over *state: ui.CheckboxStateBase with the same look and springs as Checkbox. Off draws an outline, On fills the box and draws a check mark, and Mixed fills it and draws a dash growing from its middle, all with the Fast Spatial spring.
A click, or Space while it has the keyboard focus, sets CheckOn from Off or Mixed, and CheckOff from On; assistive technology sees the mixed state:
all := ui.CheckOff
if n := app.selected(); n == len(app.rows) {
all = ui.CheckOn
} else if n > 0 {
all = ui.CheckMixed
}
md3e.CheckboxState(c, &all, md3e.CheckboxOptions{Label: "Select all"})
func ChipGroup ¶
func ChipGroup(c *ui.Context, fn func(), opts ...ChipGroupOptions) ui.Element
ChipGroup builds a wrapping flow container for chips, as a tag editor or a filter bar: a ui.Row with Wrap, RoleGroup, the configured column and row gaps, and the chips that fn builds. Chips that do not fit on a line flow onto the next, right to left when the window reads so.
md3e.ChipGroup(c, func() {
for _, tag := range app.tags {
md3e.InputChip(c, tag, md3e.InputChipOptions{OnRemove: ...})
}
}, md3e.ChipGroupOptions{Label: "Tags"})
func CircularProgress ¶
CircularProgress builds a Material Design 3 circular progress indicator: a rounded active arc, a track gap and the unfinished ring. Determinate values in 0..1 animate; a negative value spins an extending and shrinking arc. ReduceMotion freezes an indeterminate ring and settles a determinate one without extra frames.
func CircularWavyProgress ¶
CircularWavyProgress builds the wavy variant of CircularProgress: the ring's radius follows R + A·sin(kθ + φ), converging near the arc ends and at 0% and 100%. An indeterminate ring also turns continuously.
func Collapsible ¶ added in v0.2.0
func Collapsible(c *ui.Context, label string, open *bool, body func(), opts ...DisclosureOptions) ui.Element
Collapsible builds a Material Design 3 Expressive disclosure section with an accessible trigger (RoleDisclosure) and collapsible body content bound to *open.
In standard motion it wraps ui.CollapsibleBase so expand/collapse height and chevron rotation share a single 200ms Progress() channel. When theme-level ReduceMotion is enabled without system ReduceMotion, it switches cleanly to a static RoleDisclosure button and conditional panel so zero animation frames are queued. On collapse, keyboard focus inside the panel evacuates cleanly to the trigger, and collapsing panels are marked AccessHidden(true) and IgnoreInput(true).
md3e.Collapsible(c.Key("advanced"), "Advanced options", &app.advOpen, func() {
ui.Text(c, "Custom DNS and timeout settings")
})
func ColorPicker ¶ added in v0.2.0
ColorPicker builds a Material Design 3 Expressive color picker over ui.ColorPicker bound to *color, pairing HSVA 2D saturation/brightness picking, hue/opacity sliders, hex input, and preset swatches with a cached HCT tonal swatch strip derived via tokens.HCTFromColor.
md3e.ColorPicker(c.Key("accent-picker"), &app.accent, md3e.ColorPickerOptions{
Label: "Accent color",
OnChanged: func(col ui.Color) { app.seed = col },
})
func ColorWell ¶ added in v0.2.0
ColorWell builds a Material Design 3 Expressive color swatch trigger bound to *color that opens an anchored L2 Popover containing a ColorPicker.
Clicking or pressing Enter/Space toggles the picker popover, Escape or outside clicks dismiss it and return focus cleanly to the well button, and assistive technology sees RoleColorWell with the color's hex value.
md3e.ColorWell(c.Key("seed-well"), &app.seed, md3e.ColorWellOptions{
Label: "Seed color",
ShowHex: true,
})
func Combobox ¶ added in v0.2.0
func Combobox(c *ui.Context, selected *string, choices []string, opts ...CompletionOptions) ui.Element
Combobox builds a Material Design 3 Expressive combo box bound to *selected among choices. It renders a filled text input paired with a toggle chevron and an L2 anchored suggestion popup (180ms O enter, 130ms I exit, Flip).
Typed edits stay strictly isolated in an internal draft string until the user chooses a candidate with Enter or pointer click; Escape closes the popup while keeping focus, blur rolls any uncommitted draft back to *selected, and zero-match filters show "No matches" without modifying *selected.
md3e.Combobox(c.Key("city"), &app.city, []string{"Paris", "Lyon", "Tokyo"}, md3e.CompletionOptions{
Label: "City",
Placeholder: "Choose a city",
})
func CommandPalette ¶ added in v0.2.0
func CommandPalette(c *ui.Context, open *bool, commands []Command, opts ...PaletteOptions) ui.Element
CommandPalette builds a modal L3 searchable command hub overlay while *open is true, returning a fixed zero-size host element that stores all palette UI state (query, navigation stack, highlight, scroll) per window in ui.Local with zero package-global state.
Activating a parent Command with Children pushes into that sub-level without closing the palette or running callbacks; Escape pops back up one level with its prior query and selection intact until reaching the root, where Escape or scrim click closes the palette and restores focus cleanly. Activating an enabled leaf closes *open first, updates *Recent and calls OnRun, and then invokes cmd.Run once.
func ConfirmDialog ¶ added in v0.2.0
ConfirmDialog builds a concise MD3E confirmation modal dialog atop AlertDialog with localized "Confirm" / "Cancel" defaults, optional Destructive error emphasis, and isolated OnConfirm / OnCancel callbacks.
func ContextMenu ¶
func ContextMenu(c *ui.Context, target ui.Element, items []MenuItem, opts ...MenuOptions) ui.Element
ContextMenu gives target a Material Design 3 Expressive context menu, opened where target is right-clicked or below it for the menu key or Shift+F10, with the same panel and items as DropdownMenu. It returns target:
row := md3e.ContextMenu(c, row, []md3e.MenuItem{
{Label: "Rename", Shortcut: "F2", OnClick: app.rename},
{Label: "Delete", OnClick: app.delete, Disabled: note.locked},
}, md3e.MenuOptions{Label: "Row actions"})
func DataTable ¶
func DataTable(c *ui.Context, columns []DataTableColumn, count int, cell func(row, col int), opts ...DataTableOptions) ui.Element
DataTable builds a Material Design 3 Expressive data table over ui.Table, preserving sticky headers, column drag reordering, edge resizing, double-click auto-fit, single/multi-column sorting, cell block selection, horizontal/vertical virtualization, and context menus inside an MD3E tonal surface container.
func DataTableCellText ¶
DataTableCellText builds a single-line (or bounded-line) table cell text element styled with MD3E typography while preserving row foreground color inheritance so selected rows automatically transition to OnSecondaryContainer.
func DatePicker ¶
DatePicker builds a Material Design 3 Expressive date picker over *value: a month calendar with six weeks, the adjacent months' days in gray, a ring on today, a Primary circle on the chosen day, month paging buttons, a title that opens a year grid, and a switch to a YYYY-MM-DD text field that validates as it changes and applies a valid date at once. Arrow keys move a cursor among the days, Page Up and Page Down page months, Home and End go to the month's first and last days, and Enter or Space chooses the cursor's day.
With Mode DatePickerModal, Open is required: the calendar shows in a modal dialog with Cancel and OK actions, spring scale and fade, a scrim, Escape, focus locked inside, and the focus back on the trigger as it closes. A DatePicker keeps the time of day and the location of *value, as ui.Calendar does. Weeks start on FirstWeekday (Sunday by default), and the calendar mirrors right to left.
md3e.DatePicker(c, &app.day, md3e.DatePickerOptions{Label: "Due date"})
func DateRangePicker ¶
DateRangePicker builds a Material Design 3 Expressive date range picker over *start and *end: the same month calendar and header as DatePicker, where a first click chooses the start, a second the end (swapping them when the end comes first), and a third starts a new range. The endpoints paint as Primary circles with OnPrimary text, and the days between them join in a continuous PrimaryContainer band whose row ends are rounded, across weeks and months. A zero *end means the range is still open; a zero *start means none is chosen. The text entry view edits both endpoints as YYYY-MM-DD fields.
md3e.DateRangePicker(c, &app.from, &app.to, md3e.DatePickerOptions{Label: "Trip"})
func DefaultLoadingPolygons ¶
func DefaultLoadingPolygons() []*shape.RoundedPolygon
DefaultLoadingPolygons returns the seven-shape MD3E loading sequence: SoftBurst, Cookie9Sided, Pentagon, Pill, Sunny, Cookie4Sided and Oval.
func DisplayText ¶ added in v0.2.0
DisplayText builds a ui.Text element styled for hero/display numerals and titles, defaulting to tokens.DisplayLarge when opts is omitted or leaves TextOptions.Role unset (0).
func Divider ¶
func Divider(c *ui.Context, opts ...DividerOptions) ui.Element
Divider builds a Material Design 3 divider: a 1 DIP OutlineVariant line with ui.RoleSeparator, across its parent or down it, inset from the logical start and end. The horizontal insets use ui's logical padding, so a line inset from the left in a left-to-right layout is inset from the right right to left:
md3e.Divider(c)
md3e.Divider(c, md3e.DividerOptions{Inset: 16})
func DropZone ¶ added in v0.2.0
func DropZone[T any](c *ui.Context, content func(active bool), opts ...DropZoneOptions[T]) ui.Element
DropZone builds an MD3E drop target for in-process dragged values of type T (from Element.Drag), bridging upstream ui.DragOver[T] and ui.Drop[T].
Hover/active transitions animate smoothly in the DrawOver paint layer via the standard 140ms O / 180ms O ramp and snap immediately under ReduceMotion.
func DropdownMenu ¶
DropdownMenu builds a Material Design 3 Expressive drop-down menu: a text trigger with a chevron that opens a ui.MenuBase panel below it, styled with large corners, a SurfaceContainerLow fill, Level2 shadows and SecondaryContainer highlighted rows. Items may carry icons, shortcuts, check and radio marks, dividers and submenus; Up, Down, Home, End and typing move the highlight, Right and Left open and close submenus (mirrored right to left), Enter and Space choose, and Escape, Tab or a press outside close the menu. A disabled trigger, or one under a disabled ancestor, keeps it closed.
md3e.DropdownMenu(c, "Sort by", []md3e.MenuItem{
{Label: "Name", Checkable: true, Checked: app.byName, OnClick: app.sortByName},
{Label: "Date", Checkable: true, Checked: !app.byName, OnClick: app.sortByDate},
{Separator: true},
{Label: "More", Submenu: []md3e.MenuItem{{Label: "Advanced", OnClick: app.advanced}}},
}, md3e.MenuOptions{Label: "Sort"})
func EditableText ¶ added in v0.2.0
EditableText builds a Material Design 3 Expressive inline-editable text control over ui.EditableText bound to *value.
Standalone instances enter edit mode on double-click or Enter with focus, pre-selecting the base name before the last '.' extension, committing on Enter or blur, and canceling on Escape. Inside VirtualList, DataTable, or OutlineTable rows, F2 (or Enter on macOS) and delayed single-click on an already-chosen row initiate rename and restore table focus on completion.
md3e.EditableText(c.Key("doc-title"), &doc.Title, md3e.EditableTextOptions{
Role: tokens.TitleMedium,
Emphasized: true,
Label: "Document title",
})
func ElevatedCard ¶
func ElevatedCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
ElevatedCard builds a Card with the elevated container. Options other than the variant apply as Card's do.
func EmptyState ¶
EmptyState builds a centered MD3E empty-state placeholder with an optional illustration or expressive shaped IconBadge, title, supporting description, and primary/secondary action buttons.
func ExtendedFAB ¶
ExtendedFAB builds a Material Design 3 Expressive extended floating action button: a ui.ButtonBase 56 DIP high (or 96 for the large size) carrying an icon and a label, with the scheme's container and content colors, Level3 shadows lifting to Level4 while pressed, StateLayer and Ripple, and the Medium 16 DIP (Large 28 DIP) corner that morphs toward the pressed radius.
A non-nil Expanded pointer folds the label: the button springs from its square, icon-only width to its full width and the text fades with it, as an app makes room around a scrolling list:
md3e.ExtendedFAB(c, "New message", editIcon,
md3e.ExtendedFABOptions{Expanded: &app.composeExpanded})
func FAB ¶
FAB builds a Material Design 3 Expressive floating action button: a ui.ButtonBase of exact Small (40×40), Medium (56×56) or Large (96×96) size, with the scheme's container and content colors, Level3 Key/Ambient shadows that rise to Level4 while pressed, an MD3E StateLayer with Expressive Ripple, and a Fast Spatial corner morph toward its pressed radius.
label is required and becomes the accessible name, since the icon alone names nothing to assistive technology; FAB panics for an empty one. The optional Visible pointer hides the button with a scale and fade when false:
compose := md3e.FAB(c, "Compose", addIcon, md3e.FABOptions{Color: md3e.FABTertiary})
if compose.Clicked() {
app.startCompose()
}
func FABMenu ¶
func FABMenu(c *ui.Context, items []FABMenuItem, opts ...FABMenuOptions) ui.Element
FABMenu builds a Material Design 3 Expressive FAB menu: a standard 56 DIP FAB that opens a scrim-covered menu of two to six large pill items, each with an icon and a label, in place of the old speed dial. While the menu shows, the trigger is covered by a high-contrast circular close button whose × rotates in with the Fast Spatial spring, and the items spring up in sequence. Pressing the scrim, Escape, the close button, or an item closes the menu and gives the keyboard focus back to the trigger.
The item count is part of the spec: FABMenu panics for fewer than two or more than six items.
md3e.FABMenu(c, []md3e.FABMenuItem{
{Label: "New file", Icon: addIcon, OnClick: app.newFile},
{Label: "New folder", Icon: editIcon, OnClick: app.newFolder},
}, md3e.FABMenuOptions{Label: "Create"})
func FileDropZone ¶ added in v0.2.0
FileDropZone builds an MD3E drop target for files dragged from the OS (bridging Element.FileDragOver and Element.DroppedFiles) with optional case-insensitive extension filtering.
func FilledCard ¶
func FilledCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
FilledCard builds a Card with the filled container.
func FilterChip ¶
FilterChip builds a Material Design 3 Expressive filter chip over *selected, as a tag filter: a ui.ToggleBase with the chip container, which a click, or Space while it has the keyboard focus, toggles and Changed reports. Selecting it springs the container to SecondaryContainer without a border, switches the label and icons to OnSecondaryContainer with the Fast Effects spring, and scales mdicon.Check into the leading slot with the Fast Spatial spring; deselecting springs it back. Assistive technology sees a check box whose checked state follows *selected.
md3e.FilterChip(c, &app.onlyUnread, "Unread", md3e.FilterChipOptions{
LeadingIcon: starIcon,
})
func FindBar ¶ added in v0.2.0
func FindBar(c *ui.Context, open *bool, query *string, matches int, current *int, opts ...FindOptions) ui.Element
FindBar builds an inline Material Design 3 Expressive find-and-replace bar while *open is true, bridging upstream ui.FindBar inside an isolated parent container with optional CaseSensitive ("Aa"), Regex (".*"), and Replacement controls.
When closed, FindBar mounts no ui.FindBar, shortcuts, or focus stops so inactive documents never contend for Cmd+G / F3. Callers with multiple documents should install FindBar only for the active document (or ensure at most one document has *open == true at a time). Closing via Escape, Done, or setting *open = false restores keyboard focus to the triggering editor or control if focus lived inside the bar.
func FloatingToolbar ¶
func FloatingToolbar(c *ui.Context, items []FloatingToolbarItem, opts ...FloatingToolbarOptions) ui.Element
FloatingToolbar builds a Material Design 3 Expressive floating toolbar: an elevated pill that gathers related actions, horizontal (64 DIP high) or vertical (64 DIP wide), in the standard raised surface or the vibrant PrimaryContainer tone. It holds the items as one RoleToolbar focus group that the arrow keys move through, carries Level3 Key/Ambient shadows, and can sit beside a standard FAB, sharing its container alignment and a 12 DIP gap; the row mirrors right to left.
Expanded folds the toolbar down to its first item with the Default Spatial spring, and Visible hides the whole group with a scale and fade:
md3e.FloatingToolbar(c, []md3e.FloatingToolbarItem{
{Label: "Bold", Icon: editIcon, OnClick: app.bold},
{Label: "Add", Icon: addIcon, OnClick: app.add},
}, md3e.FloatingToolbarOptions{Label: "Format", Fab: &app.fab})
func Form ¶ added in v0.2.0
func Form(c *ui.Context, body func(), opts ...FormOptions) ui.Element
Form builds a responsive Material Design 3 Expressive settings/editor form.
At desktop window widths (>= 600 DIP), Form lays out fields via ui.Form so right-aligned labels align in a unified column across SettingsGroup sections. Below 600 DIP it switches to a single stacked column while keeping the same keyed container slot so child editors preserve focus, selection, and IME state.
When Dirty is true (or action callbacks are provided without Dirty), Form renders a transaction bar with Discard and Save actions. Save obeys CanSubmit and never clears *Dirty automatically so failed validation preserves edits.
md3e.Form(c.Key("settings"), func() {
md3e.SettingsGroup(c.Key("net"), "Network", func() {
md3e.FormField(c.Key("host"), "Host", func() {
md3e.TextField(c.Key("hostIn"), &app.host, md3e.TextFieldOptions{Placeholder: "localhost"})
})
})
}, md3e.FormOptions{Dirty: &app.dirty, OnSubmit: app.save, OnDiscard: app.discard})
func FormField ¶ added in v0.2.0
FormField builds a labeled form field around control using ui.Field, supplying accessible label association, helper Description, and Error messaging while exposing field error context to child MD3E controls.
Inner text/selection controls with an empty Label inherit label as their accessible name, and draw Error borders/indicators without duplicating the error message rendered beneath the field.
md3e.FormField(c.Key("hostField"), "Host", func() {
md3e.TextField(c.Key("host"), &app.host, md3e.TextFieldOptions{Placeholder: "example.com"})
}, md3e.FieldOptions{Description: "Primary hostname", Error: app.hostErr})
func FormatKeyChord ¶ added in v0.2.0
FormatKeyChord returns the visible shortcut representation of chord for the active platform (for example "⌘K" / "⌥⇧⌘F" on macOS/iOS, or "Ctrl+K" / "Ctrl+Shift+Z" elsewhere). FormatKeyChord is strictly formatting and never registers any keyboard shortcut.
func FullScreenDialog ¶
FullScreenDialog builds a Material Design 3 Expressive full-screen dialog: a ui.DialogBase whose panel fills the window, with a top bar holding a close button, the title and an optional save action, and a scrolling body below it. It keeps the keyboard inside, closes with Escape or its close button, and gives the focus back to the element that opened it.
md3e.FullScreenDialog(c, &app.editing, md3e.FullScreenDialogOptions{
Title: "New note", SaveLabel: "Save", OnSave: app.save, Content: app.editor,
})
func GridView ¶ added in v0.2.0
func GridView(c *ui.Context, count int, minWidth, height float32, item func(i int), opts ...GridViewOptions) ui.Element
GridView builds a virtualized Material Design 3 Expressive responsive card grid over ui.GridView, instantiating only items near the viewport so collections of hundreds of thousands of items scroll smoothly.
Columns automatically fill the available width with items at least minWidth wide and height tall. Built-in 2D arrow, Home/End, type-ahead navigation, RTL mirroring, multi-selection (Cmd/Ctrl+click, Shift+click, Cmd/Ctrl+A), and drag reordering follow upstream ui.GridView semantics inside MD3E theme and surface tokens.
md3e.GridView(c.Key("photos"), len(photos), 140, 120, func(i int) {
md3e.Text(c, photos[i].Title, tokens.TitleSmall)
}, md3e.GridViewOptions{
Selected: &app.selected,
ItemLabel: func(i int) string { return photos[i].Title },
Label: "Photos",
}).Fill()
func HeadlineText ¶ added in v0.2.0
HeadlineText builds a ui.Text element styled for prominent headings, defaulting to tokens.HeadlineMedium when opts is omitted or leaves TextOptions.Role unset (0).
func HistoryButtons ¶ added in v0.2.0
HistoryButtons builds paired Back and Forward navigation buttons backed by upstream ui.BackButton and ui.ForwardButton, retaining disabled edge states, RTL arrow mirroring, and the built-in 15-item right-click history menu.
md3e.HistoryButtons(c.Key("history"), doc.Router)
func IconBadge ¶
IconBadge builds an MD3E icon container badge with tonal, filled, outlined, or custom polygon styling, suited for quick-toggle cards, list prefixes, and expressive status accents.
func IconButton ¶
IconButton builds a Material Design 3 Expressive icon button: a ui.ButtonBase of an exact tier height and Narrow/Default/Wide width with a single centered icon, MD3E variant colors, a StateLayer with Expressive Ripple, and a Fast Spatial corner morph toward the tier's pressed radius.
label is required and becomes the accessible name, since the icon alone names nothing to assistive technology; IconButton panics for an empty one. A narrow or wide round button is a pill, its ends as round as its half width. The MD3E Focus state layer marks keyboard focus; ui's default focus ring is turned off so it cannot overdraw the morphing corner.
search := md3e.IconButton(c, "Search", searchIcon, md3e.IconButtonOptions{Size: tokens.SizeS})
if search.Clicked() {
app.openSearch()
}
func Image ¶
func Image(c *ui.Context, src ui.ImageSource, opts ...ImageOptions) ui.Element
Image builds an MD3E image container displaying local bitmaps or SVGs (ui.ImageSource) with Fit, ObjectPosition, ShapeScale / independent Radii / *shape.RoundedPolygon clipping, smooth load fade-in, tonal Skeleton loading placeholder, error placeholder with optional retry, and optional click ripple.
func InputChip ¶
InputChip builds a Material Design 3 Expressive input chip, as a contact or filter token the user entered: a 32 DIP container holding a body ui.ButtonBase (an optional avatar or leading icon, the label, and an optional trailing icon) and a separate 24 DIP close button drawing mdicon.Close. The body and the close button are siblings with independent hit regions, MD3E ripples and accessible names, so clicking one never reports the other; the close button defaults to the name "Remove <label>".
md3e.InputChip(c, person.Name, md3e.InputChipOptions{
LeadingIcon: person.Avatar,
Avatar: true,
OnRemove: func() { app.remove(person) },
})
func Kbd ¶ added in v0.2.0
Kbd builds a compact non-interactive keyboard shortcut cap (RoleText) using SurfaceContainerHighest, an OutlineVariant border, and monospace tabular numerals. It never registers shortcuts or accepts keyboard focus.
func LabelText ¶ added in v0.2.0
LabelText builds a ui.Text element styled for compact labels and badges, defaulting to tokens.LabelMedium when opts is omitted or leaves TextOptions.Role unset (0).
func LinearProgress ¶
LinearProgress builds a Material Design 3 linear determinate progress indicator (value in 0..1) or an indeterminate one (value < 0): a rounded active segment, an optional buffered segment via ProgressOptions.Buffer, a clear track gap, an unfinished track and a stop indicator dot at the far end of the track. Right to left, it fills from the right and the dot sits at the left end. Determinate changes animate with the Default Spatial spring; indeterminate mode runs a continuous two-segment relay (Primary + Trailing bars) and pauses automatically when off-screen. ReduceMotion settles at once and shows a still centered segment without asking for frames.
func LinearWavyProgress ¶
LinearWavyProgress builds the wavy variant of LinearProgress: the active segment is a sine wave whose amplitude smooths to zero at its ends and near 0% and 100%. An indeterminate indicator runs a continuous two-segment wavy relay across the track and pauses when scrolled off-screen.
func Link ¶ added in v0.2.0
Link builds an MD3E-styled hyperlink backed by ui.Link. Inside a RouterView, app-relative or rooted paths without a URL scheme push onto the enclosing Router; full URLs delegate to the host URL opener.
md3e.Link(c, "Open item", "/items/42")
func List ¶
List builds a Material Design 3 Expressive list: a ui.RoleList of ui.RoleListItem rows, each with an optional overline, headline, supporting text, leading slot (icon, avatar or control), trailing meta and control. Rows with OnClick, or every row of a list with Selected, are interactive ui.ButtonBase rows with a StateLayer and Expressive Ripple; the arrows move the focus among them and Enter or Space chooses. When an interactive row is chosen, *Selected is updated and OnSelect fires before item.OnClick so click handlers that delete or reorder rows never have *Selected overwritten.
List materializes all rows in a ui.Column so it measures naturally inside any layout or outer ui.Scroll container; for virtualized feeds of thousands of rows, compose ui.List directly under ThemeScope.
Segmented lists attach their rows as card pieces with md3e's expressive corner rhythm, animating a chosen or pressed row to full large corners while its container settles on SecondaryContainer. Right to left mirrors the row layout through ui's logical edges:
md3e.List(c, []md3e.ListItem{
{Headline: "Wi-Fi", SupportingText: "Home network", Icon: wifiIcon},
{Headline: "Bluetooth", SupportingText: "2 devices"},
}, md3e.ListOptions{Label: "Settings", Segmented: true, Selected: &app.setting})
func ListDetailPane ¶
func ListDetailPane(c *ui.Context, list func(), detail func(), opts ...ListDetailPaneOptions) ui.Element
ListDetailPane builds a Material Design 3 Adaptive two-pane list/detail layout over upstream ui.Split / ui.SplitPercent with SplitReset and a themed MD3E drag handle indicator. Under WindowCompact it collapses into a single pane controlled by ShowDetail; under WindowMedium and WindowExpanded both panes render side by side (mirroring cleanly in ui.RightToLeft).
func LoadingIndicator ¶
func LoadingIndicator(c *ui.Context, opts ...LoadingOptions) ui.Element
LoadingIndicator builds a Material Design 3 Expressive shape-morphing loading indicator: it cycles through a sequence of rounded polygons (the seven MD3E shapes by default), morphing each into the next with an eased step and turning 45° per step around its center. LoadingStandard paints the shape in Primary with no container; LoadingContained paints a PrimaryContainer circle with the shape inset in OnPrimaryContainer. Paused freezes it, and ReduceMotion (the theme's or the desktop's) shows the first shape still. The indicator pauses while outside the viewport.
It reports assistive technology a progress indicator of unknown length, named by Label:
md3e.LoadingIndicator(c, md3e.LoadingOptions{Style: md3e.LoadingContained, Label: "Loading inbox"})
func MenuButton ¶
func MenuButton(c *ui.Context, label string, icon IconDraw, items []MenuItem, opts ...MenuOptions) ui.Element
MenuButton builds a Material Design 3 Expressive icon menu button: a round tonal trigger holding icon, named by label, which opens the same menu as DropdownMenu. It takes a width-sized icon button's look and the same keys.
func MorphIconButton ¶
func MorphIconButton(c *ui.Context, on *bool, label string, icon IconDraw, opts ...MorphIconButtonOptions) ui.Element
MorphIconButton builds a Material Design 3 Expressive *bool-bound toggle button on top of ui.ButtonBase. Clicking or pressing Enter/Space toggles *on, morphs smoothly between Shape (off) and SelectedShape (on) with motion.FastSpatial (or the configured Spring), cross-fades/scales between icon and SelectedIcon, and clips StateLayer and Expressive Ripple to the live morphed outline.
label is required and becomes the accessible name with ui.RoleToggleButton and Checked(*on). Pass c.Key(...) before calling MorphIconButton when the button can reorder across frames.
func NavigationBar ¶
func NavigationBar(c *ui.Context, destinations []NavigationDestination, opts ...NavigationBarOptions) ui.Element
NavigationBar builds a Material Design 3 Expressive navigation bar: a row of destinations along the bottom of a window, each an icon and an optional label, with an elastic SecondaryContainer pill behind the selected icon. A click, or Enter or Space on a focused destination, writes Selected and calls Changed; the horizontal arrows move the focus among the destinations and mirror right to left. Count and dot badges anchor on the destination icons.
The pill expands and fades with the Fast Spatial spring, and reduced motion settles it at once:
md3e.NavigationBar(c, []md3e.NavigationDestination{
{Label: "Home", Icon: homeIcon},
{Label: "Inbox", Icon: mailIcon, Badge: "3"},
}, md3e.NavigationBarOptions{Selected: &app.tab})
func NavigationDrawer ¶
func NavigationDrawer(c *ui.Context, items []NavigationDrawerItem, opts ...NavigationDrawerOptions) ui.Element
NavigationDrawer builds a Material Design 3 Expressive navigation drawer: a vertical panel of destinations with optional section titles, dividers, count badges and a long SecondaryContainer pill behind the selected destination.
As a modal drawer it shows in a ui.Overlay over a scrim that takes the focus, inheriting the active ThemeScope. A scrim press, Escape, or a horizontal drag past 72 DIP toward the drawer's edge closes it and gives the focus back to where it was; a shorter drag springs back. Right to left anchors the panel on the right and mirrors the closing direction. The inline dismissible drawer animates its width in and out of the layout, keeps its contents out of the focus order while closed, and names itself a region:
md3e.NavigationDrawer(c, []md3e.NavigationDrawerItem{
{Label: "Inbox", Icon: mailIcon, Badge: "3"},
{Label: "Settings", Icon: settingsIcon, Section: "Account"},
}, md3e.NavigationDrawerOptions{Modal: true, Open: &app.drawer, Selected: &app.page})
func NavigationRail ¶
func NavigationRail(c *ui.Context, destinations []NavigationDestination, opts ...NavigationRailOptions) ui.Element
NavigationRail builds a Material Design 3 Expressive navigation rail: a vertical strip of destinations along the start edge of a window. Collapsed, it is 80 DIP wide and stacks each icon over its short label; expanded, it grows to the Density default (256/192/180 DIP) or ExpandedWidth with the icon and label in a row on a SecondaryContainer pill. In the default NavigationRailIndicatorPill style, the pill's leading edge advances with DefaultSpatial while the trailing edge follows with SlowSpatial (configurable via IndicatorMotion or Theme.IndicatorMotion) for an Expressive elastic worm transition; in NavigationRailIndicatorPillWithBar, each destination capsule cross-fades in place (FastEffects) while the leading Primary accent bar stretches elastically across destinations. The rail width springs between collapsed and expanded with the Default Spatial spring, and reduced motion settles both at once with zero pending frames.
An optional Header slot holds a FAB, and the arrows move the focus among the destinations, Enter or Space choosing:
md3e.NavigationRail(c, []md3e.NavigationDestination{
{Label: "Home", Icon: homeIcon},
{Label: "Mail", Icon: mailIcon, Badge: "3"},
}, md3e.NavigationRailOptions{Selected: &app.tab, Expanded: &app.railExpanded})
func NavigationSidebar ¶ added in v0.2.0
func NavigationSidebar(c *ui.Context, selected *string, groups []NavGroup, opts ...SidebarOptions) ui.Element
NavigationSidebar builds an adaptive desktop navigation sidebar that projects a single NavGroup/NavItem model into:
- Expanded tree navigation (ui.TreeBase with Arrow/Home/End/Left/Right and first-letter type-select, external IconDraw, Badges, ContextMenu, in-place FastEffects row capsules, and a parent-tracked elastic Primary leading accent bar),
- Collapsed icon-only rail (56..64 DIP with PlainTooltips, in-place FastEffects icon capsules, elastic Primary accent bar inheriting its vertical span across Tree <-> Rail switches, and smooth DefaultSpatial width spring), or
- Compact bottom bar + overflow menu when placed inside AppShell at WindowCompact (omitting desktop Header and Footer slots).
Only one interactive projection is built per frame, and keyboard focus is transferred across projection changes by stable NavItem.ID when focus was inside a destination item.
md3e.NavigationSidebar(c, &app.dest, app.groups, md3e.SidebarOptions{
Expanded: &app.sidebarExpanded,
OnSelected: app.navigate,
})
func NumberInput ¶ added in v0.2.0
func NumberInput(c *ui.Context, value *float64, lo, hi, step float64, opts ...NumberInputOptions) ui.Element
NumberInput builds a Material Design 3 Expressive numeric input bound to *value within [lo, hi] with step precision and tabular lining figures.
Typed numbers apply immediately once valid and within [lo, hi]; Up/Down arrow keys and the trailing "-" / "+" buttons (supporting hold-to-repeat) step by step; losing focus formats the displayed text to match step's decimal places. NaN, ±Inf, and out-of-range inputs are sanitized safely.
md3e.NumberInput(c.Key("interval"), &app.intervalMs, 100, 5000, 50, md3e.NumberInputOptions{
Variant: md3e.TextFieldOutlined,
Label: "Sampling interval",
Suffix: "ms",
})
func OutlineTable ¶ added in v0.2.0
func OutlineTable[K comparable]( c *ui.Context, state *ui.OutlineState[K], columns []DataTableColumn, roots []K, children func(K) []K, cell func(item K, col int), opts ...OutlineTableOptions[K], ) ui.Element
OutlineTable builds a generic Material Design 3 Expressive hierarchical multi-column table over ui.OutlineTable, pairing virtualized tree rows with sortable/resizable columns, animated MD3E disclosure chevrons, optional vertical indent guides, and RoleTree / RoleTreeItem keyboard navigation.
md3e.OutlineTable(c.Key("files"), &app.files, cols, roots, childrenOf, func(path string, col int) {
switch col {
case 0:
md3e.DataTableCellText(c, filepath.Base(path))
case 1:
md3e.DataTableCellText(c, sizeOf(path), md3e.DataTableCellOptions{Numeric: true})
}
}, md3e.OutlineTableOptions[string]{
Selected: &app.selectedRow,
ShowIndentGuides: true,
Label: "Workspace files",
}).Fill()
func OutlinedCard ¶
func OutlinedCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
OutlinedCard builds a Card with the outlined container.
func PageTransition ¶
PageTransition wraps a keyed view in a clipped stage container and animates content swaps whenever key changes. Only key changes trigger transitions; repeated builds with the same key produce zero extra animation frames, even if the surrounding pane resizes.
Under ReduceMotion (c.Preferences().ReduceMotion or Theme.ReduceMotion) or TransitionNone, pages swap immediately with zero pending animation frames. Outgoing pages render as inert exit ghosts (non-interactive, hidden from assistive technology, and with Element.Valid() == false in draw callbacks).
Like ThemeScope, PageTransition sizes to its content by default; chain .Fill() or .Grow(1) when placing it inside a full-height layout pane. Keys must be comparable.
func Pagination ¶
Pagination builds a Material Design 3 Expressive 1-based pagination bar (pages 1..totalPages) inside a ui.RoleNavigation horizontal focus group: optional First/Last edge buttons, Previous/Next icon buttons, TabularNums page capsules with FastSpatial press corner morphing, and automatic ellipsis windowing when totalPages exceeds the visible window.
Out-of-bounds *page values are safely clamped into [1, totalPages] (or 0 when totalPages <= 0), Previous/First disable automatically on page 1, Next/Last disable on totalPages, and navigation icons mirror cleanly in ui.RightToLeft.
func PaintDropInsertionLine ¶ added in v0.2.0
PaintDropInsertionLine paints an MD3E 2 DIP Primary drop insertion indicator with 4 DIP circular end caps along r (horizontal when vertical is false, vertical when vertical is true). Non-finite or zero-span bounds are ignored.
func PaintTopSpecular ¶ added in v0.2.0
func PaintTopSpecular(p *ui.Painter, r ui.Rect, radius float32, th *Theme, level tokens.ElevationLevel)
PaintTopSpecular paints the MD3E dark-mode E2/E3 inner-top 2 DIP specular reflection clipped inside a rounded rectangle of radius. It is a no-op in light mode, high-contrast mode, or non-E2/E3 elevations, and is ghost-draw safe (reads no live element state and schedules no frames).
func PillTabs ¶
PillTabs builds a Material Design 3 Expressive capsule tab bar on top of ui.TabsBase: a full-pill tonal trough with an Expressive dual-edge elastic active capsule (default leading edge DefaultSpatial, trailing edge SlowSpatial — configurable via IndicatorMotion or Theme.IndicatorMotion, swapping symmetrically on reversals and in RTL), optional tab icons and count/dot badges, full RoleTabList/RoleTab semantics, Arrow/Home/End keyboard navigation (skipping disabled tabs and mirroring right-to-left), and Theme.Density scaling.
On the first laid-out frame the active capsule snaps directly onto the selected tab rather than sliding in from zero.
func PlainTooltip ¶
func PlainTooltip(c *ui.Context, anchor ui.Element, text string, opts ...PlainTooltipOptions) ui.Element
PlainTooltip shows text in a Material Design 3 plain tooltip beside anchor once the pointer rests on it or the keyboard focus comes to it, and sets the anchor's description so screen readers read the same help. The tip uses InverseSurface/InverseOnSurface, goes with Escape or a press, and the pointer goes through it, as Base UI's tooltip: it is not interactive.
It returns anchor for chaining:
btn := md3e.PlainTooltip(c, md3e.IconButton(c, "Share", shareIcon), "Share with others")
func Popover ¶ added in v0.2.0
func Popover(c *ui.Context, trigger ui.Element, open *bool, body func(), opts ...PopoverOptions) ui.Element
Popover builds a Material Design 3 Expressive lightweight anchored overlay panel attached to trigger while *open is true, returning a fixed zero-size host element that consumes the caller's c.Key(...) for stable identity across open and closed passes.
Popover bridges ui.PopoverBase with SurfaceContainerHigh elevation styling, Level2 shadows, dark-mode top specular reflection, high-contrast 1.5 DIP outline support, and L2 anchored choreography (180ms Curve O enter, 130ms Curve I exit, AttachedOrigin + Flip, zero frames under ReduceMotion).
Pressing outside the panel (and trigger) or pressing Escape dismisses the popover without blocking pointer delivery to underlying controls. Nested overlays built inside body (such as Select or DropdownMenu) inherit parent overlay teardown and Escape layering (innermost closes first), and focus returns to the opener only when it remains present, enabled, and uncovered by a newer modal.
btn := md3e.Button(c.Key("filters-btn"), "Filters")
if btn.Clicked() {
app.filtersOpen = !app.filtersOpen
}
md3e.Popover(c.Key("filters-pop"), btn, &app.filtersOpen, func() {
app.buildFilterControls(c)
}, md3e.PopoverOptions{Label: "Filters", MinWidth: 260})
func PostSnackbar ¶ added in v0.2.0
func PostSnackbar(c *ui.Context, message SnackbarOptions) string
PostSnackbar enqueues a SnackbarOptions notification into the window's shared ToastViewportBase stack (rendered by ToastStack), returning its toast ID. Duration <= 0 normalizes to the 4s MD3 snackbar default; ShowClose and DoubleLine are preserved via Toast.Data. Existing SnackbarHost / SnackbarState queues remain unaffected.
func PrimaryTabs ¶
PrimaryTabs builds a Material Design 3 Expressive primary tab bar: a ui.TabsBase with equal-width or scrollable tabs, an icon and a label each, and a rounded Primary bar under the chosen tab whose leading edge advances with DefaultSpatial while the trailing edge follows with SlowSpatial (configurable via IndicatorMotion or Theme.IndicatorMotion, and inverting cleanly in RTL) for an elastic worm transition. A click, or the arrows, Home or End while a tab has the focus, chooses a tab, past the disabled ones, and the horizontal keys mirror right to left. The first laid-out frame places the bar at once rather than sliding it in from zero.
md3e.PrimaryTabs(c, []md3e.TabItem{
{Label: "Overview"},
{Label: "Activity", Icon: starIcon},
}, md3e.TabsOptions{Selected: &app.tab})
func PromptDialog ¶ added in v0.2.0
PromptDialog builds an MD3E modal text-input prompt dialog atop AlertDialog. It clones *value into an isolated ui.Local draft on each open so edits never mutate caller state until Confirm (or Enter inside the input) passes Validate. Cancelling via Cancel, Escape, or DismissOnScrim leaves *value untouched.
func Radio ¶
func Radio[T comparable](c *ui.Context, selected *T, value T, label string, opts ...RadioOptions) ui.Element
Radio builds a Material Design 3 Expressive radio button over *selected, choosing value: a ui.RadioBase[T] row whose key is the caller's c.Key, a 20 DIP ring with a 10 DIP dot that springs into its middle when chosen, the visible label, and MD3E hover, focus and press layers. The ring turns from OnSurfaceVariant to Primary as the dot arrives with the Fast Spatial spring.
A click, or Space while it has the keyboard focus, selects value; assistive technology sees a radio button, on while *selected is value. Put radios in a RadioGroup for one Tab stop and arrow-key navigation:
md3e.Radio(c, &app.size, "Large", "Large")
func RadioGroup ¶
func RadioGroup(c *ui.Context, fn func(), opts ...RadioGroupOptions) ui.Element
RadioGroup builds a Material Design 3 Expressive radio group: a ui.RadioGroup column (or row with Horizontal) of the radios fn builds, which is one Tab stop and takes the arrows, Home and End to move and choose among them. Assistive technology sees RoleRadioGroup named by Label:
md3e.RadioGroup(c, func() {
md3e.Radio(c, &app.size, "Small", "Small")
md3e.Radio(c, &app.size, "Large", "Large")
}, md3e.RadioGroupOptions{Label: "Size"})
func RangeSlider ¶
func RangeSlider(c *ui.Context, low, high *float64, lo, hi float64, opts ...RangeSliderOptions) ui.Element
RangeSlider builds a Material Design 3 Expressive range slider over *low and *high between lo and hi, as a price range: two independently focusable capsule handles, each a RoleSlider named by MinLabel and MaxLabel, that keep *low <= *high. Pressing the track drags the handle nearest the pointer (and on equal values the one the drag moves toward, so they never lock); the arrows, Page Up, Page Down, Home and End move the focused handle. The active track spans the handles with 6 DIP Track Gaps, a discrete Step draws stop dots, and the dragged or focused handle shows its value in a teardrop pill. Track: the row mirrors right to left, the low value at the right.
md3e.RangeSlider(c, &app.min, &app.max, 0, 1000, md3e.RangeSliderOptions{
Label: "Price", Step: 10,
})
func RichTooltip ¶
RichTooltip shows a Material Design 3 rich tooltip beside anchor: a title, a body and an optional interactive action button, on a SurfaceContainer panel with a Level2 shadow. Unlike PlainTooltip it is a real popover, so the pointer can move onto the panel and press its action; the panel goes with Escape, a press outside, or the pointer leaving both the anchor and the panel. It shows after Delay on hover, at once on keyboard focus, keeps its local ThemeScope, and returns anchor:
btn := md3e.RichTooltip(c, md3e.Button(c, "Details"), md3e.RichTooltipOptions{
Title: "Details", Body: "Shows the full record.",
Action: &md3e.RichTooltipAction{Label: "Open", OnClick: app.open},
})
func RouterView ¶ added in v0.2.0
func RouterView(c *ui.Context, r *ui.Router, page func(*ui.Route), opts ...RouterViewOptions) ui.Element
RouterView mounts r directly onto upstream r.View(c, page) without wrapping a second PageTransition, preserving upstream page state caching, TransitionMatch hero flights, nested Route.View layouts, and focus/title announcements.
In browser builds (js/wasm), the first mounted Router claims window URL fragment history; multi-document desktop apps typically create one *ui.Router per document tab while keeping drafts, ScrollStates, and selection snapshots in the document model so state survives beyond the 10-page upstream view cache.
md3e.RouterView(c.Key(doc.ID), doc.Router, func(r *ui.Route) {
r.Title(doc.Title)
doc.Build(c, r)
}).Fill()
func SearchAppBar ¶
SearchAppBar builds a Material Design 3 Expressive search app bar: an elevated, full-cornered Surface Container pill around a ui.TextInputBase editing *query, with an optional leading search/back button, a trailing clear button (mdicon.Clear) while the query is non-empty, and other trailing actions. Edits and Enter report through OnChanged and OnSubmitted.
The input is keyed by the stable "search-query" key inside the bar, so a caller's c.Key on the bar itself stays with the outer element:
md3e.SearchAppBar(c, &app.query, md3e.SearchAppBarOptions{
Placeholder: "Search mail",
OnSubmitted: app.runSearch,
})
func SearchBar ¶ added in v0.2.0
SearchBar builds a Material Design 3 Expressive elevated capsule search bar sharing the exact editing, clearing, IME, Escape, and suggestion semantics of SearchField with the prominent SurfaceContainerHigh / Level2 navigation bar appearance of SearchAppBar.
md3e.SearchBar(c.Key("global-search"), &app.query, md3e.SearchOptions{
Placeholder: "Search workspace",
ShortcutHint: "⌘K",
Suggestions: app.history,
OnSubmit: app.runSearch,
})
func SearchField ¶ added in v0.2.0
SearchField builds a Material Design 3 Expressive compact search field editing *query with an optional suggestion popover, shortcut hint badge, clear button, and Escape-to-dismiss/clear semantics:
While an IME is composing, Escape and Enter remain with the input method.
When suggestions are open, the first Escape closes suggestions without clearing the query; the next Escape clears a non-empty query; an Escape on an empty, closed field bubbles to any enclosing dialog or popover.
Picking a suggestion dispatches OnChanged once without firing OnSubmit; pressing Enter with no highlighted suggestion dispatches OnSubmit once.
md3e.SearchField(c.Key("filter"), &app.query, md3e.SearchOptions{ Placeholder: "Filter connections", ShortcutHint: "/", OnChanged: app.applyFilter, })
func SecondaryTabs ¶
SecondaryTabs builds a Material Design 3 Expressive secondary tab bar: the same ui.TabsBase behaviour as PrimaryTabs, with a full-width Primary indicator sitting on an OutlineVariant divider along the bottom of the track. Icon and label tabs stay supported.
func SegmentedTabs ¶
SegmentedTabs builds a compact segmented capsule tab control on top of ui.TabsBase: a tighter density-aware trough (defaulting to SurfaceContainer with a SurfaceContainerLowest active capsule and subtle hairline framing) suited for desktop toolbars, view switchers, and filter bars.
func Select ¶ added in v0.2.0
func Select[T comparable](c *ui.Context, value *T, choices []SelectChoice[T], opts ...SelectOptions[T]) ui.Element
Select builds a Material Design 3 Expressive generic dropdown selector over *value using ui.SelectBase (when Open is nil) or ui.SelectBaseOpen (when Open is provided). The caller's c.Key lands directly on the returned trigger element.
Group headers render visibly without occupying option indices, disabled items are skipped by pointer and keyboard navigation, focus-scoped type-ahead jumps the cursor via SelectParts.Highlight using committed Unicode text (Enter or Space commits), and the option popup uses L2 anchored choreography (180ms O enter, 130ms I exit, Flip).
md3e.Select(c.Key("route"), &app.route, []md3e.SelectChoice[string]{
{Value: "rule", Label: "Rule", Group: "Routing"},
{Value: "global", Label: "Global", Group: "Routing"},
{Value: "direct", Label: "Direct", Group: "Bypass"},
}, md3e.SelectOptions[string]{Label: "Routing mode"})
func SettingsGroup ¶ added in v0.2.0
func SettingsGroup(c *ui.Context, title string, body func(), opts ...SettingsGroupOptions) ui.Element
SettingsGroup groups related FormField rows under title using ui.Fieldset, preserving unified label-column alignment when placed inside Form.
md3e.SettingsGroup(c.Key("security"), "Security", func() {
md3e.FormField(c.Key("tlsField"), "Encryption", func() {
md3e.Switch(c.Key("tls"), "Require TLS", &app.tls)
})
}, md3e.SettingsGroupOptions{Description: "Transport authentication"})
func ShapeButton ¶
ShapeButton builds a Material Design 3 Expressive polygon-shaped button on top of ui.ButtonBase. It supports any *shape.RoundedPolygon (such as shape.Cookie9Sided(), shape.SoftBurst(), shape.Sunny(), or shape.Circle()), smoothly morphs toward PressedShape while pressed (and toward SelectedShape when Selected is true) via MD3E physics springs, clips its MD3E StateLayer and Expressive Ripple strictly to the live morphing outline, and adapts its SizeTier metrics to Theme.Density.
label is required for accessibility and becomes the button's accessible name; ShapeButton panics when label is empty.
func SideSheet ¶ added in v0.2.0
SideSheet builds a Material Design 3 Expressive adaptive side sheet around main and detail while *open is true.
In SideSheetStandard, when the container has at least ContentMin + 4 + MinWidth DIP (or 600 DIP when no limits are specified), it animates its push width smoothly between 0 and *Width using DefaultSpatial on open and 160ms Curve I monotonic exit on close (keeping content width fixed inside a clipping container to prevent per-frame text reflow). Once settled open, it docks detail at the trailing edge via ui.Split with SplitSecond, SplitGap(4), SplitReset(320), SplitLimits, SurfaceContainer fill, E0 elevation, and an MD3E resize handle (RTL mirrored). When settled closed, ui.Split is not mounted so no hidden handle or splitter intercepts pointer cursors or Tab navigation.
When space is narrower than the threshold (or Mode is SideSheetModal), it presents detail as an L3 modal sheet over a dimming scrim with SurfaceContainerHigh, Level3 elevation, 20 DIP inner corners and 0 outer corners (mirrored in RTL), DefaultSpatial slide-in, and 160ms Curve I monotonic exit, preserving the caller's *Width and restoring keyboard focus on close.
For lossless state retention across Standard <-> Modal parent-chain switches, main should store long-lived document state in caller-owned models such as *ui.ScrollState, *ui.ListState, *string, or ui.FocusBind.
By default detail sits inside a scrolling padded column (16 DIP padding, 12 DIP gap). Set Header and/or Footer to pin non-scrolling top/bottom chrome in both Standard and Modal modes, and set DisableScroll / DisablePadding when hosting a custom scroller such as a chat transcript, VirtualList, or DataTable.
md3e.SideSheet(c.Key("inspector"), &app.inspect, func() {
app.buildLedger(c)
}, func() {
app.buildInspector(c)
}, md3e.SideSheetOptions{
Label: "Connection details",
Width: &app.inspectorWidth,
ContentMin: 420,
MinWidth: 260,
MaxWidth: 480,
})
func Skeleton ¶
func Skeleton(c *ui.Context, opts ...SkeletonOptions) ui.Element
Skeleton builds an MD3E tonal shimmering placeholder block (single rectangle, circle, pill, or multi-line text stack). Its GPU Oklab shimmer sweep runs strictly inside Draw via p.AnimationFrame(), stops requesting frames when scrolled off-screen (p.Visible()), respects ReduceMotion and Static (zero pending frames), and is ghost-draw safe when exiting.
func Slider ¶
Slider builds a Material Design 3 Expressive slider over *value between lo and hi: a ui.SliderBase whose key is the caller's c.Key, drawing a 16 DIP rounded track, a 4x44 vertical capsule handle with 6 DIP Track Gaps, stop dots for a discrete Step, and a pill value indicator above the handle while it is dragged or keyboard-focused. The handle narrows from 4 to 2 DIP as it is pressed or focused, with the Fast Spatial spring, and the indicator springs in and out around it in an overlay that inherits the active ThemeScope.
Dragging the track, pressing it, or the arrows, Page Up, Page Down, Home and End while it has the focus set *value; Centered fills from the middle. Right to left, the low value sits at the right and the arrows mirror:
md3e.Slider(c, &app.volume, 0, 100, md3e.SliderOptions{
Label: "Volume", Step: 5,
})
func SmallBadge ¶
func SmallBadge(c *ui.Context, opts ...BadgeOptions) ui.Element
SmallBadge builds the 6x6 DIP Error dot of Material Design 3, without text, for an unread marker. Give it a Label so assistive technology reads what it means:
md3e.SmallBadge(c, md3e.BadgeOptions{Label: "New message"})
func SnackbarHost ¶
func SnackbarHost(c *ui.Context, state *SnackbarState) ui.Element
SnackbarHost draws state's snackbars in a ui.Overlay, inheriting the active ThemeScope, and returns a zero-size element that takes no room in its parent. Place it anywhere in the view; one state has one host:
app.snack = &md3e.SnackbarState{}
// ... in the view:
md3e.SnackbarHost(c, app.snack)
func SplitButton ¶
func SplitButton(c *ui.Context, label string, opts ...SplitButtonOptions) (group, action, arrow ui.Element, open *bool)
SplitButton builds a Material Design 3 Expressive split button: a leading ui.ButtonBase doing the action joined to a trailing ui.ButtonBase whose chevron opens a menu panel through ui.PopoverBase. Its two segments share the variant's container and border, with the outer ends as round as the shape and the seam corners small, mirrored right to left. Opening the menu morphs the arrow segment into a symmetric pill with the Default Spatial spring and turns its chevron 180 degrees; closing restores both.
Clicking the arrow, Enter, Space or the up and down arrows on it, and Alt+Down on either segment toggle the menu; Escape and a press outside close it. Assistive technology sees a group of the action button and a menu button, expanded while the menu shows:
group, action, _, _ := md3e.SplitButton(c, "Save", md3e.SplitButtonOptions{
Menu: func(panel ui.Element) {
panel.Children(func() {
if ui.ButtonBase(c).Label("Save as").Clicked() {
app.saveAs()
}
})
},
})
if action.Clicked() {
app.save()
}
group is the RoleGroup already placed among its siblings, which a caller may style further; action and arrow are its segments, read in the pass that built them; open reports and sets whether the menu shows, owned by the caller through SplitButtonOptions.Open or kept in a local of group otherwise. They are separate values because go tool mygo vet forbids ui.Element fields in structs: an element expires before the next build pass.
func StatusBar ¶ added in v0.2.0
func StatusBar(c *ui.Context, leading func(), opts ...StatusBarOptions) ui.Element
StatusBar builds a compact desktop bottom status bar with leading and optional trailing regions. The bar uses RoleRegion rather than RoleStatus so frequent live-metric updates do not flood screen readers; callers should place Role(ui.RoleStatus) selectively on discrete status text nodes inside it.
md3e.StatusBar(c, func() {
ui.Text(c, app.status).Role(ui.RoleStatus)
}, md3e.StatusBarOptions{
Trailing: func() { ui.Text(c, app.cursorPos) },
})
func StatusPill ¶
StatusPill builds a compact MD3E status pill with a leading indicator dot (static or smoothly pulsing) and status label.
func Stepper ¶ added in v0.2.0
func Stepper(c *ui.Context, value *float64, lo, hi, step float64, opts ...StepperOptions) ui.Element
Stepper builds a Material Design 3 Expressive segmented pill stepper bound to *value within [lo, hi], supporting pointer clicks, hold-to-repeat, keyboard arrows/Home/End (mirrored in RTL), and RoleStepper assistive-technology increment/decrement semantics.
md3e.Stepper(c.Key("copies"), &app.copies, 1, 99, 1, md3e.StepperOptions{
Label: "Copies",
ShowValue: true,
})
func SuggestionChip ¶
SuggestionChip builds a Material Design 3 Expressive suggestion chip that proposes a completion, as "Try a sample": the same geometry and looks as AssistChip, for a suggestion rather than an action.
func SupportingPane ¶
func SupportingPane(c *ui.Context, main func(), supporting func(), opts ...SupportingPaneOptions) ui.Element
SupportingPane builds a Material Design 3 Adaptive main + supporting split layout over upstream ui.SplitPercent with SplitReset and a themed MD3E drag handle indicator. Under WindowCompact it switches between main and supporting in a single pane; under wider breakpoints it shows main alone or both panes side by side (mirroring cleanly in ui.RightToLeft).
Without WidthOverride it resolves its breakpoint from the content area it is built in (ContentSizeClassOf), so inside an AdaptiveScaffold the supporting pane does not open just because the window is wide while the rail leaves a narrower content area.
func Surface ¶
func Surface(c *ui.Context, opts ...SurfaceOptions) ui.Element
Surface builds an MD3E layout container (ui.Column) with tonal surface and Key/Ambient elevation, uniform/independent-4-corner or RoundedPolygon shape rendering, optional border, accessible content color & typography inheritance, and RTL-aware logical spacing.
func SurfaceColorForElevation ¶
func SurfaceColorForElevation(t *Theme, level tokens.ElevationLevel) ui.Color
SurfaceColorForElevation maps level (Level0..Level5) to MD3E's tonal Surface Container step scale (Surface -> SurfaceContainerLow -> SurfaceContainer -> SurfaceContainerHigh -> SurfaceContainerHighest), falling back to tonal tint mixing if container roles are unset in a partial custom Theme.
func Switch ¶
Switch builds a Material Design 3 Expressive switch over *on: a ui.SwitchBase row whose key is the caller's c.Key, carrying the 52x32 track and its handle, and optionally the visible label that toggles it. The handle moves with the Fast Spatial spring, grows from 16 to 24 DIP as the switch turns on (28 while pressed) and shows an mdicon.Check, while the track fades from SurfaceContainerHighest with an Outline border to Primary. MD3E state layers mark hover, focus and press.
A click, or Space while the switch has the keyboard focus, turns *on over; assistive technology sees a switch named by Label:
md3e.Switch(c.Key("wifi"), &app.wifi, md3e.SwitchOptions{Label: "Wi-Fi"})
The key lands on the stateful base itself, never on a wrapper row, so c.Key("wifi") keeps the switch's identity. Right to left, the track sits at the row's end and the handle mirrors with it.
func SwitchCard ¶
SwitchCard builds a single-row card quick-toggle bound to *on: an optional leading IconBadge or custom widget, a title and optional subtitle, and a trailing MD3E Switch.
Key isolation: any caller c.Key(...) lands on the outer card container while the embedded Switch uses an independent stable child key, preventing key theft across dynamic lists. Clicking either the card body or the Switch toggles *on exactly once without conflict, and keyboard focus lands cleanly on the single RoleSwitch control.
func TabStrip ¶ added in v0.2.0
func TabStrip(c *ui.Context, active *string, tabs []DocumentTab, opts ...TabStripOptions) ui.Element
TabStrip builds a desktop multi-document tab bar over ui.TabsBase with:
Stable string ID projection onto TabsBase indices,
Pinned prefix partition (compact pinned tabs without inline close buttons; unpinned tabs cannot be dragged into the pinned partition),
Independent inline close button hit targets & dirty indicators,
Middle-click (Button=2) close with 4 DIP drag threshold validation,
Right-click context menu (Close, Close Others, Close Tabs to the End via snapshotted unpinned IDs, Pin/Unpin),
Horizontal scrolling + fixed "All open tabs" dropdown & New Tab button,
Drag-and-drop partition reordering (ui.Drag / ui.Drop) and window-outside OnDetach (ui.DragMissed compared against c.Size()).
md3e.TabStrip(c.Key("documents"), &app.activeID, app.tabs, md3e.TabStripOptions{ Label: "Open documents", OnNew: app.newDoc, OnSelect: app.selectDoc, OnRequestClose: app.requestClose, OnPin: app.setPinned, OnMove: app.moveBefore, OnDetach: app.detachWindow, })
func TabularNums ¶
TabularNums enables OpenType tabular lining figures ("tnum") on el so digits share a uniform advance width for aligned metrics, timestamps, and tables.
func Tag ¶
Tag builds a compact MD3E informational tag supporting tonal and outlined treatments, semantic color roles (Primary, Secondary, Tertiary, Error, Warning, Success, Neutral), optional leading icon, and optional click or close actions.
func Text ¶
Text builds a ui.Text element styled with the MD3E typography role and optional emphasized weight from CurrentTheme(c). At most one emphasized flag may be supplied.
func TextArea ¶
TextArea builds a multi-line Material Design 3 Expressive text area over *value, filled or outlined, around a ui.TextAreaBase keyed internally in the field's row. It shares the floating label, slots, supporting text, counter and error behavior of TextField, wraps at its width, keeps the 120 DIP height by default and scrolls its text beyond it.
md3e.TextArea(c, &app.notes, md3e.TextFieldOptions{
Variant: md3e.TextFieldOutlined, Label: "Notes", Height: 160,
})
func TextField ¶
TextField builds a Material Design 3 Expressive single-line text field over *value, filled or outlined, around a ui.TextInputBase keyed internally in the field's row. The floating label rests in the content area while the field is empty, blurred and no input method composes, and springs to the top with the Fast Spatial spring when the field is focused, holds text, or an IME is composing, so marked text never overlaps the label. An outlined field breaks its top border around the floated label; a filled field grows its bottom indicator from the middle in Primary, or shows Error.
A caller's c.Key lands on the outer column, the documented identity of the field, while the input keeps its own key in the row:
md3e.TextField(c.Key("email"), &app.email, md3e.TextFieldOptions{
Label: "Email", SupportingText: "We never share it",
})
func TextWith ¶
TextWith builds a ui.Text element styled with MD3E typography, optional monospace font family, tabular numerals, line clamping/truncation, and foreground color override. At most one TextOptions value may be passed.
When opts is omitted, tokens.BodyMedium is used; when opts is passed with the zero Role (tokens.DisplayLarge), DisplayLarge is preserved for backward compatibility. Prefer BodyText, LabelText, TitleText, or HeadlineText when passing TextOptions{Color: ...} without specifying Role.
func ThemeScope ¶
ThemeScope establishes t (resolved against c.Preferences()) as the active MD3E theme for content, simultaneously bridging into ui.Themed so native MyGo controls, nested scopes, and overlays launched inside content inherit the exact same palette, typography metrics, and accessibility preferences.
A ThemeScope takes the height its content needs, as a ui.Themed column does. When it wraps a whole window and its content fills or scrolls the window (a ui.Column with Fill(), a ui.Scroll with Grow(1)), chain Fill() on the returned element so those sizes resolve against the window rather than growing without bound:
md3e.ThemeScope(c, th, func() {
ui.Column(c).Fill().Children(app)
}).Fill()
func TimePicker ¶
TimePicker builds a Material Design 3 Expressive time picker over *value: a clock dial with a Primary hand and a circle at the chosen tick, whose hours and minutes sit above it as tabs, with an AM/PM switch in a 12-hour cycle. Pressing or dragging anywhere on the dial snaps to the angle's hour or minute, the 24-hour dial telling its outer 00, 13–23 ring from the inner 1–12 one by radius, and releasing after choosing an hour springs the hand over to the minute dial. The header's mode button swaps the dial for hour and minute fields with steppers, each validating its range and syncing with the dial; arrow keys step the dial's active segment, Page Up and Page Down step five, and Enter or Space moves from the hours to the minutes. Value keeps its date and location.
md3e.TimePicker(c, &app.alarm, md3e.TimePickerOptions{Label: "Alarm"})
func TitleText ¶ added in v0.2.0
TitleText builds a ui.Text element styled for card/pane/section titles, defaulting to tokens.TitleMedium when opts is omitted or leaves TextOptions.Role unset (0).
func ToastStack ¶ added in v0.2.0
func ToastStack(c *ui.Context, opts ...ToastStackOptions) ui.Element
ToastStack mounts the window's Material Design 3 Expressive concurrent toast notification viewport via ui.ToastViewportBase. Call once per view (including when zero toasts are active so the final toast finishes its exit transition).
ToastStack enforces a 3-visible cap while older overflow toasts continue counting down, supports hover/focus timer pause, same-ID replacement, click pass-through on surrounding empty space, non-focus-stealing coexistence with modals/editors, L2 180ms Curve O / 130ms Curve I motion (0 frames under ReduceMotion), and both logical RTL and explicit physical corner anchoring.
func ToggleIconButton ¶
func ToggleIconButton(c *ui.Context, on *bool, label string, icon IconDraw, opts ...ToggleIconButtonOptions) ui.Element
ToggleIconButton builds a Material Design 3 Expressive toggle icon button: a ui.ToggleBase that flips *on when clicked, or with Space while it has the focus, which Changed reports. Its unselected shape is the round one and its selected shape is the tier's square radius; the corner morphs between them with the Fast Spatial spring, while pressed it shrinks toward the tier's pressed radius, and its container and icon colors follow the variant and the state. The optional SelectedIcon replaces the icon while it is on.
label is required and becomes the accessible name; assistive technology sees a toggle button pressed while *on. As with ui.ToggleBase, a toggle whose identity changes with the data needs its persistent key before it is built, so that its state and focus follow it:
md3e.ToggleIconButton(c.Key("favorite"), &app.favorite, "Favorite", starOutlineIcon,
md3e.ToggleIconButtonOptions{SelectedIcon: starFilledIcon})
func TokenField ¶ added in v0.2.0
func TokenField(c *ui.Context, values *[]string, suggestions []string, opts ...TokenFieldOptions) ui.Element
TokenField builds a Material Design 3 Expressive chip/token input wrapping ui.TokenField for *values with optional suggestion matching and external Query binding.
Clicking a suggestion or typing Enter/comma adds a unique token, Backspace on an empty input removes the trailing token, and OnChanged receives an independent slice snapshot only when *values itself changes (never merely on Query typing).
md3e.TokenField(c.Key("tags"), &app.tags, []string{"Go", "UI", "MD3E"}, md3e.TokenFieldOptions{
Label: "Tags",
Query: &app.tagQuery,
})
func TopAppBar ¶
TopAppBar builds a Material Design 3 Expressive top app bar: a Small or CenterAligned 64 DIP bar, or a Medium (112 DIP) or Large (152 DIP) bar whose height, title size and Surface -> Surface Container tone interpolate with ScrollProgress as the content scrolls under it. It carries a leading navigation button, the title and optional subtitle, and trailing icon buttons; the row mirrors right to left.
md3e.TopAppBar(c, "Inbox", md3e.TopAppBarOptions{
Variant: md3e.TopAppBarLarge,
NavigationIcon: menuIcon,
Subtitle: "3 unread",
ScrollProgress: app.scroll,
})
func TreeView ¶
TreeView builds a Material Design 3 Expressive hierarchical tree over ui.TreeBase, preserving full RoleTree / RoleTreeItem semantics, single-Tab FocusGroup navigation, Up/Down/Left/Right/Home/End and type-ahead keyboard handling.
Branch disclosure chevrons rotate smoothly between 0° and ±90° via motion.FastSpatial (mirrored in ui.RightToLeft), selected rows show a SecondaryContainer capsule with MD3E StateLayer / Ripple feedback in DrawOver, and optional OutlineVariant indent guide lines align vertically beneath expanded parents. When TreeNode.Open is nil on a branch with Children, expansion state falls back to a stable ui.Local binding keyed to the node.
func VirtualList ¶
func VirtualList(c *ui.Context, count int, row func(r ui.ListRow), opts ...VirtualListOptions) ui.Element
VirtualList builds a virtualized Material Design 3 Expressive list over ui.List, instantiating only rows near the viewport so hundreds of thousands or millions of rows scroll smoothly.
Hover, press, and ripple feedback are evaluated strictly inside each row container's DrawOver pass via ui.ListRow.Hovered / Pressed / PointerPosition so pointer movement never triggers full-tree view rebuilds. Layout spacing and scrollbar clearance automatically adapt to Theme.Density, ReduceMotion, and ui.RightToLeft directionality.
func WindowTitleBar ¶
func WindowTitleBar(c *ui.Context, opts ...WindowTitleBarOptions) ui.Element
WindowTitleBar builds a cross-platform MD3E desktop window title bar that respects c.TitleBar() safe insets, integrates seamlessly with SurfaceContainerLowest, supports window dragging and double-click maximize via DragWindow(), exposes Leading/Center/Trailing slots, automatically syncs native window button polarity via SetWindowButtonsTheme when system buttons are visible, gracefully collapses crowded centered Title text below 520 DIP, and optionally renders accessible MD3E Pin, Minimize, Maximize/Restore (marked MaximizeButton for Windows 11 Snap Layouts), and Close controls.
Desktop recommendation: on Windows and Linux, set TitleBarStyle: mygo.TitleBarHidden and HideWindowButtons: true on mygo.WindowOptions with ShowWindowControls: true here; on macOS, keep HideWindowButtons: false so native traffic lights stay inside c.TitleBar().
Types ¶
type AccordionOptions ¶ added in v0.2.0
AccordionOptions configures Accordion.
type AccordionSection ¶ added in v0.2.0
AccordionSection describes one collapsible section in Accordion.
type ActionTileOptions ¶
type ActionTileOptions struct {
// Subtitle displays muted secondary copy beneath the title.
Subtitle string
// Leading renders a custom leading widget (such as Avatar or custom IconBadge).
// Takes precedence over LeadingIcon when non-nil.
Leading func()
// LeadingIcon renders a leading IconBadge when Leading is nil.
LeadingIcon IconDraw
// IconBadge customizes the IconBadge generated for LeadingIcon.
IconBadge IconBadgeOptions
// Meta displays optional right-aligned muted metadata (such as a version,
// latency, or selected value) before the chevron.
Meta string
// Badge displays an optional compact Badge before the chevron.
Badge string
// Trailing renders custom trailing content before the chevron.
Trailing func()
// HideChevron suppresses the trailing RTL-adaptive navigation chevron.
HideChevron bool
// Variant selects the card container style.
Variant CardVariant
// HasVariant explicitly selects CardElevated (zero value) vs the default
// tonal SurfaceContainerLow container.
HasVariant bool
// Hairline draws a subtle 1 DIP tonal border around the tile.
Hairline bool
// ShapeScale selects an MD3E corner radius token (default ShapeLarge).
ShapeScale tokens.ShapeScale
// Radius overrides the corner radius in DIP when positive and finite.
Radius float32
// OnClick runs when the tile is clicked or activated with Enter/Space.
OnClick func()
// Label overrides the accessible button name (defaults to title).
Label string
// Disabled disables interaction and applies MD3E disabled color tokens.
Disabled bool
}
ActionTileOptions configures ActionTile, a one-row clickable navigation or action card with leading icon badge, title/subtitle, trailing metadata/badge, and an RTL-adaptive chevron.
type AdaptiveScaffoldOptions ¶
type AdaptiveScaffoldOptions struct {
// Selected points to the selected destination index; nil keeps local state.
Selected *int
// Changed runs when a navigation destination is chosen.
Changed func(i int)
// RailExpanded optionally owns the expanded state of NavigationRail. When
// nil, WindowExpanded automatically expands the rail while WindowMedium
// keeps it collapsed.
RailExpanded *bool
// RailExpandedWidth overrides the expanded NavigationRail width in DIP.
RailExpandedWidth float32
NavigationLabels NavigationLabelMode
// "Navigation" when empty.
NavigationLabel string
// Header builds an optional full-width top header (such as WindowTitleBar
// or TopAppBar) above the navigation and content region.
Header func() ui.Element
// RailHeader builds an optional header slot at the top of NavigationRail.
RailHeader func() ui.Element
// FAB builds an optional floating action button anchored at the bottom-end
// corner of the content region (RTL-aware).
FAB func() ui.Element
// Background overrides the scaffold canvas fill; defaults to Theme.Colors.Surface.
Background ui.Color
// WidthOverride overrides c.Size()'s width when resolving WindowSizeClass.
WidthOverride float32
// Disabled disables navigation interactions.
Disabled bool
// IndicatorMotion optionally overrides the NavigationRail elastic indicator
// springs. Zero value inherits Theme.IndicatorMotion.
IndicatorMotion ElasticIndicatorMotion
}
AdaptiveScaffoldOptions configures AdaptiveScaffold. The zero value adapts automatically between a bottom NavigationBar (Compact), a collapsed NavigationRail (Medium), and an expanded NavigationRail (Expanded).
type AlertDialogOptions ¶
type AlertDialogOptions struct {
// Icon draws an optional centered icon above the headline.
Icon IconDraw
// Headline is the dialog's title and accessible name.
Headline string
// SupportingText is the body below the headline.
SupportingText string
// Content builds an optional scrollable area between the text and the
// actions, for a longer message or a form.
Content func() ui.Element
// Confirm is the high-emphasis action, drawn last.
Confirm *DialogAction
// Dismiss is the low-emphasis action, drawn before Confirm, and run when
// Escape closes the dialog.
Dismiss *DialogAction
// DismissOnScrim closes the dialog when its scrim is pressed; a click on
// the scrim does nothing unless it is set.
DismissOnScrim bool
// Label overrides the accessible name; the headline by default.
Label string
// Width is the panel width in DIP; 360 when zero or negative.
Width float32
}
AlertDialogOptions configures AlertDialog. The zero value is an enabled, 360 DIP wide alert that closes with Escape but not with a click on its scrim.
type AppBarAction ¶
type AppBarAction struct {
// Label is the accessible name of the action.
Label string
// Icon draws the action's icon.
Icon IconDraw
// OnClick runs when the action is pressed.
OnClick func()
}
AppBarAction is one trailing action of a TopAppBar or SearchAppBar.
type AppShellOptions ¶ added in v0.2.0
type AppShellOptions struct {
// Layout chooses between TopBarAcross and SidebarToTop on Medium/Expanded
// windows. Both modes keep Content under the exact same parent element chain
// so editors, scroll positions, and focus survive layout changes.
Layout ShellLayout
// TitleBar builds the optional top bar (typically WindowTitleBar).
TitleBar func()
// NavigationSidebar or NavigationRail). On WindowCompact, AppShell moves the
// navigation slot to the bottom edge so NavigationSidebar projects cleanly
// as a bottom bar.
Navigation func()
// Status builds the optional bottom bar (typically StatusBar).
Status func()
// Zoom optionally applies a content zoom factor via c.SetZoom once per
// change. Zero preserves the window's current zoom factor.
Zoom float32
}
AppShellOptions configures AppShell. The zero value uses TopBarAcross layout and preserves the window's current zoom factor.
type AvatarOptions ¶
type AvatarOptions struct {
// Text provides the user name or initials displayed when Image is nil.
Text string
// Image optionally renders a bitmap or SVG scaled with ui.Cover inside the
// avatar's circular or custom RoundedPolygon clip.
Image ui.ImageSource
// Size is the avatar diameter/side in DIP (defaults to 40, scaled by Density).
Size float32
// Shape optionally clips the avatar container and image to a custom
// *shape.RoundedPolygon instead of a circle.
Shape *shape.RoundedPolygon
// Tone selects the semantic tonal background when rendering initials
// (defaults to TonePrimary).
Tone SemanticTone
// HasTone distinguishes ToneNeutral explicitly from the zero value.
HasTone bool
// ContainerColor overrides the background color.
ContainerColor ui.Color
// ContentColor overrides the initials ink color.
ContentColor ui.Color
// Status optionally draws an RTL-aware bottom-end presence dot.
Status AvatarStatus
// StatusRingColor overrides the cutout halo behind the status dot
// (defaults to cs.Surface so callers can match card container surfaces).
StatusRingColor ui.Color
// Label overrides the accessible name (RoleImage); defaults to Text.
Label string
}
AvatarOptions configures Avatar.
type AvatarStatus ¶
type AvatarStatus int
AvatarStatus selects an optional presence indicator dot on Avatar.
const ( // AvatarStatusNone shows no status indicator dot (default). AvatarStatusNone AvatarStatus = iota // AvatarStatusOnline shows a green online dot. AvatarStatusOnline // AvatarStatusBusy shows an error/red busy dot. AvatarStatusBusy // AvatarStatusAway shows an amber away dot. AvatarStatusAway // AvatarStatusOffline shows a muted neutral offline dot. AvatarStatusOffline )
type BadgeOptions ¶
type BadgeOptions struct {
// MaxCount caps a numeric badge: a larger count reads "999+" for the default
// 999. A value of zero or less keeps 999.
MaxCount int
// Visible hides the badge when it points to false; nil shows it.
Visible *bool
// ShowZero shows a numeric zero count; by default a zero badge is hidden.
ShowZero bool
// Label overrides the accessible name; the badge's text names it otherwise.
Label string
// ContainerColor overrides the Error container color.
ContainerColor ui.Color
// ContentColor overrides the OnError content color.
ContentColor ui.Color
// CutoutColor optionally paints a crisp 1.5 DIP outer separation halo
// around the badge when overlaid on saturated icons or avatars.
CutoutColor ui.Color
}
BadgeOptions configures a Badge or SmallBadge. The zero value is a visible Error-colored badge that shows every count, truncating above 999.
type BadgedBoxOptions ¶
type BadgedBoxOptions struct {
// Label describes the whole group for assistive technology; a clickable
// content element already names it, and the badge names its own count.
Label string
}
BadgedBoxOptions configures BadgedBox.
type BannerAction ¶
type BannerAction struct {
Label string
OnClick func()
}
BannerAction defines an inline action button displayed inside a Banner.
type BannerOptions ¶
type BannerOptions struct {
// Tone selects the semantic color role (Neutral uses SurfaceContainerLow
// with hairline outline; Primary/Secondary/Tertiary/Error/Warning/Success
// use their harmonized tonal container pair).
Tone SemanticTone
// Icon draws an optional 20 DIP leading icon.
Icon IconDraw
// Title optionally renders a short emphasized heading above the message.
Title string
// Actions displays up to 2 inline action buttons.
Actions []BannerAction
// Open optionally controls visibility. When non-nil and *Open is false,
// Banner renders a zero-size box; clicking the dismiss button sets *Open to
// false before invoking OnDismiss.
Open *bool
// Dismissible shows a trailing close button (automatically enabled when
// OnDismiss is non-nil).
Dismissible bool
// DismissLabel overrides the close button's accessible label ("Dismiss").
DismissLabel string
// OnDismiss runs when the user activates the dismiss button.
OnDismiss func()
// Label overrides the accessible region name.
Label string
}
BannerOptions configures Banner, a non-modal top-of-page notification bar.
type BentoGridOptions ¶
type BentoGridOptions struct {
// Columns fixes the grid column count when > 0. When <= 0, columns adapt
// automatically to WindowSizeClass (Compact: 1, Medium: 2, Expanded: 4,
// unless overridden by CompactColumns / MediumColumns / ExpandedColumns).
Columns int
// CompactColumns overrides the column count for WindowCompact (default 1).
CompactColumns int
// MediumColumns overrides the column count for WindowMedium (default 2).
MediumColumns int
// ExpandedColumns overrides the column count for WindowExpanded (default 4).
ExpandedColumns int
// Gap sets the grid cell spacing in DIP. When <= 0 or non-finite, adapts to
// Theme.Density (Comfortable: 16, Desktop: 12, Compact: 8).
Gap float32
// Tracks optionally defines explicit ui.Track column definitions instead of
// equal Fr(1) columns.
Tracks []ui.Track
// WidthOverride overrides c.Size()'s width when resolving WindowSizeClass.
WidthOverride float32
// Label optionally names the grid region for assistive technology.
Label string
}
BentoGridOptions configures BentoGrid.
type BottomSheetOptions ¶
type BottomSheetOptions struct {
// Modal shows the sheet over a fading scrim in a ui.Overlay, taking the
// focus, closing with Escape or a scrim press and giving the focus back;
// without it the sheet is laid out inline at the bottom of its parent.
Modal bool
// Detents are the modal sheet's resting heights as fractions of the
// window height, smallest first; {0.5, 1} when empty. A drag settles on
// the nearest, and one pulled further than the dismiss threshold closes
// the sheet.
Detents []float32
// Detent points to the resting detent; nil keeps it in the sheet's local
// state. Dragging writes the nearest detent into it.
Detent *int
// Height is the standard sheet's height in DIP; 320 when zero or negative.
Height float32
// Content builds the sheet's scrolling body.
Content func() ui.Element
// Label names the sheet for assistive technology; "Bottom sheet" when
// empty.
Label string
// Changed runs after a drag settles on another detent.
Changed func(i int)
}
BottomSheetOptions configures BottomSheet. The zero value is an inline standard sheet 320 DIP high that keeps no detent of its own.
type BreadcrumbItem ¶
type BreadcrumbItem struct {
// Label is the visible segment text and accessible name.
Label string
// Icon draws an optional leading icon before Label.
Icon IconDraw
// OnClick runs when an enabled ancestor segment (or its collapsed entry in
// the overflow menu) is clicked or activated by Enter or Space.
OnClick func()
// Disabled disables interaction for this segment.
Disabled bool
}
BreadcrumbItem describes one segment of a Breadcrumb navigation trail.
type BreadcrumbOptions ¶
type BreadcrumbOptions struct {
// MaxVisible limits how many visible breadcrumb segments (including the
// overflow menu button when collapsed) appear at once. Zero enables
// automatic responsive collapsing based on available layout width; positive
// values force collapsing whenever len(items) > MaxVisible (and still
// collapse further if available width is narrower).
MaxVisible int
// Separator draws the divider icon between visible segments. Nil uses an
// RTL-adaptive ChevronRight / ChevronLeft icon.
Separator IconDraw
// Label names the navigation landmark for assistive technology
// ("Breadcrumb" when empty).
Label string
// Disabled disables interaction across all breadcrumb segments and the
// overflow menu.
Disabled bool
}
BreadcrumbOptions configures Breadcrumb. The zero value produces an enabled, responsive trail that automatically collapses intermediate segments into an overflow menu when horizontal space runs short.
type ButtonGroupItem ¶
type ButtonGroupItem struct {
// Label is the visible label and the accessible name.
Label string
// LeadingIcon draws an icon before the label.
LeadingIcon IconDraw
// TrailingIcon draws an icon after the label.
TrailingIcon IconDraw
// Disabled disables this button alone.
Disabled bool
}
ButtonGroupItem is one button of a button group.
type ButtonGroupKind ¶
type ButtonGroupKind int
ButtonGroupKind selects how a button group's buttons meet.
const ( // ButtonGroupStandard keeps its buttons apart, each a full shape of its // own, and lets the pressed one widen as its neighbors give way. ButtonGroupStandard ButtonGroupKind = iota // ButtonGroupConnected joins its buttons with a tight gap and small inner // corners, the group's outer ends keeping the large shape radius; the // chosen button becomes a full pill. ButtonGroupConnected )
type ButtonGroupOptions ¶
type ButtonGroupOptions struct {
// Kind selects the Standard or Connected layout.
Kind ButtonGroupKind
// Variant selects the look of the group's buttons; the chosen buttons of a
// selectable group use it, the others show an outline.
Variant ButtonVariant
// Size selects the XS..XL tier of every button.
Size tokens.SizeTier
// Shape selects the resting shape. Connected groups keep this radius on
// their outer ends.
Shape ButtonShape
// Disabled disables the whole group.
Disabled bool
// Label names the group for assistive technology.
Label string
}
ButtonGroupOptions configures ButtonGroup, ButtonGroupMulti and ButtonGroupActions. The zero value is a standard, filled, extra small, round group that is enabled.
type ButtonOptions ¶
type ButtonOptions struct {
// Variant selects the button's MD3E look.
Variant ButtonVariant
// Size selects the XS..XL size tier, which fixes the height, horizontal
// padding, icon size, icon-label gap and typography. An out-of-range tier
// falls back to SizeXS.
Size tokens.SizeTier
// Shape selects the resting corner shape.
Shape ButtonShape
// LeadingIcon draws an icon before the label, at the tier's icon size.
LeadingIcon IconDraw
// TrailingIcon draws an icon after the label, at the tier's icon size.
TrailingIcon IconDraw
// Disabled disables the button: it takes no clicks, keys or focus, and
// shows MD3E's disabled colors without ui's automatic 0.5 dimming.
Disabled bool
// Label overrides the accessible name. By default the visible label names
// the button; give an empty label with an icon and a Label for an
// icon-only button.
Label string
}
ButtonOptions configures Button. The zero value is a filled, extra small, round button with no icons that is enabled.
type ButtonShape ¶
type ButtonShape int
ButtonShape selects a button's resting corner shape. Both shapes shrink their corners toward the size tier's pressed radius with the Fast Spatial spring while the button is pressed.
const ( // ButtonShapeRound is the full pill shape: the tier height's half. ButtonShapeRound ButtonShape = iota // ButtonShapeSquare is the tier's square radius (12/12/16/28/28). ButtonShapeSquare )
type ButtonVariant ¶
type ButtonVariant int
ButtonVariant selects one of the five Material Design 3 Expressive button looks. The zero value, ButtonFilled, is the high-emphasis action.
const ( // ButtonFilled paints the Primary container with OnPrimary content. ButtonFilled ButtonVariant = iota // ButtonTonal paints the SecondaryContainer with OnSecondaryContainer content. ButtonTonal // ButtonElevated paints the Level1 surface with Primary content and // MD3E Level1 Key/Ambient shadows, lifting to Level2 while pressed. ButtonElevated // ButtonOutlined draws an Outline border around Primary content. ButtonOutlined // ButtonText draws no container, only Primary content. ButtonText )
type CardOptions ¶
type CardOptions struct {
// Variant selects the card's container treatment.
Variant CardVariant
// Clickable makes the card an interactive ui.ButtonBase with ripple
// feedback, a focus stop and a pressed corner morph. OnClick alone makes it
// clickable too.
Clickable bool
// OnClick runs when a clickable card is clicked or activated by Enter or
// Space. It makes the card clickable even without Clickable.
OnClick func()
// Disabled disables a clickable card: it takes no clicks or focus and shows
// MD3E's disabled container and content tokens.
Disabled bool
// Label names the card for assistive technology.
Label string
// Padding is the content inset in DIP; 16 when zero or negative.
Padding float32
// ShapeScale selects an MD3E corner radius token for the card (for example
// tokens.ShapeLargeIncreased or tokens.ShapeExtraLarge for Bento layouts).
// The zero value (ShapeNone) defaults to tokens.ShapeLargeIncreased (20 DIP)
// for Elevated/Filled cards and tokens.ShapeLarge (16 DIP) for Outlined
// cards. Radius > 0 overrides ShapeScale when set.
ShapeScale tokens.ShapeScale
// Radius overrides the resting corner radius in DIP; takes precedence over
// ShapeScale when positive and finite.
Radius float32
// Hairline draws a subtle 1 DIP tonal highlight border on elevated or filled
// cards (ignored when disabled). On outlined cards, HairlineColor can still
// customize the border color.
Hairline bool
// HairlineColor overrides the default Hairline stroke color when A > 0.
HairlineColor ui.Color
// Optional gradient fills applied when the card is enabled. When both are
// set, LinearGradient paints first and RadialGradient overlays it.
LinearGradient *ui.LinearGradient
RadialGradient *ui.RadialGradient
// Backdrop optionally paints clipped decorative graphics inside the card
// bounds after the fill/gradient and before children. The callback must be
// pure and ghost-draw safe (no animation requests or interaction queries).
Backdrop func(p *ui.Painter, r ui.Rect)
// ContainerColor overrides the card's enabled background color when A > 0
// (for example cs.PrimaryContainer, cs.ErrorContainer, or a custom Bento
// accent color). Zero keeps the Variant's default surface role.
ContainerColor ui.Color
// ContentColor overrides the card's enabled foreground text color and
// StateLayer/Ripple ink when A > 0. Zero resolves Theme.ContentColorFor(bg)
// when ContainerColor is set, or cs.OnSurface for default Variant surfaces.
ContentColor ui.Color
// PressedScale optionally scales an interactive card around its center
// using the MD3E FastSpatial spring while pressed (for example 0.975).
// Zero, negative, or non-finite values disable press scaling.
PressedScale float32
}
CardOptions configures Card. The zero value is an elevated, padding 16 card that is not clickable.
type CardVariant ¶
type CardVariant int
CardVariant selects one of the three Material Design 3 card looks.
const ( // CardElevated paints SurfaceContainerLow with Level1 shadows, lifting to // Level2 while hovered or pressed. CardElevated CardVariant = iota // CardFilled paints SurfaceContainerLow without shadows. CardFilled // CardOutlined paints the Surface fill with an OutlineVariant border (or // 1.5 DIP Outline in HighContrast). CardOutlined )
type CarouselItem ¶
type CarouselItem struct {
// Label is the accessible name of the slide and the fallback caption.
Label string
// Content builds what the slide shows; it is clipped to the slide's
// rounded box. A nil builder paints the tonal surface and the label.
Content func() ui.Element
}
CarouselItem is one slide of a Carousel.
type CarouselLayout ¶
type CarouselLayout int
CarouselLayout selects how a Carousel sizes the items around its focused one.
const ( // CarouselHero shows the focused item large with its neighbours peeking at // the sides, which grow as they come into focus. CarouselHero CarouselLayout = iota // CarouselMultiBrowse shows the focused item large, the next one medium and // the rest small, so several items stay browsable at once. CarouselMultiBrowse // CarouselUncontained shows every item at the same width, without sizing // the focused one up. CarouselUncontained )
type CarouselOptions ¶
type CarouselOptions struct {
// Index points to the focused item; nil keeps it in the carousel's local
// state. Clicks, dragging and the caller's writes move the focus.
Index *int
// Layout selects the Hero, MultiBrowse or Uncontained sizing.
Layout CarouselLayout
// Height is the item height in DIP; 220 when zero or negative.
Height float32
// Gap is the space between items in DIP; 8 when zero or negative.
Gap float32
// Label names the carousel for assistive technology; "Carousel" when
// empty.
Label string
// Changed runs after a click, drag or the arrows choose another item.
Changed func(i int)
// Disabled disables the slides and their input.
Disabled bool
}
CarouselOptions configures a Carousel. The zero value is an enabled Hero carousel that keeps its own focused item.
type CheckboxOptions ¶
type CheckboxOptions struct {
// Label is the visible text after the box, and names the check box for
// assistive technology.
Label string
// Disabled disables the check box: it ignores the pointer, the keyboard
// and focus, and uses MD3E's disabled colors without ui's dimming.
Disabled bool
// Error paints the box with the error palette: an Error outline while
// off, and an Error container with an OnError check while on or mixed.
Error bool
// ErrorMessage tells assistive technology why the value is invalid. With
// Error set, the check box reports itself invalid, and the message as its
// description.
ErrorMessage string
// TouchTarget overrides the 40 DIP square the box sits in; values below
// the box's 18 DIP are raised to it.
TouchTarget float32
}
CheckboxOptions configures Checkbox and CheckboxState. The zero value is an enabled, valid check box with a 40 DIP touch target and no visible label.
type ChipGroupOptions ¶
type ChipGroupOptions struct {
// Label names the group for assistive technology.
Label string
// RowGap is the vertical space between wrapped lines, 8 DIP by default.
RowGap float32
// ColumnGap is the horizontal space between chips, 8 DIP by default.
ColumnGap float32
}
ChipGroupOptions configures ChipGroup. The zero value spaces chips 8 DIP apart in both directions.
type ChipOptions ¶
type ChipOptions struct {
// Elevated paints SurfaceContainerLow with MD3E Level1 shadows instead of
// the default outlined look.
Elevated bool
// LeadingIcon draws an 18 DIP icon before the label.
LeadingIcon IconDraw
// TrailingIcon draws an 18 DIP icon after the label.
TrailingIcon IconDraw
// Disabled disables the chip: it takes no pointer, keys or focus, and
// shows MD3E's disabled colors without ui's automatic dimming.
Disabled bool
// Label overrides the accessible name. By default the visible label names
// the chip.
Label string
// OnClick runs when the chip is clicked, or with Enter or Space while it
// has the keyboard focus.
OnClick func()
}
ChipOptions configures AssistChip and SuggestionChip. The zero value is an enabled, outlined chip with no icons.
type ColorPickerOptions ¶ added in v0.2.0
type ColorPickerOptions struct {
// Label names the color picker region for assistive technology.
Label string
// ShowTonalSwatches controls whether the 5-stop HCT tonal ramp (Tones 20,
// 40, 60, 80, 90 derived from *color's hue/chroma) is displayed below the
// picker. Nil defaults to true.
ShowTonalSwatches *bool
// Disabled disables color picking, sliders, hex typing, and swatches.
Disabled bool
// OnChanged runs once whenever *color changes.
OnChanged func(ui.Color)
}
ColorPickerOptions configures a Material Design 3 Expressive ColorPicker. The zero value displays the HSVA square, hue/opacity sliders, hex input, standard swatches, and an HCT tonal ramp swatch strip derived from *color.
type ColorWellOptions ¶ added in v0.2.0
type ColorWellOptions struct {
// Label names the color well for assistive technology (inherits FormField
// label when empty inside FormField).
Label string
// Open optionally binds the popover open state to a caller-owned *bool.
// Nil manages local open state via ui.Local.
Open *bool
// ShowHex shows the formatted hex color string beside the swatch inside the
// well trigger.
ShowHex bool
// Disabled disables the color well and closes any open picker popover.
Disabled bool
// OnChanged runs once whenever *color changes.
OnChanged func(ui.Color)
}
ColorWellOptions configures a Material Design 3 Expressive ColorWell. The zero value creates an interactive color swatch trigger that opens an L2 Popover containing a ColorPicker.
type Command ¶ added in v0.2.0
type Command struct {
// ID uniquely identifies the command for Recent tracking, OnRun reporting,
// and deterministic tie-breaking.
ID string
// Label is the visible primary label and searchable command title.
Label string
// Group names the category header shown in flat root lists and breadcrumbs.
Group string
// Keywords supplies optional extra search terms matched alongside Label.
Keywords []string
// Shortcut displays an optional display-only keyboard chord hint at the
// trailing edge; CommandPalette never registers duplicate shortcuts for it.
Shortcut KeyChord
// Disabled marks the command (and all descendants if it has Children)
// non-executable and non-focusable.
Disabled bool
// Children nests sub-commands navigated in-place when this command is
// activated.
Children []Command
// Run invokes the leaf command once after closing the palette and running
// bookkeeping (*Recent and OnRun). Groups with non-empty Children navigate
// inward instead of calling Run.
Run func()
}
Command describes one item or submenu group inside CommandPalette.
type CompletionOptions ¶ added in v0.2.0
type CompletionOptions struct {
Label string
Placeholder string
Disabled bool
OnChanged func(string)
}
CompletionOptions configures Combobox and Autocomplete.
type ConfirmDialogOptions ¶ added in v0.2.0
type ConfirmDialogOptions struct {
// Icon draws an optional centered icon above the headline.
Icon IconDraw
// Headline is the dialog's title and accessible name.
Headline string
// SupportingText explains what confirmation will do.
SupportingText string
// ConfirmLabel labels the primary confirmation button; "Confirm" when empty.
ConfirmLabel string
// CancelLabel labels the dismiss button; "Cancel" when empty.
CancelLabel string
// Destructive styles the confirmation action using Error / OnError colors
// for irreversible operations such as permanent deletion.
Destructive bool
// DismissOnScrim closes the dialog when the backdrop scrim is pressed.
DismissOnScrim bool
// Label overrides the accessible name; Headline by default.
Label string
// Width is the panel width in DIP; 360 when zero or negative.
Width float32
// OnConfirm runs when the Confirm action is triggered.
OnConfirm func()
// OnCancel runs when Cancel, Escape, or (with DismissOnScrim) scrim press
// dismisses the dialog.
OnCancel func()
}
ConfirmDialogOptions configures ConfirmDialog.
type DataTableCellOptions ¶
type DataTableCellOptions struct {
// Role selects the MD3E typography role when HasRole is true (or when Role
// is non-zero). Zero with HasRole=false uses Density-aware BodyMedium /
// BodySmall.
Role tokens.TypeRole
HasRole bool
Emphasized bool
// Numeric enables OpenType tabular lining figures ("tnum").
Numeric bool
// Mono selects CurrentTheme(c).MonoFont (or system "monospace").
Mono bool
// Truncate selects end, middle, or start ellipsis when text overflows.
Truncate TruncateMode
// MaxLines limits lines (defaults to single-line truncation when <= 0).
MaxLines int
// Muted tints the text with OnSurfaceVariant when Color is transparent.
Muted bool
// Color overrides the foreground text color when non-transparent (A > 0).
// Leaving Color zero preserves selected-row foreground inheritance.
Color ui.Color
}
DataTableCellOptions configures DataTableCellText.
type DataTableColumn ¶
type DataTableColumn struct {
// Title heads the column in the sticky table header.
Title string
// ID identifies the column for layout persistence (ListState.Columns) and
// sorting (SortOrder.Column). Title is used when ID is empty.
ID string
// Width is the initial column width in DIP, or 0 to share remaining space.
Width float32
// MinWidth and MaxWidth constrain user column resizing in DIP (0 = none).
MinWidth float32
MaxWidth float32
// Align controls cell content alignment. When Numeric is true and Align is
// left at its zero value (ui.Start), it resolves to ui.End (mirrored in RTL).
Align ui.Align
// Sortable allows clicking the column header to sort rows when Sort or
// SortBy is configured.
Sortable bool
// Fixed locks column order and width so users cannot drag or resize it.
Fixed bool
// RowHeader marks the column as row headers (ui.RoleRowHeader) for screen
// readers and whole-row selection in CellSelect mode.
RowHeader bool
// Numeric enables tabular lining figures ("tnum") on cell text and defaults
// cell alignment to ui.End.
Numeric bool
// Mono applies CurrentTheme(c).MonoFont (or system "monospace") to the
// column's cell context.
Mono bool
}
DataTableColumn describes a column of a DataTable.
type DataTableMenuAction ¶
type DataTableMenuAction struct {
Label string
Subtitle string
Trailing string
Separator bool
Checkable bool
Radio bool
Checked bool
Danger bool
Disabled bool
Shortcut ui.Modifiers
Key ui.Key
OnClick func()
}
DataTableMenuAction describes one item in a DataTable header or cell context menu bridged via ApplyDataTableMenuActions.
type DataTableOptions ¶
type DataTableOptions struct {
// State optionally provides a caller-owned ui.ListState for scroll control,
// sort state, column layout, cell selection, and Move animations.
State *ui.ListState
// ItemKey maps a row index to a stable comparable key so selection and row
// state survive insertions, deletions, and sorting.
ItemKey func(row int) any
// Selected binds single-row selection (index or -1 for none).
Selected *int
// Selection binds multi-row selection (*ui.Selection[K]).
Selection ui.Selector
// RowLabel returns the accessible and type-select label for row.
RowLabel func(row int) string
// IsHeader reports whether row renders as a sticky full-width section
// header.
IsHeader func(row int) bool
// Sort binds single-column sort state.
Sort *ui.SortOrder
// SortBy binds multi-column sort state (kept synchronized with Sort if both
// are provided).
SortBy *[]ui.SortOrder
// Layout binds column order and user-resized widths (bidirectional sync
// with ListState.Columns).
Layout *ui.TableLayout
// RoundRows rounds hovered and selected row corners using the MD3E small
// corner token.
RoundRows bool
// CellSelect enables spreadsheet-style block cell selection when Selection
// is also set.
CellSelect bool
// CellsStyle customizes cell selection and striped row colors.
CellsStyle ui.CellsStyle
// Hairline draws a subtle 1 DIP MD3E hairline border around the table shell.
Hairline bool
// Elevation selects the MD3E tonal surface tier and shadows for the table
// container. Zero defaults to tonal Level1 (SurfaceContainerLow) without
// drop shadows.
Elevation tokens.ElevationLevel
// ShapeScale selects the outer container corner token. Zero defaults to
// tokens.ShapeLarge (16 DIP).
ShapeScale tokens.ShapeScale
// RowHeight fixes row height in DIP when positive and finite. When <= 0 or
// non-finite, automatically follows Theme.Density (Comfortable: 48,
// Desktop: 38, Compact: 32).
RowHeight float32
// HeaderMenu builds a context menu when right-clicking a column header
// (col == -1 for the header area past the last column).
HeaderMenu func(m *ui.Menu, col int)
// HeaderCell appends custom trailing badges or tooltips inside each column
// header cell.
HeaderCell func(cell ui.Element, col int)
// CellMenu builds a context menu when right-clicking a data cell.
CellMenu func(m *ui.Menu, row, col int)
// OnRowClick runs when a data row is primary-clicked.
OnRowClick func(row int)
// OnRowSubmit runs when a data row is double-clicked or activated with Enter.
OnRowSubmit func(row int)
// OnSortChanged runs when Sort or SortBy changes after a header click.
OnSortChanged func(sort ui.SortOrder, sortBy []ui.SortOrder)
// OnLayoutChanged runs once a column drag, resize, or double-click fit
// commits a new TableLayout.
OnLayoutChanged func(layout ui.TableLayout)
// Label names the table for assistive technology.
Label string
// Disabled disables table interaction and dims content using MD3E disabled
// opacity tokens.
Disabled bool
}
DataTableOptions configures a Material Design 3 Expressive DataTable.
type DatePickerMode ¶
type DatePickerMode int
DatePickerMode selects how a DatePicker or DateRangePicker shows: docked inline in a card, or in a modal dialog over the window.
const ( // DatePickerDocked draws the calendar inline: a SurfaceContainer card with // a month grid, a header and an optional text entry view. DatePickerDocked DatePickerMode = iota // DatePickerModal draws the calendar in a modal dialog over a scrim, with // Cancel and OK actions, spring scale and fade in and out, Escape and a // scrim press closing it, and the focus returning to the trigger. DatePickerModal )
type DatePickerOptions ¶
type DatePickerOptions struct {
// Mode selects the docked or modal presentation.
Mode DatePickerMode
// Open owns the modal's open state and is required by DatePickerModal;
// Escape, a scrim press, Cancel and OK clear it. Docked pickers ignore it.
Open *bool
// Label names the picker and its modal dialog for assistive technology;
// "Choose date" or "Choose dates" by default.
Label string
// Disabled disables the whole picker: it takes no pointer or keyboard
// input and paints MD3E's disabled tokens.
Disabled bool
// FirstWeekday is the first column of a week, Sunday by default and
// Monday in many regions. Values outside Sunday..Saturday fall back to
// Sunday.
FirstWeekday time.Weekday
// OnChanged runs after the user picks a date or finishes a valid edit.
OnChanged func()
}
DatePickerOptions configures DatePicker and DateRangePicker. The zero value is an enabled inline calendar whose weeks start on Sunday.
type DialogAction ¶
type DialogAction struct {
// Label is the visible text and the accessible name.
Label string
// OnClick runs when the button is pressed, before the dialog closes.
OnClick func()
}
DialogAction is one button of an AlertDialog.
type DisclosureOptions ¶ added in v0.2.0
DisclosureOptions configures Collapsible.
type DividerOptions ¶
type DividerOptions struct {
// Vertical draws a line down its container instead of across it, as a
// separator between columns.
Vertical bool
// Thickness is the line's width in DIP; 1 when zero or negative.
Thickness float32
// Color overrides the line color; OutlineVariant when zero.
Color ui.Color
// Inset insets both logical ends of a horizontal line, or both vertical
// ends of a vertical one, in DIP.
Inset float32
// StartInset insets the line's logical start (the left in a left-to-right
// layout, the right right to left), in DIP.
StartInset float32
// EndInset insets the line's logical end, in DIP.
EndInset float32
// Label names the separator for assistive technology.
Label string
}
DividerOptions configures a Divider. The zero value is a 1 DIP horizontal line in OutlineVariant with no inset.
type DocumentTab ¶ added in v0.2.0
type DocumentTab struct {
// ID uniquely identifies the document tab across reorders, pinning, and
// closures.
ID string
// Title is the visible tab title and accessible base name.
Title string
// Icon draws an optional leading 16 DIP icon.
Icon IconDraw
// Dirty displays a dirty indicator dot and appends dirty context to the
// accessible description.
Dirty bool
// Pinned places the tab in the leading pinned prefix partition with compact
// width and no inline close button.
Pinned bool
}
DocumentTab describes one document tab in a TabStrip.
type DropZoneOptions ¶ added in v0.2.0
type DropZoneOptions[T any] struct { // Label sets the accessible landmark name for the drop region. Label string // Hint is rendered when content is nil. Defaults to "Drop item here". Hint string // ShapeScale overrides the container corner radius token. Zero defaults // to tokens.ShapeLarge. ShapeScale tokens.ShapeScale // CanAccept filters dragged payloads of type T before activating the // zone or accepting drops. Nil accepts all payloads of type T. CanAccept func(T) bool // OnDrop is invoked once when an accepted payload of type T is dropped. OnDrop func(T) // Disabled prevents drag acceptance, visual activation, and drops. Disabled bool }
DropZoneOptions configures an in-process typed DropZone target.
type EditableTextOptions ¶ added in v0.2.0
type EditableTextOptions struct {
// Role selects the MD3E typography role when HasRole is true (or Role != 0).
// Zero with HasRole=false uses BodyMedium.
Role tokens.TypeRole
HasRole bool
Emphasized bool
Mono bool
TabularNums bool
// Label names the editable text control for assistive technology.
Label string
// Disabled prevents entering inline edit mode and renders disabled MD3E
// foreground opacity.
Disabled bool
// OnChanged runs once whenever an inline edit is committed (Enter or blur)
// with a new string value.
OnChanged func(string)
}
EditableTextOptions configures a Material Design 3 Expressive EditableText. The zero value renders single-line BodyMedium text that switches to an inline editor on double-click, Enter (when standalone), or F2 / delayed click inside DataTable, VirtualList, and OutlineTable rows.
type ElasticIndicatorMotion ¶ added in v0.2.0
type ElasticIndicatorMotion struct {
// Lead and Trail select MD3E spring tokens when Configured is true.
// Use ElasticIndicatorSprings(lead, trail) so FastSpatial (zero value) is
// recognized as explicitly configured.
Lead motion.Token
Trail motion.Token
Configured bool
// LeadSpring and TrailSpring optionally override the leading and trailing
// physical springs directly when non-zero (for example
// ui.SpringOptions{Duration: 220*time.Millisecond, Bounce: 0.2}).
// Non-zero SpringOptions take precedence over Lead / Trail.
LeadSpring ui.SpringOptions
TrailSpring ui.SpringOptions
}
ElasticIndicatorMotion configures the leading and trailing springs of a bidirectional elastic ("worm") indicator used across NavigationSidebar, NavigationRail, PrimaryTabs, SecondaryTabs, PillTabs, and SegmentedTabs.
The zero value inherits Theme.IndicatorMotion, which defaults to DefaultElasticIndicatorMotion (motion.DefaultSpatial leading and motion.SlowSpatial trailing, arriving in roughly 200-350ms under Expressive motion). Use ElasticIndicatorSprings for MD3E token pairs (including motion.FastSpatial == 0) or ElasticIndicatorSpringOptions for explicit ui.SpringOptions (such as custom Duration/Bounce or Stiffness/Damping).
func DefaultElasticIndicatorMotion ¶ added in v0.2.0
func DefaultElasticIndicatorMotion() ElasticIndicatorMotion
DefaultElasticIndicatorMotion returns the default elastic indicator pacing: motion.DefaultSpatial on the leading edge and motion.SlowSpatial on the trailing edge (~200-350ms visual travel under Expressive motion).
func ElasticIndicatorSpringOptions ¶ added in v0.2.0
func ElasticIndicatorSpringOptions(lead, trail ui.SpringOptions) ElasticIndicatorMotion
ElasticIndicatorSpringOptions returns an ElasticIndicatorMotion using explicit leading and trailing ui.SpringOptions (for example custom Duration and Bounce, or Stiffness and Damping). Any zero edge falls back to the active theme or default pacing.
func ElasticIndicatorSprings ¶ added in v0.2.0
func ElasticIndicatorSprings(lead, trail motion.Token) ElasticIndicatorMotion
ElasticIndicatorSprings returns an ElasticIndicatorMotion driven by the given MD3E leading and trailing spring tokens.
type EmptyStateOptions ¶
type EmptyStateOptions struct {
// Illustration renders a custom illustration or widget above the title.
// Takes precedence over Icon when non-nil.
Illustration func()
// Icon draws a centered expressive IconBadge above the title when
// Illustration is nil.
Icon IconDraw
// IconShape optionally styles the IconBadge with a custom RoundedPolygon
// (such as shape.SoftBurst() or shape.Cookie9Sided()).
IconShape *shape.RoundedPolygon
// Description displays muted supporting copy beneath the title.
Description string
// PrimaryActionLabel renders a filled primary action button when non-empty.
PrimaryActionLabel string
// OnPrimaryAction runs when the primary action button is clicked.
OnPrimaryAction func()
// SecondaryActionLabel renders an outlined secondary action button when non-empty.
SecondaryActionLabel string
// OnSecondaryAction runs when the secondary action button is clicked.
OnSecondaryAction func()
// Actions optionally renders custom action controls in the centered action row.
Actions func()
// Padding sets the outer padding in DIP (defaults to 24, scaled by Density).
Padding float32
// Label overrides the accessible group label (defaults to title).
Label string
}
EmptyStateOptions configures EmptyState.
type ExtendedFABOptions ¶
type ExtendedFABOptions struct {
// Size selects the Medium (56 DIP) or Large (96 DIP) height; other sizes
// fall back to Medium.
Size FABSize
// Color selects the container/content pairing.
Color FABColorScheme
// Disabled disables the button with MD3E's disabled tokens.
Disabled bool
// Expanded, when set, collapses the label while false: the button springs
// to its square, icon-only width and fades the text out. Nil keeps it
// expanded.
Expanded *bool
// Label overrides the accessible name; the visible label names it by
// default.
Label string
}
ExtendedFABOptions configures ExtendedFAB. The zero value is a primary container, medium, enabled, expanded button.
type FABColorScheme ¶
type FABColorScheme int
FABColorScheme selects the container/content pairing of a floating action button.
const ( // FABPrimary paints PrimaryContainer with OnPrimaryContainer content. FABPrimary FABColorScheme = iota // FABSecondary paints SecondaryContainer with OnSecondaryContainer // content. FABSecondary // FABTertiary paints TertiaryContainer with OnTertiaryContainer content. FABTertiary // FABSurface keeps the Surface container with Primary content, lifted by // its Level3 shadows. FABSurface )
type FABMenuItem ¶
type FABMenuItem struct {
// Label is the visible text and the accessible name of the item.
Label string
// Icon draws the item's leading icon.
Icon IconDraw
// OnClick runs when the item is chosen.
OnClick func()
// Disabled disables this item alone.
Disabled bool
}
FABMenuItem is one action of a FABMenu.
type FABMenuOptions ¶
type FABMenuOptions struct {
// Open lets the caller own the menu's expanded state, as when the app
// closes it from elsewhere; nil keeps the state in the control.
Open *bool
// Color selects the trigger FAB's container/content pairing.
Color FABColorScheme
// Label names the trigger for assistive technology; "Menu" when empty.
Label string
// Icon is the trigger's icon while the menu is closed; mdicon.Add when
// nil.
Icon IconDraw
// CloseLabel names the in-place close button; "Close menu" when empty.
CloseLabel string
// MenuLabel names the menu panel for assistive technology; "Menu actions"
// when empty.
MenuLabel string
// Disabled disables the trigger and keeps the menu closed.
Disabled bool
}
FABMenuOptions configures FABMenu. The zero value is a primary container trigger that keeps its own open state.
type FABOptions ¶
type FABOptions struct {
// Size selects the Small, Medium or Large geometry. A size outside the
// three falls back to FABSizeMedium.
Size FABSize
// Color selects the container/content pairing.
Color FABColorScheme
// Disabled disables the button with MD3E's disabled tokens rather than
// ui's automatic dimming.
Disabled bool
// Visible, when set, hides the button while false: it springs down to a
// smaller scale and fades out without leaving the layout.
Visible *bool
}
FABOptions configures FAB. The zero value is a primary container, medium, enabled button.
type FABSize ¶
type FABSize int
FABSize selects one of the three Material Design 3 Expressive floating action button sizes.
const ( // FABSizeMedium is the standard 56×56 button with a 24 DIP icon and 16 // DIP corners; it is the zero value, as FABOptions documents. FABSizeMedium FABSize = iota // FABSizeSmall is the 40×40 button with a 24 DIP icon and 12 DIP corners. FABSizeSmall // FABSizeLarge is the 96×96 button with a 36 DIP icon and 28 DIP corners. FABSizeLarge )
type FieldOptions ¶ added in v0.2.0
FieldOptions configures FormField helper description and validation error.
type FileDropZoneOptions ¶ added in v0.2.0
type FileDropZoneOptions struct {
// Label sets the accessible landmark name for the file drop region.
Label string
// Hint is rendered when content is nil. Defaults to "Drop files here".
Hint string
// ShapeScale overrides the container corner radius token. Zero defaults
// to tokens.ShapeLarge.
ShapeScale tokens.ShapeScale
// Extensions optionally filters dropped file paths by case-insensitive
// suffix (for example ".md" or "png"). Empty accepts all files.
Extensions []string
// OnDropFiles is invoked when at least one matching file is dropped.
OnDropFiles func([]string)
// Disabled prevents OS file drag highlight and drop delivery.
Disabled bool
}
FileDropZoneOptions configures an OS file drop target built by FileDropZone.
type FilterChipOptions ¶
type FilterChipOptions struct {
// Elevated paints SurfaceContainerLow with MD3E Level1 shadows instead of
// the default outlined look.
Elevated bool
// LeadingIcon draws an 18 DIP icon before the label while the chip is
// unselected; selecting it replaces the icon with the check mark.
LeadingIcon IconDraw
// TrailingIcon draws an 18 DIP icon after the label.
TrailingIcon IconDraw
// Disabled disables the chip: it takes no pointer, keys or focus, and
// still reports its selected state to assistive technology.
Disabled bool
// Label overrides the accessible name. By default the visible label names
// the chip.
Label string
// OnChanged runs with the new selected state after a click, Space, or
// Enter toggles it.
OnChanged func(selected bool)
}
FilterChipOptions configures FilterChip. The zero value is an enabled, outlined filter chip.
type FindOptions ¶ added in v0.2.0
type FindOptions struct {
// CaseSensitive optionally binds the case-sensitivity ("Aa") toggle state.
CaseSensitive *bool
// Regex optionally binds the regular-expression (".*") toggle state. When
// enabled, non-empty queries are compiled via regexp.Compile; invalid
// patterns clear effective matches to zero, clamp *current to 0, show a
// RoleAlert validation error, and disable Replace actions.
Regex *bool
// Replacement optionally enables a second compact replacement row bound to
// this string alongside "Replace" and "Replace All" actions.
Replacement *string
// OnReplace runs when the user triggers single replacement (all=false via
// Replace button or Enter in the replacement input) or replace-all
// (all=true via Replace All button or Cmd/Ctrl+Enter).
OnReplace func(all bool)
}
FindOptions configures optional search flags and inline replacement controls for FindBar.
type FloatingToolbarFab ¶
type FloatingToolbarFab struct {
// Label is the accessible name of the FAB.
Label string
// Icon draws the FAB's icon; mdicon.Add when nil.
Icon IconDraw
// OnClick runs when the FAB is pressed.
OnClick func()
// Color selects the FAB's container/content pairing.
Color FABColorScheme
}
FloatingToolbarFab couples a standard FAB to a FloatingToolbar.
type FloatingToolbarItem ¶
type FloatingToolbarItem struct {
// Label is the accessible name of the item.
Label string
// Icon draws the item's icon.
Icon IconDraw
// OnClick runs when the item is pressed.
OnClick func()
// Disabled disables this item alone.
Disabled bool
}
FloatingToolbarItem is one action of a FloatingToolbar.
type FloatingToolbarOptions ¶
type FloatingToolbarOptions struct {
// Orientation selects the horizontal or vertical layout.
Orientation ToolbarOrientation
// Tone selects the standard or vibrant colors.
Tone FloatingToolbarTone
// Label names the toolbar for assistive technology; "Toolbar" when empty.
Label string
// Expanded, when set, collapses the toolbar to its first item while false,
// springing its length down with the Default Spatial spring.
Expanded *bool
// Visible, when set, hides the whole toolbar and its FAB while false.
Visible *bool
// Fab, when set, couples a standard FAB beside the toolbar.
Fab *FloatingToolbarFab
}
FloatingToolbarOptions configures FloatingToolbar. The zero value is a horizontal, standard tone, expanded and visible toolbar with no FAB.
type FloatingToolbarTone ¶
type FloatingToolbarTone int
FloatingToolbarTone selects the color family of a FloatingToolbar.
const ( // ToolbarStandard paints the raised Surface Container with OnSurface // content. ToolbarStandard FloatingToolbarTone = iota // ToolbarVibrant paints PrimaryContainer with OnPrimaryContainer content. ToolbarVibrant )
type FocusRingStyle ¶
type FocusRingStyle int
FocusRingStyle selects how AttachStateLayer and AttachRipple draw the keyboard focus outline when el.FocusVisible() is true.
const ( // FocusRingAuto draws a shape-conforming MD3E outer keyboard focus ring // matching the element's live corner radii or custom polygon contour. FocusRingAuto FocusRingStyle = iota // FocusRingInset draws the keyboard focus ring inside the element's clip // bounds (used by compact edge-aligned chrome such as WindowTitleBar). FocusRingInset // FocusRingNone suppresses the outline ring, retaining only the internal // Focus StateLayer tint. FocusRingNone )
type FormOptions ¶ added in v0.2.0
FormOptions configures Form transaction state and responsive form submission.
type FullScreenDialogOptions ¶
type FullScreenDialogOptions struct {
// Title is the top bar's title and the dialog's accessible name.
Title string
// Content builds the scrolling body.
Content func() ui.Element
// SaveLabel adds a text action at the top bar's end; none when empty.
SaveLabel string
// OnSave runs when the save action is chosen, before the dialog closes.
OnSave func()
// CloseLabel names the top bar's close button; "Close" when empty.
CloseLabel string
// OnClose runs when the dialog closes by its button, Escape or a backdrop
// press.
OnClose func()
// Label overrides the accessible name; the title by default.
Label string
}
FullScreenDialogOptions configures FullScreenDialog.
type GridViewOptions ¶ added in v0.2.0
type GridViewOptions struct {
// State optionally provides a caller-owned ui.GridState for scroll control,
// multi-selection, item keys, and drag reordering. When nil, an internal
// ui.GridState is managed automatically with ui.Local.
State *ui.GridState
// ItemKey maps an item index to a stable comparable key for multi-selection
// and for identifying cells within each virtualized row.
ItemKey func(item int) any
// Selected binds single-item selection (index or -1 for none). When
// Selection, OnChanged, or OnSubmit is set without Selected, an internal
// cursor is bound automatically so pointer and keyboard selection remain
// active. The cursor is an index and is cleared if it goes out of range.
Selected *int
// Selection binds multi-item selection (*ui.Selection[K]).
Selection ui.Selector
// ItemLabel returns the accessible and type-select label for item.
ItemLabel func(item int) string
// Reorder enables drag-to-reorder of grid items. items lists the dragged
// indices in ascending order and to is the target index before which they
// should move (count for the end).
Reorder func(items []int, to int)
// OnChanged runs when the grid's selection changes (via pointer click or
// keyboard navigation), receiving the current cursor index (or -1).
OnChanged func(item int)
// OnSubmit runs when an item is double-clicked or activated with Enter,
// receiving the current cursor index (or -1).
OnSubmit func(item int)
// Container wraps the grid inside a SurfaceContainerLow rounded surface.
Container bool
// Hairline draws a subtle 1 DIP MD3E hairline border around the grid
// container.
Hairline bool
// ShapeScale overrides the outer container corner token when Container or
// Hairline is enabled. Zero defaults to tokens.ShapeLarge.
ShapeScale tokens.ShapeScale
// Padding adds inner inset padding around the grid in DIP (sanitized to
// >= 0).
Padding float32
// Label names the grid for assistive technology.
Label string
// Disabled disables grid interaction, selection, keyboard navigation, and
// drag reordering.
Disabled bool
}
GridViewOptions configures a Material Design 3 Expressive GridView. The zero value produces a density-aware virtualized responsive card grid backed by ui.GridView with MD3E selection surfaces, focus borders, hover state layers, and optional container framing.
type HistoryOptions ¶ added in v0.2.0
type HistoryOptions struct {
// Label names the history button group for assistive technology; "History"
// when empty.
Label string
}
HistoryOptions configures HistoryButtons.
type IconBadgeOptions ¶
type IconBadgeOptions struct {
// Variant selects the MD3E container and icon color roles (default IconBadgeTonal).
Variant IconBadgeVariant
// Size selects the XS..XL tier scaled by Theme.Density.ButtonSpec.
Size tokens.SizeTier
// ContainerSize optionally overrides the badge's square side in DIP.
ContainerSize float32
// IconSize optionally overrides the inner icon size in DIP.
IconSize float32
// Shape optionally renders the badge container using a custom
// *shape.RoundedPolygon (for example shape.Cookie9Sided() or shape.Sunny()).
// Takes precedence over Radius and ShapeScale.
Shape *shape.RoundedPolygon
// ShapeScale selects an MD3E corner radius token when Shape is nil. Zero
// defaults to tokens.ShapeMedium.
ShapeScale tokens.ShapeScale
// Radius overrides the corner radius in DIP when Shape is nil and positive.
Radius float32
// ContainerColor optionally overrides the container fill color.
ContainerColor ui.Color
// ContentColor optionally overrides the icon ink color.
ContentColor ui.Color
// BorderColor optionally overrides the Outlined border color.
BorderColor ui.Color
// Label optionally sets an accessible name (RoleImage). When empty, the
// badge is decorative.
Label string
// Disabled applies MD3E disabled container and content tokens.
Disabled bool
}
IconBadgeOptions configures IconBadge. The zero value is a SizeXS tonal rounded-square badge scaled by Theme.Density.
type IconBadgeVariant ¶
type IconBadgeVariant int
IconBadgeVariant selects the MD3E color treatment of IconBadge.
const ( // IconBadgeTonal paints SecondaryContainer with OnSecondaryContainer ink (default). IconBadgeTonal IconBadgeVariant = iota // IconBadgeFilled paints Primary with OnPrimary ink. IconBadgeFilled // IconBadgeOutlined paints a transparent container with OutlineVariant border // and OnSurfaceVariant ink. IconBadgeOutlined // IconBadgePrimaryTonal paints PrimaryContainer with OnPrimaryContainer ink. IconBadgePrimaryTonal // IconBadgeTertiaryTonal paints TertiaryContainer with OnTertiaryContainer ink. IconBadgeTertiaryTonal // IconBadgeErrorTonal paints ErrorContainer with OnErrorContainer ink. IconBadgeErrorTonal )
type IconButtonOptions ¶
type IconButtonOptions struct {
// Variant selects the MD3E look.
Variant IconButtonVariant
// Size selects the XS..XL tier: height, icon size and pressed radius. An
// out-of-range tier falls back to SizeXS.
Size tokens.SizeTier
// Width selects Narrow, Default or Wide.
Width IconButtonWidth
// Shape selects the resting corner shape. A round icon button of the
// default width is a circle; narrow and wide ones are pills.
Shape ButtonShape
// Disabled disables the button and dims nothing: MD3E disabled colors are
// applied directly.
Disabled bool
}
IconButtonOptions configures IconButton and ToggleIconButton. The zero value is a standard, extra small, default width, round icon button.
type IconButtonVariant ¶
type IconButtonVariant int
IconButtonVariant selects the MD3E icon button look of IconButton and ToggleIconButton.
const ( // IconButtonStandard draws no container in its resting state, with an // OnSurfaceVariant icon; a toggle's selected state keeps that plain // container and turns the icon Primary. IconButtonStandard IconButtonVariant = iota // IconButtonFilled paints Primary with an OnPrimary icon; a toggle's // resting state paints SurfaceContainerHighest instead. IconButtonFilled // IconButtonTonal paints SecondaryContainer with an OnSecondaryContainer // icon; a toggle's resting state paints SurfaceContainerHighest. IconButtonTonal // IconButtonOutlined draws an Outline border; a toggle's selected state // paints InverseSurface with an InverseOnSurface icon. IconButtonOutlined )
type IconButtonWidth ¶
type IconButtonWidth int
IconButtonWidth selects the container width of an icon button around its size tier's height.
const ( // IconButtonWidthDefault is as wide as the tier is high: a circle for the // round shape. IconButtonWidthDefault IconButtonWidth = iota // IconButtonWidthNarrow is 0.75 of the tier height. IconButtonWidthNarrow // IconButtonWidthWide is 1.25 of the tier height. IconButtonWidthWide )
type IconDraw ¶
IconDraw paints an icon inside r using ink, such as any custom drawing function matching this signature.
type ImageOptions ¶
type ImageOptions struct {
// Fit selects how src fits inside the box (Contain by default).
Fit ui.Fit
// ObjectPosition places the image within its box as [x, y] fractions in 0..1
// when HasObjectPosition is true (default center [0.5, 0.5]).
ObjectPosition [2]float32
HasObjectPosition bool
// Shape selection priority: Shape polygon > Radii [4] > Radius > ShapeScale.
ShapeScale tokens.ShapeScale
Radius float32
HasRadius bool
Radii [4]float32
HasRadii bool
Shape *shape.RoundedPolygon
// BorderWidth draws a crisp outline around the image container or polygon.
BorderWidth float32
// BorderColor overrides the outline color (defaults to OutlineVariant).
BorderColor ui.Color
// Background overrides the tonal placeholder/backdrop fill color.
Background ui.Color
// Grayscale renders rectangular/rounded-corner images in shades of gray.
// Note: when Shape (custom polygon) is set, a subtle tonal veil is used
// because ui.Painter clips polygons independently of ui.Image.Grayscale.
Grayscale bool
// Width, Height, and AspectRatio optionally size the host box in DIPs.
// When Width and Height are zero and src is non-nil, the intrinsic size of
// src is used unless overridden by chaining .Size(...) or .Fill().
Width float32
Height float32
AspectRatio float32
// FadeIn fades the image in on initial mount. Transitions from Loading/nil
// to a loaded src fade in automatically unless NoFade or ReduceMotion is set.
FadeIn bool
// NoFade disables fade-in opacity transitions.
NoFade bool
// Loading renders an MD3E tonal pulsing Skeleton clipped to the image shape.
Loading bool
// Failed renders the MD3E error placeholder (implied automatically when
// Error != nil).
Failed bool
// Error triggers the error placeholder when non-nil.
Error error
// ErrorText displays optional supporting copy below the error icon.
ErrorText string
// RetryLabel customizes the error retry button text (defaults to "Retry").
RetryLabel string
// OnRetry renders an interactive retry button in the error state.
OnRetry func()
// LoadingContent overrides the default Skeleton when Loading is true.
LoadingContent func()
// ErrorContent overrides the default error placeholder when Failed/Error != nil.
ErrorContent func()
// Label names the image (ui.RoleImage, or ui.RoleButton when OnClick != nil).
Label string
// MatchKey attaches a shared-element ui.ElementTransition (Fly: true) for
// smooth hero transitions (for example into media.ImageLightbox).
MatchKey any
// OnClick makes the non-error image interactive with MD3E StateLayer/Ripple.
OnClick func()
// Disabled disables interaction and applies MD3E disabled visual treatment.
Disabled bool
}
ImageOptions configures md3e.Image for displaying local bitmaps or SVGs with MD3E shape scales, custom RoundedPolygon masks, smooth load fade-in, and tonal loading/error placeholders.
type InputChipOptions ¶
type InputChipOptions struct {
// Elevated paints SurfaceContainerLow with MD3E Level1 shadows instead of
// the default outlined look.
Elevated bool
// LeadingIcon draws a 24 DIP avatar when Avatar is set, or an 18 DIP icon
// otherwise, before the label.
LeadingIcon IconDraw
// Avatar clips LeadingIcon to a 24 DIP circle and tightens the start
// padding, as an input chip shows a person or entity.
Avatar bool
// TrailingIcon draws an 18 DIP icon after the label, before the close
// button.
TrailingIcon IconDraw
// Disabled disables the whole chip, its close button too.
Disabled bool
// Label overrides the accessible name of the chip's body. By default the
// visible label names it.
Label string
// RemoveLabel overrides the accessible name of the close button; "Remove
// <label>" by default.
RemoveLabel string
// OnClick runs when the body of the chip is clicked, or with Enter or
// Space while it has the keyboard focus.
OnClick func()
// OnRemove runs when the close button is clicked, or pressed with Enter or
// Space while it has the keyboard focus.
OnRemove func()
}
InputChipOptions configures InputChip. The zero value is an enabled, outlined chip with an accessible close button.
type KbdOptions ¶ added in v0.2.0
type KbdOptions struct {
// AccessibleLabel overrides the screen-reader label synthesized from the
// key chord (for example "Command+K" or "Control+K").
AccessibleLabel string
}
KbdOptions configures Kbd.
type KeyChord ¶ added in v0.2.0
KeyChord describes a display-only keyboard shortcut chord combining zero or more modifier flags with a primary key.
type LinkOptions ¶ added in v0.2.0
type LinkOptions struct {
// Label overrides the accessible name exposed to assistive technology.
Label string
}
LinkOptions configures Link.
type ListDetailPaneOptions ¶
type ListDetailPaneOptions struct {
// SplitWidth controls the list pane width in DIP when SplitPercent is nil.
// When both SplitWidth and SplitPercent are nil, local state initialized to
// DefaultListWidth (320 DIP) is used.
SplitWidth *float32
// SplitPercent optionally controls the list pane width as a percentage
// (0..100) via ui.SplitPercent instead of fixed DIPs.
SplitPercent *float32
// DefaultListWidth is the initial and double-click reset size in DIP
// (default 320) or percentage (default 35) when SplitPercent is used.
DefaultListWidth float32
// ShowDetail selects whether the detail pane is displayed when collapsed to
// a single pane under WindowCompact. Nil shows the list pane.
ShowDetail *bool
// WidthOverride overrides c.Size()'s width when resolving WindowSizeClass.
WidthOverride float32
// Label optionally names the list-detail region for assistive technology.
Label string
}
ListDetailPaneOptions configures ListDetailPane.
type ListItem ¶
type ListItem struct {
// Key is the row's stable identity across rebuilds, as an item's ID. Rows
// without one are keyed by their index.
Key any
// Overline is the small text above the headline.
Overline string
// Headline is the row's main text and its accessible name.
Headline string
// SupportingText is the secondary text below the headline.
SupportingText string
// Icon draws a 24 DIP leading icon when Leading is nil.
Icon IconDraw
// Leading builds the leading slot (an avatar, an icon or a control) in
// place of Icon.
Leading func() ui.Element
// Trailing builds the trailing slot (metadata, an icon or a control).
Trailing func() ui.Element
// Meta is trailing text shown before any Trailing slot.
Meta string
// OnClick runs when the row is clicked or activated by Enter or Space. A
// row with OnClick, or a list with Selected, is interactive.
OnClick func()
// Disabled disables this row alone.
Disabled bool
}
ListItem describes one row of a List: its text, its leading and trailing slots, and what choosing it does.
type ListOptions ¶
type ListOptions struct {
// Label names the list for assistive technology.
Label string
// Segmented draws the rows as attached card pieces: the first rounds its
// top corners, the last its bottom corners, inner rows keep small corners
// and a single row rounds all four. A chosen or pressed row rounds all four
// with the Default Spatial spring.
Segmented bool
// Selected points to the chosen row, -1 for none. The list writes clicks
// and Enter or Space into it as it builds, and their state reaches
// assistive technology.
Selected *int
// OnSelect runs after a click chooses a row.
OnSelect func(i int)
// Disabled disables the whole list.
Disabled bool
}
ListOptions configures a List. The zero value is a plain, enabled list of rows without selection.
type LoadingOptions ¶
type LoadingOptions struct {
// Style selects the standard or contained look.
Style LoadingStyle
// Size is the component's square side in DIP; 48 when zero or invalid.
Size float32
// Polygons overrides the shapes the indicator cycles through, in order.
// Each adjacent pair, including the last back to the first, is morphed.
// nil or an empty list uses DefaultLoadingPolygons.
Polygons []*shape.RoundedPolygon
// Paused freezes the indicator at the phase it shows, asking for no
// animation frames.
Paused bool
// Label names the progress indicator for assistive technology; "Loading"
// when empty.
Label string
}
LoadingOptions configures LoadingIndicator. The zero value is a 48 DIP standard indicator running the default seven-shape sequence.
type LoadingStyle ¶
type LoadingStyle int
LoadingStyle selects the look of a LoadingIndicator.
const ( // LoadingStandard draws no container: the morphing shape alone, in Primary. LoadingStandard LoadingStyle = iota // LoadingContained draws a PrimaryContainer circle with the shape inset in // OnPrimaryContainer, as the filled MD3E loading indicator. LoadingContained )
type MenuItem ¶
type MenuItem struct {
// Label is the visible text and the accessible name.
Label string
// Icon draws an optional leading 20 DIP icon.
Icon IconDraw
// Shortcut is shown at the row's end, as "⌘C"; it is a hint only.
Shortcut string
// ShortcutChord optionally formats a platform-aware shortcut hint at the
// row's end when Shortcut is empty (display only; never registers hotkeys).
ShortcutChord KeyChord
// Separator draws a divider instead of a row.
Separator bool
// Checkable makes the row a check box item showing Checked.
Checkable bool
// Radio makes the row a radio item showing Checked.
Radio bool
// Checked marks a check box or radio item chosen.
Checked bool
// Disabled grays the row out and keeps the pointer and the keys off it.
Disabled bool
Submenu []MenuItem
// OnClick runs when the row is chosen, before the menu closes.
OnClick func()
}
MenuItem is one row of a DropdownMenu, MenuButton or ContextMenu.
type MenuOptions ¶
type MenuOptions struct {
// Open lets the caller own the menu's open state; nil keeps it in the
// control.
Open *bool
// Label names the menu for assistive technology.
Label string
// Disabled disables the trigger and keeps the menu closed.
Disabled bool
// Width fixes the menu panel's width in DIP; its content's when zero.
Width float32
}
MenuOptions configures DropdownMenu, MenuButton and ContextMenu.
type MorphIconButtonOptions ¶
type MorphIconButtonOptions struct {
// Variant selects the MD3E color role treatment (default ShapeButtonFilled).
Variant ShapeButtonVariant
// Size selects the XS..XL tier scaled by Theme.Density.ButtonSpec.
Size tokens.SizeTier
// Width optionally overrides the container width in DIP.
Width float32
// Height optionally overrides the container height in DIP.
Height float32
// IconSize optionally overrides the centered icon size in DIP.
IconSize float32
// Shape is the unselected polygon outline. Defaults to shape.Circle().
Shape *shape.RoundedPolygon
// SelectedShape is the selected polygon outline. Defaults to shape.Square().
SelectedShape *shape.RoundedPolygon
// PressedShape optionally overrides the polygon morphed toward while
// actively pressed. When nil, pressing nudges along the Shape <->
// SelectedShape morph so release flows seamlessly into the toggled shape.
PressedShape *shape.RoundedPolygon
// SelectedIcon optionally cross-fades and scales in while *on is true.
SelectedIcon IconDraw
// Spring selects the MD3E spring token driving shape morphs. Zero value
// uses motion.FastSpatial.
Spring motion.Token
// ContainerColor optionally overrides the unselected container fill color.
ContainerColor ui.Color
// ContentColor optionally overrides the unselected icon ink color.
ContentColor ui.Color
// SelectedContainerColor optionally overrides the selected container fill.
SelectedContainerColor ui.Color
// SelectedContentColor optionally overrides the selected icon ink color.
SelectedContentColor ui.Color
// BorderColor optionally overrides the Outlined stroke color.
BorderColor ui.Color
// OnChanged runs immediately after a click or Enter/Space toggles *on.
OnChanged func(on bool)
// Disabled disables interaction and applies MD3E disabled color tokens.
Disabled bool
}
MorphIconButtonOptions configures MorphIconButton, a *bool-bound expressive toggle button that continuously morphs between Shape (off) and SelectedShape (on) and cross-fades between icon and SelectedIcon (for example Play <-> Pause).
type NavGroup ¶ added in v0.2.0
type NavGroup struct {
ID string
Label string
// When nil, the group remains always open.
Open *bool
Items []NavItem
}
NavGroup groups related NavItems inside NavigationSidebar.
type NavItem ¶ added in v0.2.0
type NavItem struct {
// collapses, and projection transitions.
ID string
Label string
Badge string
Icon IconDraw
Menu func(*ui.Menu)
}
NavItem describes one navigation destination shared across NavigationSidebar, collapsed icon-only Rail projection, and Compact bottom bar projection.
type NavigationBarOptions ¶
type NavigationBarOptions struct {
// clicks and keyboard activation into it as it builds.
Selected *int
// Selected is nil.
Changed func(i int)
Labels NavigationLabelMode
Label string
Disabled bool
}
NavigationBarOptions configures a NavigationBar. The zero value is an enabled bar with always-visible labels that keeps no selection of its own.
type NavigationDestination ¶
type NavigationDestination struct {
Label string
Icon IconDraw
// adds none.
Badge string
SmallBadge bool
Disabled bool
}
NavigationDestination is one destination of a NavigationBar or NavigationRail.
type NavigationDrawerItem ¶
type NavigationDrawerItem struct {
Label string
Icon IconDraw
Badge string
// item before it, adding a divider between sections.
Section string
Disabled bool
}
NavigationDrawerItem is one destination of a NavigationDrawer, optionally opening a new section.
type NavigationDrawerOptions ¶
type NavigationDrawerOptions struct {
// drawer's local state.
Open *bool
// closes on Escape, a scrim press or a drag past the threshold, and gives
// the focus back to where it was. Without it the drawer is inline and
// dismissible, animating its width in and out of the layout.
Modal bool
Selected *int
Changed func(i int)
Label string
Disabled bool
Width float32
}
NavigationDrawerOptions configures a NavigationDrawer. The zero value is an inline, enabled drawer that keeps its own open state.
type NavigationLabelMode ¶
type NavigationLabelMode int
NavigationLabelMode selects when a navigation destination shows its label.
const ( NavigationLabelsAlways NavigationLabelMode = iota NavigationLabelsSelectedOnly // accessible names. NavigationLabelsNever )
type NavigationRailIndicatorStyle ¶
type NavigationRailIndicatorStyle int
NavigationRailIndicatorStyle selects the active destination indicator style rendered by NavigationRail.
const ( // capsule that slides vertically between destinations. NavigationRailIndicatorPill NavigationRailIndicatorStyle = iota // SecondaryContainer capsule (FastEffects) with a desktop-style leading // Primary accent bar (on the left in LTR, right in RTL) whose vertical // span is driven directly by the Expressive elastic worm indicator. NavigationRailIndicatorPillWithBar )
type NavigationRailOptions ¶
type NavigationRailOptions struct {
// writes clicks and keyboard activation into it as it builds.
Selected *int
Changed func(i int)
// rail's own local state.
Expanded *bool
// non-finite fall back to the active theme Density default (256 Comfortable,
// 192 Desktop, 180 Compact); positive values below the collapsed width (80)
// are clamped to 80 so collapse/expand transitions stay aligned.
ExpandedWidth float32
// sliding capsule (NavigationRailIndicatorPill) or a desktop capsule paired
// with a leading accent bar (NavigationRailIndicatorPillWithBar).
IndicatorStyle NavigationRailIndicatorStyle
Header func() ui.Element
Align ui.Align
Label string
Disabled bool
// (clamped to 56..64 DIP), hiding short text labels and showing an
// automatic PlainTooltip on collapsed destinations. Zero keeps the 80 DIP
// collapsed rail with short labels below icons.
IconOnlyWidth float32
Footer func()
// of the rail that updates Expanded (or local state when Expanded is nil).
ShowToggle bool
// elastic indicator. Zero value inherits Theme.IndicatorMotion (default
// motion.DefaultSpatial leading + motion.SlowSpatial trailing).
IndicatorMotion ElasticIndicatorMotion
}
NavigationRailOptions configures a NavigationRail. The zero value is an enabled, collapsed rail whose destinations align to the top.
type NumberInputOptions ¶ added in v0.2.0
type NumberInputOptions struct {
// Variant selects TextFieldFilled (default) or TextFieldOutlined.
Variant TextFieldVariant
// Label names the field and renders a compact caption above the number
// inside the input. Leave empty inside FormField to inherit the field's
// accessible label.
Label string
// Placeholder shows when the text buffer is temporarily cleared during editing.
Placeholder string
// Prefix renders an optional leading unit/currency text (e.g. "$").
Prefix string
// Suffix renders an optional trailing unit text before the step buttons
// (e.g. "ms", "px", "%").
Suffix string
// SupportingText displays helper text below the field.
SupportingText string
// Error highlights the field using MD3E error tokens and marks aria-invalid.
Error bool
// ErrorMessage renders error text below the field when Error is true.
ErrorMessage string
// ReadOnly allows reading and focusing the number without modifying *value.
ReadOnly bool
// Disabled disables editing, keyboard stepping, and step buttons.
Disabled bool
// OnChanged runs once whenever *value changes via typing, arrow keys, or
// step buttons.
OnChanged func(float64)
}
NumberInputOptions configures a Material Design 3 Expressive NumberInput. The zero value creates an enabled, filled numeric input with tabular figures and integrated decrement/increment step buttons.
type OutlineTableOptions ¶ added in v0.2.0
type OutlineTableOptions[K comparable] struct { // Selected binds single-row selection (flattened row index or -1 for none). Selected *int // Selection binds multi-row key selection (*ui.Selection[K]). Selection *ui.Selection[K] // RowLabel returns the accessible and type-select label for item. RowLabel func(item K) string // Sort binds single-column sort state. Sort *ui.SortOrder // SortBy binds multi-column sort state (kept synchronized with Sort if both // are provided). SortBy *[]ui.SortOrder // Layout binds column order and user-resized widths (bidirectional sync // with state.List.Columns). Layout *ui.TableLayout // RoundRows rounds hovered and selected row corners using the MD3E small // corner token. RoundRows bool // CellSelect enables spreadsheet-style block cell selection when Selection // is also set. CellSelect bool // CellsStyle customizes cell selection and striped row colors. CellsStyle ui.CellsStyle // Hairline draws a subtle 1 DIP MD3E hairline border around the table shell. Hairline bool // Elevation selects the MD3E tonal surface tier and shadows for the table // container. Zero defaults to tonal Level1 (SurfaceContainerLow) without // drop shadows. Elevation tokens.ElevationLevel // ShapeScale selects the outer container corner token. Zero defaults to // tokens.ShapeLarge (16 DIP). ShapeScale tokens.ShapeScale // RowHeight fixes row height in DIP when positive and finite. When <= 0 or // non-finite, automatically follows Theme.Density (Comfortable: 48, // Desktop: 38, Compact: 32). RowHeight float32 // ShowIndentGuides draws subtle vertical OutlineVariant connector lines // aligned beneath ancestor disclosure chevrons. ShowIndentGuides bool // Indent overrides per-level indentation width in DIP when positive and // finite. Zero uses a density-aware default (16 Compact / 18 Desktop / 20 // Comfortable). Indent float32 // HeaderMenu builds a context menu when right-clicking a column header // (col == -1 for the header area past the last column). HeaderMenu func(m *ui.Menu, col int) // HeaderCell appends custom trailing badges or tooltips inside each column // header cell. HeaderCell func(cell ui.Element, col int) // CellMenu builds a context menu when right-clicking a data cell. CellMenu func(m *ui.Menu, item K, col int) // OnRowClick runs when a row is primary-clicked. OnRowClick func(item K) // OnRowSubmit runs when a row is double-clicked or activated with Enter. OnRowSubmit func(item K) // OnSortChanged runs when Sort or SortBy changes after a header click. OnSortChanged func(sort ui.SortOrder, sortBy []ui.SortOrder) // OnLayoutChanged runs once a column drag, resize, or double-click fit // commits a new TableLayout. OnLayoutChanged func(layout ui.TableLayout) // Label names the tree table for assistive technology. Label string // Disabled disables interaction across the entire outline table. Disabled bool }
OutlineTableOptions configures a Material Design 3 Expressive OutlineTable. The zero value builds a density-aware hierarchical table over ui.OutlineTable with animated MD3E disclosure chevrons, tonal container surfaces, and full RoleTree keyboard and assistive-technology semantics.
type PaginationOptions ¶
type PaginationOptions struct {
// ShowEdges adds First page and Last page icon buttons at the ends of the
// pagination bar.
ShowEdges bool
// SiblingCount sets how many page numbers render immediately before and
// after the current page. Values <= 0 default to 1.
SiblingCount int
// MaxButtons caps the total number of page and ellipsis slots between
// Previous and Next when > 0. Values <= 0 use SiblingCount (7 slots when
// SiblingCount defaults to 1). One slot shows the current page. Two slots
// show the first and current pages, or the first and last on page 1.
MaxButtons int
// Variant selects the MD3E look of the active page button (ButtonFilled by
// default, or ButtonTonal for SecondaryContainer). Inactive page buttons
// render as ButtonText (or ButtonOutlined when Variant is ButtonOutlined).
Variant ButtonVariant
// OnChanged runs when clicking or activating a button changes the active
// page, after *page is updated.
OnChanged func(page int)
// Label names the navigation landmark for assistive technology
// ("Pagination" when empty).
Label string
// Disabled disables interaction across every button in the pagination bar.
Disabled bool
}
PaginationOptions configures Pagination. The zero value produces an enabled, Filled-accent 1-based pagination bar with Previous/Next buttons, 1 sibling page on each side of the current page, and tabular numerals.
type PaletteOptions ¶ added in v0.2.0
type PaletteOptions struct {
// Label names the modal command palette dialog for assistive technology;
// "Command palette" when empty.
Label string
// Recent optionally points to the caller's MRU list of command IDs. When
// provided, CommandPalette prepends executed leaf command IDs (deduplicated)
// and ranks recent items higher.
Recent *[]string
// OnRun is invoked right before cmd.Run when a non-disabled leaf command is
// activated, after the palette closes and *Recent is updated.
OnRun func(id string)
}
PaletteOptions configures CommandPalette.
type PillTabsOptions ¶
type PillTabsOptions struct {
// Selected points to the active tab index. When nil, the tab bar stores its
// selection in local state.
Selected *int
// Changed runs after a click or keyboard navigation changes the selection.
Changed func(i int)
// Tone selects the active capsule and trough color roles.
Tone PillTabsTone
// Scrollable lays tabs out at their natural widths inside a horizontal
// scroller, automatically scrolling the chosen tab into view.
Scrollable bool
// FullWidth stretches the capsule trough across its parent's width and
// shares width equally among tabs (ignored when Scrollable is true).
FullWidth bool
// Label names the tab list for assistive technology; "Tabs" when empty.
Label string
// Disabled disables every tab in the strip.
Disabled bool
// IndicatorMotion optionally overrides the leading/trailing springs of the
// elastic capsule indicator. Zero value inherits Theme.IndicatorMotion
// (default motion.DefaultSpatial leading + motion.SlowSpatial trailing).
IndicatorMotion ElasticIndicatorMotion
}
PillTabsOptions configures PillTabs and SegmentedTabs. The zero value is an enabled, content-sized pill tab strip that manages its own selection.
type PillTabsTone ¶
type PillTabsTone int
PillTabsTone selects the color pairing for the sliding active capsule of PillTabs and SegmentedTabs.
const ( // PillTabsToneAuto selects PillTabsTonePrimary for PillTabs, and // PillTabsToneSurface for SegmentedTabs. PillTabsToneAuto PillTabsTone = iota // PillTabsTonePrimary paints a Primary active capsule with OnPrimary text // over the unified tonal trough (Dark SurfaceContainerLowest / Light // SurfaceContainer). PillTabsTonePrimary // PillTabsToneSecondary paints a SecondaryContainer active capsule with // OnSecondaryContainer text over the unified tonal trough. PillTabsToneSecondary // PillTabsToneSurface paints a neutral tonal active capsule (Dark // SurfaceContainerHigh / Light SurfaceContainerLowest) with OnSurface text // over the unified tonal trough. PillTabsToneSurface )
type PlainTooltipOptions ¶
type PlainTooltipOptions struct {
// Description is the help text assistive technology reads after the
// anchor's name; text when empty.
Description string
// ShortcutChord optionally displays a non-interactive Kbd shortcut pill
// beside the tooltip label and includes its spoken name in Description when
// Description is empty.
ShortcutChord KeyChord
}
PlainTooltipOptions configures PlainTooltip.
type PopoverOptions ¶ added in v0.2.0
type PopoverOptions struct {
// Label names the popover panel for assistive technology.
Label string
// Placement overrides the default AnchorBottomStart -> AnchorTopStart
// attachment; Flip remains active along both axes.
Placement *PopoverPlacement
// MinWidth sets the minimum panel width in DIP, clamped to the available
// viewport width inside edge margins.
MinWidth float32
}
PopoverOptions configures Popover. The zero value opens an anchored L2 popover below the trigger's start edge (AnchorBottomStart -> AnchorTopStart), flipping automatically when constrained against the viewport edge.
type PopoverPlacement ¶ added in v0.2.0
type PopoverPlacement struct {
// At is the anchor point on the trigger element (for example
// ui.AnchorBottomStart or ui.AnchorEnd).
At ui.Anchor
// Self is the point on the popover panel aligned with At (for example
// ui.AnchorTopStart or ui.AnchorStart).
Self ui.Anchor
}
PopoverPlacement pairs an anchor point on the trigger element with the connecting point on the Popover panel itself.
type ProgressOptions ¶
type ProgressOptions struct {
// Label names the indicator for assistive technology.
Label string
// Disabled shows MD3E's disabled colors without ui's automatic dimming.
Disabled bool
// Thickness is the bar or ring thickness in DIP; 4 when zero or invalid.
Thickness float32
// TrackGap is the clear space between the active segment and the track, in
// DIP; 4 when zero or invalid.
TrackGap float32
// Width fixes a linear indicator's width; zero fills its column.
Width float32
// Size is a circular indicator's square side in DIP; 48 when zero or
// invalid.
Size float32
// Buffer is an optional secondary progress value in 0..1 (for buffered
// media or streaming sync), drawn between the active segment and the
// unfinished track with TrackGap clearance. Zero (or non-positive /
// non-finite) keeps the default single-progress appearance.
Buffer float64
}
ProgressOptions configures the linear and circular MD3E progress indicators. The zero value is an enabled 4 DIP thick indicator with a 4 DIP track gap that fills its column (linear) or is 48 DIP across (circular).
type PromptDialogOptions ¶ added in v0.2.0
type PromptDialogOptions struct {
// Icon draws an optional centered icon above the headline.
Icon IconDraw
// Headline is the dialog's title and accessible name.
Headline string
// SupportingText provides optional instructions above the text input.
SupportingText string
// FieldLabel names the outlined text field; "Value" when empty.
FieldLabel string
// Placeholder shows inside the text field while empty.
Placeholder string
// ConfirmLabel labels the primary submit button; "Confirm" when empty.
ConfirmLabel string
// CancelLabel labels the dismiss button; "Cancel" when empty.
CancelLabel string
// DismissOnScrim closes the dialog when the backdrop scrim is pressed.
DismissOnScrim bool
// Label overrides the accessible name; Headline by default.
Label string
// Width is the panel width in DIP; 360 when zero or negative.
Width float32
// Validate optionally validates the draft string right before confirming.
// Returning a non-empty error string keeps the dialog open and displays the
// message on the text field without mutating *value.
Validate func(draft string) string
// OnConfirm runs with the committed draft string after *value has been
// updated atomically.
OnConfirm func(value string)
// OnCancel runs when Cancel, Escape, or (with DismissOnScrim) scrim press
// dismisses the dialog without modifying *value.
OnCancel func()
}
PromptDialogOptions configures PromptDialog.
type RadioGroupOptions ¶
type RadioGroupOptions struct {
// Label names the group for assistive technology.
Label string
// Horizontal lays the radios in a row with a 16 DIP gap instead of the
// default column.
Horizontal bool
// Disabled disables the whole group and its radios.
Disabled bool
}
RadioGroupOptions configures RadioGroup. The zero value is a vertical group with an 8 DIP gap and no accessible name.
type RadioOptions ¶
type RadioOptions struct {
// Disabled disables the radio button: it ignores the pointer, the keyboard
// and focus, and uses MD3E's disabled colors without ui's dimming.
Disabled bool
// Label overrides the accessible name. The visible label names the button
// by default.
Label string
// TouchTarget overrides the 40 DIP square the ring sits in; values below
// the ring's 20 DIP are raised to it.
TouchTarget float32
}
RadioOptions configures Radio. The zero value is an enabled radio button with a 40 DIP touch target.
type RangeSliderOptions ¶
type RangeSliderOptions struct {
// Label names the group of the two handles for assistive technology.
Label string
// MinLabel and MaxLabel name the low and high handles; "Min" and "Max" by
// default.
MinLabel, MaxLabel string
// Disabled disables the range slider and both handles.
Disabled bool
// Step snaps both values to lo and its multiples, draws a stop dot at
// each, and moves the focused handle by one step per key. Zero keeps the
// values continuous.
Step float64
// TrackHeight overrides the 16 DIP track height.
TrackHeight float32
// ThumbHeight overrides the 44 DIP capsule handle height.
ThumbHeight float32
// FormatLabel formats the values shown in the indicators.
FormatLabel func(float64) string
}
RangeSliderOptions configures RangeSlider. The zero value is an enabled, continuous range slider named "Min" and "Max" with a 16 DIP track.
type RichTooltipAction ¶
type RichTooltipAction struct {
// Label is the button's visible text and accessible name.
Label string
// OnClick runs when the action is chosen.
OnClick func()
}
RichTooltipAction is the optional action button of a RichTooltip.
type RichTooltipOptions ¶
type RichTooltipOptions struct {
// Title is the tooltip's heading; optional.
Title string
// Body is the tooltip's supporting text.
Body string
// Action adds an interactive button at the tooltip's end, whose reach the
// pointer must keep, so RichTooltip uses a popover rather than the
// pointer-through tooltip base.
Action *RichTooltipAction
// Label names the tooltip for assistive technology; the title when empty.
Label string
// Width fixes the panel's width in DIP; 320 when zero or invalid.
Width float32
// Delay is how long the pointer rests on the anchor before the tooltip
// shows; 600ms when zero, and a negative delay shows it at once.
Delay time.Duration
// Description, when set, describes the anchor to assistive technology.
Description string
}
RichTooltipOptions configures RichTooltip.
type RouterViewOptions ¶ added in v0.2.0
type RouterViewOptions struct {
// Transition temporarily overrides r.Transition while this RouterView builds
// and is restored before RouterView returns. Under ReduceMotion,
// ui.TransitionNone is always used. MyGo may still finish a transition
// that began before ReduceMotion was enabled.
Transition *ui.Transition
// Animation temporarily overrides r.Animation while this RouterView builds
// and is restored before RouterView returns.
Animation *ui.Animation
}
RouterViewOptions configures RouterView. Nil fields preserve the Router's own Transition and Animation values.
type SearchAppBarOptions ¶
type SearchAppBarOptions struct {
// Placeholder shows while the query is empty and names the field when no
// Label overrides it.
Placeholder string
// Label overrides the accessible name of the text field.
Label string
// LeadingIcon draws the leading button's icon; mdicon.Search when nil.
LeadingIcon IconDraw
// LeadingLabel names the leading button; "Search" when empty.
LeadingLabel string
// OnLeading runs when the leading button is pressed. Without it the
// leading icon is decorative.
OnLeading func()
// Trailing are extra trailing action buttons.
Trailing []AppBarAction
// AutoFocus focuses the field as it appears.
AutoFocus bool
// Disabled disables the bar and its field.
Disabled bool
// OnChanged runs with the query whenever the user edits it.
OnChanged func(query string)
// OnSubmitted runs with the query when Enter submits it.
OnSubmitted func(query string)
}
SearchAppBarOptions configures SearchAppBar. The zero value is an enabled bar with a leading search icon and a "Search" placeholder.
type SearchOptions ¶ added in v0.2.0
type SearchOptions struct {
// Label names the search input for assistive technology. When empty, Label
// falls back to Placeholder or "Search" (unless named by an enclosing
// FormField).
Label string
// Placeholder shows while the query is empty. Every build writes the
// resolved placeholder unconditionally so dynamic clears never leave a stale
// hint behind.
Placeholder string
// ShortcutHint renders an optional compact keyboard hint badge (such as
// "⌘K" or "/") at the trailing edge while the query is empty.
ShortcutHint string
// ShortcutChord optionally renders a platform-aware non-interactive Kbd cap
// at the trailing edge while the query is empty and ShortcutHint is empty.
ShortcutChord KeyChord
// Suggestions lists candidate queries ranked prefix-first as the user types
// or presses Down.
Suggestions []string
// Disabled disables editing, suggestion popups, and the clear action using
// MD3E's 38% disabled content opacity.
Disabled bool
// OnChanged runs once per user edit, clear, Escape clear, or suggestion pick
// with the updated query string.
OnChanged func(string)
// OnSubmit runs once when Enter submits the current query without picking a
// highlighted suggestion.
OnSubmit func(string)
}
SearchOptions configures SearchField and SearchBar. The zero value creates an enabled search input with a magnifying glass icon and a "Search" placeholder.
type SelectChoice ¶ added in v0.2.0
type SelectChoice[T comparable] struct { // Value is the comparable option value written into *value when chosen. // Each choice in a Select must have a unique Value. Value T // Label is the visible option text, accessible name, and type-ahead target. Label string // Group optionally places a non-selectable section header above contiguous // choices sharing the same Group string. Group headers do not occupy option // indices. Group string // Icon draws an optional 18 DIP icon before the choice label. Icon IconDraw // Disabled excludes this option from pointer selection, arrow navigation, // and type-ahead matching while keeping it visible. Disabled bool }
SelectChoice describes one selectable option in Select.
type SelectOptions ¶ added in v0.2.0
type SelectOptions[T comparable] struct { // Label names the select trigger and renders a compact caption inside it. // Leave empty when wrapped by FormField so FormField supplies the accessible // label. Label string // Variant selects TextFieldFilled (default) or TextFieldOutlined styling. Variant TextFieldVariant // Open optionally binds the popup open state to a caller-owned *bool via // ui.SelectBaseOpen; nil uses ui.SelectBase's local open state. Open *bool // Disabled disables the trigger, closes any open popup, and prevents both // pointer and keyboard changes. Disabled bool // OnChanged runs once when the user chooses a new value. OnChanged func(T) }
SelectOptions configures Select. The zero value creates an enabled, filled select using local open state.
type SemanticTone ¶
type SemanticTone int
SemanticTone selects a harmonized MD3E semantic color role used by Tag, StatusPill, Avatar, and Banner.
const ( // ToneNeutral uses tonal surface colors (SurfaceContainerHighest / OnSurfaceVariant). ToneNeutral SemanticTone = iota // TonePrimary uses PrimaryContainer / OnPrimaryContainer. TonePrimary // ToneSecondary uses SecondaryContainer / OnSecondaryContainer. ToneSecondary // ToneTertiary uses TertiaryContainer / OnTertiaryContainer. ToneTertiary // ToneError uses ErrorContainer / OnErrorContainer. ToneError // ToneWarning uses an HCT-derived amber tonal pair adapted to Light/Dark/Contrast. ToneWarning // ToneSuccess uses an HCT-derived emerald tonal pair adapted to Light/Dark/Contrast. ToneSuccess )
type SettingsGroupOptions ¶ added in v0.2.0
type SettingsGroupOptions struct {
Description string
}
SettingsGroupOptions configures SettingsGroup.
type ShapeButtonOptions ¶
type ShapeButtonOptions struct {
// Variant selects the MD3E color role treatment (default ShapeButtonFilled).
Variant ShapeButtonVariant
// Size selects the XS..XL tier scaled by Theme.Density.ButtonSpec. An
// out-of-range tier falls back to tokens.SizeXS.
Size tokens.SizeTier
// Width optionally overrides the container width in DIP. Defaults to the
// density-scaled tier height (square bounding box).
Width float32
// Height optionally overrides the container height in DIP. Defaults to the
// density-scaled tier height.
Height float32
// IconSize optionally overrides the centered icon size in DIP. Defaults to
// the density-scaled tier icon size.
IconSize float32
// Shape is the resting polygon outline (for example shape.Cookie9Sided(),
// shape.SoftBurst(), shape.Sunny(), or shape.Circle()). Defaults to
// shape.Circle() when nil.
Shape *shape.RoundedPolygon
// PressedShape is the polygon morphed toward while pressed. When nil, a
// custom Shape morphs toward shape.Circle() (a softer pressed silhouette),
// and a nil/default circular Shape morphs toward shape.Square().
PressedShape *shape.RoundedPolygon
// Selected activates the controlled selected visual state, morphing from
// Shape toward SelectedShape and cross-fading to SelectedIcon when set.
Selected bool
// SelectedShape is the polygon morphed toward when Selected is true.
// Defaults to shape.Square() when nil.
SelectedShape *shape.RoundedPolygon
// SelectedIcon optionally cross-fades and scales in when Selected is true.
SelectedIcon IconDraw
// Spring selects the MD3E spring token driving shape morphs. Zero value
// uses motion.FastSpatial.
Spring motion.Token
// ContainerColor optionally overrides the container fill color when enabled.
ContainerColor ui.Color
// ContentColor optionally overrides the icon ink color when enabled.
ContentColor ui.Color
// BorderColor optionally overrides the Outlined stroke color when enabled.
BorderColor ui.Color
// OnClick runs when the button is clicked or activated via Enter or Space.
OnClick func()
// Disabled disables interaction and applies MD3E disabled color tokens
// without ui's automatic opacity dimming.
Disabled bool
}
ShapeButtonOptions configures ShapeButton. The zero value is a filled, SizeXS, circular polygon button that morphs toward a rounded square while pressed.
type ShapeButtonVariant ¶
type ShapeButtonVariant int
ShapeButtonVariant selects the Material Design 3 Expressive color treatment of ShapeButton and MorphIconButton. The zero value, ShapeButtonFilled, fills the polygon with Primary (or SurfaceContainerHighest when unselected on a MorphIconButton).
const ( // ShapeButtonFilled paints Primary with OnPrimary content (or // SurfaceContainerHighest with OnSurfaceVariant when unselected on a // MorphIconButton). ShapeButtonFilled ShapeButtonVariant = iota // ShapeButtonTonal paints SecondaryContainer with OnSecondaryContainer // content (or SurfaceContainerHighest when unselected on a MorphIconButton). ShapeButtonTonal // ShapeButtonOutlined draws an Outline stroke around the polygon; a // selected MorphIconButton switches to InverseSurface / InverseOnSurface. ShapeButtonOutlined // ShapeButtonStandard draws no resting fill, revealing the morphed polygon // through the MD3E StateLayer and Ripple; a selected MorphIconButton tints // its icon Primary. ShapeButtonStandard )
type ShapeScale ¶
type ShapeScale struct {
None float32
ExtraSmall float32
Small float32
Medium float32
Large float32
LargeIncreased float32
ExtraLarge float32
ExtraLargeIncreased float32
ExtraExtraLarge float32
Full float32
}
ShapeScale holds corner radius values in DIPs keyed to MD3E shape tokens.
func DefaultShapeScale ¶
func DefaultShapeScale() ShapeScale
DefaultShapeScale returns the standard MD3E shape scale radius values.
func (ShapeScale) Radius ¶
func (s ShapeScale) Radius(scale tokens.ShapeScale) float32
Radius returns the radius in DIPs configured for scale. Fields left at zero fall back to the standard MD3E radius for their own scale, so a partial ShapeScale customizes just the steps it sets.
type ShellLayout ¶ added in v0.2.0
type ShellLayout uint8
ShellLayout selects the high-level chrome arrangement of AppShell on Medium and Expanded viewports.
const ( // TopBarAcross spans the TitleBar across the full window width at the top, // with Navigation and Content arranged below it. TopBarAcross ShellLayout = iota // SidebarToTop spans the Navigation sidebar to the top edge of the window // (automatically reserving c.TitleBar() physical start safe insets when // native caption buttons overlap), with TitleBar above the Content column. SidebarToTop )
type SideSheetMode ¶ added in v0.2.0
type SideSheetMode uint8
SideSheetMode selects whether SideSheet docks inline beside main content or floats over a modal scrim.
const ( // SideSheetStandard lays out the detail sheet inline at the trailing edge // using ui.Split (with SplitSecond and SplitLimits) when enough horizontal // room is available, automatically downgrading to SideSheetModal when the // available width falls below ContentMin + seam + MinWidth. SideSheetStandard SideSheetMode = iota // SideSheetModal always presents the detail sheet in a modal ui.Overlay // sliding from the trailing edge over a scrim. SideSheetModal )
type SideSheetOptions ¶ added in v0.2.0
type SideSheetOptions struct {
// Mode chooses between inline resizable Standard docking and Modal overlay
// presentation.
Mode SideSheetMode
// Label names the side sheet region or modal dialog for assistive
// technology; "Details" when empty.
Label string
// Width optionally binds the sheet width in DIP. When nil, SideSheet keeps
// a local width initialized to 320 DIP. When downgraded to SideSheetModal,
// *Width is preserved untouched so widening the window restores it.
Width *float32
// ContentMin sets the minimum width in DIP for the main content pane when
// docked inline in SideSheetStandard.
ContentMin float32
// MinWidth sets the minimum width in DIP for the side sheet pane.
MinWidth float32
// MaxWidth sets the maximum width in DIP for the side sheet pane.
MaxWidth float32
// Header builds an optional sticky header pinned at the top of the side
// sheet above the detail body. Both SideSheetStandard and SideSheetModal
// keep Header non-scrolling and full-width.
Header func()
// sheet below the detail body. Both SideSheetStandard and SideSheetModal
// keep Footer non-scrolling and full-width.
Footer func()
// DisableScroll omits the built-in ui.Scroll wrapper around detail and hosts
// detail inside a flexible growing column (Grow(1).FillWidth().MinWidth(0).MinHeight(0))
// so callers can mount their own VirtualList, DataTable, or independent scroller.
DisableScroll bool
// DisablePadding omits the default 16 DIP padding and 12 DIP gap around
// detail so callers can build edge-to-edge scrolling panels or apply custom insets.
DisablePadding bool
}
SideSheetOptions configures SideSheet. The zero value selects SideSheetStandard with a remembered 320 DIP local width and auto-downgrades to modal below 600 DIP (or below ContentMin + 4 + MinWidth when limits are specified).
type SidebarOptions ¶ added in v0.2.0
type SidebarOptions struct {
// Label names the navigation landmark for assistive technology; "Navigation"
// when empty.
Label string
// Expanded controls whether the sidebar renders as a full labeled tree (true)
// or collapses into an icon-only rail (false). When nil, local state
// initialized to true is used.
Expanded *bool
// Header builds an optional top-pinned slot above the scrollable groups in
// desktop/expanded Tree and icon-only Rail projections. It is intentionally
// omitted in the Compact bottom-bar projection.
Header func()
// desktop/expanded Tree and icon-only Rail projections. It is intentionally
// omitted in the Compact bottom-bar projection.
Footer func()
// OnSelected runs after the user chooses a new destination ID.
OnSelected func(id string)
// IconOnlyWidth sets the collapsed icon-only rail width in DIP (clamped to
// 56..64 DIP). Zero uses the Density default (56 Desktop/Compact, 64
// Comfortable).
IconOnlyWidth float32
// IndicatorMotion optionally overrides the leading/trailing springs of the
// elastic Primary accent bar. Zero value inherits Theme.IndicatorMotion
// (default motion.DefaultSpatial leading + motion.SlowSpatial trailing).
IndicatorMotion ElasticIndicatorMotion
}
SidebarOptions configures NavigationSidebar.
type SkeletonOptions ¶
type SkeletonOptions struct {
// Shape selects SkeletonRect (default), SkeletonCircle, or SkeletonPill.
Shape SkeletonShape
// Width sets a fixed width in DIP. Zero fills available width (except
// SkeletonCircle, where width defaults to Height).
Width float32
// Height sets the block (or single-line) height in DIP. Defaults to 16 DIP
// (or 40 DIP for SkeletonCircle).
Height float32
// Radius overrides the corner radius in DIP when positive and finite.
Radius float32
// Lines > 1 renders a vertical stack of text placeholder lines whose final
// line is shortened to 65% width for natural paragraph rhythm.
Lines int
// LineGap sets the vertical spacing between Lines in DIP (default 8 DIP).
LineGap float32
// Static disables the tonal pulse animation, asking for zero animation frames.
Static bool
// Label optionally names the loading placeholder for assistive technology.
Label string
}
SkeletonOptions configures Skeleton. The zero value is a full-width, 16 DIP tall rounded-rectangle skeleton with a subtle tonal pulse.
type SkeletonShape ¶
type SkeletonShape int
SkeletonShape selects the geometry preset of Skeleton.
const ( // SkeletonRect draws a rounded-rectangle placeholder block (default). SkeletonRect SkeletonShape = iota // SkeletonCircle draws a circular placeholder (for avatars and icon buttons). SkeletonCircle // SkeletonPill draws a full pill-rounded placeholder (for chips and buttons). SkeletonPill )
type SliderOptions ¶
type SliderOptions struct {
// Label names the slider for assistive technology.
Label string
// Disabled disables the slider: it ignores the pointer, the keys and
// focus, and uses MD3E's disabled colors without ui's dimming.
Disabled bool
// Step snaps the value to lo and its multiples, draws a stop dot at each,
// and moves it by one step per arrow key. Zero keeps the value continuous.
Step float64
// Centered fills the active track from the range's middle to the handle
// rather than from its low end, as a gain or balance slider.
Centered bool
// TrackHeight overrides the 16 DIP track height; it is clamped to the
// slider's 48 DIP row.
TrackHeight float32
// ThumbHeight overrides the 44 DIP capsule handle height.
ThumbHeight float32
// FormatLabel formats the value shown in the indicator above the handle.
// The default writes the step's decimals, two for a continuous slider.
FormatLabel func(float64) string
}
SliderOptions configures Slider. The zero value is an enabled, continuous, uncentered slider with a 16 DIP track and value indicator.
type SnackbarOptions ¶
type SnackbarOptions struct {
// Message is the snackbar's text, which also names it for assistive
// technology.
Message string
// ActionLabel adds a high-contrast text button at the end; OnAction runs
// when it is chosen, and the snackbar closes.
ActionLabel string
// OnAction runs when the action button is pressed.
OnAction func()
// ShowClose adds a close button beside the message.
ShowClose bool
// DoubleLine puts the message above the actions instead of beside them,
// for a longer message.
DoubleLine bool
// Duration is how long the snackbar stays before it goes by itself; 4
// seconds when zero or negative. Hovering or focusing it pauses the
// countdown.
Duration time.Duration
}
SnackbarOptions is one message of a SnackbarState queue.
type SnackbarState ¶
type SnackbarState struct {
// contains filtered or unexported fields
}
SnackbarState is a single-queue Material Design 3 snackbar controller. Show enqueues messages; the one showing stays until its action, its close button, its timeout, or a swipe to either side, then the next follows in order. The SnackbarHost that draws it reads this state, and its countdown follows the frame clock, which ui.NewTester.Advance drives.
func (*SnackbarState) Show ¶
func (s *SnackbarState) Show(o SnackbarOptions)
Show enqueues a snackbar. With none showing it starts at once; otherwise it waits its turn behind the ones already queued:
app.snack.Show(md3e.SnackbarOptions{Message: "Note deleted", ActionLabel: "Undo", OnAction: app.undo})
type SplitButtonOptions ¶
type SplitButtonOptions struct {
// Variant selects the look: Filled, Tonal, Elevated or Outlined. The text
// variant has no container to split, and falls back to Outlined.
Variant ButtonVariant
// Size selects the XS..XL tier.
Size tokens.SizeTier
// Disabled disables the whole control, the arrow included.
Disabled bool
// ActionDisabled disables the leading action alone, leaving the menu.
ActionDisabled bool
// LeadingIcon draws an icon before the action's label, at the tier's
// icon size.
LeadingIcon IconDraw
// ArrowLabel names the menu trigger for assistive technology; "More
// options" when empty.
ArrowLabel string
// Open lets the caller own the menu's expanded state, as when the app opens
// it from elsewhere; nil keeps the state in the control.
Open *bool
// Menu builds the menu's content in panel whenever the menu shows. Without
// one the arrow has nothing to open.
Menu func(panel ui.Element)
}
SplitButtonOptions configures SplitButton. The zero value is a filled, extra small split button that is enabled.
type StateLayerOptions ¶
type StateLayerOptions struct {
// Color is the overlay tint color (typically the component's ContentColor or
// OnSurface). Defaults to CurrentTheme(c).Colors.OnSurface when zero.
Color ui.Color
// Radii sets independent [TL, TR, BR, BL] corner radii in DIPs for clipping.
Radii [4]float32
HasRadii bool
// Radius sets a uniform corner radius when Radii is unset.
Radius float32
// Clip confines the state layer and ripple to a box and corner radii it
// computes from the element's own painted window-space rectangle r, returning
// (box, radii) in the same window coordinates (e.g. a navigation destination's
// indicator pill inside its full-cell button). Nil paints over the whole box.
Clip func(r ui.Rect) (box ui.Rect, radii [4]float32)
// Shape optionally clips the state layer and ripple to a custom polygon.
Shape *shape.RoundedPolygon
// ClipPath optionally returns a dynamic *ui.Path (such as a live shape.Morph
// outline) in window coordinates for clipping the state layer and ripple.
// When set, ClipPath takes precedence over Shape and Radii.
ClipPath func(r ui.Rect) *ui.Path
// BorderInset shrinks the clip box inward by BorderInset DIPs (e.g., stroke width).
BorderInset float32
// FocusRing selects how the keyboard focus outline is rendered when
// el.FocusVisible() is true (defaults to FocusRingAuto).
FocusRing FocusRingStyle
// FocusHaloColor optionally paints a backing contrast halo beneath the outer
// focus ring (for example cs.Surface around photo-backed interactive surfaces).
FocusHaloColor ui.Color
// Dragged activates the MD3E Dragged state layer opacity (0.16).
Dragged bool
// DisableRipple disables expanding circular ripple waves while retaining StateLayer.
DisableRipple bool
// Disabled suppresses hover, focus, and ripple feedback.
Disabled bool
}
StateLayerOptions configures MD3E StateLayer and ExpressiveRipple rendering.
type StatusBarOptions ¶ added in v0.2.0
type StatusBarOptions struct {
// Label names the status bar landmark for assistive technology; "Status bar"
// when empty.
Label string
// Trailing builds optional right-aligned status items (RTL-mirrored).
Trailing func()
}
StatusBarOptions configures StatusBar.
type StatusPillOptions ¶
type StatusPillOptions struct {
// Tone selects the semantic color role (Neutral, Primary, Secondary,
// Tertiary, Error, Warning, Success).
Tone SemanticTone
// Pulsing enables a gentle breathing halo around the status dot. The pulse
// runs strictly inside Draw via p.AnimationFrame(), pauses automatically
// when scrolled off-screen (p.Visible()), respects ReduceMotion, and is
// ghost-draw safe.
Pulsing bool
// Outlined draws a 1 DIP semantic border on a transparent background
// instead of a tonal pill fill.
Outlined bool
// DotColor optionally overrides the indicator dot color.
DotColor ui.Color
// Label overrides the accessible status name (defaults to text).
Label string
}
StatusPillOptions configures StatusPill.
type StepperOptions ¶ added in v0.2.0
type StepperOptions struct {
// Label names the stepper for assistive technology; falls back to FormField
// label when empty inside FormField.
Label string
// ShowValue displays the formatted tabular readout between the decrement and
// increment buttons.
ShowValue bool
// FormatValue customizes how the displayed value (and accessible Value) is
// formatted when non-nil.
FormatValue func(float64) string
// Disabled disables interaction and applies MD3E disabled content opacity.
Disabled bool
// ReadOnly keeps the stepper focusable and readable while preventing changes.
ReadOnly bool
// OnChanged runs once whenever *value changes.
OnChanged func(float64)
}
StepperOptions configures a Material Design 3 Expressive Stepper. The zero value produces a density-aware segmented pill stepper with "-" and "+" buttons and RoleStepper keyboard/assistive-technology semantics.
type SupportingPaneOptions ¶
type SupportingPaneOptions struct {
// SplitPercent controls the main pane width percentage (0..100). When nil,
// local state initialized to DefaultMainPercent (70%) is used.
SplitPercent *float32
// DefaultMainPercent is the initial and double-click reset percentage for
// the main pane (default 70; clamped to 20..85).
DefaultMainPercent float32
// ShowSupporting controls supporting pane visibility. When nil, defaults to
// visible in WindowExpanded and hidden in WindowCompact/WindowMedium. When
// non-nil, *ShowSupporting explicitly toggles visibility (under WindowCompact,
// true switches the single pane to supporting).
ShowSupporting *bool
// WidthOverride overrides c.Size()'s width when resolving WindowSizeClass.
WidthOverride float32
// Label optionally names the supporting-pane region for assistive technology.
Label string
}
SupportingPaneOptions configures SupportingPane.
type SurfaceOptions ¶
type SurfaceOptions struct {
// Elevation selects the MD3E tonal surface tier and Key/Ambient drop shadows.
Elevation tokens.ElevationLevel
// TonalElevation optionally overrides the tonal elevation step used when
// Color is unset (or mixed via SurfaceTint when TonalTint is true). A
// non-zero value may raise or lower the tone independently of Elevation's
// shadows.
TonalElevation tokens.ElevationLevel
// TonalTint mixes SurfaceTint onto an explicit Color using the active elevation's TintRatio.
TonalTint bool
// Color overrides the background fill. When zero, the tonal surface color for
// TonalElevation (or Elevation) is resolved from CurrentTheme(c).
Color ui.Color
// ContentColor overrides the foreground TextColor inherited by child elements.
// When zero, Theme.ContentColorFor(bg) picks the accessible On* role.
ContentColor ui.Color
// BorderWidth draws an outline border in DIPs around the surface.
BorderWidth float32
// BorderColor overrides the outline color (defaults to Theme.Colors.OutlineVariant).
BorderColor ui.Color
// Hairline draws a subtle 1 DIP tonal highlight border when BorderWidth <= 0,
// adapting to light, dark, and high-contrast themes for crisp surface separation.
Hairline bool
// HairlineColor overrides the default Hairline stroke color when A > 0.
HairlineColor ui.Color
// Optional gradient fills applied over the surface container. When both are
// supplied, LinearGradient paints first and RadialGradient overlays it.
LinearGradient *ui.LinearGradient
RadialGradient *ui.RadialGradient
// Backdrop optionally paints custom decorative graphics (such as Hero card
// organic waves or clipped geometric patterns) inside the surface bounds
// after the fill/gradient and before children. The callback must be pure
// and must not request animation frames or query element state so exit
// transitions remain ghost-draw safe.
Backdrop func(p *ui.Painter, r ui.Rect)
// Shape selection priority: Shape polygon > Radii [4] > Radius > ShapeScale.
ShapeScale tokens.ShapeScale
Radius float32
HasRadius bool
Radii [4]float32
HasRadii bool
Shape *shape.RoundedPolygon
// Typography inheritance (optional): applies TypeRole onto the surface box.
TypeRole tokens.TypeRole
HasTypeRole bool
TypeEmphasized bool
// RTL-aware logical padding and margins in DIPs.
PaddingStart float32
PaddingEnd float32
PaddingTop float32
PaddingBottom float32
MarginStart float32
MarginEnd float32
MarginTop float32
MarginBottom float32
// Clip enforces child clipping inside the surface corners.
Clip bool
// DisableShadow suppresses Key/Ambient drop shadows while keeping tonal fill.
DisableShadow bool
}
SurfaceOptions configures a Material Design 3 Expressive Surface container.
type SwitchCardOptions ¶
type SwitchCardOptions struct {
// Subtitle displays muted secondary copy beneath the title.
Subtitle string
// Leading renders a custom leading widget (such as Avatar or custom IconBadge).
// Takes precedence over LeadingIcon when non-nil.
Leading func()
// LeadingIcon renders a leading IconBadge when Leading is nil.
LeadingIcon IconDraw
// IconBadge customizes the IconBadge generated for LeadingIcon.
IconBadge IconBadgeOptions
// OnIcon overrides the Switch's selected thumb icon.
OnIcon IconDraw
// OffIcon sets an optional Switch unselected thumb icon.
OffIcon IconDraw
// Variant selects the card container style (default CardFilled / SurfaceContainerLow).
Variant CardVariant
// HasVariant explicitly selects CardElevated (zero value) vs the SwitchCard
// default tonal SurfaceContainerLow look.
HasVariant bool
// Hairline draws a subtle 1 DIP tonal border around the card.
Hairline bool
// ShapeScale selects an MD3E corner radius token (default ShapeLarge).
ShapeScale tokens.ShapeScale
// Radius overrides the corner radius in DIP when positive and finite.
Radius float32
// OnChanged runs after clicking the card row, clicking the switch, or
// pressing Space while the switch has keyboard focus.
OnChanged func(on bool)
// Label overrides the switch's accessible name (defaults to title).
Label string
// Disabled disables both the card row and the embedded Switch.
Disabled bool
}
SwitchCardOptions configures SwitchCard, a one-row card-style quick toggle combining an optional leading icon badge, title/subtitle, and trailing MD3E Switch with isolated key ownership.
type SwitchOptions ¶
type SwitchOptions struct {
// Label is the visible text after the track, and names the switch for
// assistive technology. An empty label draws the track alone.
Label string
// Disabled disables the switch: it ignores the pointer, the keyboard and
// focus, and uses MD3E's disabled colors without ui's automatic dimming.
Disabled bool
// OffIcon draws in the off handle, beside the track's outline, as a close
// mark. A nil OffIcon keeps the bare 16 DIP handle; an icon makes the off
// handle 24 DIP, as MD3E has it.
OffIcon IconDraw
// OnIcon replaces the mdicon.Check of the selected handle.
OnIcon IconDraw
}
SwitchOptions configures Switch. The zero value is an enabled switch with an mdicon.Check in its selected handle and no visible label.
type TabItem ¶
type TabItem struct {
// Key optionally identifies the tab across dynamic reordering or edits.
Key any
// Label is the visible text and the accessible name.
Label string
// Icon draws an optional leading icon.
Icon IconDraw
// Badge optionally displays a compact count or short text badge beside the
// label (rendered by PillTabs and SegmentedTabs).
Badge string
// BadgeDot optionally shows a 6 DIP indicator dot when Badge is empty
// (rendered by PillTabs and SegmentedTabs).
BadgeDot bool
// Disabled disables this tab alone: the pointer and the arrows, Home and
// End pass over it.
Disabled bool
}
TabItem is one tab of PrimaryTabs, SecondaryTabs, PillTabs, or SegmentedTabs.
type TabStripOptions ¶ added in v0.2.0
type TabStripOptions struct {
// Label names the tab strip for assistive technology; "Open documents" when
// empty.
Label string
// OnSelect runs after the user selects a different tab ID.
OnSelect func(id string)
// OnRequestClose runs when the user requests closing a tab (inline close
// button, middle click, or context menu). The application owns tabs and
// handles dirty confirmation before removing the tab.
OnRequestClose func(id string)
// OnNew runs when the user clicks the fixed trailing New Tab button. When nil,
// no New Tab button is shown.
OnNew func()
// OnPin runs when the user toggles Pin/Unpin in a tab's context menu.
OnPin func(id string, pinned bool)
// OnMove runs when a tab is dragged and dropped onto another tab or the
// partition end. beforeID == "" denotes the end of that partition (pinned or
// unpinned). Non-pinned tabs cannot be moved into the pinned partition.
OnMove func(id, beforeID string)
// OnDetach runs when a dragged tab is released outside the window bounds,
// passing the release point in content DIP coordinates.
OnDetach func(id string, at ui.Point)
}
TabStripOptions configures TabStrip.
type TabsOptions ¶
type TabsOptions struct {
// Selected points to the chosen tab; nil keeps the selection in the tab
// bar's local state. The bar writes clicks and the keys into it as it
// builds.
Selected *int
// Changed runs after a click or key chooses another tab.
Changed func(i int)
// Scrollable lays the tabs out at their natural widths in a horizontal
// scroller, scrolling the chosen tab into view as the selection moves,
// instead of sharing the width equally.
Scrollable bool
// Label names the tab list for assistive technology; "Tabs" when empty.
Label string
// Disabled disables every tab.
Disabled bool
// IndicatorMotion optionally overrides the leading/trailing springs of the
// elastic underline indicator. Zero value inherits Theme.IndicatorMotion
// (default motion.DefaultSpatial leading + motion.SlowSpatial trailing).
IndicatorMotion ElasticIndicatorMotion
}
TabsOptions configures PrimaryTabs and SecondaryTabs. The zero value is a fixed, enabled tab bar that keeps its own selection.
type TagOptions ¶
type TagOptions struct {
// Variant selects TagTonal (default) or TagOutlined.
Variant TagVariant
// Tone selects the semantic color role (Neutral, Primary, Secondary,
// Tertiary, Error, Warning, Success).
Tone SemanticTone
// LeadingIcon draws an optional 14 DIP icon before the label.
LeadingIcon IconDraw
// OnClick makes the tag interactive and invokes OnClick on click/Enter/Space.
OnClick func()
// OnClose adds a trailing dismiss button invoking OnClose.
OnClose func()
// CloseLabel overrides the close button's accessible name ("Remove <text>").
CloseLabel string
// Label overrides the tag's accessible name.
Label string
// Disabled disables interaction and applies MD3E disabled color tokens.
Disabled bool
}
TagOptions configures Tag. The zero value is a compact, non-interactive neutral tonal tag.
type TagVariant ¶
type TagVariant int
TagVariant selects the container treatment of Tag.
const ( // TagTonal fills a compact tonal container (default). TagTonal TagVariant = iota // TagOutlined draws a crisp 1 DIP border around a transparent container. TagOutlined )
type TextFieldOptions ¶
type TextFieldOptions struct {
// Variant selects the filled or outlined look.
Variant TextFieldVariant
// Label floats from the content area to the top of the field when the
// field is focused, holds text, or an input method composes, and names the
// field for assistive technology.
Label string
// Placeholder shows in the input while the label floats and the value is
// empty. Without a Label it also names the field.
Placeholder string
// LeadingIcon draws a 24 DIP decorative icon before the text.
LeadingIcon IconDraw
// TrailingIcon draws a 24 DIP icon after the text. With OnTrailing set it
// becomes an interactive button, as a password visibility toggle or a
// clear action.
TrailingIcon IconDraw
// TrailingLabel names the interactive trailing button for assistive
// technology; "Action" by default.
TrailingLabel string
// OnTrailing runs when the interactive trailing button is clicked.
OnTrailing func()
// Prefix shows before the text while the field is focused or holds text.
Prefix string
// Suffix shows after the text while the field is focused or holds text.
Suffix string
// SupportingText shows below the field and describes it to assistive
// technology.
SupportingText string
// MaxLength limits the text, in UTF-16 code units as ui's inputs count it.
MaxLength int
// CharacterCounter shows the length below the field, as "12/50" when
// MaxLength is set.
CharacterCounter bool
// Error marks the value invalid, paints the error palette and sets
// aria-invalid on the input.
Error bool
// ErrorMessage tells assistive technology why the value is invalid, as
// aria-errormessage, and shows in place of the supporting text.
ErrorMessage string
// ReadOnly lets the text be read and selected but not changed.
ReadOnly bool
// Password hides the text of a single-line field; a text area shows it.
Password bool
// Disabled disables the field with MD3E's disabled colors, without ui's
// automatic dimming.
Disabled bool
// Height overrides the text area's 120 DIP height. TextField ignores it.
Height float32
// OnChanged runs with the value whenever the user edits it.
OnChanged func(string)
// OnSubmitted runs with the value when Enter submits a single-line field.
OnSubmitted func(string)
}
TextFieldOptions configures TextField and TextArea. The zero value is an enabled, filled, single-line field with no label or icons.
type TextFieldVariant ¶
type TextFieldVariant int
TextFieldVariant selects the Material Design 3 Expressive text field look.
const ( // TextFieldFilled fills the container with SurfaceContainerHighest, rounds // its top corners and draws the bottom indicator line. TextFieldFilled TextFieldVariant = iota // TextFieldOutlined draws a full border around a transparent container, // with a notch in the top edge while the label floats. TextFieldOutlined )
type TextOptions ¶
type TextOptions struct {
// Role selects the MD3E typography scale role.
Role tokens.TypeRole
// Emphasized switches to the emphasized weight variant of Role.
Emphasized bool
// MaxLines limits the text to at most n lines with ellipsis when positive.
MaxLines int
// Truncate chooses end, middle, or start ellipsis placement. Setting
// TruncateMiddle or TruncateStart without MaxLines applies single-line
// truncation automatically.
Truncate TruncateMode
// Mono switches the text to CurrentTheme(c).MonoFont when configured, or
// the system "monospace" font family otherwise.
Mono bool
// TabularNums enables OpenType tabular lining figures ("tnum") so digits
// share uniform width across live counters, tables, and metrics.
TabularNums bool
// Color overrides the foreground text color when non-transparent (A > 0).
Color ui.Color
}
TextOptions configures TextWith. When TextWith is called without options, tokens.BodyMedium is used. When a TextOptions value is passed, Role selects the MD3E type scale role (note: the zero value of tokens.TypeRole is tokens.DisplayLarge; out-of-range roles fall back to tokens.BodyMedium).
type Theme ¶
type Theme struct {
Dark bool
Colors tokens.ColorScheme
SurfaceStyle tokens.SurfaceStyle
Motion motion.Scheme
Density tokens.Density
Typography tokens.TypographyScale
Shapes ShapeScale
Contrast tokens.Contrast
TextScale float32
ReduceMotion bool
IndicatorMotion ElasticIndicatorMotion
Font string
MonoFont string
// Extended semantic status roles used by banners, badges, and ui.Theme bridging.
Warning ui.Color
OnWarning ui.Color
WarningContainer ui.Color
OnWarningContainer ui.Color
Success ui.Color
OnSuccess ui.Color
SuccessContainer ui.Color
OnSuccessContainer ui.Color
// contains filtered or unexported fields
}
Theme aggregates all Material Design 3 Expressive design tokens and runtime accessibility preferences needed to render and animate components cleanly.
func CurrentTheme ¶
CurrentTheme returns the active *Theme for c. Inside ThemeScope or an overlay (ui.Overlay, PopoverBase, DialogBase, MenuBase) launched from a ThemeScope, it retrieves that scope's resolved theme; if a nested ui.Themed overrides c.Theme(), it adapts automatically to Dark/Accent changes; otherwise it falls back to DefaultTheme(c).
func DefaultTheme ¶
DefaultTheme derives and caches the MD3E Theme matching c's Dark appearance and OS/window Preferences (Accent, HighContrast, TextScale, ReduceMotion). Passing nil returns a standard light baseline theme.
func LerpTheme ¶
LerpTheme interpolates between from and to at fraction t (clamped to [0, 1], with NaN treated as 0). All 49 ColorScheme roles and extended Warning/Success semantic roles are smoothly mixed while preserving usable foreground contrast and non-transparent colors across mid-transition luminance crossings. TextScale interpolates linearly, while discrete fields (Dark, SurfaceStyle, Motion, Density, Shapes, Typography, Contrast, ReduceMotion, Font, MonoFont) switch at t >= 0.5. Intermediate themes clear seed provenance so they never pollute schemeCache.
func ThemeFromColorScheme ¶ added in v0.2.0
func ThemeFromColorScheme(cs tokens.ColorScheme, opts ...ThemeOptions) *Theme
ThemeFromColorScheme constructs an MD3E Theme directly from an explicit tokens.ColorScheme without regenerating palette roles from a seed color. At most one ThemeOptions value may be passed; zero options yields a light theme with Expressive spring motion and standard contrast. If cs is the zero ColorScheme, it falls back to a default palette derived from DefaultSeedColor with opts; otherwise every color role in cs is preserved verbatim.
func ThemeFromSeed ¶
func ThemeFromSeed(seed ui.Color, opts ...ThemeOptions) *Theme
ThemeFromSeed derives an MD3E Theme from seed using Material HCT palettes. At most one ThemeOptions value may be passed; zero options yields a light TonalSpot theme using Expressive spring motion.
func (*Theme) Animation ¶
Animation resolves token against t.Motion while respecting t.ReduceMotion.
func (*Theme) Clone ¶
Clone returns a shallow value copy of t so callers can customize fields safely without mutating a shared or cached theme.
func (*Theme) ContentColorFor ¶
ContentColorFor returns the pairing On* foreground color for common theme background roles, falling back to high-contrast light/dark ink by luminance.
func (*Theme) EffectiveTextScale ¶
EffectiveTextScale returns a positive text scale multiplier (1.0 when unset).
func (*Theme) ToUITheme ¶
ToUITheme bridges t's Material Design 3 Expressive color roles, metrics, and accessibility settings onto a freshly allocated native *ui.Theme so built-in MyGo controls, text defaults, and overlays share a cohesive palette.
func (*Theme) WithPreferences ¶
func (t *Theme) WithPreferences(p ui.Preferences) *Theme
WithPreferences returns a resolved Theme incorporating desktop accessibility preferences (HighContrast, TextScale, ReduceMotion). If t was built via ThemeFromSeed and HighContrast is active, the color scheme is regenerated at tokens.ContrastHigh cleanly; manual themes strengthen outline visibility.
type ThemeOptions ¶
type ThemeOptions struct {
Dark bool
Variant tokens.Variant
Contrast tokens.Contrast
SurfaceStyle tokens.SurfaceStyle
Motion motion.Scheme
Density tokens.Density
Font string
MonoFont string
TextScale float32
ReduceMotion bool
IndicatorMotion ElasticIndicatorMotion
Shapes *ShapeScale
Typography *tokens.TypographyScale
// Optional overrides for extended semantic status roles. Fields with alpha
// > 0 override the default semantic palette matching Dark and Contrast.
Warning ui.Color
OnWarning ui.Color
WarningContainer ui.Color
OnWarningContainer ui.Color
Success ui.Color
OnSuccess ui.Color
SuccessContainer ui.Color
OnSuccessContainer ui.Color
}
ThemeOptions configures how ThemeFromSeed and ThemeFromColorScheme construct an MD3E theme.
type ThemeTransitionOptions ¶
type ThemeTransitionOptions struct {
// Token selects the MD3E effects spring driving the transition. The zero
// value defaults to motion.DefaultEffects (~230ms critically damped, zero
// overshoot); motion.FastEffects and motion.SlowEffects are also supported.
Token motion.Token
}
ThemeTransitionOptions configures how AnimatedThemeScope transitions between themes when color or appearance signatures change.
type TimePickerMode ¶
type TimePickerMode int
TimePickerMode selects the body of a TimePicker: a clock dial, or hour and minute fields with steppers.
const ( // TimePickerDial shows the Material clock dial, with the hours and minutes // above it and an AM/PM switch in a 12-hour cycle. TimePickerDial TimePickerMode = iota // TimePickerInput shows hour and minute text fields with steppers. TimePickerInput )
type TimePickerOptions ¶
type TimePickerOptions struct {
// Mode selects the initial body; the user can switch it with the header's
// mode button.
Mode TimePickerMode
// HourCycle is 12 for a 12-hour cycle with AM and PM, or 24 for a 24-hour
// one; any other value means 12.
HourCycle int
// Label names the picker for assistive technology.
Label string
// Disabled disables the whole picker: it takes no pointer or keyboard
// input and paints MD3E's disabled tokens.
Disabled bool
// OnChanged runs after the user picks a time.
OnChanged func()
}
TimePickerOptions configures TimePicker. The zero value is an enabled clock dial in a 12-hour cycle.
type ToastStackOptions ¶ added in v0.2.0
type ToastStackOptions struct {
// Corner sets the screen corner or edge anchor where notifications stack.
// When nil, ui.AnchorBottomEnd is used (following RTL layout direction).
// Explicit physical anchors such as ui.AnchorTopLeft or ui.AnchorBottomLeft
// stay pinned to that physical side even under RightToLeft.
Corner *ui.Anchor
// MaxWidth caps each toast card's width in DIP (default 360, further
// clamped to winW - 32 on narrow viewports).
MaxWidth float32
}
ToastStackOptions configures ToastStack.
type ToggleIconButtonOptions ¶
type ToggleIconButtonOptions struct {
// Variant selects the MD3E look.
Variant IconButtonVariant
// Size selects the XS..XL tier.
Size tokens.SizeTier
// Width selects Narrow, Default or Wide.
Width IconButtonWidth
// SelectedIcon draws in place of the icon while *on is true, as a filled
// star replacing an outline one.
SelectedIcon IconDraw
// Disabled disables the toggle and dims nothing.
Disabled bool
}
ToggleIconButtonOptions configures ToggleIconButton.
type TokenFieldOptions ¶ added in v0.2.0
TokenFieldOptions configures TokenField.
type ToolbarAction ¶ added in v0.2.0
type ToolbarAction struct {
// ID optionally gives the action a stable key across dynamic reorders.
ID string
// Label is the visible button text (and accessible name / overflow item label).
Label string
// Icon draws an optional leading icon inside the action button.
Icon IconDraw
// Disabled disables clicking, overflow execution, and keyboard focus for this action.
Disabled bool
// Run executes when the action is clicked, triggered from the keyboard, or chosen
// from the toolbar overflow menu.
Run func()
}
ToolbarAction describes a command button inside an ActionToolbar.
type ToolbarOptions ¶ added in v0.2.0
type ToolbarOptions struct {
// Label names the toolbar landmark for assistive technology; "Toolbar" when empty.
Label string
}
ToolbarOptions configures ActionToolbar.
type ToolbarOrientation ¶
type ToolbarOrientation int
ToolbarOrientation selects the axis of a FloatingToolbar.
const ( // ToolbarHorizontal lays the controls out in a 64 DIP high pill. ToolbarHorizontal ToolbarOrientation = iota // ToolbarVertical lays them out in a 64 DIP wide pill. ToolbarVertical )
type TopAppBarOptions ¶
type TopAppBarOptions struct {
// Variant selects the Small, CenterAligned, Medium or Large layout.
Variant TopAppBarVariant
NavigationIcon IconDraw
NavigationLabel string
OnNavigation func()
// Subtitle shows a supporting line under the title.
Subtitle string
// Actions are the trailing icon buttons.
Actions []AppBarAction
// Label overrides the accessible name of the bar; the title by default.
Label string
// ScrollProgress collapses Medium and Large bars as it goes from 0, fully
// expanded, to 1, the small 64 DIP bar with the Surface Container tone.
// Values outside 0..1 are clamped.
ScrollProgress float32
}
TopAppBarOptions configures TopAppBar. The zero value is a small, expanded bar with no navigation icon, subtitle or actions.
type TopAppBarVariant ¶
type TopAppBarVariant int
TopAppBarVariant selects one of the four Material Design 3 Expressive top app bar layouts.
const ( // TopAppBarSmall is the 64 DIP bar with a left-aligned title. TopAppBarSmall TopAppBarVariant = iota // TopAppBarCenterAligned is the 64 DIP bar with a centered title. TopAppBarCenterAligned // TopAppBarMedium expands to 112 DIP with a large title that collapses to // 64 DIP with ScrollProgress. TopAppBarMedium // TopAppBarLarge expands to 152 DIP with an even larger title that // collapses to 64 DIP with ScrollProgress. TopAppBarLarge )
type TransitionMode ¶
type TransitionMode int
TransitionMode selects the motion choreography used by PageTransition and AnimatedContent when switching between keyed pages.
const ( // TransitionFadeThrough is the default Material Design 3 Fade-Through // choreography: outgoing content fades out over 90ms Curve I before // incoming content enters sequentially over 180ms Curve O with a subtle // scale-up (0.98 -> 1) and fade, preventing overlapping text ghosting. TransitionFadeThrough TransitionMode = iota // (DefaultSpatial, 24 DIP default) pages along the vertical axis according // to Direction (suited for vertical NavigationRail page switching). TransitionSharedAxisY // (DefaultSpatial, 24 DIP default) pages along the horizontal axis according // to Direction, mirroring automatically in right-to-left layouts. TransitionSharedAxisX // TransitionNone swaps pages immediately with no transition animation. TransitionNone )
type TransitionOptions ¶
type TransitionOptions struct {
// Mode selects the transition pattern (default TransitionFadeThrough).
Mode TransitionMode
// Direction controls the axis sign for SharedAxis modes: > 0 moves forward
// (+1), < 0 moves backward (-1), and 0 auto-infers from ordered integer keys
// (defaulting to +1 for other key types). TransitionSharedAxisX mirrors
// automatically in right-to-left layouts.
Direction int
// Distance overrides the travel distance in DIP for SharedAxis modes
// (default 24 DIP) and optionally adds a vertical rise for
// TransitionFadeThrough (default 0 DIP). Non-positive or non-finite values
// use the mode default.
Distance float32
// Scale overrides the entering initial scale for TransitionFadeThrough
// (default 0.98). Values <= 0, >= 1, or non-finite use the default.
Scale float32
// AfterExits holds the incoming page unseen until the outgoing page finishes
// leaving for SharedAxis modes; TransitionFadeThrough always runs
// sequentially (90ms I exit followed by 180ms O enter) to avoid overlap.
AfterExits bool
}
TransitionOptions configures PageTransition and AnimatedContent. The zero value uses TransitionFadeThrough (sequential 90ms I exit + 180ms O scale 0.98 -> 1 enter) and forward direction (+1).
type TreeNode ¶
type TreeNode struct {
// Key uniquely identifies this node among its siblings and serves as the
// selection value when TreeViewOptions.Selected is used and SelectionID is
// nil. Comparable keys keep keyboard focus and local expansion state
// attached to the node across sibling expansions or insertions. When
// TreeViewOptions.Selected is used without SelectionID, Key must be unique
// across the entire tree (or include parent identity); for sibling-scoped
// duplicate leaf keys across branches, set SelectionID.
Key any
// SelectionID optionally provides a tree-unique comparable identifier for
// TreeViewOptions.Selected and OnSelect while keeping Key sibling-scoped.
// When nil, Key is used.
SelectionID any
// Label is the visible node label and accessible name.
Label string
// Icon draws an optional leading icon between the disclosure chevron and
// Label.
Icon IconDraw
// Badge displays an optional trailing count or short tag.
Badge string
// Open optionally controls whether a branch node is expanded. When nil and
// Children is non-empty, TreeView manages expansion state locally via
// ui.Local.
Open *bool
// Children lists nested nodes rendered beneath this branch while open.
Children []TreeNode
// Disabled disables interaction for this node and its subtree.
Disabled bool
// OnClick runs when the node row is activated via click, Enter, or Space
// (toggling the disclosure chevron alone does not invoke OnClick).
OnClick func()
}
TreeNode describes one node in a TreeView hierarchy.
type TreeViewOptions ¶
type TreeViewOptions struct {
// Selected optionally points to the currently selected node Key. Clicking a
// row with a non-nil Key updates *Selected before invoking OnSelect and
// TreeNode.OnClick.
Selected *any
// OnSelect runs when a row is activated via click, Enter, or Space, after
// *Selected (if non-nil) has been updated.
OnSelect func(key any)
// ShowIndentGuides draws subtle vertical OutlineVariant connector lines
// beneath open branches aligned with each parent's disclosure chevron.
ShowIndentGuides bool
// Label names the tree landmark for assistive technology ("Tree" when
// empty).
Label string
// Disabled disables interaction across the entire tree.
Disabled bool
}
TreeViewOptions configures TreeView. The zero value produces an enabled, density-aware MD3E tree without indent guide lines.
type TruncateMode ¶
type TruncateMode int
TruncateMode selects where the ellipsis appears when text is clipped to a maximum line count.
const ( // TruncateEnd places the ellipsis at the end of the clipped text (default). TruncateEnd TruncateMode = iota // TruncateMiddle keeps both the start and end of the clipped text, placing // the ellipsis in the middle of the last line (ideal for file paths/IDs). TruncateMiddle // TruncateStart keeps the end of the clipped text, placing the ellipsis at // the start of the last line. TruncateStart )
type TypeStyleMetrics ¶
type TypeStyleMetrics struct {
Size float32
LineHeight float32
Weight int
Tracking float32
Font string
}
TypeStyleMetrics holds resolved typographic measurements in DIPs after applying the active Theme scale and accessibility TextScale.
func TypeStyleOf ¶
TypeStyleOf resolves the MD3E TypeStyleMetrics for role (standard or emphasized) from CurrentTheme(c), scaled by the theme's EffectiveTextScale.
type VirtualListOptions ¶
type VirtualListOptions struct {
// State optionally provides a caller-owned ui.ListState for scroll control,
// sticky headers, multi-selection, and Move/Follow animations. When nil, an
// internal ui.ListState is managed automatically with ui.Local.
State *ui.ListState
// ItemKey maps a row index to a stable comparable key so selection and row
// state survive insertions, deletions, and sorting.
ItemKey func(row int) any
// Selected binds single-row selection (index or -1 for none).
Selected *int
// Selection binds multi-row selection (*ui.Selection[K]).
Selection ui.Selector
// RowLabel returns the accessible and type-select label for row.
RowLabel func(row int) string
// IsHeader reports whether row renders as a sticky section header.
IsHeader func(row int) bool
// Segmented draws rows as MD3E segmented card pieces: first row in a
// section rounds top corners (large), last rounds bottom corners (large),
// inner rows keep small corners, and selected rows round all four corners
// with SecondaryContainer fill.
Segmented bool
// RowHeight fixes the height of non-header rows in DIP when positive and
// finite. When <= 0 or non-finite, non-header rows use the active
// Theme.Density one-line height as a minimum and grow for taller content.
RowHeight float32
// Gap overrides the spacing between rows in DIP when positive and finite.
// When <= 0 or non-finite, defaults to 2 DIP for Segmented lists and 0
// otherwise.
Gap float32
// Padding adds inner inset padding around the virtual list content in DIP
// (sanitized to >= 0). Trailing padding always reserves extra clearance for
// the vertical scrollbar in both LTR and RTL layouts.
Padding float32
// Container wraps the list inside a SurfaceContainerLow rounded surface.
Container bool
// Hairline draws a subtle 1 DIP MD3E hairline border around the list
// container.
Hairline bool
// ShapeScale overrides the outer container corner token when Container or
// Hairline is enabled. Zero defaults to tokens.ShapeLarge.
ShapeScale tokens.ShapeScale
// OnClick runs when a non-header row is primary-clicked, after *Selected
// and Selection have been updated.
OnClick func(row int)
// OnSubmit runs when a row is submitted via double-click or Enter.
OnSubmit func(row int)
// Label names the list for assistive technology.
Label string
// Disabled disables list interaction and renders disabled MD3E content
// tokens.
Disabled bool
}
VirtualListOptions configures a Material Design 3 Expressive VirtualList. The zero value produces a density-aware virtualized list backed by ui.List with MD3E row heights, hover/press/ripple state layers, and scrollbar clearance.
type WindowController ¶
type WindowController interface {
Minimize()
ToggleMaximize()
Close()
IsMaximized() bool
SetAlwaysOnTop(v bool)
}
WindowController is the minimal native window interface satisfied directly by *mygo.Window without coupling package md3e to the platform window backend. When the bound window also implements the optional SetWindowButtonsTheme(mygo.ThemeSource) method (as *mygo.Window does), WindowTitleBar automatically syncs native system caption button appearance with the active light/dark theme whenever system buttons are visible.
type WindowSizeClass ¶
type WindowSizeClass int
WindowSizeClass classifies the available layout width into the three Material Design 3 Adaptive breakpoints.
const ( // WindowCompact covers narrow viewports (< 600 DIP, e.g. phones and narrow panes). WindowCompact WindowSizeClass = iota // WindowMedium covers medium viewports (600..840 DIP, e.g. tablets and split windows). WindowMedium // WindowExpanded covers wide viewports (>= 840 DIP, e.g. desktop and landscape tablets). WindowExpanded )
func ContentSizeClassOf ¶
func ContentSizeClassOf(c *ui.Context) WindowSizeClass
ContentSizeClassOf returns the WindowSizeClass of the content area c is being built in: inside an AdaptiveScaffold content slot, the window width less the navigation rail's actual share (80 DIP collapsed, or its expanded width), and the window width elsewhere. Nested BentoGrid and SupportingPane use it so a wide window whose rail leaves a Medium or Compact content area does not force four Bento columns or an automatic supporting pane.
It never changes WindowSizeClassOf, which keeps measuring the whole window. Passing nil returns WindowCompact.
func WindowSizeClassForWidth ¶
func WindowSizeClassForWidth(w float32) WindowSizeClass
WindowSizeClassForWidth resolves the M3 Adaptive WindowSizeClass for width w in DIP. Non-positive, NaN, and -Inf widths return WindowCompact; +Inf returns WindowExpanded.
func WindowSizeClassOf ¶
func WindowSizeClassOf(c *ui.Context) WindowSizeClass
WindowSizeClassOf returns the WindowSizeClass for c's current window width. Passing nil returns WindowCompact.
It always measures the whole window, even inside an AdaptiveScaffold content area; use ContentSizeClassOf there for the width left beside the rail.
func (WindowSizeClass) String ¶
func (s WindowSizeClass) String() string
String returns the canonical breakpoint name ("Compact", "Medium", or "Expanded").
type WindowTitleBarOptions ¶
type WindowTitleBarOptions struct {
// Title is the window title shown in the center region when Center is nil.
Title string
// Height overrides the minimum bar height in DIP. Actual height is always
// at least c.TitleBar().Height so system controls never clip.
Height float32
// Background overrides the title bar fill. When zero, uses
// SurfaceColorForElevation(th, Elevation) if Elevation > Level0, or
// SurfaceContainerLowest otherwise.
Background ui.Color
// Elevation optionally raises the title bar tonal surface tier.
Elevation tokens.ElevationLevel
// Divider draws a subtle 1 DIP hairline along the bottom edge of the bar.
Divider bool
// Label names the title bar landmark for assistive technology; defaults to
// "Title bar".
Label string
// Leading builds optional content on the start side (after safe insets).
Leading func() ui.Element
// Center builds optional center content in place of Title.
Center func() ui.Element
// Trailing builds optional actions on the end side (before window controls).
Trailing func() ui.Element
// Window optionally binds a *mygo.Window (or custom WindowController) so
// built-in Pin, Minimize, Maximize/Restore, and Close controls act directly
// on the window when explicit callbacks are nil. When native system buttons
// remain visible (HideWindowButtons: false, i.e. non-zero c.TitleBar()),
// WindowTitleBar also inspects the optional SetWindowButtonsTheme method
// to sync native caption glyph polarity with th.Dark. Safe to leave nil in tests.
Window WindowController
// ShowWindowControls renders MD3E Minimize, Maximize/Restore (marked
// MaximizeButton for Windows 11 Snap Layouts), and Close buttons with
// height-aligned rounded hover highlights. Recommended on non-macOS desktop
// windows configured with TitleBarStyle: mygo.TitleBarHidden and
// HideWindowButtons: true. Even when false, providing any individual
// OnMinimize / OnMaximize / OnClose callback shows that control.
ShowWindowControls bool
// Pinned binds an always-on-top toggle button when non-nil (or when OnPin
// is set). Clicking toggles *Pinned, updates Window.SetAlwaysOnTop when
// Window is set, and calls OnPin.
Pinned *bool
// OnPin runs after the pin button toggles always-on-top state.
OnPin func(pinned bool)
// Maximized reflects the maximized visual state and accessible label
// ("Restore" vs "Maximize") when Window is nil.
Maximized bool
// OnMinimize overrides the Minimize button action.
OnMinimize func()
// OnMaximize overrides the Maximize/Restore button action.
OnMaximize func()
// OnClose overrides the Close button action.
OnClose func()
}
WindowTitleBarOptions configures WindowTitleBar. The zero value renders a seamlessly integrated SurfaceContainerLowest title bar whose height adapts to c.TitleBar() and Theme.Density, reserves platform safe insets (macOS traffic lights / Windows & Linux system controls), and enables window dragging and double-click maximize via DragWindow().
For desktop apps on Windows and Linux, pairing mygo.WindowOptions{ TitleBarStyle: mygo.TitleBarHidden, HideWindowButtons: true} with ShowWindowControls: true is recommended so WindowTitleBar renders 100% MD3E-styled, height-aligned Minimize, Maximize/Restore (integrated with Windows 11 Snap Layouts), and Close controls with rounded hover highlights. Keep HideWindowButtons: false on macOS to preserve native traffic lights.
Source Files
¶
- actiontoolbar.go
- adaptive.go
- appbar.go
- appshell.go
- badge.go
- breadcrumb.go
- button.go
- buttongroup.go
- card.go
- carousel.go
- checkbox.go
- chip.go
- choreography.go
- colorpicker.go
- combobox.go
- commandpalette.go
- datatable.go
- datepicker.go
- dialog.go
- disclosure.go
- divider.go
- doc.go
- dropzone.go
- editabletext.go
- fab.go
- fabmenu.go
- feedback_extra.go
- findbar.go
- form.go
- gridview.go
- iconbutton.go
- image.go
- indicator.go
- kbd.go
- list.go
- loading.go
- menu.go
- navbar.go
- navdrawer.go
- navrail.go
- navsidebar.go
- numberinput.go
- outlinetable.go
- pagination.go
- pilltabs.go
- popover.go
- progress.go
- radio.go
- ripple.go
- routerview.go
- search.go
- select.go
- shapebutton.go
- sheet.go
- shell.go
- sidesheet.go
- slider.go
- snackbar.go
- splitbutton.go
- status.go
- statusbar.go
- surface.go
- switch.go
- tabs.go
- tabstrip.go
- textfield.go
- theme.go
- tiles.go
- timepicker.go
- toast.go
- toolbar.go
- tooltip.go
- transition.go
- treeview.go
- typography.go
- virtuallist.go
- window_scope.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package charts provides Material Design 3 Expressive (MD3E) real-time and statistical data visualization components built over MyGo's headless github.com/egoist/mygo/ui/chart primitives.
|
Package charts provides Material Design 3 Expressive (MD3E) real-time and statistical data visualization components built over MyGo's headless github.com/egoist/mygo/ui/chart primitives. |
|
Package codeview provides a thin Material Design 3 Expressive (MD3E) theme, typography, and scrollbar bridge for MyGo's native code editor and diff viewer (github.com/egoist/mygo/ui/editor).
|
Package codeview provides a thin Material Design 3 Expressive (MD3E) theme, typography, and scrollbar bridge for MyGo's native code editor and diff viewer (github.com/egoist/mygo/ui/editor). |
|
Package docview provides Material Design 3 Expressive (MD3E) document, Markdown, callout, code card, and scroll-linked outline components built over MyGo's github.com/egoist/mygo/ui/markdown engine.
|
Package docview provides Material Design 3 Expressive (MD3E) document, Markdown, callout, code card, and scroll-linked outline components built over MyGo's github.com/egoist/mygo/ui/markdown engine. |
|
examples
|
|
|
desktop-demo
command
Command desktop-demo is PulseDesk, a compact Material Design 3 Expressive desktop workbench.
|
Command desktop-demo is PulseDesk, a compact Material Design 3 Expressive desktop workbench. |
|
gallery
command
Command gallery is the interactive showcase of every mygo-md3e component, from the M1 design tokens to the M8 pickers: pages of a ui.Router reachable from a collapsible NavigationRail, with live seed, variant, contrast, light and dark, motion scheme, reduce motion and right-to-left controls in the header, all passed down by md3e.ThemeScope so pages, dialogs, sheets, menus, snackbars and modal pickers share the same theme.
|
Command gallery is the interactive showcase of every mygo-md3e component, from the M1 design tokens to the M8 pickers: pages of a ui.Router reachable from a collapsible NavigationRail, with live seed, variant, contrast, light and dark, motion scheme, reduce motion and right-to-left controls in the header, all passed down by md3e.ThemeScope so pages, dialogs, sheets, menus, snackbars and modal pickers share the same theme. |
|
workbench
command
|
|
|
internal
|
|
|
mdicon
Package mdicon provides built-in Material Design 24x24 vector icons used by md3e components cleanly without init() hooks or global icon registries so applications only link the specific icons they reference.
|
Package mdicon provides built-in Material Design 24x24 vector icons used by md3e components cleanly without init() hooks or global icon registries so applications only link the specific icons they reference. |
|
Package motion holds the Material Design 3 Expressive motion physics: the Expressive and Standard schemes' spatial and effects springs, and their conversion to the ui package's physical spring options.
|
Package motion holds the Material Design 3 Expressive motion physics: the Expressive and Standard schemes' spatial and effects springs, and their conversion to the ui package's physical spring options. |
|
Package shape is the Material Design 3 Expressive shape system: a RoundedPolygon built from a closed chain of cubic Béziers, the 35 built-in MD3E shapes, and morphing between any two of them.
|
Package shape is the Material Design 3 Expressive shape system: a RoundedPolygon built from a closed chain of cubic Béziers, the 35 built-in MD3E shapes, and morphing between any two of them. |
|
Package symbols provides 220+ zero-bloat rounded 24x24 vector UI symbols for MyGo UI and mygo-md3e.
|
Package symbols provides 220+ zero-bloat rounded 24x24 vector UI symbols for MyGo UI and mygo-md3e. |
|
Package tokens holds the Material Design 3 Expressive design tokens: the HCT color space and its CAM16 appearance model, tonal palettes and dynamic color schemes, typography, shape and elevation.
|
Package tokens holds the Material Design 3 Expressive design tokens: the HCT color space and its CAM16 appearance model, tonal palettes and dynamic color schemes, typography, shape and elevation. |