# Search Bar — React Native component for Expo

> Focus pops the magnifier and springs in Cancel; suggestions drop down below.

Search field with a soft focus halo: the magnifier pops on focus, Cancel slides in as the field springs narrower, the clear button scales in and a spinning arc shows loading. Suggestions drop down in an animated panel with recent / trending icons and the matching text in bold; a trailing slot fits a filter or mic button. The minimal variant expands from a round icon.

- Docs: https://expokit.in/docs/components/search-bar
- Tier: Free
- Also called: search input, search box, animated search bar
- Category: Inputs
- Platforms: iOS, Android, web
- Expo Go: yes, no development build needed
- npm dependencies: react-native-svg
- Uses ExpoKit items: kit
- Variants: With Suggestions, Live Results, Minimal, With Filter, Sizes

## Installation

Run once per project: `npx @expokit/cli@latest init` (shared theme + KitProvider). Then:

```bash
npx @expokit/cli@latest add search-bar
```

The CLI copies the source into your project (you own the code) and installs react-native-svg.

Import: `import { SearchBar } from "@/components/ui/search-bar";`

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"default" \| "filled" \| "minimal"` | `"default"` | Outlined pill, iOS grey field, or a round icon that expands into a field. |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | 34 / 44 / 56pt tall; font, icons, padding and radius scale too. |
| `value / defaultValue / onChangeText` | `string` | — | Controlled or uncontrolled query. |
| `loading` | `boolean` | `false` | Crossfades the magnifier into a spinning arc. |
| `showCancel` | `boolean` | `true (false for minimal)` | Slide a Cancel button in while searching. |
| `cancelLabel` | `string` | `labels.cancel` | Cancel button text. |
| `onCancel` | `() => void` | — | After Cancel clears the query and blurs. |
| `onClear` | `() => void` | — | After the clear button empties the query. |
| `align` | `"left" \| "right"` | `"left"` | Minimal only: where the collapsed icon rests. |
| `suggestions` | `{ key, label, hint?, icon?: 'recent' \| 'trending' \| 'search' }[]` | — | Shown in a dropdown panel while focused; the matching text is bolded. |
| `onSelectSuggestion` | `(item) => void` | — | Called after a suggestion is picked (the query is set to its label). |
| `filterSuggestions` | `boolean` | `true` | Filter suggestions by the query. Turn off to filter them yourself. |
| `maxSuggestions` | `number` | `6` | Most rows shown in the panel. |
| `trailing` | `ReactNode` | — | Rendered inside the field on the right, e.g. a filter or mic button. |
| `accent` | `string` | `theme accent` | Focus ring, caret and Cancel colour. |
| `style` | `StyleProp<ViewStyle>` | — | Style for the root view around the field, cancel button and suggestions. |
| `className` | `string` | — | Tailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides. |
| `…TextInputProps` | `` | — | placeholder, onSubmitEditing, autoFocus, … |

## Behaviour & accessibility

- **Motion**: On focus a halo glows and the magnifier pops; Cancel slides in as the field springs narrower and the clear button scales in. loading swaps the magnifier for a spinning arc.
- **Touch**: The 'minimal' variant rests as a round icon and expands into a full field when tapped. Picking a suggestion fills the query and dismisses the keyboard.
- **Screen readers**: The input has the search role, labelled by its placeholder. 'Clear search', Cancel and each suggestion are labelled buttons.
- **Web**: The browser outline is replaced by the border and halo, and the suggestion panel stays open a beat after blur so clicks land.

## FAQ

### How do I make a search input in React Native?

Use ExpoKit's Search Bar: run npx @expokit/cli@latest add search-bar in your Expo or React Native project and it copies a ready-made search input into your app as plain TypeScript you can edit. It works on iOS, Android and web, and in Expo Go.

### Does Search Bar work in Expo Go?

Yes. Search Bar runs in Expo Go on iOS and Android with no development build — its packages (react-native-svg) are all included in Expo Go.

### How do I add Search Bar to my Expo app?

Run npx @expokit/cli@latest add search-bar in your project. The CLI copies the component's source into your app and installs react-native-svg, so the code is yours to change.

### Is Search Bar free?

Yes. Search Bar is free: its full source is on this page and the CLI installs it without an account.

### Can I change how Search Bar looks?

Yes. It takes its colours, radius and light / dark mode from useKit(), so wrapping your app in <KitProvider accent radius> re-skins it with every other ExpoKit component. The code lives in your project, so you can also edit anything directly.

## More

- Live preview, variants and code: https://expokit.in/docs/components/search-bar
- Every ExpoKit component, screen, template and chart: https://expokit.in/llms.txt
- Install commands and props for every free component: https://expokit.in/llms-full.txt
- Pricing: https://expokit.in/pricing
