Skip to content

Right to left

Arabic, with the layout mirrored.

Live demo, try it.Open full screen ↗
  1. direction="rtl" mirrors the icon, the text, the clear button and Cancel.
  2. clearButtonAccessibilityLabel translates what a screen reader says.

Uses

This is the code running in the phone. Copy it into your app.

example/demos/rtl.tsx
import { useState } from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import Search from 'react-native-search-box';
const DISHES = ['كبسة', 'منسف', 'فلافل', 'حمص', 'تبولة', 'كنافة', 'شاورما', 'مقلوبة', 'فتوش', 'ملوخية'];
export default function Rtl() {
const [query, setQuery] = useState('');
const reset = () => setQuery('');
return (
<View style={styles.screen}>
<Search
direction="rtl"
backgroundColor="#f5f0e6"
titleCancelColor="#9a3412"
placeholder="بحث"
cancelTitle="إلغاء"
clearButtonAccessibilityLabel="مسح"
inputHeight={40}
inputBorderRadius={12}
inputStyle={styles.input}
searchIconExpandedMargin={16}
placeholderExpandedMargin={32}
onChangeText={setQuery}
onDelete={reset}
onCancel={reset}
/>
<ScrollView keyboardShouldPersistTaps="handled">
{DISHES.filter((dish) => dish.includes(query.trim())).map((dish) => (
<Text key={dish} style={styles.row}>
{dish}
</Text>
))}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
screen: { flex: 1, backgroundColor: '#fffaf0' },
input: { fontSize: 16, color: '#431407' },
row: {
paddingVertical: 14,
marginHorizontal: 16,
fontSize: 18,
textAlign: 'right',
color: '#431407',
borderBottomWidth: 1,
borderColor: '#f0e6d2',
},
});