components

package
v4.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package components holds the headless component templates that `gwc add` copies into your project. They are compiled here so the catalog never ships a broken component; on copy, only the package clause changes — you own the result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert

func Alert(parseProps AlertProps) ui.Node

Alert is an accessible status message implementing the WAI-ARIA alert pattern: a role="alert" region (with an aria-live politeness the screen reader announces) carrying a short, restyleable message. Copied into your repo by `gwc add alert` — you own it.

func Breadcrumb(parseProps BreadcrumbProps) ui.Node

Breadcrumb is an accessible navigation trail implementing the WAI-ARIA breadcrumb pattern: a <nav aria-label="Breadcrumb"> wrapping an ordered list of links, with the final entry marked aria-current="page" and rendered as plain text rather than a link. Copied into your repo by `gwc add breadcrumb`; restyle via the gwc-breadcrumb classes.

func Disclosure

func Disclosure(parseProps DisclosureProps) ui.Node

Disclosure is an accessible show/hide region implementing the WAI-ARIA disclosure pattern: a <button> carries aria-expanded and aria-controls pointing at a region whose visibility is driven by component state, so assistive technology always announces the correct expanded/collapsed state. Restyle freely via the gwc-disclosure classes — you own this file.

func Switch

func Switch(parseProps SwitchProps) ui.Node

Switch is an accessible on/off control implementing the WAI-ARIA switch pattern: a role="switch" button carrying aria-checked, toggled by click (and, natively, the space/enter a button already handles). It is controlled — render with On and handle OnToggle. Copied into your repo by `gwc add switch`; restyle via the gwc-switch classes.

func Tabs

func Tabs(parseProps TabsProps) ui.Node

Tabs implements the WAI-ARIA tabs pattern: a role="tablist" of role="tab" buttons — each with aria-selected, aria-controls, and a single roving tab stop (tabindex 0 on the active tab, -1 on the rest) — controlling role="tabpanel" regions linked back with aria-labelledby. Selection is click-driven here; to add arrow-key roving, wire the tab buttons through ui.UseCompositeNavigation. You own this file — restyle via the gwc-tabs classes.

Types

type AlertProps

type AlertProps struct {
	// Variant styles the alert (info/success/warning/danger); it is reflected as a class
	// and does not change semantics.
	Variant string
	// Title is an optional bold heading.
	Title string
	// Message is the alert body.
	Message string
	// Assertive escalates the live-region politeness for urgent alerts.
	Assertive bool
}

AlertProps configures an Alert.

type BreadcrumbProps struct {
	// Items are the trail, root first.
	Items []Crumb
}

BreadcrumbProps configures a Breadcrumb.

type Crumb

type Crumb struct {
	// Label is the visible text.
	Label string
	// Href is the link target; the last crumb usually has an empty Href (current page).
	Href string
}

Crumb is one breadcrumb entry.

type DisclosureProps

type DisclosureProps struct {
	// Summary is the always-visible trigger label.
	Summary string
	// DefaultOpen sets the initial expanded state.
	DefaultOpen bool
	// Children render inside the collapsible region.
	Children []ui.Node
}

DisclosureProps configures a Disclosure.

type SwitchProps

type SwitchProps struct {
	// Label is the accessible name of the switch.
	Label string
	// On is the current state (controlled by the parent).
	On bool
	// OnToggle is called with the requested next state when the user activates the switch.
	OnToggle func(parseNext bool)
	// Disabled greys out and blocks interaction.
	Disabled bool
}

SwitchProps configures a Switch.

type TabItem

type TabItem struct {
	// ID is a stable, unique identifier for the tab (used to link tab and panel).
	ID string
	// Label is the tab's button text.
	Label string
	// Content renders inside the tab's panel.
	Content []ui.Node
}

TabItem is one tab and its panel content.

type TabsProps

type TabsProps struct {
	// ID is the base id for the tablist.
	ID string
	// Tabs are the tabs, in order.
	Tabs []TabItem
	// DefaultIndex is the initially selected tab.
	DefaultIndex int
}

TabsProps configures a Tabs widget.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL