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 navigation, overlays, virtualized tables, 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 ActionTile(c *ui.Context, title string, opts ...ActionTileOptions) 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 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 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 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 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 Divider(c *ui.Context, opts ...DividerOptions) ui.Element
- func DropdownMenu(c *ui.Context, label string, items []MenuItem, opts ...MenuOptions) 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 FilledCard(c *ui.Context, content func(), opts ...CardOptions) ui.Element
- func FilterChip(c *ui.Context, selected *bool, label string, opts ...FilterChipOptions) ui.Element
- func FloatingToolbar(c *ui.Context, items []FloatingToolbarItem, opts ...FloatingToolbarOptions) ui.Element
- func FullScreenDialog(c *ui.Context, open *bool, opts ...FullScreenDialogOptions) 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 LinearProgress(c *ui.Context, value float64, opts ...ProgressOptions) ui.Element
- func LinearWavyProgress(c *ui.Context, value float64, opts ...ProgressOptions) 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 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 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 PrimaryTabs(c *ui.Context, tabs []TabItem, opts ...TabsOptions) 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 SearchAppBar(c *ui.Context, query *string, opts ...SearchAppBarOptions) 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 ShapeButton(c *ui.Context, label string, icon IconDraw, opts ...ShapeButtonOptions) 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 StatusPill(c *ui.Context, text string, opts ...StatusPillOptions) 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 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 ToggleIconButton(c *ui.Context, on *bool, label string, icon IconDraw, ...) 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 ActionTileOptions
- type AdaptiveScaffoldOptions
- type AlertDialogOptions
- type AppBarAction
- 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 DataTableCellOptions
- type DataTableColumn
- type DataTableMenuAction
- type DataTableOptions
- type DatePickerMode
- type DatePickerOptions
- type DialogAction
- type DividerOptions
- type EmptyStateOptions
- type ExtendedFABOptions
- type FABColorScheme
- type FABMenuItem
- type FABMenuOptions
- type FABOptions
- type FABSize
- type FilterChipOptions
- type FloatingToolbarFab
- type FloatingToolbarItem
- type FloatingToolbarOptions
- type FloatingToolbarTone
- type FocusRingStyle
- type FullScreenDialogOptions
- type IconBadgeOptions
- type IconBadgeVariant
- type IconButtonOptions
- type IconButtonVariant
- type IconButtonWidth
- type IconDraw
- type ImageOptions
- type InputChipOptions
- type ListDetailPaneOptions
- type ListItem
- type ListOptions
- type LoadingOptions
- type LoadingStyle
- type MenuItem
- type MenuOptions
- type MorphIconButtonOptions
- type NavigationBarOptions
- type NavigationDestination
- type NavigationDrawerItem
- type NavigationDrawerOptions
- type NavigationLabelMode
- type NavigationRailIndicatorStyle
- type NavigationRailOptions
- type PaginationOptions
- type PillTabsOptions
- type PillTabsTone
- type PlainTooltipOptions
- type ProgressOptions
- type RadioGroupOptions
- type RadioOptions
- type RangeSliderOptions
- type RichTooltipAction
- type RichTooltipOptions
- type SearchAppBarOptions
- type SemanticTone
- type ShapeButtonOptions
- type ShapeButtonVariant
- type ShapeScale
- type SkeletonOptions
- type SkeletonShape
- type SliderOptions
- type SnackbarOptions
- type SnackbarState
- type SplitButtonOptions
- type StateLayerOptions
- type StatusPillOptions
- type SupportingPaneOptions
- type SurfaceOptions
- type SwitchCardOptions
- type SwitchOptions
- type TabItem
- 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 ToggleIconButtonOptions
- 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.1.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 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 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 the Fast Spatial spring and fades out the same way, keeping its closing overlay until the animation ends so the focus returns to the element that opened it. 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 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 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. 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 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 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 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 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 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 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 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 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 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 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 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 that glides smoothly along the vertical axis between destinations with the Fast Spatial spring. 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 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 PillTabs ¶
PillTabs builds a Material Design 3 Expressive capsule tab bar on top of ui.TabsBase: a full-pill tonal trough with a FastSpatial spring-animated sliding active capsule, 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 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 that slides along the track with the Fast Spatial spring as the choice moves. 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 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 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 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 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 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 StatusPill ¶
StatusPill builds a compact MD3E status pill with a leading indicator dot (static or smoothly pulsing) and status label.
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 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.
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 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 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 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
}
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 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) keeps tokens.ShapeMedium. 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)
}
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 the Level1 surface with Level1 shadows, lifting to // Level2 while pressed. CardElevated CardVariant = iota // CardFilled paints the SurfaceContainerHighest fill without shadows. CardFilled // CardOutlined paints the Surface fill with an OutlineVariant border. 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 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.ShapeMedium.
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 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 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 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 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 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 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 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
// 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 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 // a desktop-style leading accent bar (on the left in LTR, right in RTL) // that tracks the active destination alongside the capsule. 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
}
NavigationRailOptions configures a NavigationRail. The zero value is an enabled, collapsed rail whose destinations align to the top.
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 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
}
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 PrimaryContainer on SurfaceContainerHighest for // PillTabs, and SurfaceContainerLowest on SurfaceContainer for SegmentedTabs. PillTabsToneAuto PillTabsTone = iota // PillTabsTonePrimary paints a PrimaryContainer active capsule with // OnPrimaryContainer text over a SurfaceContainerHighest trough. PillTabsTonePrimary // PillTabsToneSecondary paints a SecondaryContainer active capsule with // OnSecondaryContainer text over a SurfaceContainerHighest trough. PillTabsToneSecondary // PillTabsToneSurface paints an elevated SurfaceContainerLowest active // capsule with OnSurface text over a SurfaceContainer 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
}
PlainTooltipOptions configures PlainTooltip.
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 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 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 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 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 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 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 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 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
}
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
Motion motion.Scheme
Density tokens.Density
Typography tokens.TypographyScale
Shapes ShapeScale
Contrast tokens.Contrast
TextScale float32
ReduceMotion bool
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, Motion, Density, Shapes, Typography, Contrast, ReduceMotion, Font, MonoFont) switch at t >= 0.5. Intermediate themes clear seed provenance so they never pollute schemeCache.
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
Motion motion.Scheme
Density tokens.Density
Font string
MonoFont string
TextScale float32
ReduceMotion bool
Shapes *ShapeScale
Typography *tokens.TypographyScale
}
ThemeOptions configures how ThemeFromSeed constructs 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 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 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 cleanly while incoming content // enters with a subtle scale-up (0.96 -> 1), gentle upward rise, and fade. TransitionFadeThrough TransitionMode = iota // vertical axis according to Direction (suited for vertical NavigationRail // page switching). TransitionSharedAxisY // 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 30 DIP) and the subtle vertical rise for TransitionFadeThrough
// (default 8 DIP). Non-positive or non-finite values use the mode default.
Distance float32
// Scale overrides the entering initial scale for TransitionFadeThrough
// (default 0.96). Values <= 0, >= 1, or non-finite use the default.
Scale float32
// AfterExits holds the incoming page unseen until the outgoing page finishes
// leaving, producing a sequential two-phase transition instead of an
// overlapping cross-transition.
AfterExits bool
}
TransitionOptions configures PageTransition and AnimatedContent. The zero value uses TransitionFadeThrough with MD3E spring timing 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. Comparable keys
// keep keyboard focus and local expansion state attached to the node across
// sibling expansions or insertions.
Key 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
¶
- adaptive.go
- appbar.go
- badge.go
- breadcrumb.go
- button.go
- buttongroup.go
- card.go
- carousel.go
- checkbox.go
- chip.go
- datatable.go
- datepicker.go
- dialog.go
- divider.go
- doc.go
- fab.go
- fabmenu.go
- feedback_extra.go
- iconbutton.go
- image.go
- list.go
- loading.go
- menu.go
- navbar.go
- navdrawer.go
- navrail.go
- pagination.go
- pilltabs.go
- progress.go
- radio.go
- ripple.go
- shapebutton.go
- sheet.go
- shell.go
- slider.go
- snackbar.go
- splitbutton.go
- status.go
- surface.go
- switch.go
- tabs.go
- textfield.go
- theme.go
- tiles.go
- timepicker.go
- toolbar.go
- tooltip.go
- transition.go
- treeview.go
- typography.go
- virtuallist.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. |
|
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. |