from typing import List
options: List[str] = ["Option 1", "Option 2", "Option 3"]
class SelectState(rx.State):
option: str = "No selection yet."
def index():
return rx.vstack(
rx.heading(SelectState.option),
rx.select(
options,
placeholder="Select an example.",
on_change=SelectState.set_option,
color_schemes="twitter",
),
)
from typing import List
options: List[str] = ["Option 1", "Option 2", "Option 3"]
class MultiSelectState(rx.State):
option: List[str] = []
def index():
return rx.vstack(
rx.heading(MultiSelectState.option),
rx.select(
options,
placeholder="Select examples",
is_multi=True,
on_change=MultiSelectState.set_option,
close_menu_on_select=False,
color_schemes="twitter",
),
)
rx.vstack(
rx.select(
options, placeholder="Select an example.", size="xs"
),
rx.select(
options, placeholder="Select an example.", size="sm"
),
rx.select(
options, placeholder="Select an example.", size="md"
),
rx.select(
options, placeholder="Select an example.", size="lg"
),
)
rx.vstack(
rx.select(
options,
placeholder="Select an example.",
variant="outline",
),
rx.select(
options,
placeholder="Select an example.",
variant="filled",
),
rx.select(
options,
placeholder="Select an example.",
variant="flushed",
),
rx.select(
options,
placeholder="Select an example.",
variant="unstyled",
),
)
rx.select(
options,
placeholder="Select an example.",
color="white",
bg="#68D391",
border_color="#38A169",
)
Select component is a component that allows users pick a value from predefined options. Ideally, it should be used when there are more than 5 options, otherwise you might consider using a radio group instead.