Skip to main content

io.select.single

Prompts the app user to select a single value from a set of provided values.

Usage

const currency = await io.select.single("Currency", {
options: [
{
label: "US Dollar",
value: "USD",
},
{
label: "Canadian Dollar",
value: "CAD",
},
{
label: "Euro",
value: "EUR",
},
],
defaultValue: "USD",
helpText: "Currency for this transaction",
});

const currencyCode = currency.value;
interval.com

Props

defaultValueOptional string or objectDefault preselected option. Must be an item in defined options.
helpTextOptional stringSecondary label providing additional context for the selection.
optionsRequired array of strings or objectsArray of possible values to be selected.
searchableOptional booleanWhether the select should support filtering options via a search box.

Returns: The selected option.

Examples

String options

The options property can also be an array of strings, which is equivalent to objects with identical label and value properties with the string values. A string will be returned if this form is used.

const currencyCode = await io.select.single("Currency", {
options: ["USD", "CAD", "EUR"],
defaultValue: "USD",
helpText: "Currency for this transaction",
});
Did this section clearly explain what you wanted to learn?