Combobox

Description

Create a select you type into to filter its options.

Usage

bc_combobox(
  id,
  ...,
  placeholder = "",
  name = id,
  selected = "",
  empty = "No items found.",
  multiple = FALSE,
  auto_highlight = FALSE,
  disabled = FALSE,
  class = NULL,
  aria_label = NULL
)

Arguments

Argument Description
id String. The input ID. NULL uses a random ID.
... Options from bc_combobox_option() and bc_combobox_group(), or a character vector of values.
placeholder String. Text shown while empty.
name String. The form field name. Defaults to id.
selected Character vector. The starting value, or values when multiple = TRUE.
empty String. Text shown when no options match. Defaults to "No items found.".
multiple Bool. Whether the user can select several options. Defaults to FALSE.
auto_highlight Bool. Highlight the first matching option as the list opens or filters. Defaults to FALSE.
disabled Bool. Whether the input is disabled. Defaults to FALSE.
class Character vector. Extra CSS classes.
aria_label String. Accessible name for the combobox. Set it when there is no visible label, since the placeholder doesn't count.

Value

An htmltools tag.

Details

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

See Also

bc_combobox_option(), bc_combobox_group(), bc_combobox_separator()

Examples

bc_combobox(
  "framework",
  bc_combobox_option("Next.js"),
  bc_combobox_option("SvelteKit"),
  bc_combobox_option("Remix"),
  placeholder = "Select a framework",
  class = "w-60"
)