Skip to main content

Select

The Select widget provides a dropdown menu that allows users to choose one option from a list of choices.

States

StateTypeDefaultDescription
valueint32NoneCurrent selected option index

Properties

PropertyTypeDefaultDescription
labelstring""Label text displayed above the select
options[]string[]Array of option labels to display in the dropdown
placeholderstring""Placeholder text displayed when no option is selected
default_valueint32NoneInitial selected option index
requiredboolFalseWhether a selection is required
disabledboolFalseWhether the select is disabled

Examples

Basic Select

package main

import (
"github.com/trysourcetool/sourcetool-go"
"github.com/trysourcetool/sourcetool-go/selectbox"
)

func main() {
func page(ui sourcetool.UIBuilder) error {
// Create a basic select
selectbox := ui.Selectbox("Country", selectbox.Placeholder("Choose a country"), selectbox.Options("United States", "Canada", "United Kingdom", "Australia"))
}
}

Select with Default Value

// Create a select with a default value
selectbox := ui.Selectbox("Country", selectbox.Options("United States", "Canada", "United Kingdom", "Australia"), selectbox.DefaultValue("United States"))
  • MultiSelect - For selecting multiple options from a list
  • Radio - Alternative for selecting from a small set of visible options