Skip to content

SheetPicker

The SheetPicker component presents a searchable list of options in a modal sheet, ideal for long lists.

import { SwiftUI } from '@mgcrea/react-native-swiftui';
const [selectedCountry, setSelectedCountry] = useState('us');
<SwiftUI.SheetPicker
label="Country"
selectedValue={selectedCountry}
options={[
{ value: 'us', label: 'United States' },
{ value: 'uk', label: 'United Kingdom' },
{ value: 'ca', label: 'Canada' },
// ... more options
]}
title="Select Country"
searchPlaceholder="Search countries"
onChange={setSelectedCountry}
/>
PropTypeDefaultDescription
labelstring-Field label
selectedValuestring-Currently selected value
optionsreadonly NativeSheetPickerOptionInput[]-Array of options
titlestring-Sheet title
searchPlaceholderstring-Search field placeholder
placeholderstring-Placeholder when no selection
autoDismissbooleantrueAuto-dismiss after selection
disabledbooleanfalseDisable picker
isPresentedboolean-Controlled presentation state
onChange(value: string) => void-Called when selection changes
onDismiss() => void-Called when sheet is dismissed
childrenReactNode-Custom trigger content

Options can be strings or objects:

// Simple strings
options={['Apple', 'Banana', 'Orange']}
// Labeled options
options={[
{ value: 'apple', label: 'Apple' },
{ value: 'banana', label: 'Banana' },
{ value: 'orange', label: 'Orange' },
]}
const [country, setCountry] = useState('');
<SwiftUI.Form>
<SwiftUI.Section header="Location">
<SwiftUI.SheetPicker
label="Country"
selectedValue={country}
options={countries}
title="Select Country"
searchPlaceholder="Search countries..."
placeholder="Choose a country"
onChange={setCountry}
/>
</SwiftUI.Section>
</SwiftUI.Form>
const categories = [
{ value: 'electronics', label: 'Electronics' },
{ value: 'clothing', label: 'Clothing & Apparel' },
{ value: 'home', label: 'Home & Garden' },
{ value: 'sports', label: 'Sports & Outdoors' },
{ value: 'books', label: 'Books & Media' },
{ value: 'toys', label: 'Toys & Games' },
];
const [category, setCategory] = useState('');
<SwiftUI.SheetPicker
label="Category"
selectedValue={category}
options={categories}
title="Select Category"
searchPlaceholder="Search categories"
onChange={setCategory}
/>

Keep sheet open after selection:

const [isOpen, setIsOpen] = useState(false);
const [selected, setSelected] = useState('');
<SwiftUI.SheetPicker
label="Select Multiple"
selectedValue={selected}
options={options}
isPresented={isOpen}
autoDismiss={false}
onChange={setSelected}
onDismiss={() => setIsOpen(false)}
/>

Ideal for long lists with search:

const fruits = [
'Apple', 'Apricot', 'Avocado', 'Banana', 'Blackberry',
'Blueberry', 'Cherry', 'Coconut', 'Cranberry', 'Date',
'Dragon Fruit', 'Fig', 'Grape', 'Grapefruit', 'Guava',
'Honeydew', 'Kiwi', 'Lemon', 'Lime', 'Lychee',
'Mango', 'Melon', 'Nectarine', 'Orange', 'Papaya',
'Passion Fruit', 'Peach', 'Pear', 'Pineapple', 'Plum',
'Pomegranate', 'Raspberry', 'Strawberry', 'Tangerine', 'Watermelon',
];
const [fruit, setFruit] = useState('');
<SwiftUI.SheetPicker
label="Favorite Fruit"
selectedValue={fruit}
options={fruits}
title="Choose a Fruit"
searchPlaceholder="Search fruits..."
placeholder="Select your favorite"
onChange={setFruit}
/>
<SwiftUI.SheetPicker
label="Region"
selectedValue="us"
options={regions}
disabled
onChange={() => {}}
/>
<SwiftUI.Form>
<SwiftUI.Section header="Shipping Address">
<SwiftUI.TextField
label="Street"
text={street}
onChange={setStreet}
/>
<SwiftUI.TextField
label="City"
text={city}
onChange={setCity}
/>
<SwiftUI.SheetPicker
label="State"
selectedValue={state}
options={usStates}
title="Select State"
searchPlaceholder="Search states"
onChange={setState}
/>
<SwiftUI.TextField
label="ZIP Code"
text={zip}
keyboardType="numberPad"
onChange={setZip}
/>
</SwiftUI.Section>
</SwiftUI.Form>