SearchBar
SearchBar provides an integrated search input featuring built-in debounced callbacks, an animated clear button, loading spinner states, and a smooth iOS/Material style cancel button transition.
Usage
import { useState } from 'react';import { SearchBar } from '@masumdev/rn-ui';
export function SearchBarExample() { const [query, setQuery] = useState('');
return ( <SearchBar placeholder="Search documents or members..." value={query} onChangeText={setQuery} onSearchDebounced={(cleanQuery) => console.log('Searching for:', cleanQuery)} debounceMs={300} showCancelButton /> );}Pill Outline Variant
import { SearchBar } from '@masumdev/rn-ui';
<SearchBar placeholder="Filter contacts..." variant="outline" shape="pill" tone="accent" cancelLabel="Done"/>Props API
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Controlled input string value. |
defaultValue | string | "" | Uncontrolled initial search text. |
onChangeText | (text: string) => void | — | Callback invoked immediately on text change. |
onSearchDebounced | (query: string) => void | — | Debounced callback invoked after typing pauses. |
debounceMs | number | 300 | Delay in milliseconds for debounced callback. |
onClear | () => void | — | Callback fired when the clear button is pressed. |
onCancel | () => void | — | Callback fired when the cancel button is pressed. |
loading | boolean | false | Displays an activity spinner in place of the clear button. |
showCancelButton | boolean | true | Animates in a cancel button when focused or populated. |
cancelLabel | string | "Cancel" | Text label for the cancel button. |
tone | ComponentTone | "primary" | Semantic color intent for focused border and cancel button. |
variant | "filled" | "outline" | "soft" | "filled" | Visual structure and background styling. |
size | ComponentSize | "md" | Size preset (sm, md, lg). |
shape | ComponentShape | "rounded" | Border radius shape (rounded, pill, square). |
disabled | boolean | false | Whether the search bar interaction is disabled. |
haptic | boolean | true | Enable tactile feedback on clear and cancel actions. |
glass | boolean | false | Enable translucent glassmorphism background styling. |