Skip to content
프로젝트

anhtuank7c/react-native-search-box

GitHub에서 보기

소개

iOS 검색창에서 영감을 받은 간단하고 가벼우며 빠르고 유연한 애니메이션 검색창입니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

react-native-search-box

English | Tiếng Việt

An animated, iOS-style search bar for React Native. No dependencies, no native code. iOS, Android and web, with TypeScript types.

Documentation with live demos and copyable code →

Filter a list
Filter a list
Live search
Live search
Contacts
Contacts
Recent searches
Recent searches
In a header
In a header
Themed
Themed

Also: playground, hide on scroll, minimal, right to left.

Installation

npm install react-native-search-box

Works in Expo Go, needs no linking. React 16.8 and React Native 0.60 or later.

Usage

import { useState } from 'react';
import { FlatList, Text, View } from 'react-native';
import Search from 'react-native-search-box';

const cities = ['Berlin', 'Hà Nội', 'Paris', 'Tokyo'];

export default function App() {
  const [query, setQuery] = useState('');

  return (
    <View style={{ flex: 1 }}>
      <Search value={query} onChangeText={setQuery} />
      <FlatList
        data={cities.filter((city) => city.toLowerCase().includes(query.toLowerCase()))}
        keyboardShouldPersistTaps="handled"
        renderItem={({ item }) => <Text style={{ padding: 16 }}>{item}</Text>}
        keyExtractor={(city) => city}
      />
    </View>
  );
}

Search when typing stops

<Search searchDelay={350} onSearch={async (text) => setResults(await api.search(text))} />

Left aligned, without Cancel or animation

<Search placeholderAlign="left" showCancelButton={false} animated={false} />

In a row

<View style={{ flexDirection: 'row' }}>
  <Avatar />
  <Search containerStyle={{ flex: 1 }} />
</View>

Control it through a ref

const box = useRef<Search>(null);

await box.current?.focus('shoes');
await box.current?.search();

API

Group Props
Text value defaultValue placeholder cancelTitle autoFocus editable textInputProps
Behavior searchDelay showCancelButton useClearButton collapseOnBlur keyboardShouldPersist placeholderAlign animated animationDuration direction
Callback onChangeText onSearch onFocus onBlur onDelete onCancel (with before* / after*)
Style containerStyle inputStyle inputHeight backgroundColor iconSearch iconDelete …
Testing testID inputTestID cancelButtonTestID clearButtonTestID

Full reference: props, methods.

Upgrading from 0.0.20

Props, defaults and ref methods are kept. A few behaviors changed, see Migration and the changelog.

Help

Troubleshooting · Contributing · Security

License

MIT

관련 프로젝트 살펴보기

불러오는 중…