Select

The Select feature enables users to choose an option from a list within a form field. By default, the first option in the list is displayed. However, you can also configure a different option to be pre-selected from the list.

TypeResource
DesignFigma
MobileMobile Storybook
CodeGitlab

Select Preview

Usage

import id.co.biofarma.binduiandroid.components.select.Select
  // options
  val options = listOf(
      DataOption("1", "Dokter Umum"),
      DataOption("2", "Dokter THT"),
      DataOption("3", "Dokter Gigi"),
      DataOption("4", "Dokter Bedah"),
      DataOption("5", "Dokter Penyakit Dalam"),
      DataOption("6", "Dokter Penyakit Luar"),
      DataOption("7", "Dokter Kulit"),
      DataOption("8", "Dokter Ahli Saraf")
  )
 
  // state selected options
  var selectedItems by remember { mutableStateOf(listOf<DataOption>()) }
 
  Select(
    type = "outline",
    required = true,
    label = "Pilih Spesialis",
    size = "md",
    radius = "sm",
    selectedOptions = selectedItems,
    placeholder = "Pilih Spesialis",
    disabled = false,
    helperText = "Helper text",
    errorMessage = "Field Spesialis Required",
    options = options,
    isError = false,
    multiselect = true,
    onChange = { selected ->
      selectedItems = if (selectedItems.contains(selected)) {
        selectedItems - selected
      } else {
        selectedItems + selected
      }
    }
  )

Examples

Variant

Use the variants outline, background, or underline to change style of the select.

Select Example Variant


Multiple (optional)

Use multiple to turn single into multiple select.

Select Example Multiple


Size

Use the size sm, md, or lg to change the size of the select.

Select Example Multiple


Radius

Use the radius sm, md, or lg to change the radius of the select.

Select Example Multiple


Props

PropsRequiredDefaultTypedescription
idtrue-stringA unique identifier for the select.
labelfalse-stringThe label text for the select.
typetrueoutlineoutline, background, underlineThe visual style variant type of the select.
sizetruemdsm, md, lgThe size of the select.
radiustruexsnone, xs, sm, md, lg, xl, fullCorner radius of the select.
optionsfalse-List<DataOption>A list of available options for selection. Each option is represented by a DataOption(id: String, label: String) object.
selectedOptionsfalse-List<DataOption>A list of pre-selected options. Used for multi-selection or default single selection.
multiselectfalsefalsebooleanIf true, select will be set to multiple select.
requiredtruefalsebooleanIf true, required state will be set for the select.
onChangetrue-(DataOption) -> Unit = {}A callback triggered when an option is selected. Receives the selected DataOption as a parameter.
placeholdertrue-stringPlacholder information to provide input select area information.
disabledfalsefalsebooleanIf true, select will be set to disabled state.
isErrorfalsefalsebooleanIf true, select will be set to error state.
helperTextfalse-stringHelper text information to provide select information.
errorMessagefalse-stringText displayed below the input when there is an error, indicating invalid select or a validation issue.
stylefalse-ModifierCustom styles for the select component.
BIND © Biofarma Innovate Next-level Design .