Client-mode comboboxes toggle entirely in the browser (no HTTP on open/select); server-mode keeps an HTMX lazy/search path for options that can't be pre-rendered.
DefaultRendered example
Technology
Healthcare
Finance
Retail
Education
Usage Example
// Client mode: options are pre-rendered, toggling happens in the browser.varIndustryCfg=combobox.Config{ID:"industry",Name:"industry",Label:"Industry",Mode:combobox.ModeSingle,Source:combobox.Source{Static:industryOptions},}@combobox.Combobox(IndustryCfg,combobox.State{Options:IndustryCfg.Source.Static})
Client Multi-Select
Mode: combobox.ModeMultiple with EnableClearAll — still fully client-side.
Use a non-empty LazyEndpoint to select server mode, then set Toggle/Options/Clear endpoints for HTMX selection, search, and clearing. The current LazyEndpoint value is a mode marker; OptionsEndpoint is the URL actually requested.
DependsOn adds other fields to combobox HTMX requests. Add an hx-get on the parent field when changing it should immediately refresh the dependent options.
Cascading Server FiltersRendered example
No matches found
Cascading Server Filters
selectedProvider:="aws"varClusterCfg=combobox.Config{ID:"cluster",Name:"cluster",Mode:combobox.ModeSingle,EnableSearch:true,DependsOn:[]string{"provider"},ToggleEndpoint:"/api/.../clusters/toggle",OptionsEndpoint:"/api/.../clusters/options",ClearEndpoint:"/api/.../clusters/clear",Source:combobox.Source{LazyEndpoint:"/api/.../clusters/options"},}// OptionsProvider receives search and deps["provider"] on the server.clustersProvider:=func(ctxcontext.Context,searchstring,depsmap[string]string)([]combobox.Option,error){returnclustersForProvider(deps["provider"],search)}<selectname="provider"hx-get={ClusterCfg.OptionsEndpoint}hx-trigger="change"hx-target="#cluster-options"hx-swap="outerHTML"hx-include="#cluster [data-combobox-search], #cluster input[type=hidden]"><optionvalue={selectedProvider}>AWS</option></select>@combobox.Combobox(ClusterCfg,combobox.State{})
Go API
v0.2.7
The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.
Goshtoso can store preferences and demo state in your browser. Some examples use cookies and IndexedDB to persist local demo state. There is no analytics, advertising, or third-party tracking. You can use the site without storage, but preferences and some examples will reset or stop persisting. Details in our Privacy Policy.