Bus UI Select

Choice lists with typed options and validation.

Use the select helper when the module needs a controlled dropdown with a stable selected option and the options themselves stay in Go data.

Component API

FunctionProps typeImport path
SelectSelectPropsgithub.com/busdk/bus-ui/pkg/ui

When to use it

Use the select node API when the control should render a finite set of options with one selected value. The public API is pkg/ui.

See also Field, Form, and Reference.

Example

Loading Select demo...

Go API

import (
  gx "github.com/busdk/bus-gx/pkg/gx"
  ui "github.com/busdk/bus-ui/pkg/ui"
)

node, err := ui.Select(ui.SelectProps{
  Name:     "status",
  Selected: "ready",
  Options: []ui.SelectOption{
    {ID: "ready", Label: "Ready"},
    {ID: "blocked", Label: "Blocked"},
  },
})
if err != nil {
  return err
}

html, err := gx.RenderHTML(node)

.gx source

In .gx source, author the visible component state as GX markup. Keep the Go API block above for the package helper or render-boundary call.

package busuiexamples

import gx "github.com/busdk/bus-gx/pkg/gx"

func SelectExample() gx.Node {
  return <label class="field" for="state">
  <Text value={"State"}></Text>
  <select id="state" name="state" value="ready">
    <option value="ready" selected><Text value={"Ready"}></Text></option>
  </select>
</label>
}