selectcomponent

package
v0.0.0-...-8815ff5 Latest Latest
Warning

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

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

Documentation

Overview

templ: version: v0.3.960

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Select

func Select(args SelectArgs) templ.Component

Select renders the main select wrapper with Datastar state management If Options are provided, it will automatically render the complete select UI

func SelectContent

func SelectContent(args SelectContentArgs) templ.Component

SelectContent - dropdown content container

func SelectGroup

func SelectGroup(args SelectGroupArgs) templ.Component

SelectGroup renders a group container for items

func SelectItem

func SelectItem(args SelectItemArgs) templ.Component

SelectItem - individual option in the select dropdown

func SelectLabel

func SelectLabel(args SelectLabelArgs) templ.Component

SelectLabel renders a label for a group of items

func SelectSeparator

func SelectSeparator(args SelectSeparatorArgs) templ.Component

SelectSeparator renders a visual separator between groups

func SelectTrigger

func SelectTrigger(args SelectTriggerArgs) templ.Component

SelectTrigger - button that opens/closes the select dropdown

func SelectValue

func SelectValue(args SelectValueArgs) templ.Component

SelectValue displays the currently selected value or placeholder

Types

type SelectArgs

type SelectArgs struct {
	// ID is used for scoping datastar signals
	ID string

	// Open controls whether the select is open (controlled)
	Open bool

	// DefaultOpen sets the initial open state (uncontrolled)
	DefaultOpen bool

	// Value is the current selected value
	Value string

	// DefaultValue is the initial value when uncontrolled
	DefaultValue string

	// Options is a slice of options to render automatically
	Options []SelectOptionArgs

	// Name for form submission
	Name string

	// Disabled makes the select non-interactive
	Disabled bool

	// Required for form validation
	Required bool

	// Placeholder text to show when no value is selected
	Placeholder string

	// OnChange is an optional Datastar expression to execute when value changes
	// Example: "@post('/api/update')"
	OnChange string

	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectArgs defines the properties for the main Select component

type SelectContentArgs

type SelectContentArgs struct {
	// ID must match the parent Select ID for signal scoping
	ID string

	// Position determines how the content is positioned relative to the trigger
	// Options: "item-aligned", "popper"
	Position string

	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectContentArgs defines the properties for the SelectContent component

type SelectContentHandler

type SelectContentHandler struct {
	// contains filtered or unexported fields
}

SelectContentHandler creates handlers for select content functionality

func NewSelectContentHandler

func NewSelectContentHandler(selectID string, signals *utils.SignalManager) *SelectContentHandler

NewSelectContentHandler creates a select content handler

func (*SelectContentHandler) BuildKeyboardHandler

func (s *SelectContentHandler) BuildKeyboardHandler() string

BuildKeyboardHandler creates the content keyboard navigation handler

type SelectGroupArgs

type SelectGroupArgs struct {
	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectGroupArgs defines the properties for the SelectGroup component

type SelectItemArgs

type SelectItemArgs struct {
	// ID must match the parent Select ID for signal scoping
	ID string

	// Value is the value of this item
	Value string

	// Index is the position of this item in the list (for keyboard navigation)
	Index int

	// Disabled makes the item non-selectable
	Disabled bool

	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectItemArgs defines the properties for the SelectItem component

type SelectItemHandler

type SelectItemHandler struct {
	// contains filtered or unexported fields
}

SelectItemHandler creates handlers for select item functionality

func NewSelectItemHandler

func NewSelectItemHandler(selectID, value string) *SelectItemHandler

NewSelectItemHandler creates a select item handler

func (*SelectItemHandler) BuildClickHandler

func (s *SelectItemHandler) BuildClickHandler() string

BuildClickHandler creates the item click handler

func (*SelectItemHandler) BuildKeyboardHandler

func (s *SelectItemHandler) BuildKeyboardHandler() string

BuildKeyboardHandler creates the item keyboard handler

type SelectLabelArgs

type SelectLabelArgs struct {
	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectLabelArgs defines the properties for the SelectLabel component

type SelectOptionArgs

type SelectOptionArgs struct {
	// Value is the value of this option
	Value string `json:"value"`

	// Label is the display text for this option
	Label string `json:"label"`

	// Disabled makes this option non-selectable
	Disabled bool `json:"disabled,omitempty"`

	// Group is the optional group name for this option
	Group string `json:"group,omitempty"`
}

SelectOptionArgs represents a single option in the select dropdown

type SelectSeparatorArgs

type SelectSeparatorArgs struct {
	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectSeparatorArgs defines the properties for the SelectSeparator component

type SelectSignals

type SelectSignals struct {
	Open        bool   `json:"open"`
	Value       string `json:"value"`
	Label       string `json:"label"`
	Highlighted int    `json:"highlighted"` // Index of currently highlighted item (-1 = none)
}

SelectSignals defines the signal structure for select components

type SelectTriggerArgs

type SelectTriggerArgs struct {
	// ID must match the parent Select ID for signal scoping
	ID string

	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes

	// Disabled makes the trigger non-interactive
	Disabled bool
}

SelectTriggerArgs defines the properties for the SelectTrigger component

type SelectTriggerHandler

type SelectTriggerHandler struct {
	// contains filtered or unexported fields
}

SelectTriggerHandler creates handlers for select trigger functionality

func NewSelectTriggerHandler

func NewSelectTriggerHandler(selectID string, signals *utils.SignalManager) *SelectTriggerHandler

NewSelectTriggerHandler creates a select trigger handler

func (*SelectTriggerHandler) BuildClickHandler

func (s *SelectTriggerHandler) BuildClickHandler() string

BuildClickHandler creates the trigger click handler

func (*SelectTriggerHandler) BuildKeyboardHandler

func (s *SelectTriggerHandler) BuildKeyboardHandler() string

BuildKeyboardHandler creates the trigger keyboard navigation handler

type SelectValueArgs

type SelectValueArgs struct {
	// ID must match the parent Select ID for signal scoping
	ID string

	// Placeholder text to show when no value is selected
	Placeholder string

	// Class allows additional CSS classes to be added
	Class string

	// Attributes allows additional HTML attributes to be added
	Attributes templ.Attributes
}

SelectValueArgs defines the properties for the SelectValue component

Jump to

Keyboard shortcuts

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