selectc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package selectc provides select dropdown components matching shadcn/ui design.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NativeSelect

func NativeSelect(options []NativeSelectOption, opts ...SelectOption) g.Node

NativeSelect creates a native HTML select dropdown (for simpler use cases) This uses the browser's native select with custom styling

Example:

selectc.NativeSelect(
    []selectc.NativeSelectOption{
        {Value: "us", Label: "United States"},
        {Value: "uk", Label: "United Kingdom", Selected: true},
    },
    selectc.WithName("country"),
)

func Select

func Select(opts []SelectOption, children ...g.Node) g.Node

Select creates an interactive select dropdown using Alpine.js This provides a custom styled select with full keyboard navigation

Example:

selectc.Select(
    []selectc.SelectOption{selectc.WithName("country")},
    selectc.SelectTrigger(
        selectc.SelectValue("Select a country"),
    ),
    selectc.SelectContent(
        selectc.SelectItem("us", "United States"),
        selectc.SelectItem("uk", "United Kingdom"),
    ),
)

func SelectContent

func SelectContent(opts []SelectContentOption, children ...g.Node) g.Node

SelectContent creates the dropdown content container

Example:

selectc.SelectContent(
    nil,
    selectc.SelectItem("apple", "Apple"),
    selectc.SelectItem("banana", "Banana"),
)

func SelectGroup

func SelectGroup(children ...g.Node) g.Node

SelectGroup creates a group of related select items

Example:

selectc.SelectGroup(
    selectc.SelectLabel("Fruits"),
    selectc.SelectItem("apple", "Apple"),
    selectc.SelectItem("banana", "Banana"),
)

func SelectItem

func SelectItem(value string, label string, opts []SelectItemOption) g.Node

SelectItem creates a selectable option within the dropdown

Example:

selectc.SelectItem("us", "United States", nil)
selectc.SelectItem("uk", "United Kingdom", []selectc.SelectItemOption{selectc.WithItemDisabled()})

func SelectLabel

func SelectLabel(text string, attrs ...g.Node) g.Node

SelectLabel creates a label for a select group

Example:

selectc.SelectLabel("Fruits")

func SelectSeparator

func SelectSeparator(attrs ...g.Node) g.Node

SelectSeparator creates a visual separator between items

Example:

selectc.SelectSeparator()

func SelectTrigger

func SelectTrigger(opts []SelectTriggerOption, children ...g.Node) g.Node

SelectTrigger creates the button that opens the select dropdown

Example:

selectc.SelectTrigger(
    []selectc.SelectTriggerOption{selectc.WithTriggerSize(selectc.SelectSizeSm)},
    selectc.SelectValue("Select an option"),
)

func SelectValue

func SelectValue(placeholder string, attrs ...g.Node) g.Node

SelectValue creates the value display inside the trigger

Example:

selectc.SelectValue("Select a fruit...")

Types

type NativeSelectOption

type NativeSelectOption struct {
	Value    string
	Label    string
	Selected bool
	Disabled bool
}

NativeSelectOption defines a native select option

type SelectContentOption

type SelectContentOption func(*SelectContentProps)

SelectContentOption is a functional option for SelectContent

func WithContentAlign

func WithContentAlign(align string) SelectContentOption

WithContentAlign sets the content alignment

func WithContentAttrs

func WithContentAttrs(attrs ...g.Node) SelectContentOption

WithContentAttrs adds custom attributes to the content

func WithContentClass

func WithContentClass(class string) SelectContentOption

WithContentClass adds custom classes to the content

func WithContentPosition

func WithContentPosition(position string) SelectContentOption

WithContentPosition sets the content position

type SelectContentProps

type SelectContentProps struct {
	Position string // "item-aligned" or "popper"
	Align    string // "start", "center", "end"
	Class    string
	Attrs    []g.Node
}

SelectContentProps defines the dropdown content configuration

type SelectItemOption

type SelectItemOption func(*SelectItemProps)

SelectItemOption is a functional option for SelectItem

func WithItemAttrs

func WithItemAttrs(attrs ...g.Node) SelectItemOption

WithItemAttrs adds custom attributes to the item

func WithItemClass

func WithItemClass(class string) SelectItemOption

WithItemClass adds custom classes to the item

func WithItemDisabled

func WithItemDisabled() SelectItemOption

WithItemDisabled disables the item

type SelectItemProps

type SelectItemProps struct {
	Disabled bool
	Class    string
	Attrs    []g.Node
}

SelectItemProps defines the item configuration

type SelectOption

type SelectOption func(*SelectProps)

SelectOption is a functional option for Select

func WithAttrs

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

WithAttrs adds custom attributes to the select

func WithClass

func WithClass(class string) SelectOption

WithClass adds custom classes to the select

func WithDefaultValue

func WithDefaultValue(value string) SelectOption

WithDefaultValue sets the default selected value

func WithDisabled

func WithDisabled() SelectOption

WithDisabled disables the select

func WithID

func WithID(id string) SelectOption

WithID sets the select ID

func WithName

func WithName(name string) SelectOption

WithName sets the select name for form submission

func WithRequired

func WithRequired() SelectOption

WithRequired makes the select required

type SelectProps

type SelectProps struct {
	Name         string
	ID           string
	DefaultValue string
	Disabled     bool
	Required     bool
	Class        string
	Attrs        []g.Node
}

SelectProps defines the select root configuration

type SelectSize

type SelectSize string

SelectSize defines the size variants for the select trigger

const (
	SelectSizeDefault SelectSize = "default"
	SelectSizeSm      SelectSize = "sm"
)

type SelectTriggerOption

type SelectTriggerOption func(*SelectTriggerProps)

SelectTriggerOption is a functional option for SelectTrigger

func WithTriggerAttrs

func WithTriggerAttrs(attrs ...g.Node) SelectTriggerOption

WithTriggerAttrs adds custom attributes to the trigger

func WithTriggerClass

func WithTriggerClass(class string) SelectTriggerOption

WithTriggerClass adds custom classes to the trigger

func WithTriggerSize

func WithTriggerSize(size SelectSize) SelectTriggerOption

WithTriggerSize sets the trigger size

type SelectTriggerProps

type SelectTriggerProps struct {
	Size  SelectSize
	Class string
	Attrs []g.Node
}

SelectTriggerProps defines the trigger button configuration

Jump to

Keyboard shortcuts

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