suiss/uim · Pattern

Search Picker

A select field that opens a drawer with a search box and a filtered, optionally grouped list of options.

Search Picker is an open-source mobile pattern from suiss/uim: components composed into a flow for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Search Picker on iOS in light mode

SearchPicker renders a field-style DrawerTrigger with the selected label and an up-down caret. Pressing it opens a Drawer with a search input and a scrollable list of options.

Typing filters options by label, case-insensitively. Options with a group are shown under a group heading. Choosing an option selects it, closes the drawer and clears the search. Use it when the list is too long to scan, such as countries, cities or frameworks.

Installation

$ pnpm dlx @esuiss/uim@latest add search-picker

The CLI also adds what it builds on: Drawer, Icon, Text.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Drawer, Icon, Text.

  2. Copy the source into components/patterns/search-picker.tsx:

uniwind/components/patterns/search-picker.tsx
import { cn } from "cn"
import {
  CaretUpDownIcon,
  CheckIcon,
  MagnifyingGlassIcon,
} from "phosphor-react-native"
import * as React from "react"
import {
  Pressable,
  ScrollView,
  TextInput,
  useWindowDimensions,
  View,
} from "react-native"
import {
  Drawer,
  1. Update the import paths to match your project.

Usage

import { SearchPicker } from "@/components/patterns/search-picker"
<SearchPicker items={frameworks} placeholder="Select a framework" searchPlaceholder="Search frameworks..." emptyText="No framework found." accessibilityLabel="Framework" className="w-56" />

Pass items as an array of { value, label, group?, disabled? }. The SearchPickerItem type is exported.

Use it uncontrolled with defaultValue, or controlled with value and onValueChange; the value is a string or null. emptyText shows when nothing matches.

Examples

With value

Starts with a preset selection via defaultValue.

iOS
Search Picker (with value) on iOS in light mode

Grouped

Cities grouped by country, with custom placeholders.

iOS
Search Picker (grouped) on iOS in light mode

With title

Adds a heading to the drawer with title.

iOS
Search Picker (with title) on iOS in light mode

With close button

Shows a close button in the drawer.

iOS
Search Picker (with close button) on iOS in light mode

With close label

Labels the close button Cancel with closeLabel.

iOS
Search Picker (with close label) on iOS in light mode

Disabled

A disabled field that cannot open the drawer.

iOS
Search Picker (disabled) on iOS in light mode

Invalid

Shows the error border and tint with invalid.

iOS
Search Picker (invalid) on iOS in light mode

Controlled

Holds the value in state and prints the selection below.

iOS
Search Picker (controlled) on iOS in light mode

Floating

Detaches the drawer from the screen edges.

iOS
Search Picker (floating) on iOS in light mode

API Reference

SearchPicker

PropType
About
The options, each with value, label and optional group and disabled.
Type
SearchPickerItem[]
Default
required
About
The selected value when controlled, or null.
Type
stringnull
Default
—
About
The initial value when uncontrolled.
Type
stringnull
Default
—
About
Called with the chosen value.
Type
(value: string | null) => void
Default
—
About
Text shown in the field when nothing is selected.
Type
string
Default
—
About
Placeholder and label of the search input. Defaults to Search....
Type
string
Default
"Search..."
About
Text shown when no option matches. Defaults to No results found..
Type
string
Default
"No results found."
About
Heading shown at the top of the drawer.
Type
string
Default
—
About
Prevents opening and dims the field.
Type
boolean
Default
—
About
Insets the drawer from the screen edges.
Type
boolean
Default
—
About
Shows a close button in the drawer. Defaults to false.
Type
boolean
Default
false
About
Label of the close button.
Type
string
Default
—
About
Applies the error border and background.
Type
boolean
Default
—
Type
string
Default
—
About
Label for the field.
Type
string
Default
—
About
Links the field to a visible label.
Type
string
Default
—

Accessibility

  • Each option is a button that exposes selected and disabled states.
  • Each group has the group role and is labelled by its name.
  • The search input is labelled by searchPlaceholder.
  • Without a title, the drawer is labelled by the placeholder or accessibilityLabel.

Notes

  • The list stays between 40% and 60% of the window height, and taps work while the keyboard is open.
  • The field uses bg-control, border-danger with a bg-danger tint when invalid, and bg-control-disabled when disabled; the tint is stronger in dark mode.
  • The search input disables autocorrect and autocapitalization.