Large Title Header

A screen header with a large title.

Pro component

Requires all-access to use the source code

Apple
Apple
1

Add the following dependencies to your project:

2

Edit _layout.tsx:

Wrap the _layout.tsx in <KeyboardProvider> with the 2 boolean props of statusBarTranslucent and navigationBarTranslucent

~/app/_layout.tsx
    import '../global.css';
    import 'expo-dev-client';

    import { PortalHost } from '@rn-primitives/portal';
    import { StatusBar } from 'expo-status-bar';
+   import { KeyboardProvider } from 'react-native-keyboard-controller';   
    // YOUR_OTHER_IMPORTS

    import { useColorScheme, useInitialAndroidBarSync } from '~/lib/useColorScheme';
    import { NAV_THEME } from '~/theme';

    export {    
      // Catch any errors thrown by the Layout component.
      ErrorBoundary,
    } from 'expo-router';

    export default function RootLayout() {    
      useInitialAndroidBarSync();
      const { colorScheme, isDarkColorScheme } = useColorScheme();
    
      return (
        <>
          <StatusBar
            key={`root-status-bar-${isDarkColorScheme ? 'light' : 'dark'}`}
            style={isDarkColorScheme ? 'light' : 'dark'}
          />
+         <KeyboardProvider statusBarTranslucent navigationBarTranslucent>
              <NavThemeProvider value={NAV_THEME[colorScheme]}>
                 {/* YOUR_ROOT_NAVIGATOR */}
                 <PortalHost />
              </NavThemeProvider>
+          </KeyboardProvider>
        </>
      );
    }
import { Icon } from '@roninoss/icons';
import * as React from 'react';
import { Platform, View } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import Animated, { FadeIn, LinearTransition, ZoomOut } from 'react-native-reanimated';

import { Button } from '../~/components/nativewindui/Button';
import { LargeTitleHeader } from '~/components/nativewindui/LargeTitleHeader';
import { LargeTitleSearchBarRef } from '~/components/nativewindui/LargeTitleHeader/types';
import { Text } from '~/components/nativewindui/Text';
import { useColorScheme } from '~/lib/useColorScheme';

export default function LargeTitleHeaderScreen() {
  const { colors } = useColorScheme();
  const searchBarRef = React.useRef<LargeTitleSearchBarRef>(null);
  const [materialPreset, setMaterialPreset] = React.useState<'stack' | 'inline'>('stack');
  return (
    <>
      <LargeTitleHeader
        title="Large title"
        materialPreset={materialPreset}
        rightView={() => (
          <Button variant="plain" size="icon">
            <Icon size={24} name="account-circle-outline" color={colors.foreground} />
          </Button>
        )}
        searchBar={{
          ref: searchBarRef,
          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>
          ),
        }}
      />
      <Animated.ScrollView
        layout={LinearTransition}
        contentInsetAdjustmentBehavior="automatic"
        contentContainerClassName="flex-1 py-10 px-4 gap-12">
        <Button
          onPress={() => {
            searchBarRef.current?.focus();
          }}>
          <Text>Focus input</Text>
        </Button>
        {Platform.OS !== 'ios' && (
          <Button
            variant={materialPreset === 'inline' ? 'secondary' : 'tonal'}
            onPress={() => {
              setMaterialPreset((prev) => (prev === 'inline' ? 'stack' : 'inline'));
            }}>
            <Text>Switch to {materialPreset === 'inline' ? 'stack' : 'inline'}</Text>
          </Button>
        )}
      </Animated.ScrollView>
    </>
  );
}
Logo

Unlock All Pro Screens & Components

Elevate your app with powerful, native-feeling components and templates. Build faster with beautiful ready-to-use designs.

Get all-access

Usage

The Large Title 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 Large Title Header.

For help on how to nest navigators, check out Expo's documentation.

import { LargeTitleHeader } from '~/components/nativewindui/LargeTitleHeader';
<LargeTitleHeader title="Large title" />

Props

LargeTitleHeader

PropTypeDescription
iosBackButtonMenuEnabledbooleanEnables or disables the iOS back button menu.
iosBackButtonTitlestringTitle for the iOS back button.
iosBackButtonTitleVisiblebooleanDetermines if the iOS back button title is visible.
iosBlurEffectHeaderOptions["headerBlurEffect"] | "none"The blur effect for the iOS header. Default is "systemMaterial".
materialPreset'stack' | 'inline'Material design preset for the header layout.
materialTitleClassNamestringClass name for styling the Android title.
backVisiblebooleanDetermines if the back button is visible.
shadowVisiblebooleanControls the visibility of the shadow. For iOS, iosBlurEffect must be "none".
leftViewHeaderOptions["headerLeft"]Custom component for the left side of the header.
rightViewHeaderOptions["headerRight"]Custom component for the right side of the header.
shownbooleanControls the visibility of the header.
titlestringTitle text for the header.
backgroundColorstringBackground color for the header.
screenScreenOptionsOptions for screen navigation and presentation.
searchBarobjectOptions and configuration for the search bar within the header.
searchBar.iosCancelButtonTextstringText for the iOS search bar cancel button.
searchBar.iosHideWhenScrollingbooleanHides the search bar when scrolling on iOS.
searchBar.iosTintColorstringTint color for the iOS search bar.
searchBar.materialRightViewHeaderOptions["headerRight"]Custom component for the right side of the Android search bar.
searchBar.materialBlurOnSubmitbooleanBlurs the search bar when submitting input on Android.
searchBar.materialOnSubmitEditing((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | undefinedCallback function triggered when submitting input.
searchBar.autoCapitalizeNativeStackNavigationSearchBarOptions["autoCapitalize"]Configures the auto-capitalization behavior.
searchBar.inputTypeNativeStackNavigationSearchBarOptions["inputType"]Defines the input type for the search bar.
searchBar.onBlur() => voidCallback function triggered when the search bar loses focus.
searchBar.onCancelButtonPress() => voidCallback function triggered when the cancel button is pressed.
searchBar.onChangeText(text: string) => voidCallback function triggered when the text in the search bar changes.
searchBar.onFocus() => voidCallback function triggered when the search bar gains focus.
searchBar.onSearchButtonPress() => voidCallback function triggered when the search button is pressed.
searchBar.placeholderstringPlaceholder text for the search bar.
searchBar.refReact.RefObject<LargeTitleSearchBarRef>Reference to the search bar commands.
searchBar.textColorstringText color for the search bar input.
searchBar.contentReact.ReactNodeCustom content to display within the search bar.
© Ronin Technologies LLC 2024