templUI Pro coming soon  

50% OFF Join Waitlist

Select Box

Dropdown control for choosing from predefined options.

Source
TailwindCSS
Vanilla JS

Installation

  1. Install the component

    templui add selectbox
  2. Add the JavaScript to your layout

    @selectbox.Script()
    @popover.Script()
    

    Call this template in your base layout file (e.g., in the <head> section).

Examples

With Label

Multiple

Multiple Pills

Disabled

Form

Select a fruit category.

A fruit selection is required.

API Reference

Required parameter
Hover for description

SelectBox

Root container for the select box component.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-
Multiple
bool
false

Trigger

Button that opens the select dropdown when clicked.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-
Name
string
-
Required
bool
false
Disabled
bool
false
HasError
bool
false
Multiple
bool
false
ShowPills
bool
false
SelectedCountText
string
-

Value

Display area for the selected value(s) or placeholder text.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-
Placeholder
string
-
Multiple
bool
false

Content

Dropdown container that holds the selectable options.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-
NoSearch
bool
false
SearchPlaceholder
string
-

Group

Container for grouping related select options together.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-

Label

Label text for a group of select options.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-

Item

Individual selectable option within the dropdown.

Name Type Default
ID
string
-
Class
string
-
Attributes
templ.Attributes
-
Value
string
-
Selected
bool
false
Disabled
bool
false