Documentation
¶
Overview ¶
Package sidebar provides sidebar navigation components with provider pattern integration.
The sidebar uses ForgeUI's provider pattern for state management, allowing child components to access sidebar state without prop drilling.
Index ¶
- func Sidebar(children ...g.Node) g.Node
- func SidebarContent(children ...g.Node) g.Node
- func SidebarFooter(children ...g.Node) g.Node
- func SidebarGroup(children ...g.Node) g.Node
- func SidebarGroupAction(icon g.Node, label string) g.Node
- func SidebarGroupCollapsible(opts []SidebarGroupOption, children ...g.Node) g.Node
- func SidebarGroupContent(key string, children ...g.Node) g.Node
- func SidebarGroupLabel(text string, children ...g.Node) g.Node
- func SidebarGroupLabelCollapsible(key string, text string, icon g.Node) g.Node
- func SidebarHeader(children ...g.Node) g.Node
- func SidebarInput(placeholder string, name string, attrs ...g.Node) g.Node
- func SidebarInset(children ...g.Node) g.Node
- func SidebarInsetHeader(children ...g.Node) g.Node
- func SidebarLayout(children ...g.Node) g.Node
- func SidebarLayoutContent(children ...g.Node) g.Node
- func SidebarMenu(children ...g.Node) g.Node
- func SidebarMenuAction(icon g.Node, label string, attrs ...g.Node) g.Node
- func SidebarMenuBadge(text string) g.Node
- func SidebarMenuButton(label string, opts ...SidebarMenuButtonOption) g.Node
- func SidebarMenuItem(children ...g.Node) g.Node
- func SidebarMenuSub(children ...g.Node) g.Node
- func SidebarMenuSubButton(label string, href string, active bool) g.Node
- func SidebarMenuSubItem(children ...g.Node) g.Node
- func SidebarMenuTooltip(label string, children ...g.Node) g.Node
- func SidebarRail() g.Node
- func SidebarSeparator() g.Node
- func SidebarToggle() g.Node
- func SidebarTrigger() g.Node
- func SidebarTriggerDesktop() g.Node
- func SidebarWithOptions(opts []SidebarOption, children ...g.Node) g.Node
- type SidebarCollapsibleMode
- type SidebarGroupOption
- type SidebarGroupProps
- type SidebarMenuButtonOption
- func WithActive(active bool) SidebarMenuButtonOption
- func WithMenuActive() SidebarMenuButtonOption
- func WithMenuAsButton() SidebarMenuButtonOption
- func WithMenuAttrs(attrs ...g.Node) SidebarMenuButtonOption
- func WithMenuBadge(badge g.Node) SidebarMenuButtonOption
- func WithMenuClass(class string) SidebarMenuButtonOption
- func WithMenuHref(href string) SidebarMenuButtonOption
- func WithMenuIcon(icon g.Node) SidebarMenuButtonOption
- func WithMenuSize(size SidebarMenuButtonSize) SidebarMenuButtonOption
- func WithMenuTooltip(text string) SidebarMenuButtonOption
- func WithMenuVariant(variant SidebarMenuButtonVariant) SidebarMenuButtonOption
- type SidebarMenuButtonProps
- type SidebarMenuButtonSize
- type SidebarMenuButtonVariant
- type SidebarOption
- func WithCollapsible(collapsible bool) SidebarOption
- func WithCollapsibleMode(mode SidebarCollapsibleMode) SidebarOption
- func WithDefaultCollapsed(collapsed bool) SidebarOption
- func WithKeyboardShortcut(key string) SidebarOption
- func WithKeyboardShortcutEnabled(enabled bool) SidebarOption
- func WithPersistState(persist bool) SidebarOption
- func WithSide(side forgeui.Side) SidebarOption
- func WithSidebarAttrs(attrs ...g.Node) SidebarOption
- func WithSidebarClass(class string) SidebarOption
- func WithStorageKey(key string) SidebarOption
- func WithStorageType(storageType string) SidebarOption
- func WithVariant(variant SidebarVariant) SidebarOption
- type SidebarProps
- type SidebarVariant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sidebar ¶
Sidebar creates a collapsible sidebar navigation with Alpine.js stores.
The sidebar uses Alpine.js stores for state management, allowing any component on the page to access sidebar state via $store.sidebar. Use SidebarLayoutContent or SidebarInset to create content areas that react to sidebar state changes.
Example:
sidebar.Sidebar(
sidebar.SidebarHeader(g.Text("My App")),
sidebar.SidebarContent(
menu.Section("Main",
menu.Item("/dashboard", g.Text("Dashboard")),
menu.Item("/users", g.Text("Users")),
),
),
sidebar.SidebarFooter(g.Text("© 2024")),
)
func SidebarContent ¶
SidebarContent creates the main navigation area Matches shadcn sidebar-content styling
Example:
sidebar.SidebarContent(
menu.Section("Main",
menu.Item("/", g.Text("Home")),
),
)
func SidebarFooter ¶
SidebarFooter creates the sidebar footer section
Example:
sidebar.SidebarFooter(
menu.Item("#", g.Text("Settings")),
)
func SidebarGroup ¶
SidebarGroup creates a collapsible group within the sidebar
Example:
sidebar.SidebarGroup(
sidebar.SidebarGroupLabel("Projects"),
sidebar.SidebarMenu(...),
)
func SidebarGroupAction ¶
SidebarGroupAction creates an action button for a group (e.g., "Add Project")
Example:
sidebar.SidebarGroupAction(icons.Plus(), "Add Project")
func SidebarGroupCollapsible ¶
func SidebarGroupCollapsible(opts []SidebarGroupOption, children ...g.Node) g.Node
SidebarGroupCollapsible creates a collapsible group with animation
Example:
sidebar.SidebarGroupCollapsible(
[]SidebarGroupOption{sidebar.WithGroupKey("projects"), sidebar.WithGroupDefaultOpen(true)},
sidebar.SidebarGroupLabel("Projects"),
sidebar.SidebarMenu(...),
)
func SidebarGroupContent ¶
SidebarGroupContent wraps collapsible group content
Example:
sidebar.SidebarGroupContent("projects", sidebar.SidebarMenu(...))
func SidebarGroupLabel ¶
SidebarGroupLabel creates a label for a sidebar group Matches shadcn sidebar-group-label styling
Example:
sidebar.SidebarGroupLabel("Navigation")
func SidebarGroupLabelCollapsible ¶
SidebarGroupLabelCollapsible creates a clickable label for collapsible groups Matches shadcn sidebar-group-label styling with collapsible behavior
Example:
sidebar.SidebarGroupLabelCollapsible("projects", "Projects", icon)
func SidebarHeader ¶
SidebarHeader creates the sidebar header section
Example:
sidebar.SidebarHeader(
html.Img(g.Attr("src", "/logo.svg")),
g.Text("My App"),
)
func SidebarInput ¶
SidebarInput creates a search/filter input for the sidebar
Example:
sidebar.SidebarInput("Search...", "search-query")
func SidebarInset ¶
SidebarInset creates the main content area with proper layout Uses Alpine store to access sidebar state (works as sibling to Sidebar)
Example:
sidebar.SidebarInset(
sidebar.SidebarInsetHeader(...),
html.Main(...),
)
func SidebarInsetHeader ¶
SidebarInsetHeader creates a header with sidebar trigger and breadcrumbs
Example:
sidebar.SidebarInsetHeader(
sidebar.SidebarTrigger(),
breadcrumb.Breadcrumb(...),
)
func SidebarLayout ¶
SidebarLayout creates a layout wrapper that adjusts content for sidebar width
Example:
sidebar.SidebarLayout(
sidebar.Sidebar(...),
html.Main(...), // your content
)
func SidebarLayoutContent ¶
SidebarLayoutContent creates content area that respects sidebar width Uses Alpine store to access sidebar state (works as sibling to Sidebar)
Example:
sidebar.SidebarLayoutContent(
html.Div(...), // your page content
)
func SidebarMenu ¶
SidebarMenu creates a menu list container Matches shadcn sidebar-menu styling
Example:
sidebar.SidebarMenu(
sidebar.SidebarMenuItem(...),
)
func SidebarMenuAction ¶
SidebarMenuAction creates an action button that appears on hover
Example:
sidebar.SidebarMenuAction(icons.MoreVertical(), "Options")
func SidebarMenuBadge ¶
SidebarMenuBadge creates a badge for menu items
Example:
sidebar.SidebarMenuBadge("12")
func SidebarMenuButton ¶
func SidebarMenuButton(label string, opts ...SidebarMenuButtonOption) g.Node
SidebarMenuButton creates a menu button/link with icon and label
Example:
sidebar.SidebarMenuButton(
"Dashboard",
sidebar.WithMenuHref("/dashboard"),
sidebar.WithMenuIcon(icons.LayoutDashboard()),
sidebar.WithMenuActive(),
)
func SidebarMenuItem ¶
SidebarMenuItem creates a menu item container Matches shadcn sidebar-menu-item styling
Example:
sidebar.SidebarMenuItem(
sidebar.SidebarMenuButton(...),
)
func SidebarMenuSub ¶
SidebarMenuSub creates a submenu container Matches shadcn sidebar-menu-sub styling with border indicator
Example:
sidebar.SidebarMenuSub(
sidebar.SidebarMenuSubItem(...),
)
func SidebarMenuSubButton ¶
SidebarMenuSubButton creates a submenu button/link Matches shadcn sidebar-menu-sub-button styling
Example:
sidebar.SidebarMenuSubButton("Settings", "/settings", false)
func SidebarMenuSubItem ¶
SidebarMenuSubItem creates a submenu item Matches shadcn sidebar-menu-sub-item styling
Example:
sidebar.SidebarMenuSubItem(
sidebar.SidebarMenuSubButton(...),
)
func SidebarMenuTooltip ¶
SidebarMenuTooltip wraps a menu button with a tooltip that shows when sidebar is collapsed
Example:
sidebar.SidebarMenuTooltip("Dashboard",
sidebar.SidebarMenuButton("Dashboard", ...),
)
func SidebarRail ¶
SidebarRail creates an invisible rail for better collapse interaction Uses Alpine store for toggling
Example:
sidebar.SidebarRail()
func SidebarSeparator ¶
SidebarSeparator creates a visual separator in the sidebar
Example:
sidebar.SidebarSeparator()
func SidebarToggle ¶
SidebarToggle creates a collapse/expand toggle button
Example:
sidebar.SidebarToggle()
func SidebarTrigger ¶
SidebarTrigger creates a trigger button for mobile/desktop Uses Alpine store for toggling (works from anywhere on the page)
Example:
sidebar.SidebarTrigger()
func SidebarTriggerDesktop ¶
SidebarTriggerDesktop creates a desktop-only trigger Uses Alpine store for toggling (works from anywhere on the page)
Example:
sidebar.SidebarTriggerDesktop()
func SidebarWithOptions ¶
func SidebarWithOptions(opts []SidebarOption, children ...g.Node) g.Node
SidebarWithOptions creates sidebar with custom options and Alpine.js store integration
Types ¶
type SidebarCollapsibleMode ¶
type SidebarCollapsibleMode string
SidebarCollapsibleMode defines how the sidebar collapses
const ( CollapsibleOffcanvas SidebarCollapsibleMode = "offcanvas" // Slides off screen CollapsibleIcon SidebarCollapsibleMode = "icon" // Shrinks to icon only CollapsibleNone SidebarCollapsibleMode = "none" // Not collapsible )
type SidebarGroupOption ¶
type SidebarGroupOption func(*SidebarGroupProps)
SidebarGroupOption is a functional option for configuring collapsible sidebar groups
func WithGroupClass ¶
func WithGroupClass(class string) SidebarGroupOption
WithGroupClass adds custom classes
func WithGroupCollapsible ¶
func WithGroupCollapsible() SidebarGroupOption
WithGroupCollapsible makes the group collapsible
func WithGroupDefaultOpen ¶
func WithGroupDefaultOpen(open bool) SidebarGroupOption
WithGroupDefaultOpen sets the default open state
func WithGroupKey ¶
func WithGroupKey(key string) SidebarGroupOption
WithGroupKey sets a unique key for the collapsible state
type SidebarGroupProps ¶
type SidebarGroupProps struct {
Collapsible bool
DefaultOpen bool
CollapsibleKey string
Class string
}
SidebarGroupProps defines collapsible sidebar group configuration
type SidebarMenuButtonOption ¶
type SidebarMenuButtonOption func(*SidebarMenuButtonProps)
SidebarMenuButtonOption is a functional option for menu buttons
func WithActive ¶ added in v0.0.4
func WithActive(active bool) SidebarMenuButtonOption
WithActive marks the menu item as active
func WithMenuActive ¶
func WithMenuActive() SidebarMenuButtonOption
WithMenuActive marks the menu item as active
func WithMenuAsButton ¶
func WithMenuAsButton() SidebarMenuButtonOption
WithMenuAsButton renders as button instead of link
func WithMenuAttrs ¶
func WithMenuAttrs(attrs ...g.Node) SidebarMenuButtonOption
WithMenuAttrs adds custom attributes
func WithMenuBadge ¶
func WithMenuBadge(badge g.Node) SidebarMenuButtonOption
WithMenuBadge adds a badge to the menu button
func WithMenuClass ¶
func WithMenuClass(class string) SidebarMenuButtonOption
WithMenuClass adds custom classes
func WithMenuHref ¶
func WithMenuHref(href string) SidebarMenuButtonOption
WithMenuHref sets the link URL
func WithMenuIcon ¶
func WithMenuIcon(icon g.Node) SidebarMenuButtonOption
WithMenuIcon adds an icon to the menu button
func WithMenuSize ¶
func WithMenuSize(size SidebarMenuButtonSize) SidebarMenuButtonOption
WithMenuSize sets the menu button size
func WithMenuTooltip ¶
func WithMenuTooltip(text string) SidebarMenuButtonOption
WithMenuTooltip adds a tooltip for collapsed state
func WithMenuVariant ¶
func WithMenuVariant(variant SidebarMenuButtonVariant) SidebarMenuButtonOption
WithMenuVariant sets the menu button variant
type SidebarMenuButtonProps ¶
type SidebarMenuButtonProps struct {
Href string
Active bool
Icon g.Node
Badge g.Node
Tooltip string
AsButton bool
Variant SidebarMenuButtonVariant
Size SidebarMenuButtonSize
Class string
Attrs []g.Node
}
SidebarMenuButtonProps defines menu button configuration
type SidebarMenuButtonSize ¶
type SidebarMenuButtonSize string
SidebarMenuButtonSize defines menu button sizes
const ( MenuButtonSizeSmall SidebarMenuButtonSize = "sm" MenuButtonSizeDefault SidebarMenuButtonSize = "default" MenuButtonSizeLarge SidebarMenuButtonSize = "lg" )
type SidebarMenuButtonVariant ¶
type SidebarMenuButtonVariant string
SidebarMenuButtonVariant defines menu button visual styles
const ( MenuButtonDefault SidebarMenuButtonVariant = "default" MenuButtonOutline SidebarMenuButtonVariant = "outline" )
type SidebarOption ¶
type SidebarOption func(*SidebarProps)
SidebarOption is a functional option for configuring sidebar
func WithCollapsible ¶
func WithCollapsible(collapsible bool) SidebarOption
WithCollapsible allows sidebar to be collapsed
func WithCollapsibleMode ¶
func WithCollapsibleMode(mode SidebarCollapsibleMode) SidebarOption
WithCollapsibleMode sets how the sidebar collapses
func WithDefaultCollapsed ¶
func WithDefaultCollapsed(collapsed bool) SidebarOption
WithDefaultCollapsed sets initial collapsed state
func WithKeyboardShortcut ¶
func WithKeyboardShortcut(key string) SidebarOption
WithKeyboardShortcut enables keyboard shortcut and sets the key (default: "b" for Cmd/Ctrl+B)
func WithKeyboardShortcutEnabled ¶
func WithKeyboardShortcutEnabled(enabled bool) SidebarOption
WithKeyboardShortcutEnabled enables or disables keyboard shortcuts
func WithPersistState ¶
func WithPersistState(persist bool) SidebarOption
WithPersistState enables state persistence to localStorage/sessionStorage
func WithSide ¶
func WithSide(side forgeui.Side) SidebarOption
WithSide sets sidebar position (left or right)
func WithSidebarAttrs ¶
func WithSidebarAttrs(attrs ...g.Node) SidebarOption
WithSidebarAttrs adds custom attributes to sidebar
func WithSidebarClass ¶
func WithSidebarClass(class string) SidebarOption
WithSidebarClass adds custom classes to sidebar
func WithStorageKey ¶
func WithStorageKey(key string) SidebarOption
WithStorageKey sets a custom storage key for state persistence
func WithStorageType ¶
func WithStorageType(storageType string) SidebarOption
WithStorageType sets the storage type ("localStorage" or "sessionStorage")
func WithVariant ¶
func WithVariant(variant SidebarVariant) SidebarOption
WithVariant sets the visual variant of the sidebar
type SidebarProps ¶
type SidebarProps struct {
DefaultCollapsed bool
Collapsible bool
CollapsibleMode SidebarCollapsibleMode
Variant SidebarVariant
Side forgeui.Side
Class string
Attrs []g.Node
KeyboardShortcutKey string
KeyboardShortcutEnable bool
PersistState bool
StorageKey string
StorageType string // "localStorage" or "sessionStorage"
}
SidebarProps defines sidebar configuration
type SidebarVariant ¶
type SidebarVariant string
SidebarVariant defines the visual style of the sidebar
const ( SidebarVariantSidebar SidebarVariant = "sidebar" // Default sidebar SidebarVariantFloating SidebarVariant = "floating" // Floating sidebar with rounded corners SidebarVariantInset SidebarVariant = "inset" // Inset sidebar with margins )