Skip to content

Select - Frameworks

A select is a form input component that lets users choose one option from a predefined list.

AndroidreleasedElementsreleasediOSreleasedReactreleasedVuereleased

Android

Syntax

kotlin
@Composable
fun WarpSelect(
    modifier: Modifier = Modifier,
    value: String,
    onValueChange: (String) -> Unit,
    label: String? = null,
    optionalLabel: String? = null,
    enabled: Boolean = true,
    placeholderText: String? = null,
    helpText: String? = null,
    items: List<String>? = null,
    readOnly: Boolean = false,
    expanded: Boolean = false,
    isError: Boolean = false
)

Basic usage

The Select component will show a dropdown list of String values which need to be provided with the items param. The chosen value will be returned in the onValueChange callback.

kotlin
var choice by remember { mutableStateOf("") }
WarpSelect(
    modifier = Modifier.padding(bottom = dimensions.space3),
    value = choice,
    onValueChange = { choice = it },
    label = "Label",
    placeholderText = "Select an option",
    items = listOf("One", "Two", "Three", "Four", "Five", "Six"),
    helpText = "Help text"
)

Visual options

Select can be displayed as read-only, disabled and in error mode

kotlin
var choice by remember { mutableStateOf("One") }
WarpSelect(
    modifier = Modifier.padding(bottom = dimensions.space3),
    value = choice,
    onValueChange = { choice = it },
    label = "Label",
    optionalLabel = "Optional",
    placeholderText = "Select an option",
    items = listOf("One", "Two", "Three", "Four", "Five", "Six"),
    helpText = "Help text",
    readOnly = true,
    isError = true,
    enabled = false
)

Legacy support

Not supported

Parameters

Required props

NameTypeDefaultDescription
valueStringThe text displayed currently in the select component
onValueChange(String) -> UnitLambda to be invoked when input value changes

Optional Props

NameTypeDefaultDescription
modifierModifierModifierModifier for the select component
labelStringnullThe text to display as the label above the select component
optionalLabelStringnullThe text to display next to the label above the select component
enabledBooleantrueSets the select component in disabled mode when false
readOnlyBooleanfalseSets the select component in read-only mode
placeholderTextStringnullText hint that occupies the select component when it is empty
helpTextStringnullThe text to display as the help text below the select component
isErrorBooleanfalseRenders the select component in an invalid state
itemsList?nullThe list of strings displayed in the select component menu

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system