Select creates a dropdown list of items with the selected item in closed view.
const Example = () => {
let [service, setService] = React.useState("");
return <VStack alignItems="center" space={4}>
<Select shadow={2} selectedValue={service} minWidth="200" accessibilityLabel="Choose Service" placeholder="Choose Service" _selectedItem={{
bg: "teal.600",
endIcon: <CheckIcon size="5" />
}} _light={{
bg: "coolGray.100",
_hover: {
bg: "coolGray.200"
},
_focus: {
bg: "coolGray.200:alpha.70"
}
}} _dark={{
bg: "coolGray.800",
_hover: {
bg: "coolGray.900"
},
_focus: {
bg: "coolGray.900:alpha.70"
}
}} onValueChange={itemValue => setService(itemValue)}>
<Select.Item shadow={2} label="UX Research" value="ux" />
<Select.Item shadow={2} label="Web Development" value="web" />
<Select.Item shadow={2} label="Cross Platform Development" value="cross" />
<Select.Item shadow={2} label="UI Designing" value="ui" />
<Select.Item shadow={2} label="Backend Development" value="backend" />
</Select>
</VStack>;
};
import { Select } from "native-base";
const Example = () => {
const [service, setService] = React.useState("");
return <Center>
<Box maxW="300">
<Select selectedValue={service} minWidth="200" accessibilityLabel="Choose Service" placeholder="Choose Service" _selectedItem={{
bg: "teal.600",
endIcon: <CheckIcon size="5" />
}} mt={1} onValueChange={itemValue => setService(itemValue)}>
<Select.Item label="UX Research" value="ux" />
<Select.Item label="Web Development" value="web" />
<Select.Item label="Cross Platform Development" value="cross" />
<Select.Item label="UI Designing" value="ui" />
<Select.Item label="Backend Development" value="backend" />
</Select>
</Box>
</Center>;
};
const Example = () => {
return <Center>
<FormControl w="3/4" maxW="300" isRequired isInvalid>
<FormControl.Label>Choose service</FormControl.Label>
<Select minWidth="200" accessibilityLabel="Choose Service" placeholder="Choose Service" _selectedItem={{
bg: "teal.600",
endIcon: <CheckIcon size={5} />
}} mt="1">
<Select.Item label="UX Research" value="ux" />
<Select.Item label="Web Development" value="web" />
<Select.Item label="Cross Platform Development" value="cross" />
<Select.Item label="UI Designing" value="ui" />
<Select.Item label="Backend Development" value="backend" />
</Select>
<FormControl.ErrorMessage leftIcon={<WarningOutlineIcon size="xs" />}>
Please make a selection!
</FormControl.ErrorMessage>
</FormControl>
</Center>;
};
Select implements
,
,
,
,
,
,
,
,
The placeholder that describes the Select.
The Selected Item text color.
Type: ResponsiveValue<"gray.300" | "muted.50" | "muted.800" | "text.500" | "text.400" | "muted.500" | "text.900" | "muted.200" | "muted.300" | "muted.400" | "text.50" | "text.600" | "muted.700" | ... 342 more ... | "tertiary.900">
The placeholder text color
Type: ResponsiveValue<"gray.300" | "muted.50" | "muted.800" | "text.500" | "text.400" | "muted.500" | "text.900" | "muted.200" | "muted.300" | "muted.400" | "text.50" | "text.600" | "muted.700" | ... 342 more ... | "tertiary.900">
Item props passed here will be passed to each Select.Item component.
Type: Partial<IButtonProps>
Item props passed here will be passed to the selected Select.Item component.
Type: Partial<IButtonProps>
Currently selected value. Useful for controlling the Select state
Callback to be invoked when Select value is changed
Type: (itemValue: string) => void
Whether Select is disabled
Whether Select is hovered
Whether Select is focused
If true, the focus ring of select will be visible.
If given, updates the dropdown Icon
If given, updates the dropdown Icon when opened
If given, updates the dropdown Icon when closed
Variant of the Select
Type: "outline" | "unstyled" | "rounded" | "filled" | "underlined"
Callback to be invoked when Select Dropdown or BottomSheet is opened.
Type: (nativeEvent: any) => void
Callback to be invoked when Select Dropdown or BottomSheet is closed.
Type: (nativeEvent: any) => void
props to be passed to underlying ActionSheet. Select uses ActionSheet underneath.
Type: Partial<IActionsheetProps>
props to be passed to underlying ActionSheet.Content. Select uses ActionSheet underneath.
Type: Partial<IActionsheetContentProps>
props to be passed to underlying Flatlist in ActionSheet.Content.
Type: Partial<IFlatListProps<any>>
Ref to be attached to the Select wrapper
Type: MutableRefObject<any>
SelectItem implements
,
,
,
,
,
,
,
,
,
,
The label which will be displayed.
The value to be used for the item. This is the value that will be returned on form submission.
NativeBase ships with a default theme for each component. Check out the default theme of the select
.
Info:
We can easily extend the select component theme using extendTheme function as described in the documentation .use native variant. Accessibility improvements on styled variant is in-progress.