# Native Controls Native iOS controls provide built-in haptics, accessibility, and platform-appropriate styling. ## Switch Use for binary on/off settings. Has built-in haptics. ```tsx import { Switch } from "react-native"; import { useState } from "react"; const [enabled, setEnabled] = useState(false); ; ``` ### Customization ```tsx ``` ## Segmented Control Use for non-navigational tabs or mode selection. Avoid changing default colors. ```tsx import SegmentedControl from "@react-native-segmented-control/segmented-control"; import { useState } from "react"; const [index, setIndex] = useState(0); setIndex(nativeEvent.selectedSegmentIndex)} />; ``` ### Rules - Maximum 4 options — use a picker for more - Keep labels short (1-2 words) - Avoid custom colors — native styling adapts to dark mode ### With Icons (iOS 14+) ```tsx setIndex(nativeEvent.selectedSegmentIndex)} /> ``` ## Slider Continuous value selection. ```tsx import Slider from "@react-native-community/slider"; import { useState } from "react"; const [value, setValue] = useState(0.5); ; ``` ### Customization ```tsx ``` ### Discrete Steps ```tsx ``` ## Date/Time Picker Compact pickers with popovers. Has built-in haptics. ```tsx import DateTimePicker from "@react-native-community/datetimepicker"; import { useState } from "react"; const [date, setDate] = useState(new Date()); { if (selectedDate) setDate(selectedDate); }} mode="datetime" />; ``` ### Modes - `date` — Date only - `time` — Time only - `datetime` — Date and time ### Display Styles ```tsx // Compact inline (default) // Spinner wheel // Full calendar ``` ### Time Intervals ```tsx ``` ### Min/Max Dates ```tsx ``` ## Stepper Increment/decrement numeric values. ```tsx import { Stepper } from "react-native"; import { useState } from "react"; const [count, setCount] = useState(0); ; ``` ## TextInput Native text input with various keyboard types. ```tsx import { TextInput } from "react-native"; ``` ### Keyboard Types ```tsx // Email // Phone // Number // Password // Search ``` ### Multiline ```tsx ``` ## Picker (Wheel) For selection from many options (5+ items). ```tsx import { Picker } from "@react-native-picker/picker"; import { useState } from "react"; const [selected, setSelected] = useState("js"); ; ``` ## Best Practices - **Haptics**: Switch and DateTimePicker have built-in haptics — don't add extra - **Accessibility**: Native controls have proper accessibility labels by default - **Dark Mode**: Avoid custom colors — native styling adapts automatically - **Spacing**: Use consistent padding around controls (12-16pt) - **Labels**: Place labels above or to the left of controls - **Grouping**: Group related controls in sections with headers