Select
A select component displays a dropdown list of options for the user to pick one from. It's one of the most common form controls in web applications, use it whenever you need a user to choose a single value from a predefined list and screen space is limited.
Reflex's rx.select is a fully-featured, accessible dropdown built on Radix UI primitives. It works with simple option lists or full state-bound bindings, supports form integration, keyboard navigation, and works out-of-the-box on desktop and mobile.
When to Use Select
Use rx.select when:
- You have more than five options and need to save vertical space
- The user should choose exactly one option from a predefined list
- You want a consistent dropdown that matches your app's theme
Consider alternatives when:
- You have fewer than five options → use Radio Group for better visibility
- Users need to select multiple values → use Checkbox groups or a multi-select pattern
- Users should type a value rather than choose one → use Input
- You need hierarchical or searchable options → use the low-level Select API with custom content
Basic Usage
At its simplest, pass a list of string options. The component renders a dropdown button that opens a menu of choices.
The user can click the trigger button to open the dropdown and choose a different option.
Tracking the Selected Value
In most real apps, you need to react when the user selects a value, to filter data, update a chart, save to a database, or trigger another event. Bind the select to a State var using the value prop and an on_change event handler.
You selected:
appleThis is the most common pattern. Because the select is bound to a state var, the value always reflects what's stored there, you can update it from anywhere in your app, and the select will re-render automatically.
Setting a Default Value
If you just need the select to start with a specific option chosen, without tracking the user's choice in state, use default_value. This is the simplest pattern when you only care about the value at form submission time, or when you don't need the selected value to affect anything else in your app.
Placeholder Text
When you want the select to start empty, prompting the user to make a choice, omit default_value and provide a placeholder.
Dynamic Options from State
Real applications rarely have hardcoded options. More often, options come from a database, API, or calculated from other state. Pass a state var as the options list, and the dropdown updates whenever the list changes.
ExpandCollapse
Disabled State
To prevent user interaction, set disabled=True. The select renders with a muted appearance and cannot be opened.
To disable individual items rather than the whole select, use the low-level API and set disabled=True on specific rx.select.item components.
Using Select in a Form
Select components integrate cleanly with Reflex forms. The name prop sets the key used when the form is submitted, and required=True prevents submission until the user makes a choice.
Order Form
Results:
{}ExpandCollapse
For full details on building forms, validation, and submission handling, see the Form documentation.
Mapping Display Labels to Underlying Values
When your options have separate display labels and underlying values (e.g., a user ID for the value, a name for the label), use a computed var to map between them.
Selected user ID:
user_001ExpandCollapse
For native label/value separation in the dropdown itself, use the low-level Select API and pass value= and a display label child to each rx.select.item.
Using Select Inside a Dialog
When placing a select inside a Dialog or other portal-based container, set position="popper" on the select so the dropdown menu positions itself correctly above the overlay content.
React to Open and Close Events
Beyond on_change, the on_open_change event fires when the dropdown opens or closes. Use this to trigger analytics, prefetch data, or animate related UI.
The example below uses rx.cond to swap between two badges based on whether the dropdown is open.
Open count: 0
ClosedExpandCollapse
Common Patterns
Filtering a List Based on Selection
A classic use case, the select controls what data is displayed elsewhere on the page.
ExpandCollapse
Cascading Selects
When one select's options depend on another's value, a common pattern for country/state, category/subcategory, etc.
ExpandCollapse
Related Components
- Radio Group - inline single-selection for fewer than 5 options
- Checkbox - single or multi-selection with visible state
- Form - grouping selects with other inputs for submission
- Dialog - modal dialogs that can contain selects
- Low-level Select API - fine-grained control over trigger, content, and items
Related Concepts
- State Management - how Reflex components track and update values
- Event Handlers - understanding
on_change,on_open_change, and related triggers - Forms and Validation - building complete forms with typed, validated inputs
- Computed Vars - deriving values from state for dynamic options and lookups
API Reference
rx.select
High level wrapper for the Select component.
sizedisabledcolor_schemehigh_contrastvariantradiusProps
| Prop | Type | Description |
|---|---|---|
size | "1""2""3" | The size of the select trigger. |
default_value | str | The value that's selected when the dropdown first renders. Use this when you want the select to start with a specific option but don't need to track the user's choice in app state. The value must match one of the options in the list. If both |
value | str | The currently selected value of the dropdown. When set, the component reflects this value and you must update it via an |
default_open | bool | Whether the dropdown menu is open when the component first renders. |
open | bool | Controls whether the dropdown menu is currently open. When set, you must update this prop via an |
name | str | The name attribute used when the select is submitted as part of an HTML form. This becomes the key in the submitted form data. If omitted, the select's value won't be included in form submissions. See Forms for more on integrating selects with form validation and submission. |
disabled | bool | When |
required | bool | When |
items | Sequence | The items of the select. |
placeholder | str | The text shown in the trigger button when no option has been selected. |
label | str | The label of the select. |
color_scheme | "tomato""red""ruby""crimson""pink""plum""purple""violet""iris""indigo""blue""cyan""teal""jade""green""grass""brown""orange""sky""mint""lime""yellow""amber""gold""bronze""gray" | Overrides the theme's accent color for this specific select. Accepts any Reflex color token ( |
high_contrast | bool | When |
variant | "classic""surface""soft""ghost" | The visual style of the trigger button. |
radius | "none""small""medium""large""full" | The border radius of the trigger button. Inherits from the theme by default. Use |
width | str | The width of the select. |
position | "item-aligned""popper" | Controls how the dropdown menu positions itself relative to the trigger. |