React Native / Inputs
Select
Pick one option from a list too long for radios or a segmented control. The field opens a bottom sheet of options; choosing one closes it and puts screen reader focus back on the field, which reads the new value.
import { Select } from "@stylhero/native";
Example
import { useState } from "react";
import { Select } from "@stylhero/native";
function SelectExample() {
const [resolution, setResolution] = useState<"1080p" | "1440p" | "4k">();
return (
<Select
label="Resolution"
value={resolution}
onChange={setResolution}
options={[
{ value: "1080p", label: "1080p", description: "Most monitors" },
{ value: "1440p", label: "1440p" },
{ value: "4k", label: "4K", description: "Needs a high-end GPU" },
]}
/>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label required |
string |
- | Visible label, also read by screen readers. |
onChange required |
(value: T) => void |
- | |
options required |
SelectOption<T>[] |
- | |
bottomInset |
number |
- | Extra space under the options, e.g. the bottom safe-area inset. |
disabled |
boolean |
- | |
error |
string |
- | Error message. Turns the border red and is read with the field. |
hint |
string |
- | |
placeholder |
string |
"Choose…" |
Shown while nothing is chosen. Default "Choose…". |
sheetTitle |
string |
- | Title of the sheet of options. Default label. |
style |
StyleProp<ViewStyle> |
- | |
testID |
string |
- | |
value |
T |
- |
Types
type SelectOption<T extends string> = {
value: T;
label: string;
description?: string;
disabled?: boolean;
};
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap the field | Opens the sheet of options |
| Double-tap an option | Chooses it, closes the sheet and returns focus to the field |
Accessibility
- A button that reads its label and value ("Resolution, 1440p", or "Not chosen").
- The options are radios in a radio group, with each option's description as its hint.
- Screen readers stay inside it while it's open. Android back and the iOS escape gesture (two-finger Z) close it unless
dismissable={false}.
Generated from src/components/Select.tsx. Something wrong or missing? Open an issue.