Options organized under select.optgroup headings, with a disabled, hidden first option acting as a placeholder — the standard way to show placeholder text in a native select without a real empty value being selectable.
Props used:label on select.optgroup; value, disabled, hidden on select.option; id, name, default_value, wrapper_class_name on select.
Two selects grouped under a shared field.set with a field.legend, showing how selects compose inside a larger form section.
Props used:id, name, default_value, wrapper_class_name on select; value on select.option; html_for on field.label.
import reflex as rx
from components.ui.field import field
from components.ui.select import select
def select_form() -> rx.Component:
return field.set(
field.legend("Shipping details"),
field.group(
field.root(
field.label("Country", html_for="shipping-country"),
select(
select.option("United States", value="us"),
select.option("Canada", value="ca"),
select.option("United Kingdom", value="uk"),
select.option("Germany", value="de"),
id="shipping-country",
name="country",
default_value="us",
wrapper_class_name="w-full",
),
),
field.root(
field.label("Timezone", html_for="shipping-timezone"),
select(
select.option("Pacific Time (PT)", value="pt"),
select.option("Mountain Time (MT)", value="mt"),
select.option("Central Time (CT)", value="ct"),
select.option("Eastern Time (ET)", value="et"),
id="shipping-timezone",
name="timezone",
default_value="et",
wrapper_class_name="w-full",
),
),
),
class_name="mx-auto max-w-sm",
)
Disabled
A disabled select with a field.description explaining why it's locked. Disabling cascades visually to the whole control via the wrapper's has-[select:disabled] styling.
Props used:id, default_value, disabled, wrapper_class_name on select; value on select.option.
This field is currently locked.
import reflex as rx
from components.ui.field import field
from components.ui.select import select
def select_disabled() -> rx.Component:
return rx.el.div(
field.root(
field.label("Country", html_for="country-disabled"),
select(
select.option("United States", value="us"),
select.option("Canada", value="ca"),
select.option("Mexico", value="mx"),
id="country-disabled",
default_value="us",
disabled=True,
wrapper_class_name="w-full",
),
field.description("This field is currently locked."),
),
class_name="mx-auto max-w-sm",
)
API Reference
select
The main select component. Calling select(...) directly renders the native <select> wrapped in a positioning div with the chevron icon — select is itself callable (via NativeSelect.__call__), so no separate .root is needed.