Window shells
Native windows with a plain content area or a resizable sidebar.
A shell creates a native window and lays out its content: the title bar area, window controls and, for the sidebar shell, a collapsible navigation column. Shells own the window's presentation. The application keeps its lifecycle, state, theme and localized text.
| Package | Layout |
|---|---|
shells/plain | One content area below a header that shows the title and optional actions |
shells/sidebar | A collapsible, resizable sidebar beside the content, under a floating header |
Shells open real windows, which these docs cannot show in the page; the Gallery runs both.
Plain window
shell := plain.NewShell(plain.ShellOptions{
Title: "Notes",
Width: 820,
Height: 740,
MinWidth: 820,
MinHeight: 740,
Theme: theme.Onevra,
HeaderActions: func(c *ui.Context) {
if components.IconButton(c, lucide.Settings(), "Settings", components.IconButtonPlain).Clicked() {
app.openSettings()
}
},
Content: app.view,
})
shell.Window().OnClosed(func() { mygo.App.Quit() })The header shows Title unless HeaderLeading replaces it, for example with a tab list that switches views. HeaderActions builds controls at its right. Content starts below the header; set ContentBehindHeader to let content scroll under it and pad it with plain.HeaderHeight(c).
Sidebar window
shell := sidebar.NewShell(sidebar.ShellOptions{
Title: "Library",
StateKey: "main",
Theme: theme.Onevra,
Left: app.navigation,
Content: app.page,
LeftToolbar: func(c *ui.Context) {
ui.Spacer(c)
if sidebar.IconButton(c, lucide.Settings(), "Settings").Clicked() {
app.openSettings()
}
},
})Left and Content build full-height regions behind the floating header, so their backgrounds reach the top of the window. Keep their controls clear of the header with sidebar.HeaderHeight(c) as top padding. The sidebar defaults to 220 points wide; users resize it by dragging its edge, and double-clicking the edge restores the default. Build the navigation with the Sidebar component.
Right adds a second full-height sidebar at the window's trailing edge, such as an inspector, with the window's material like Left. The floating header then ends before it, and RightHeader builds the sidebar's own header. The sidebar's toggle ends whichever header is at the window's edge, after the caption buttons' reserved room on Windows. It starts open unless RightCollapsed is set; SetRightExpanded and SetRightWidth restore a saved state.
StateKey asks MyGo to remember the window's size and position under that key. Sidebar width and the selected page remain application state.
Lifecycle
- Create shells after
mygo.App.WhenReady. - Use
shell.Window()for native events, such asOnClosed, rather than adding a second lifecycle. - Pass
Hidden: trueto prepare content and handlers before showing the window, then callShow. - Give a new project's main window an 820 × 740 initial and minimum size. The sidebar shell defaults to it; size secondary windows, such as settings, to their content.
Theme
Pass theme.Onevra as Theme, or a function returning your own *ui.Theme. The shell installs it before building anything, so its own surfaces and all content share it. See theming.
API
ShellOptions
ShellOptions configures a single-content window. Builders and Shell methods run synchronously on the UI thread, after MyGo is ready.
Prop
Type
NewShell
func NewShell(options ShellOptions) *ShellNewShell hides the standard title bar, retaining native macOS/Linux window controls and composing Onevra caption buttons on Windows. It does not show a title or add navigation, persistence, or application lifecycle policies; StateKey delegates window geometry to MyGo.
pkg.go.devShellOptions
ShellOptions describes a window and its default sidebar-and-content page. Content builders run synchronously on the UI thread.
Prop
Type
NewShell
func NewShell(options ShellOptions) *ShellNewShell creates a native window and installs the page container. It requests a titlebar material on macOS and Mica with custom caption buttons on Windows, whose maximize button brings up Windows 11's snap layouts. If no material is effective, it draws an opaque theme background. Other platforms retain their native controls. It persists no state itself; StateKey delegates window geometry to MyGo.
pkg.go.devHeaderHeight
func HeaderHeight(c *ui.Context) float32HeaderHeight is the frame's native-control clearance and modal drag height. Shell insets content by this amount unless ContentBehindHeader is set.
pkg.go.devHeaderHeight
func HeaderHeight(c *ui.Context) float32HeaderHeight returns the floating Shell header's height in DIPs for this frame, accounting for native window controls and the active theme's font size. Call it from a content builder; Shell does not automatically inset Left, Content or pages. The header remains above content for window dragging and header controls; keep interactive body content below this height.
pkg.go.devIconButton
func IconButton(c *ui.Context, icon *ui.SVG, label string) ui.ElementIconButton creates an icon-only button with a tooltip and accessible label. It uses MyGo's pointer, keyboard and focus behavior and can be placed in ui.Toolbar. Applications own the label and handle Clicked on the result. The face is transparent at rest; hover and press use translucent text color.
pkg.go.dev