Pro component
Requires all-access to use the source code
npx expo install react-native-keyboard-controller
Wrap the _layout.tsx
in <KeyboardProvider>
with the 2 boolean props of statusBarTranslucent and navigationBarTranslucent
import { Icon } from '@roninoss/icons';
import { Link } from 'expo-router';
import * as React from 'react';
import { Platform, ScrollView, View } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import Animated, { FadeIn, ZoomOut } from 'react-native-reanimated';
import { AdaptiveSearchHeader } from '~/components/nativewindui/AdaptiveSearchHeader';
import { AdaptiveSearchBarRef } from '~/components/nativewindui/AdaptiveSearchHeader/types';
import { Button } from '../~/components/nativewindui/Button';
import { Text } from '~/components/nativewindui/Text';
import { useColorScheme } from '~/lib/useColorScheme';
export default function AdaptiveHeaderScreen() {
const { colors } = useColorScheme();
const searchBarRef = React.useRef<AdaptiveSearchBarRef>(null);
return (
<>
<AdaptiveSearchHeader
iosTitle="Title"
iosIsLargeTitle={false}
shadowVisible={false}
rightView={() => (
<Button variant="plain" size="icon">
<Icon size={24} name="account-circle-outline" color={colors.foreground} />
</Button>
)}
searchBar={{
ref: searchBarRef,
iosCancelButtonText: 'Abort',
onChangeText: (text) => {
console.log(text);
},
materialRightView() {
return (
<Animated.View entering={FadeIn} exiting={ZoomOut}>
<Button variant="plain" size="icon">
<Icon size={24} name="cog-outline" color={colors.foreground} />
</Button>
</Animated.View>
);
},
content: (
<KeyboardAwareScrollView
className="ios:bg-background/95"
contentContainerClassName="flex-1"
keyboardShouldPersistTaps="always">
<View className="flex-1 items-center justify-center">
<Text>Search bar content</Text>
</View>
</KeyboardAwareScrollView>
),
}}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
contentContainerClassName="flex-1 py-10 px-4 gap-12">
<Button
onPress={() => {
searchBarRef.current?.focus();
}}>
<Text>Focus input</Text>
</Button>
{Platform.OS !== 'ios' && (
<Link href="/" asChild>
<Button variant="plain">
<Text>Go home</Text>
</Button>
</Link>
)}
</ScrollView>
</>
);
}
Unlock All Pro Screens & Components
Elevate your app with powerful, native-feeling components and templates. Build faster with beautiful ready-to-use designs.
The Adaptive Search Header can only be used with screens that are part of a Stack Navigator.
If your screen is part of a different type of navigation (like a Tab or Drawer Navigator), you’ll need to place that screen inside a Stack Navigator to use the Adaptive Search Header.
For help on how to nest navigators, check out Expo's documentation.
import { AdaptiveSearchHeader } from '~/components/nativewindui/AdaptiveSearchHeader';
<AdaptiveSearchHeader iosTitle="Adaptive Search Header" />
AdaptiveSearchHeader
Prop | Type | Default | Description |
---|---|---|---|
iosIsLargeTitle | boolean | false | Whether the iOS large title style is used. |
iosBackButtonMenuEnabled | boolean | If the iOS back button menu is enabled. | |
iosBackButtonTitle | string | The title of the iOS back button. | |
iosBackButtonTitleVisible | boolean | Whether the iOS back button title is visible. | |
iosBackVisible | boolean | Whether the iOS back button is visible. | |
iosBlurEffect | 'systemMaterial' | 'none' | HeaderOptions['headerBlurEffect'] | 'systemMaterial' | The blur effect used on iOS. |
iosTitle | string | The title of the header on iOS. | |
materialUseSafeAreaTop | boolean | true | Whether to use the safe area top on Android. |
shadowVisible | boolean | Whether the shadow is visible. iOS requires iosBlurEffect to be set to "none". | |
leftView | HeaderOptions["headerLeft"] | Left view element for the header. | |
rightView | HeaderOptions["headerRight"] | Right view element for the header. | |
shown | boolean | Whether the header is shown. | |
backgroundColor | string | Background color of the header. | |
screen | ScreenOptions | Screen options to apply to the header. | |
searchBar | object | Options for the search bar. | |
searchBar.iosCancelButtonText | string | Text for the iOS cancel button in the search bar. | |
searchBar.iosHideWhenScrolling | boolean | Whether the iOS search bar hides when scrolling. | |
searchBar.iosTintColor | string | Tint color for the iOS search bar. | |
searchBar.materialRightView | HeaderOptions["headerRight"] | Right view element for the search bar on Android. | |
searchBar.materialBlurOnSubmit | boolean | Whether the search bar blurs on submit for Android. | |
searchBar.materialOnSubmitEditing | ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | Callback triggered on submit editing for the Android search bar. | |
searchBar.autoCapitalize | NativeStackNavigationSearchBarOptions["autoCapitalize"] | Auto-capitalize behavior for the search bar input. | |
searchBar.inputType | NativeStackNavigationSearchBarOptions["inputType"] | Input type for the search bar. | |
searchBar.onBlur | () => void | Callback triggered when the search bar loses focus. | |
searchBar.onCancelButtonPress | () => void | Callback triggered when the cancel button is pressed in the search bar. | |
searchBar.onChangeText | (text: string) => void | Callback triggered when the text changes in the search bar. | |
searchBar.onFocus | () => void | Callback triggered when the search bar gains focus. | |
searchBar.onSearchButtonPress | () => void | Callback triggered when the search button is pressed in the search bar. | |
searchBar.placeholder | string | Placeholder text for the search bar. | |
searchBar.ref | React.RefObject<AdaptiveSearchBarRef> | Ref object for the search bar. | |
searchBar.textColor | string | Text color for the search bar. | |
searchBar.content | React.ReactNode | Content to be rendered inside the search bar. |