accordion

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package accordion provides collapsible accordion components following shadcn/ui patterns. Accordion uses Alpine.js Collapse plugin for smooth animations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accordion

func Accordion(children ...g.Node) g.Node

Accordion creates an accordion container

Example:

accordion.Accordion(
    accordion.WithType(accordion.TypeMultiple),
    accordion.Item("item1", "What is ForgeUI?",
        g.Text("A Go UI library...")),
    accordion.Item("item2", "How to install?",
        g.Text("Run go get...")),
)

func AccordionWithOptions

func AccordionWithOptions(opts []Option, children ...g.Node) g.Node

AccordionWithOptions creates accordion with custom options

func Item

func Item(id, title string, content ...g.Node) g.Node

Item creates an accordion item with trigger and content

Example:

accordion.Item("item1", "Question?", g.Text("Answer."))

Types

type AccordionProps

type AccordionProps struct {
	Type         Type
	Collapsible  bool // Allow closing all items (for single type)
	DefaultValue []string
	Class        string
	Attrs        []g.Node
}

AccordionProps defines accordion configuration

type Option

type Option func(*AccordionProps)

Option is a functional option for configuring accordion

func WithAttrs

func WithAttrs(attrs ...g.Node) Option

WithAttrs adds custom attributes

func WithClass

func WithClass(class string) Option

WithClass adds custom classes

func WithCollapsible

func WithCollapsible() Option

WithCollapsible allows closing all items

func WithDefaultValue

func WithDefaultValue(items ...string) Option

WithDefaultValue sets initially open items

func WithType

func WithType(t Type) Option

WithType sets the accordion type (single or multiple)

type Type

type Type string

Type defines accordion behavior

const (
	TypeSingle   Type = "single"   // Only one item can be open at a time
	TypeMultiple Type = "multiple" // Multiple items can be open
)

Jump to

Keyboard shortcuts

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