Picker
A control for selecting from a set of mutually exclusive values.
Example​
- swiftui-react-native
- SwiftUI
const selection = useBinding('Option 1');
<Picker selection={selection}>
<Text>Option 1</Text>
<Text>Option 2</Text>
<Text>Option 3</Text>
</Picker>
@State var selection = ""
Picker("Select an option", selection: $selection) {
Text("Option 1")
Text("Option 2")
Text("Option 3")
}
Props​
Picker inherits all View Modifiers as props.
prop | description | type | required | default |
---|---|---|---|---|
selection | The selected value | string | yes | undefined |
onChange | Function to execute when a selection is made | (v: string) => void | no | undefined |