Go Reference

This package provides various material design components for gio.


This package has no stable API, and should always be locked to a particular commit with go modules.

The included components attempt to conform to the material design specifications whenever possible, but they may not support unusual style tweaks or especially exotic configurations.

Implemented Components

The list of currently-Implemented components follows:

Navigation Drawer (static and modal)

The navigation drawer specified here is mostly implemented by the type NavDrawer, and the modal variant can be created with a ModalNavDrawer. The modal variant looks like this:

modal navigation drawer example screenshot


  • Animated drawer open/close.
  • Navigation items respond to hovering.
  • Navigation selection is animated.
  • Navigation item icons are optional.
  • Content can be anchored to the bottom of the drawer for pairing with a bottom app bar.

Modal features:

  • Swipe or touch scrim to close the drawer.

Known issues:

  • API targets a fairly static and simplistic menu. Sub-sections with dividers are not yet supported. An API-driven way to traverse the current menu options is also not yet supported. Contributions welcome!
App Bar (Top and Bottom)

The App Bar specified here is mostly implemented by the type AppBar. It looks like this:

Normal state:

modal navigation drawer example screenshot

Contextual state:

modal navigation drawer example screenshot


  • Action buttons and overflow menu contents can be changed easily.
  • Overflow button disappears when no items overflow.
  • Overflow menu can be dismissed by touching the scrim outside of it.
  • Action items disapper into overflow when screen is too narrow to fit them. This is animated.
  • Navigation button icon is customizable, and the button is not drawn if no icon is provided.
  • Contextual app bar can be triggered and dismissed programatically.
  • Bar supports use as a top and bottom app bar (animates the overflow menu in the proper direction).

Known Issues:

  • Compact and prominent App Bars are not yet implemented.
Side sheet (static and modal)

Side sheets (specified here) are implemented by the Sheet and ModalSheet types.


  • Animated appear/disappear

Modal features:

  • Swipe to close
  • Touch scrim to close

Known Issues:

  • Only sheets anchored on the left are currently supported (contributions welcome!)
Text Fields

Text Fields (specified here) are implemented by the TextField type.


  • Animated label transition when selected
  • Responds to hover events
  • Exposes underlying gio editor

Known Issues:

  • Icons, hint text, error text, prefix/suffix, and other features are not yet implemented.

The Divider type implements material dividers. You can customize the insets embedded in the type to change which kind of divider it is. Use the constructor functions to create nice defaults.


The Surface type is a rounded rectangle with a background color and a drop shadow. This isn't a material component per se, but is a useful building block nonetheless.


The Menu type defines contextual menus as described here.

first menu example screenshot

Known issues:

  • Does not support nested submenus (yet).

The MenuItem type provides widgets suitable for use within the Menu, though any widget can be used. Here are some MenuItems in action:

second menu example screenshot


The ContextArea type is a helper type that defines an area that accepts right-clicks. This area will display a widget when clicked (anchored at the click position). The displayed widget is overlaid on other content, and is therefore useful in displaying contextual menus.

Known issues:

  • the heuristic that ContextArea uses to attempt to avoid off-screen drawing of its contextual content can fail or backfire. Suggestions for improving this are welcome.



    Package component provides material design UI components as described by



    This section is empty.


    This section is empty.


    func DividerSubheadingText

    func DividerSubheadingText(th *material.Theme, label string) material.LabelStyle

      DividerSubheadingText returns a LabelStyle suitable for use as a subheading in a divider.

      func Interpolate

      func Interpolate(a, b color.NRGBA, progress float32) color.NRGBA
      func MenuHintText(th *material.Theme, label string) material.LabelStyle

        MenuHintText returns a LabelStyle suitable for use as hint text in a MenuItemStyle.

        func SimpleIconButton

        func SimpleIconButton(bg, fg color.NRGBA, state *widget.Clickable, icon *widget.Icon) material.IconButtonStyle

          SimpleIconButton creates an IconButtonStyle that is pre-configured to be the right size for use as an AppBarAction

          func SwapGrounds

          func SwapGrounds(p material.Palette) material.Palette

            SwapGrounds swaps the foreground and background colors of both the contrast and non-constrast colors.

            Bg <-> Fg ContrastBg <-> ContrastFg

            func SwapPairs

            func SwapPairs(p material.Palette) material.Palette

              SwapPairs swaps the contrast and non-constrast colors.

              Bg <-> ContrastBg Fg <-> ContrastFg

              func WithAlpha

              func WithAlpha(c color.NRGBA, a uint8) color.NRGBA

                WithAlpha returns the input color with the new alpha value.


                type AlphaPalette

                type AlphaPalette struct {
                	Hover, Selected uint8

                  AlphaPalette is the set of alpha values to be applied for certain material design states like hover, selected, etc...

                  type AppBar

                  type AppBar struct {
                  	NavigationButton       widget.Clickable
                  	NavigationIcon         *widget.Icon
                  	Title, ContextualTitle string
                  	// The modal layer is used to lay out the overflow menu. The nav
                  	// bar is not functional if this field is not supplied.
                  	// Anchor indicates whether the app bar is anchored at the
                  	// top or bottom edge of the interface. It defaults to Top, and
                  	// is used to orient the layout of menus relative to the bar.
                  	Anchor VerticalAnchorPosition
                  	// contains filtered or unexported fields

                    AppBar implements the material design App Bar documented here:

                    TODO(whereswaldon): implement support for RTL layouts

                    func NewAppBar

                    func NewAppBar(modal *ModalLayer) *AppBar

                      NewAppBar creates and initializes an App Bar.

                      func (*AppBar) CloseOverflowMenu

                      func (a *AppBar) CloseOverflowMenu(when time.Time)

                        CloseOverflowMenu requests that the overflow menu be closed if it is open.

                        func (*AppBar) Events

                        func (a *AppBar) Events(gtx layout.Context) []AppBarEvent

                          Events returns a slice of all AppBarActions to occur since the last frame.

                          func (*AppBar) Layout

                          func (a *AppBar) Layout(gtx layout.Context, theme *material.Theme) layout.Dimensions

                            Layout renders the app bar. It will span all available horizontal space (gtx.Constraints.Max.X), but has a fixed height.

                            func (*AppBar) SetActions

                            func (a *AppBar) SetActions(actions []AppBarAction, overflows []OverflowAction)

                              SetActions configures the set of actions available in the action item area of the app bar. They will be displayed in the order provided (from left to right) and will collapse into the overflow menu from right to left. The provided OverflowActions will always be in the overflow menu in the order provided.

                              func (*AppBar) SetContextualActions

                              func (a *AppBar) SetContextualActions(actions []AppBarAction, overflows []OverflowAction)

                                SetContextualActions configures the actions that should be available in the next Contextual mode that this action bar enters.

                                func (*AppBar) StartContextual

                                func (a *AppBar) StartContextual(when time.Time, title string)

                                  StartContextual causes the AppBar to transform into a contextual App Bar with a different set of actions than normal. If the App Bar is already in contextual mode, this has no effect. The title will be used as the contextual app bar title.

                                  func (*AppBar) StopContextual

                                  func (a *AppBar) StopContextual(when time.Time)

                                    StopContextual causes the AppBar to stop showing a contextual menu if one is currently being displayed.

                                    func (*AppBar) ToggleContextual

                                    func (a *AppBar) ToggleContextual(when time.Time, title string)

                                      ToggleContextual switches between contextual an noncontextual mode. If it transitions to contextual mode, the provided title is used.

                                      type AppBarAction

                                      type AppBarAction struct {
                                      	Layout func(gtx layout.Context, bg, fg color.NRGBA) layout.Dimensions

                                        AppBarAction configures an action in the App Bar's action items. The embedded OverflowAction provides the action information for when this item disappears into the overflow menu.

                                        func SimpleIconAction

                                        func SimpleIconAction(state *widget.Clickable, icon *widget.Icon, overflow OverflowAction) AppBarAction

                                          SimpleIconAction configures an AppBarAction that functions as a simple IconButton. To receive events from the button, use the standard methods on the provided state parameter.

                                          type AppBarContextMenuDismissed

                                          type AppBarContextMenuDismissed struct{}

                                            AppBarContextMenuDismissed indicates that the app bar context menu was dismissed during the last frame.

                                            func (AppBarContextMenuDismissed) AppBarEvent

                                            func (a AppBarContextMenuDismissed) AppBarEvent()

                                            func (AppBarContextMenuDismissed) String

                                            type AppBarEvent

                                            type AppBarEvent interface {


                                              type AppBarNavigationClicked

                                              type AppBarNavigationClicked struct{}

                                                AppBarNavigationClicked indicates that the navigation icon was clicked during the last frame.

                                                func (AppBarNavigationClicked) AppBarEvent

                                                func (a AppBarNavigationClicked) AppBarEvent()

                                                func (AppBarNavigationClicked) String

                                                func (a AppBarNavigationClicked) String() string

                                                type AppBarOverflowActionClicked

                                                type AppBarOverflowActionClicked struct {
                                                	Tag interface{}

                                                  AppBarOverflowActionClicked indicates that an action in the app bar overflow menu was clicked during the last frame.

                                                  func (AppBarOverflowActionClicked) AppBarEvent

                                                  func (a AppBarOverflowActionClicked) AppBarEvent()

                                                  func (AppBarOverflowActionClicked) String

                                                  type C

                                                  type C = layout.Context

                                                  type ContextArea

                                                  type ContextArea struct {
                                                  	// contains filtered or unexported fields

                                                    ContextArea is a region of the UI that responds to right-clicks with a contextual widget. The contextual widget is overlaid using an op.DeferOp.

                                                    func (ContextArea) Active

                                                    func (r ContextArea) Active() bool

                                                      Active returns whether the ContextArea is currently active (whether it is currently displaying overlaid content or not).

                                                      func (*ContextArea) Dismiss

                                                      func (r *ContextArea) Dismiss()

                                                        Dismiss sets the ContextArea to not be active.

                                                        func (*ContextArea) Layout

                                                        func (r *ContextArea) Layout(gtx C, w layout.Widget) D

                                                          Layout renders the context area and -- if the area is activated by an appropriate gesture -- also the provided widget overlaid using an op.DeferOp.

                                                          type D

                                                          type D = layout.Dimensions

                                                          type DividerStyle

                                                          type DividerStyle struct {
                                                          	Thickness unit.Value
                                                          	Fill      color.NRGBA
                                                          	Subheading      material.LabelStyle
                                                          	SubheadingInset layout.Inset

                                                            DividerStyle defines the presentation of a material divider, as specified here:

                                                            func Divider

                                                            func Divider(th *material.Theme) DividerStyle

                                                              Divider creates a simple full-bleed divider.

                                                              func SubheadingDivider

                                                              func SubheadingDivider(th *material.Theme, subheading string) DividerStyle

                                                                SubheadingDivider creates a full-bleed divider with a subheading.

                                                                func (DividerStyle) Layout

                                                                func (d DividerStyle) Layout(gtx C) D

                                                                  Layout renders the divider. If gtx.Constraints.Min.X is zero, it will have zero size and render nothing.

                                                                  type Hoverable

                                                                  type Hoverable struct {
                                                                  	// contains filtered or unexported fields

                                                                    Hoverable tracks mouse hovers over some area.

                                                                    func (*Hoverable) Hovered

                                                                    func (h *Hoverable) Hovered() bool

                                                                      Hovered if mouse has entered the area.

                                                                      func (*Hoverable) Layout

                                                                      func (h *Hoverable) Layout(gtx C) D

                                                                        Layout Hoverable according to min constraints.

                                                                        type MenuItemStyle struct {
                                                                        	State      *widget.Clickable
                                                                        	HoverColor color.NRGBA
                                                                        	LabelInset layout.Inset
                                                                        	Label      material.LabelStyle
                                                                        	IconSize  unit.Value
                                                                        	IconInset layout.Inset
                                                                        	Hint      material.LabelStyle
                                                                        	HintInset layout.Inset

                                                                          MenuItemStyle defines the presentation of a Menu element that has a label and optionally an icon and a hint text.

                                                                          func MenuItem(th *material.Theme, state *widget.Clickable, label string) MenuItemStyle

                                                                            MenuItem constructs a default MenuItemStyle based on the theme, state, and label.

                                                                            func (m MenuItemStyle) Layout(gtx C) D

                                                                              Layout renders the MenuItemStyle. If gtx.Constraints.Min.X is zero, it will render itself to be as compact as possible horizontally.

                                                                              type MenuState struct {
                                                                              	OptionList layout.List
                                                                              	Options    []func(gtx C) D

                                                                                MenuState holds the state of a menu material design component across frames.

                                                                                type MenuStyle struct {
                                                                                	// Inset applied around the rendered contents of the state's Options field.

                                                                                  MenuStyle defines the presentation of a material design menu component.

                                                                                  func Menu(th *material.Theme, state *MenuState) MenuStyle

                                                                                    Menu constructs a menu with the provided state and a default Surface behind it.

                                                                                    func (m MenuStyle) Layout(gtx C) D

                                                                                      Layout renders the menu.

                                                                                      type ModalLayer

                                                                                      type ModalLayer struct {
                                                                                      	Widget func(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions

                                                                                        ModalLayer is a widget drawn on top of the normal UI that can be populated by other material components with dismissble modal dialogs. For instance, the App Bar can render its overflow menu within the modal layer, and the modal navigation drawer is entirely within the modal layer.

                                                                                        func NewModal

                                                                                        func NewModal() *ModalLayer

                                                                                          NewModal creates an initializes a modal layer.

                                                                                          func (*ModalLayer) Layout

                                                                                          func (m *ModalLayer) Layout(gtx layout.Context, th *material.Theme) layout.Dimensions

                                                                                            Layout renders the modal layer. Unless a modal widget has been triggered, this will do nothing.

                                                                                            type ModalNavDrawer

                                                                                            type ModalNavDrawer struct {
                                                                                            	// contains filtered or unexported fields

                                                                                              ModalNavDrawer implements the Material Design Modal Navigation Drawer described here:

                                                                                              func ModalNavFrom

                                                                                              func ModalNavFrom(nav *NavDrawer, modal *ModalLayer) *ModalNavDrawer

                                                                                              func NewModalNav

                                                                                              func NewModalNav(modal *ModalLayer, title, subtitle string) *ModalNavDrawer

                                                                                                NewModalNav configures a modal navigation drawer that will render itself into the provided ModalLayer

                                                                                                func (*ModalNavDrawer) Appear

                                                                                                func (m *ModalNavDrawer) Appear(when time.Time)

                                                                                                func (*ModalNavDrawer) Disappear

                                                                                                func (m *ModalNavDrawer) Disappear(when time.Time)

                                                                                                func (*ModalNavDrawer) Layout

                                                                                                func (m *ModalNavDrawer) Layout() layout.Dimensions

                                                                                                func (*ModalNavDrawer) ToggleVisibility

                                                                                                func (m *ModalNavDrawer) ToggleVisibility(when time.Time)

                                                                                                type ModalSheet

                                                                                                type ModalSheet struct {
                                                                                                	// MaxWidth constrains the maximum amount of horizontal screen real-estate
                                                                                                	// covered by the drawer. If the screen is narrower than this value, the
                                                                                                	// width will be inferred by reserving space for the scrim and using the
                                                                                                	// leftover area for the drawer. Values between 200 and 400 Dp are recommended.
                                                                                                	// The default value used by NewModalNav is 400 Dp.
                                                                                                	MaxWidth unit.Value
                                                                                                	Modal *ModalLayer
                                                                                                	// contains filtered or unexported fields

                                                                                                  ModalSheet implements the Modal Side Sheet component specified at

                                                                                                  func NewModalSheet

                                                                                                  func NewModalSheet(m *ModalLayer) *ModalSheet

                                                                                                    NewModalSheet creates a modal sheet that can render a widget on the modal layer.

                                                                                                    func (*ModalSheet) Appear

                                                                                                    func (s *ModalSheet) Appear(when time.Time)

                                                                                                      Appear triggers the appearance of the ModalSheet.

                                                                                                      func (*ModalSheet) Disappear

                                                                                                      func (s *ModalSheet) Disappear(when time.Time)

                                                                                                        Disappear triggers the appearance of the ModalSheet.

                                                                                                        func (*ModalSheet) LayoutModal

                                                                                                        func (s *ModalSheet) LayoutModal(contents func(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions)

                                                                                                          ConfigureModal requests that the sheet prepare the associated ModalLayer to render itself (rather than another modal widget).

                                                                                                          func (*ModalSheet) ToggleVisibility

                                                                                                          func (s *ModalSheet) ToggleVisibility(when time.Time)

                                                                                                            ToggleVisibility triggers the appearance or disappearance of the ModalSheet.

                                                                                                            type NavDrawer struct {
                                                                                                            	Title    string
                                                                                                            	Subtitle string
                                                                                                            	// Anchor indicates whether content in the nav drawer should be anchored to
                                                                                                            	// the upper or lower edge of the drawer. This value should match the anchor
                                                                                                            	// of an app bar if an app bar is used in conjunction with this nav drawer.
                                                                                                            	Anchor VerticalAnchorPosition
                                                                                                            	// contains filtered or unexported fields

                                                                                                              NavDrawer implements the Material Design Navigation Drawer described here:

                                                                                                              func NewNav

                                                                                                              func NewNav(title, subtitle string) NavDrawer

                                                                                                                NewNav configures a navigation drawer

                                                                                                                func (m *NavDrawer) AddNavItem(item NavItem)

                                                                                                                  AddNavItem inserts a navigation target into the drawer. This should be invoked only from the layout thread to avoid nasty race conditions.

                                                                                                                  func (m *NavDrawer) CurrentNavDestination() interface{}

                                                                                                                    CurrentNavDestination returns the tag of the navigation destination selected in the drawer.

                                                                                                                    func (m *NavDrawer) LayoutContents(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation) layout.Dimensions
                                                                                                                    func (m *NavDrawer) NavDestinationChanged() bool

                                                                                                                      NavDestinationChanged returns whether the selected navigation destination has changed since the last frame.

                                                                                                                      func (m *NavDrawer) SetNavDestination(tag interface{})

                                                                                                                        SetNavDestination changes the selected navigation item to the item with the provided tag. If the provided tag does not exist, it has no effect.

                                                                                                                        type NavItem struct {
                                                                                                                        	// Tag is an externally-provided identifier for the view
                                                                                                                        	// that this item should navigate to. It's value is
                                                                                                                        	// opaque to navigation elements.
                                                                                                                        	Tag  interface{}
                                                                                                                        	Name string
                                                                                                                        	// Icon, if set, renders the provided icon to the left of the
                                                                                                                        	// item's name. Material specifies that either all navigation
                                                                                                                        	// items should have an icon, or none should. As such, if this
                                                                                                                        	// field is nil, the Name will be aligned all the way to the
                                                                                                                        	// left. A mixture of icon and non-icon items will be misaligned.
                                                                                                                        	// Users should either set icons for all elements or none.
                                                                                                                        	Icon *widget.Icon

                                                                                                                        type OverflowAction

                                                                                                                        type OverflowAction struct {
                                                                                                                        	Name string
                                                                                                                        	Tag  interface{}

                                                                                                                          OverflowAction holds information about an action available in an overflow menu

                                                                                                                          type Progress

                                                                                                                          type Progress struct {
                                                                                                                          	// contains filtered or unexported fields

                                                                                                                            Progress is an animation primitive that tracks progress of time over a fixed duration as a float between [0, 1].

                                                                                                                            Progress is reversable.

                                                                                                                            Widgets map async UI events to state changes: stop, forward, reverse. Widgets then interpolate visual data based on progress value.

                                                                                                                            Update method must be called every tick to update the progress value.

                                                                                                                            func (Progress) Direction

                                                                                                                            func (p Progress) Direction() ProgressDirection

                                                                                                                              Direction reports the current direction.

                                                                                                                              func (Progress) Finished

                                                                                                                              func (p Progress) Finished() bool

                                                                                                                              func (Progress) Progress

                                                                                                                              func (p Progress) Progress() float32

                                                                                                                                Progress reports the current progress as a float between [0, 1].

                                                                                                                                func (*Progress) Start

                                                                                                                                func (p *Progress) Start(began time.Time, direction ProgressDirection, duration time.Duration)

                                                                                                                                  Start the progress in the given direction over the given duration.

                                                                                                                                  func (Progress) Started

                                                                                                                                  func (p Progress) Started() bool

                                                                                                                                    Started reports true if progression has started.

                                                                                                                                    func (*Progress) Stop

                                                                                                                                    func (p *Progress) Stop()

                                                                                                                                      Stop the progress.

                                                                                                                                      func (*Progress) Update

                                                                                                                                      func (p *Progress) Update(now time.Time)

                                                                                                                                      type ProgressDirection

                                                                                                                                      type ProgressDirection int

                                                                                                                                        ProgressDirection specifies how to update progress every tick.

                                                                                                                                        const (
                                                                                                                                        	// Forward progresses from 0 to 1.
                                                                                                                                        	Forward ProgressDirection = iota
                                                                                                                                        	// Reverse progresses from 1 to 0.

                                                                                                                                        func (ProgressDirection) String

                                                                                                                                        func (d ProgressDirection) String() string

                                                                                                                                        type Rect

                                                                                                                                        type Rect struct {
                                                                                                                                        	Color color.NRGBA
                                                                                                                                        	Size  image.Point
                                                                                                                                        	Radii float32

                                                                                                                                        func (Rect) Layout

                                                                                                                                        func (r Rect) Layout(gtx C) D

                                                                                                                                        type Resize

                                                                                                                                        type Resize struct {
                                                                                                                                        	// Axis defines how the widgets and the handle are laid out.
                                                                                                                                        	Axis layout.Axis
                                                                                                                                        	// Ratio defines how much space is available to the first widget.
                                                                                                                                        	Ratio float32
                                                                                                                                        	// contains filtered or unexported fields

                                                                                                                                          Resize provides a draggable handle in between two widgets for resizing their area.

                                                                                                                                          func (*Resize) Layout

                                                                                                                                          func (rs *Resize) Layout(gtx layout.Context, w1, w2, handle layout.Widget) layout.Dimensions

                                                                                                                                            Layout displays w1 and w2 with handle in between.

                                                                                                                                            The widgets w1 and w2 must be able to gracefully resize their minimum and maximum dimensions in order for the resize to be smooth.

                                                                                                                                            type Scrim

                                                                                                                                            type Scrim struct {
                                                                                                                                            	// FinalAlpha is the final opacity of the scrim on a scale from 0 to 255.
                                                                                                                                            	FinalAlpha uint8

                                                                                                                                              Scrim implments a clickable translucent overlay. It can animate appearing and disappearing as a fade-in, fade-out transition from zero opacity to a fixed maximum opacity.

                                                                                                                                              func (*Scrim) Layout

                                                                                                                                                Layout draws the scrim using the provided animation. If the animation indicates that the scrim is not visible, this is a no-op.

                                                                                                                                                type ShadowStyle

                                                                                                                                                type ShadowStyle struct {
                                                                                                                                                	// The radius of the corners of the rectangle casting the surface.
                                                                                                                                                	// Non-rounded rectangles can just provide a zero.
                                                                                                                                                	CornerRadius unit.Value
                                                                                                                                                	// Elevation is how high the surface casting the shadow is above
                                                                                                                                                	// the background, and therefore determines how diffuse and large
                                                                                                                                                	// the shadow is.
                                                                                                                                                	Elevation unit.Value
                                                                                                                                                	// The colors of various components of the shadow. The Shadow()
                                                                                                                                                	// constructor populates these with reasonable defaults.
                                                                                                                                                	AmbientColor, PenumbraColor, UmbraColor color.NRGBA

                                                                                                                                                  ShadowStyle defines a shadow cast by a rounded rectangle.

                                                                                                                                                  TODO(whereswaldon): make this support RRects that do not have uniform corner radii.

                                                                                                                                                  func Shadow

                                                                                                                                                  func Shadow(radius, elevation unit.Value) ShadowStyle

                                                                                                                                                    Shadow defines a shadow cast by a rounded rectangle with the given corner radius and elevation. It sets reasonable defaults for the shadow colors.

                                                                                                                                                    func (ShadowStyle) Layout

                                                                                                                                                    func (s ShadowStyle) Layout(gtx layout.Context) layout.Dimensions

                                                                                                                                                      Layout renders the shadow into the gtx. The shadow's size will assume that the rectangle casting the shadow is of size gtx.Constraints.Min.

                                                                                                                                                      type Sheet

                                                                                                                                                      type Sheet struct{}

                                                                                                                                                        Sheet implements the standard side sheet described here:

                                                                                                                                                        func NewSheet

                                                                                                                                                        func NewSheet() Sheet

                                                                                                                                                          NewSheet returns a new sheet

                                                                                                                                                          func (Sheet) Layout

                                                                                                                                                          func (s Sheet) Layout(gtx layout.Context, th *material.Theme, anim *VisibilityAnimation, widget layout.Widget) layout.Dimensions

                                                                                                                                                            Layout renders the provided widget on a background. The background will use the maximum space available.

                                                                                                                                                            type SurfaceStyle

                                                                                                                                                            type SurfaceStyle struct {
                                                                                                                                                            	// The CornerRadius and Elevation fields of the embedded shadow
                                                                                                                                                            	// style also define the corner radius and elevation of the card.

                                                                                                                                                              SurfaceStyle defines the visual aspects of a material design surface with (optionally) rounded corners and a drop shadow.

                                                                                                                                                              func Surface

                                                                                                                                                              func Surface(th *material.Theme) SurfaceStyle

                                                                                                                                                                Surface creates a Surface style for the provided theme with sensible default elevation and rounded corners.

                                                                                                                                                                func (SurfaceStyle) Layout

                                                                                                                                                                func (c SurfaceStyle) Layout(gtx C, w layout.Widget) D

                                                                                                                                                                  Layout renders the SurfaceStyle, taking the dimensions of the surface from gtx.Constraints.Min.

                                                                                                                                                                  type TextField

                                                                                                                                                                  type TextField struct {
                                                                                                                                                                  	// Editor contains the edit buffer.
                                                                                                                                                                  	// Hoverable detects mouse hovers.
                                                                                                                                                                  	Hoverable Hoverable
                                                                                                                                                                  	// Alignment specifies where to anchor the text.
                                                                                                                                                                  	Alignment layout.Alignment
                                                                                                                                                                  	// Helper text to give additional context to a field.
                                                                                                                                                                  	Helper string
                                                                                                                                                                  	// CharLimit specifies the maximum number of characters the text input
                                                                                                                                                                  	// will allow. Zero means "no limit".
                                                                                                                                                                  	CharLimit uint
                                                                                                                                                                  	// Prefix appears before the content of the text input.
                                                                                                                                                                  	Prefix layout.Widget
                                                                                                                                                                  	// Suffix appears after the content of the text input.
                                                                                                                                                                  	Suffix layout.Widget
                                                                                                                                                                  	// contains filtered or unexported fields

                                                                                                                                                                    TextField implements the Material Design Text Field described here:

                                                                                                                                                                    func (*TextField) Clear

                                                                                                                                                                    func (in *TextField) Clear()

                                                                                                                                                                      Clear the input text and reset any error status.

                                                                                                                                                                      func (*TextField) ClearError

                                                                                                                                                                      func (in *TextField) ClearError()

                                                                                                                                                                        ClearError clears any errored status.

                                                                                                                                                                        func (TextField) IsActive

                                                                                                                                                                        func (in TextField) IsActive() bool

                                                                                                                                                                          IsActive if input is in an active state (Active, Focused or Errored).

                                                                                                                                                                          func (*TextField) IsErrored

                                                                                                                                                                          func (in *TextField) IsErrored() bool

                                                                                                                                                                            IsErrored if input is in an errored state. Typically this is when the validator has returned an error message.

                                                                                                                                                                            func (*TextField) Layout

                                                                                                                                                                            func (in *TextField) Layout(gtx C, th *material.Theme, hint string) D

                                                                                                                                                                            func (*TextField) SetError

                                                                                                                                                                            func (in *TextField) SetError(err string)

                                                                                                                                                                              SetError puts the input into an errored state with the specified error text.

                                                                                                                                                                              func (*TextField) TextTooLong

                                                                                                                                                                              func (in *TextField) TextTooLong() bool

                                                                                                                                                                                TextTooLong returns whether the current editor text exceeds the set character limit.

                                                                                                                                                                                func (*TextField) Update

                                                                                                                                                                                func (in *TextField) Update(gtx C, th *material.Theme, hint string)

                                                                                                                                                                                type TruncatingLabelStyle

                                                                                                                                                                                type TruncatingLabelStyle material.LabelStyle

                                                                                                                                                                                  TruncatingLabelStyle is a type that forces a label to fit on one line and adds a truncation indicator symbol to the end of the line if the text has been truncated.

                                                                                                                                                                                  func (TruncatingLabelStyle) Layout

                                                                                                                                                                                    Layout renders the label into the provided context.

                                                                                                                                                                                    type Validator

                                                                                                                                                                                    type Validator = func(string) string

                                                                                                                                                                                      Validator validates text and returns a string describing the error. Error is displayed as helper text.

                                                                                                                                                                                      type VerticalAnchorPosition

                                                                                                                                                                                      type VerticalAnchorPosition uint

                                                                                                                                                                                        VerticalAnchorPosition indicates the anchor position for the content of a component. Conventionally, this is use by AppBars and NavDrawers to decide how to allocate internal spacing and in which direction to animate certain actions.

                                                                                                                                                                                        const (
                                                                                                                                                                                        	Top VerticalAnchorPosition = iota

                                                                                                                                                                                        type VisibilityAnimation

                                                                                                                                                                                        type VisibilityAnimation struct {
                                                                                                                                                                                        	// How long does the animation last
                                                                                                                                                                                        	State   VisibilityAnimationState
                                                                                                                                                                                        	Started time.Time

                                                                                                                                                                                          VisibilityAnimation holds the animation state for animations that transition between a "visible" and "invisible" state for a fixed duration of time.

                                                                                                                                                                                          func (VisibilityAnimation) Animating

                                                                                                                                                                                          func (v VisibilityAnimation) Animating() bool

                                                                                                                                                                                            Animating() returns whether the animation is either in the process of appearsing or disappearing.

                                                                                                                                                                                            func (*VisibilityAnimation) Appear

                                                                                                                                                                                            func (v *VisibilityAnimation) Appear(now time.Time)

                                                                                                                                                                                              Appear triggers the animation to begin becoming visible at the provided time. It is a no-op if the animation is already visible.

                                                                                                                                                                                              func (*VisibilityAnimation) Disappear

                                                                                                                                                                                              func (v *VisibilityAnimation) Disappear(now time.Time)

                                                                                                                                                                                                Disappear triggers the animation to begin becoming invisible at the provided time. It is a no-op if the animation is already invisible.

                                                                                                                                                                                                func (*VisibilityAnimation) Revealed

                                                                                                                                                                                                func (v *VisibilityAnimation) Revealed(gtx layout.Context) float32

                                                                                                                                                                                                  Revealed returns the fraction of the animated entity that should be revealed at the current time in the animation. This fraction is computed with linear interpolation.

                                                                                                                                                                                                  Revealed should be invoked during every frame that v.Animating() returns true.

                                                                                                                                                                                                  If the animation reaches its end this frame, Revealed will transition it to a non-animating state automatically.

                                                                                                                                                                                                  If the animation is in the process of animating, calling Revealed will automatically add an InvalidateOp to the provided layout.Context to ensure that the next frame will be generated promptly.

                                                                                                                                                                                                  func (*VisibilityAnimation) String

                                                                                                                                                                                                  func (v *VisibilityAnimation) String(gtx layout.Context) string

                                                                                                                                                                                                  func (*VisibilityAnimation) ToggleVisibility

                                                                                                                                                                                                  func (v *VisibilityAnimation) ToggleVisibility(now time.Time)

                                                                                                                                                                                                    ToggleVisibility will make an invisible animation begin the process of becoming visible and a visible animation begin the process of disappearing.

                                                                                                                                                                                                    func (VisibilityAnimation) Visible

                                                                                                                                                                                                    func (v VisibilityAnimation) Visible() bool

                                                                                                                                                                                                      Visible() returns whether any part of the animated entity should be visible during the current animation frame.

                                                                                                                                                                                                      type VisibilityAnimationState

                                                                                                                                                                                                      type VisibilityAnimationState int

                                                                                                                                                                                                        VisibilityAnimationState represents possible states that a VisibilityAnimation can be in.

                                                                                                                                                                                                        const (
                                                                                                                                                                                                        	Visible VisibilityAnimationState = iota

                                                                                                                                                                                                        func (VisibilityAnimationState) String

                                                                                                                                                                                                        func (v VisibilityAnimationState) String() string