类型 Sidebar

API 文档由 Go 源码生成,内容为英文。

type Sidebar struct {

	// top of the topmost footer, or 0 when there is none

	// a group or item has been added

}

Sidebar incrementally paints a compact application navigation rail. It owns only paint-time insertion coordinates; selection remains caller-owned.

Content flows down from the top like SidebarContent: AddHeader/title, then groups (AddGroup) of menu items (AddMenuItem, with AddSubMenu under an item). Footers are reserved from the bottom edge and shrink the room above them.

构造函数

BeginSidebar#

func BeginSidebar(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, title string) Sidebar

BeginSidebar paints the neutral sidebar surface and optional product title.

BeginSidebarWithOptions#

func BeginSidebarWithOptions(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, title string, options SidebarOptions) Sidebar

BeginSidebarWithOptions paints the selected desktop surface and collapse state. Off-canvas collapsed sidebars emit no commands; icon collapse keeps a narrow rail and suppresses labels.

Floating is a rounded, ringed card inside a p-2 margin. Inset is the same margin around a plain surface: the card in that variant is the page content, which PaintSidebarInset paints.

方法

AddFooter#

func (sidebar *Sidebar) AddFooter(height float32) ui.Rect

AddFooter reserves SidebarFooter: a p-2 padded block of the given content height against the bottom edge, above any footer added before it. It returns the content rectangle and leaves less room for the content above.

AddFooterMenuItem#

func (sidebar *Sidebar) AddFooterMenuItem(item SidebarMenuItem) ui.Rect

AddFooterMenuItem paints one menu item as a footer, against the bottom edge or above the footers added before it, without changing the insertion point for ordinary menu content.

AddGroup#

func (sidebar *Sidebar) AddGroup(label string)

AddGroup paints a SidebarGroupLabel: a 32px, medium-weight caption at 70% foreground, without transforming caller text, preserving localization and acronyms exactly. A group that follows other content is separated from it by the groups' p-2 and the content's gap-2.

AddHeader#

func (sidebar *Sidebar) AddHeader(height float32) ui.Rect

AddHeader reserves SidebarHeader: a p-2 padded block of the given content height at the top. It returns the content rectangle for the caller to fill (a team switcher, a logo) and moves the insertion point below it.

AddItem#

func (sidebar *Sidebar) AddItem(id ui.ID, label, trailing string, selected, disabled bool) ui.Rect

AddItem paints one navigation destination. Selected items use a restrained blue accent; disabled items remain visible but emit no hit region.

AddMenuItem#

func (sidebar *Sidebar) AddMenuItem(item SidebarMenuItem) ui.Rect

AddMenuItem paints full Base UI menu-button state and size variants.

AddSeparator#

func (sidebar *Sidebar) AddSeparator()

AddSeparator inserts a SidebarSeparator: a divider inset by mx-2.

AddSubMenu#

func (sidebar *Sidebar) AddSubMenu(items []SidebarSubItem) ui.Rect

AddSubMenu paints SidebarMenuSub under the item just added: a one pixel rule indented from the menu with 28px buttons beside it. It returns the rectangle the sub menu occupies. Icon-collapsed sidebars hide sub menus.