Skip to content

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

SearchBarExample.tsx
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

PillSearch.tsx
import { SearchBar } from '@masumdev/rn-ui';
<SearchBar
placeholder="Filter contacts..."
variant="outline"
shape="pill"
tone="accent"
cancelLabel="Done"
/>

Props API

PropTypeDefaultDescription
valuestring—Controlled input string value.
defaultValuestring""Uncontrolled initial search text.
onChangeText(text: string) => void—Callback invoked immediately on text change.
onSearchDebounced(query: string) => void—Debounced callback invoked after typing pauses.
debounceMsnumber300Delay 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.
loadingbooleanfalseDisplays an activity spinner in place of the clear button.
showCancelButtonbooleantrueAnimates in a cancel button when focused or populated.
cancelLabelstring"Cancel"Text label for the cancel button.
toneComponentTone"primary"Semantic color intent for focused border and cancel button.
variant"filled" | "outline" | "soft""filled"Visual structure and background styling.
sizeComponentSize"md"Size preset (sm, md, lg).
shapeComponentShape"rounded"Border radius shape (rounded, pill, square).
disabledbooleanfalseWhether the search bar interaction is disabled.
hapticbooleantrueEnable tactile feedback on clear and cancel actions.
glassbooleanfalseEnable translucent glassmorphism background styling.