Select
Description
Create a dropdown for selecting one or more options.
Usage
bc_select(
...,
placeholder = NULL,
name = NULL,
id = NULL,
selected = NULL,
disabled = FALSE,
invalid = FALSE,
multiple = FALSE,
close_on_select = !multiple,
class = NULL,
aria_label = NULL
)
Arguments
| Argument | Description |
|---|---|
... |
Options from bc_select_option(), or a character vector of values. For custom content, pass a tag with role = "option". |
placeholder |
String. Text shown while nothing is chosen. |
name |
String. The form field name. Defaults to id. |
id |
String. The select's ID. Defaults to a random ID. |
selected |
Character vector. The starting value, or values when multiple = TRUE. Without it, a single select with no placeholder starts on its first option. |
disabled |
Bool. Whether the select is disabled. Defaults to FALSE. |
invalid |
Bool. Whether to show the invalid state. Defaults to FALSE. |
multiple |
Bool. Whether the user can select several options. Defaults to FALSE. |
close_on_select |
Bool. Whether selecting an option closes the list. Defaults to TRUE for a single select and FALSE for a multiple one. |
class |
Character vector. CSS classes for the select button. Set the width here, such as w-full. Defaults to w-[180px]. |
aria_label |
String. Accessible name for the select. Set it when there is no visible label. |
Value
An htmltools tag.
Details
Submits a string, or a JSON array when multiple = TRUE.
See Also
Examples
bc_select(
"Apple",
"Banana",
"Blueberry",
placeholder = "Select a fruit"
)
bc_select(
bc_select_option("light", "Light"),
bc_select_option("dark", "Dark"),
bc_select_option("system", "System"),
placeholder = "Theme",
name = "appearance",
selected = "dark"
)
bc_select(
"tank",
"healer",
"dps",
placeholder = "Any role",
multiple = TRUE,
selected = c("tank", "healer"),
class = "w-full"
)