Default#

Sidebar default example rendered by the production Go component.

Enable JavaScript to run the preview. Go source and install commands remain available.

Usage
rail := f.Slot().WidthPercent(42).MaxWidth(260).FillHeight()
items := tree.Sub(page, tree.Name("item"))
sidebar := components.BeginSidebar(canvas, theme, rail.Rect(), "Viva Studio")
sidebar.AddGroup("Workspace")
sidebar.AddMenuItem(components.SidebarMenuItem{
    ID: items.At(0), Label: "Overview", Icon: "O", Active: selected == 0,
})
sidebar.AddMenuItem(components.SidebarMenuItem{
    ID: items.At(1), Label: "Components", Icon: "C", Active: selected == 1,
})
if index, ok := canvas.ClickedIn(items); ok { selected = int(index) }

Floating#

Sidebar floating example rendered by the production Go component.

Enable JavaScript to run the preview. Go source and install commands remain available.

Usage
rail := f.Slot().WidthPercent(42).MaxWidth(260).FillHeight()
items := tree.Sub(page, tree.Name("item"))
sidebar := components.BeginSidebarWithOptions(canvas, theme, rail.Rect(), "Viva Studio",
    components.SidebarOptions{Collapsible: components.SidebarFixed, Variant: components.SidebarFloating})
sidebar.AddGroup("Workspace")
sidebar.AddMenuItem(components.SidebarMenuItem{ID: items.At(0), Label: "Overview", Icon: "O"})
sidebar.AddMenuItem(components.SidebarMenuItem{
    ID: items.At(1), Label: "Components", Icon: "C",
    Variant: components.SidebarMenuOutline,
})

Collapsed#

Sidebar collapsed example rendered by the production Go component.

Enable JavaScript to run the preview. Go source and install commands remain available.

Usage
rail := f.Slot().FillHeight()
if collapsed {
    rail.Width(theme.Metrics.ControlHeight + theme.Metrics.GapItem*2)
} else {
    rail.WidthPercent(42).MaxWidth(260)
}
sidebar := components.BeginSidebarWithOptions(canvas, theme, rail.Rect(), "Viva Studio",
    components.SidebarOptions{Collapsible: components.SidebarIcon, Collapsed: collapsed})
if f.Button(collapseID, "Toggle sidebar").Outline().Clicked() {
    collapsed = !collapsed
}
sidebar.AddMenuItem(components.SidebarMenuItem{ID: tree.ID(page, "overview"), Label: "Overview", Icon: "O"})

Installation

Copy the recipe into your own project.

Repository command
go run ./cmd/viva add --out ./components/local sidebar

Source-owned usage#

This preview calls the production Go component directly. Stable IDs, values and open state remain owned by the application; the component only paints and declares interaction semantics.

  • Read the linked component source for every option and visual decision.
  • Use the native command to verify system text, focus, accessibility and platform integration.
  • The browser preview validates shared layout and scene behavior, not native performance.

Verification boundary#

The examples cover representative states supported by the current API. They do not imply that every desktop backend has completed hardware validation.

Keyboard

Use Tab to move between controls and Ctrl/⌘ K to search the catalog. Inside a preview, the Go runtime handles keyboard input.