Select
Displays a list of options for the user to pick from, triggered by a button.
Basic Example
Usage
Disabling
It is possible to disable individual items in a select
using the disabled
prop associated with the rx.select.item
.
To prevent the user from interacting with select entirely, set the disabled
prop to True
on the rx.select.root
component.
Setting Defaults
It is possible to set several default values when constructing a select
.
The placeholder
prop in the rx.select.trigger
specifies the content that will be rendered when value
or default_value
is empty or not set.
The default_value
in the rx.select.root
specifies the value of the select
when initially rendered.
The default_value
should correspond to the value
of a child rx.select.item
.
Fully controlled
The on_change
event trigger is fired when the value of the select changes.
In this example the rx.select_root
value
prop specifies which item is selected, and this
can also be controlled using state and a button without direct interaction with the select component.
The open
prop and on_open_change
event trigger work similarly to value
and on_change
to control the open state of the select.
If on_open_change
handler does not alter the open
prop, the select will not be able to be opened or closed by clicking on the
select_trigger
.
Submitting a Form with Select
When a select is part of a form, the name
prop of the rx.select.root
sets the key that will be submitted with the form data.
The value
prop of rx.select.item
provides the value to be associated with the name
key when the form is submitted with that item selected.
When the required
prop of the rx.select.root
is True
, it indicates that the user must select a value before the form may be submitted.
Results
{}
Real World Example
Reflex Swag
$99
Reflex swag with a sense of nostalgia, as if they carry whispered tales of past adventures
Color
Size
API Reference
rx.select.trigger
The button that toggles the select.
Event Triggers
See the full list of default event triggersrx.select.group
Used to group multiple items.
Props
No component specific props
Event Triggers
See the full list of default event triggersrx.select.item
The component that contains the select items.
Event Triggers
See the full list of default event triggersrx.select.label
Used to render the label of a group, it isn't focusable using arrow keys.
Props
No component specific props
Event Triggers
See the full list of default event triggersrx.select.separator
Used to visually separate items in the Select.
Props
No component specific props