Bỏ qua để đến nội dung

Tối giản

Căn trái, không nút Cancel, không animation.

Demo chạy thật, hãy bấm thử.Mở toàn màn hình ↗
  1. showCancelButton={false} giữ ô nhập rộng hết cỡ.
  2. placeholderAlign="left" đặt icon và placeholder sát mép đầu.
  3. animated={false} tắt animation.

Dùng

Đây chính là đoạn code đang chạy trong điện thoại. Chép vào app của bạn là dùng được.

example/demos/minimal.tsx
import { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Search from 'react-native-search-box';
export default function Minimal() {
const [query, setQuery] = useState('');
return (
<View style={styles.screen}>
<Text style={styles.title}>Notes</Text>
<Search
showCancelButton={false}
placeholderAlign="left"
animated={false}
backgroundColor="transparent"
placeholder="Search notes"
inputHeight={40}
inputStyle={styles.input}
searchIconExpandedMargin={18}
placeholderExpandedMargin={34}
onChangeText={setQuery}
onDelete={() => setQuery('')}
/>
<Text style={styles.text}>{query ? `Notes about “${query}”` : 'All notes'}</Text>
</View>
);
}
const styles = StyleSheet.create({
screen: { flex: 1, backgroundColor: '#fff', padding: 16 },
title: { fontSize: 28, fontWeight: '700', color: '#111', marginBottom: 8, marginLeft: 5 },
input: {
fontSize: 16,
color: '#111',
backgroundColor: '#fff',
borderWidth: 1,
borderColor: '#d1d5db',
borderRadius: 8,
},
text: { marginTop: 16, marginLeft: 5, color: '#6b7280' },
});