selectbox

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SelectFixtures = gx.Fixtures[SelectProps]{
	"Plan":     {Name: "plan", Label: "Plan", Class: "w-48", Children: plans()},
	"Small":    {Name: "plan", Label: "Plan", Size: Sm, Class: "w-48", Children: plans()},
	"Fit":      {Name: "plan", Label: "Plan", Children: plans()},
	"Disabled": {Name: "plan", Label: "Plan", Class: "w-48", Attrs: gx.Attrs{gx.Bool("disabled", true)}, Children: SelectOption(SelectOptionProps{Value: "free", Children: gx.Text("Free")})},
	"Invalid":  {Name: "plan", Label: "Plan", Class: "w-48", Attrs: gx.Attrs{{Key: "aria-invalid", Value: "true"}}, Children: plans()},
	"Placeholder": {Name: "fruit", Label: "Fruit", Placeholder: "Select a fruit", Class: "w-48", Children: gx.Frag(
		SelectGroup(SelectGroupProps{Label: "Fruits", Children: gx.Frag(
			SelectOption(SelectOptionProps{Value: "apple", Children: gx.Text("Apple")}),
			SelectOption(SelectOptionProps{Value: "banana", Children: gx.Text("Banana")}),
		)}),
		SelectSeparator(SelectSeparatorProps{}),
		SelectGroup(SelectGroupProps{Label: "Vegetables", Children: gx.Frag(
			SelectOption(SelectOptionProps{Value: "carrot", Children: gx.Text("Carrot")}),
			SelectOption(SelectOptionProps{Value: "leek", Disabled: true, Children: gx.Text("Leek")}),
		)}),
	)},
}
View Source
var SelectGroupFixtures = gx.Fixtures[SelectGroupProps]{
	"Group": {Label: "Fruits", Children: gx.Frag(
		SelectOption(SelectOptionProps{Value: "apple", Children: gx.Text("Apple")}),
		SelectOption(SelectOptionProps{Value: "banana", Children: gx.Text("Banana")}),
	)},
}
View Source
var SelectOptionFixtures = gx.Fixtures[SelectOptionProps]{"Option": {Value: "free", Children: gx.Text("Free")}}
View Source
var SelectSeparatorFixtures = gx.Fixtures[SelectSeparatorProps]{"Default": {}}

Functions

func Select

func Select(p SelectProps) gx.Node

func SelectGroup

func SelectGroup(p SelectGroupProps) gx.Node

func SelectGroupWrap

func SelectGroupWrap(n gx.Node) gx.Node

SelectGroupWrap renders the group inside a select, as a page uses it.

func SelectOption

func SelectOption(p SelectOptionProps) gx.Node

func SelectOptionWrap

func SelectOptionWrap(n gx.Node) gx.Node

SelectOptionWrap renders the option inside a select, as a page uses it.

func SelectSeparator

func SelectSeparator(p SelectSeparatorProps) gx.Node

func SelectSeparatorWrap

func SelectSeparatorWrap(n gx.Node) gx.Node

SelectSeparatorWrap renders the separator between two options of a select.

Types

type SelectGroupProps

type SelectGroupProps struct {
	// Label is the visible name of the option group.
	Label string
	// Disabled disables every option of the group.
	Disabled bool
	// Children is the options of the group.
	Children gx.Node
}

type SelectOptionProps

type SelectOptionProps struct {
	// Value is the value the form submits when the option is selected.
	Value string
	// Selected selects the option for the first render.
	Selected bool
	// Disabled disables the option.
	Disabled bool
	// Children is the option label.
	Children gx.Node
}

type SelectProps

type SelectProps struct {
	// Name is the form field name.
	Name string
	// Label is the accessible name of the select.
	Label string
	// Size sets the height: Md or Sm.
	Size Size
	// Placeholder is the text of a disabled first option that shows while no value is selected. An
	// empty value renders no placeholder option.
	Placeholder string
	// Class adds classes to the root element.
	Class string
	// Children is the options of the select.
	Children gx.Node
	// Attrs adds HTML attributes to the select element.
	Attrs gx.Attrs
}

type SelectSeparatorProps

type SelectSeparatorProps struct {
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type Size

type Size string

Size is the height of a select.

const (
	Md Size = "default"
	Sm Size = "sm"
)

The sizes of selectbox.Select.

Jump to

Keyboard shortcuts

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