Select

Description

A dropdown of options, with a hidden input carrying what was chosen.

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. A bc_select_option(), a plain string, or a tag with role = "option" for one that carries its own markup.
placeholder String. Text shown while nothing is chosen.
name String. The name of the hidden input, defaulting to id.
id String. The ID for the select root. Trigger, popover and listbox IDs derive from it.
selected String or character vector. Initial value, or values in multiple mode.
disabled Bool. Whether the select is disabled.
invalid Bool. Whether to show the invalid state.
multiple Bool. Whether the listbox accepts several selections.
close_on_select Bool. Whether choosing closes the popover. Defaults to TRUE for a single select and FALSE for a multiple one.
class Vector of class names merged onto the trigger button, which is where the control's width is set.
aria_label String. Accessible name for the trigger, when nothing outside the control already labels it.

Value

A <div> tag of class select.

Details

Submits a string, or a JSON array when multiple = TRUE.

See Also

bc_select_option()

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"
)