list

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: 2 Imported by: 0

Documentation

Overview

Package list provides list components for displaying items in ordered or unordered lists with various styling options.

Basic Usage

list.List(
    list.ListItem(g.Text("Item 1")),
    list.ListItem(g.Text("Item 2")),
    list.ListItem(g.Text("Item 3")),
)

With Icons

list.List(
    list.Icons(),
    list.ListItem(
        icons.Check(),
        g.Text("Completed task"),
    ),
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(opts ...Option) func(...g.Node) g.Node

List creates an unordered list component.

Example:

list.List(list.Spaced())(
    list.ListItem(g.Text("First item")),
    list.ListItem(g.Text("Second item")),
)

func ListItem

func ListItem(opts ...ItemOption) func(...g.Node) g.Node

ListItem creates a list item component.

Example:

// Simple item
list.ListItem()(g.Text("Simple item"))

// Item with icon
list.ListItem()(
    icons.Check(),
    g.Text("Completed task"),
)

// Detailed item
list.ListItem(list.Detailed())(
    html.Div(
        html.Class("font-medium"),
        g.Text("Item title"),
    ),
    html.Div(
        html.Class("text-sm text-muted-foreground"),
        g.Text("Item description"),
    ),
)

// Card-style clickable item
list.ListItem(
    list.CardStyle(),
    list.WithItemOnClick("handleClick()"),
)(
    icons.User(),
    g.Text("User Name"),
    badge.Badge(g.Text("Admin")),
)

func OrderedList

func OrderedList(opts ...Option) func(...g.Node) g.Node

OrderedList creates an ordered (numbered) list component.

Example:

list.OrderedList(list.Spaced())(
    list.ListItem(g.Text("Step 1")),
    list.ListItem(g.Text("Step 2")),
)

Types

type ItemOption

type ItemOption func(*ItemProps)

ItemOption is a functional option for configuring the ListItem component.

func CardStyle

func CardStyle() ItemOption

CardStyle creates a card-style list item with border and padding.

func Clickable

func Clickable() ItemOption

Clickable makes the list item clickable with hover effects.

func Detailed

func Detailed() ItemOption

Detailed creates a list item with space for subtitle/description.

func Simple

func Simple() ItemOption

Simple creates a simple list item (default).

func WithItemAttr

func WithItemAttr(attrs ...g.Node) ItemOption

WithItemAttr adds custom HTML attributes to the list item.

func WithItemClass

func WithItemClass(class string) ItemOption

WithItemClass adds additional CSS classes to the list item.

func WithItemOnClick

func WithItemOnClick(handler string) ItemOption

WithItemOnClick adds a click handler to the list item.

func WithItemVariant

func WithItemVariant(variant ItemVariant) ItemOption

WithItemVariant sets the list item variant.

type ItemProps

type ItemProps struct {
	Variant   ItemVariant
	Class     string
	Clickable bool
	OnClick   string
	Attrs     []g.Node
}

ItemProps defines the properties for the ListItem component.

type ItemVariant

type ItemVariant string

ItemVariant represents the visual style of the list item.

const (
	ItemSimple   ItemVariant = "simple"   // Simple text item
	ItemDetailed ItemVariant = "detailed" // Item with subtitle
	ItemCard     ItemVariant = "card"     // Card-style item with border
)

type ListVariant

type ListVariant string

ListVariant represents the visual style of the list.

const (
	VariantBullets ListVariant = "bullets" // Default bullets
	VariantNone    ListVariant = "none"    // No markers
	VariantIcons   ListVariant = "icons"   // Icon markers
)

type Option

type Option func(*Props)

Option is a functional option for configuring the List component.

func Bullets

func Bullets() Option

Bullets displays the list with default bullet points.

func Icons

func Icons() Option

Icons displays the list with icon markers (provided by ListItem).

func None

func None() Option

None displays the list without markers.

func Spaced

func Spaced() Option

Spaced adds extra spacing between list items.

func WithAttr

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

WithAttr adds custom HTML attributes to the list.

func WithClass

func WithClass(class string) Option

WithClass adds additional CSS classes to the list.

func WithVariant

func WithVariant(variant ListVariant) Option

WithVariant sets the list variant.

type Props

type Props struct {
	Variant ListVariant
	Class   string
	Spaced  bool
	Attrs   []g.Node
}

Props defines the properties for the List component.

Jump to

Keyboard shortcuts

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