io.select.single
Prompts the app user to select a single value from a set of provided values.
Usage
- TypeScript
- JavaScript
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;
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;
Props
- TypeScript
- JavaScript
defaultValue
Optional
string | number | boolean | Date | object
disabled
Optional
boolean
helpText
Optional
string
options
Required
(string | number | boolean | Date | object)[]
description
Optional
string
image
OptionalNew in 0.33.0
object
{
// a URL to the image
url?: string
// the image alt tag
alt?: string
// the size of the image
size?: "thumbnail" | "small" | "medium" | "large"
}
imageUrl
Optional
string
label
Required
string | number | boolean | Date
value
Required
string | number | boolean | Date
searchable
Optional
boolean
Returns
The selected option.
defaultValue
Optional
string | number | boolean | Date | object
disabled
Optional
boolean
helpText
Optional
string
options
Required
(string | number | boolean | Date | object)[]
description
Optional
string
image
OptionalNew in 0.33.0
object
{
// a URL to the image
url?: string
// the image alt tag
alt?: string
// the size of the image
size?: "thumbnail" | "small" | "medium" | "large"
}
imageUrl
Optional
string
label
Required
string | number | boolean | Date
value
Required
string | number | boolean | Date
searchable
Optional
boolean
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.
- TypeScript
- JavaScript
const currencyCode = await io.select.single("Currency", {
options: ["USD", "CAD", "EUR"],
defaultValue: "USD",
helpText: "Currency for this transaction",
});
const currencyCode = await io.select.single("Currency", {
options: ["USD", "CAD", "EUR"],
defaultValue: "USD",
helpText: "Currency for this transaction",
});