UIViews
Picker
Choose one value from a set of options.
A controlled picker. Each option is a view marked with tag; selection must match exactly one option's tag.
import { Modifier, Picker, Text, useState } from "onescript/views"
function ColorPicker() {
const [color, setColor] = useState("red")
return (
<Picker
label="Color"
selection={color}
onSelectionChange={setColor}
>
<Text modifier={Modifier.tag("red")}>Red</Text>
<Text modifier={Modifier.tag("blue")}>Blue</Text>
</Picker>
)
}| Prop | Type | Description |
|---|---|---|
selection | string | number | Tag of the selected option. |
onSelectionChange | (value) => void | Runs with the tag of the option the user chooses. |
label | ViewChild | Optional label. |
children | ViewChild | Options. Options can come from arrays, fragments, or components. |
Tags must be unique and selection must match one of them; otherwise rendering fails with an error. 1 and "1" are different tags.
Use pickerStyle to switch between menu, segmented, wheel, and other styles. Also accepts Modifiers. It is only available in App and Action view sessions; widgets reject it with an unsupported view type error.
How is this guide?
Last updated on