CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-navigation--elements

UI Components for React Navigation providing headers, buttons, and layout components with cross-platform support

Pending
Overview
Eval results
Files

header-components.mddocs/

Header Components

Complete header system providing customizable navigation bars, back buttons, titles, and action buttons with platform-specific styling and behavior optimizations for iOS, Android, and Web.

Capabilities

Header

Main header component that provides the complete navigation header with support for titles, back buttons, custom left/right actions, search bars, and background customization.

/**
 * Main header component for navigation screens
 * @param props - Header configuration options
 * @returns React element representing the complete header
 */
function Header(props: {
  /** Header title text (required) */
  title: string;
  /** Back button configuration */
  back?: { title: string | undefined; href: string | undefined };
  /** Whether header is in modal presentation */
  modal?: boolean;
  /** Screen layout dimensions */
  layout?: Layout;
} & HeaderOptions): React.ReactElement;

Usage Examples:

import { Header } from "@react-navigation/elements";

// Basic header
<Header title="Settings" />

// Header with back button
<Header 
  title="Profile" 
  back={{ title: "Settings" }}
/>

// Customized header
<Header
  title="Messages"
  headerTintColor="#007AFF"
  headerStyle={{ backgroundColor: "#f8f9fa" }}
  headerRight={({ tintColor }) => (
    <HeaderButton onPress={handleAddMessage}>
      <Icon name="plus" color={tintColor} />
    </HeaderButton>
  )}
/>

// Transparent header
<Header
  title="Photo"
  headerTransparent={true}
  headerBackground={() => (
    <HeaderBackground style={{ backgroundColor: 'rgba(255,255,255,0.9)' }} />
  )}
/>

HeaderButton

Generic header button component with platform-specific press effects, accessibility support, and customizable styling.

/**
 * Generic header button component with platform-specific press effects
 * @param props - Button configuration and content
 * @returns React element representing a header button
 */
const HeaderButton: React.ForwardRefExoticComponent<{
  /** Callback when button is pressed */
  onPress?: () => void;
  /** Web anchor href for link behavior */
  href?: string;
  /** Whether button is disabled */
  disabled?: boolean;
  /** Screen reader accessibility label */
  accessibilityLabel?: string;
  /** Test identifier for automated testing */
  testID?: string;
  /** Icon and text tint color */
  tintColor?: string;
  /** Android material ripple color (Android >= 5.0) */
  pressColor?: string;
  /** Press opacity fallback when ripple not supported */
  pressOpacity?: number;
  /** Custom button styling */
  style?: StyleProp<ViewStyle>;
  /** Button content (usually icon or text) */
  children: React.ReactNode;
}>;

Usage Examples:

import { HeaderButton } from "@react-navigation/elements";

// Icon button
<HeaderButton 
  onPress={() => setShowSearch(true)}
  accessibilityLabel="Search"
>
  <Icon name="search" />
</HeaderButton>

// Text button
<HeaderButton 
  onPress={handleSave}
  tintColor="#007AFF"
>
  <Text>Save</Text>
</HeaderButton>

// Disabled button
<HeaderButton 
  onPress={handleDelete}
  disabled={!canDelete}
  tintColor="#FF3B30"
>
  <Icon name="trash" />
</HeaderButton>

HeaderBackButton

Specialized back button with platform-specific behavior, adaptive label display, and support for custom back icons.

/**
 * Navigation back button with platform-specific styling and behavior
 * @param props - Back button configuration
 * @returns React element representing a back button
 */
function HeaderBackButton(props: {
  /** Callback when button is pressed */
  onPress?: () => void;
  /** Web anchor href for link behavior */
  href?: string;
  /** Whether button is disabled */
  disabled?: boolean;
  /** Screen reader accessibility label */
  accessibilityLabel?: string;
  /** Test identifier for automated testing */
  testID?: string;
  /** Icon and text tint color */
  tintColor?: string;
  /** Android material ripple color */
  pressColor?: string;
  /** Press opacity fallback */
  pressOpacity?: number;
  /** Custom button styling */
  style?: StyleProp<ViewStyle>;
  /** Custom back icon renderer */
  backImage?: (props: { tintColor: string }) => React.ReactNode;
  /** Button label text (usually previous screen title) */
  label?: string;
  /** Fallback label when space is limited */
  truncatedLabel?: string;
  /** How to display icon and title */
  displayMode?: HeaderBackButtonDisplayMode;
  /** Label text styling */
  labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
  /** Whether label font should scale for accessibility */
  allowFontScaling?: boolean;
  /** Label layout change callback */
  onLabelLayout?: (e: LayoutChangeEvent) => void;
  /** Screen layout dimensions */
  screenLayout?: Layout;
  /** Title layout dimensions */
  titleLayout?: Layout;
}): React.ReactElement;

Usage Examples:

import { HeaderBackButton } from "@react-navigation/elements";

// Standard back button
<HeaderBackButton 
  onPress={() => navigation.goBack()}
  label="Settings"
/>

// Minimal back button (icon only)
<HeaderBackButton 
  onPress={() => navigation.goBack()}
  displayMode="minimal"
/>

// Custom back icon
<HeaderBackButton 
  onPress={() => navigation.goBack()}
  backImage={({ tintColor }) => (
    <Icon name="arrow-left" color={tintColor} size={20} />
  )}
/>

// Custom styling
<HeaderBackButton 
  onPress={() => navigation.goBack()}
  label="Back"
  tintColor="#007AFF"
  labelStyle={{ fontSize: 16, fontWeight: 'bold' }}
/>

HeaderTitle

Header title component with platform-specific typography and automatic color theming.

/**
 * Header title component with platform-specific typography
 * @param props - Title configuration and styling
 * @returns React element representing the header title
 */
function HeaderTitle(props: {
  /** Title text content */
  children?: string;
  /** Whether title font should scale for accessibility */
  allowFontScaling?: boolean;
  /** Title text color */
  tintColor?: string;
  /** Title layout change callback */
  onLayout?: (e: LayoutChangeEvent) => void;
  /** Custom title styling */
  style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
} & Omit<TextProps, 'style'>): React.ReactElement;

Usage Examples:

import { HeaderTitle } from "@react-navigation/elements";

// Basic title
<HeaderTitle>My Screen</HeaderTitle>

// Styled title
<HeaderTitle 
  tintColor="#333"
  style={{ fontSize: 20, fontWeight: 'bold' }}
>
  Custom Title
</HeaderTitle>

// Title with layout tracking
<HeaderTitle 
  onLayout={(e) => setTitleWidth(e.nativeEvent.layout.width)}
>
  Dynamic Title
</HeaderTitle>

HeaderBackground

Customizable header background container for gradients, images, or blur effects.

/**
 * Header background container component
 * @param props - Background styling configuration
 * @returns React element representing the header background
 */
function HeaderBackground(props: {
  /** Custom background styling */
  style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
  /** Background content */
  children?: React.ReactNode;
}): React.ReactElement;

Usage Examples:

import { HeaderBackground } from "@react-navigation/elements";

// Gradient background
<HeaderBackground 
  style={{
    backgroundColor: 'transparent',
    background: 'linear-gradient(45deg, #ff6b6b, #4ecdc4)'
  }}
/>

// Image background
<HeaderBackground>
  <Image 
    source={{ uri: 'https://example.com/header-bg.jpg' }}
    style={{ width: '100%', height: '100%' }}
    resizeMode="cover"
  />
</HeaderBackground>

// Blur background
<HeaderBackground 
  style={{ backgroundColor: 'rgba(255,255,255,0.8)' }}
>
  <BlurView intensity={80} style={StyleSheet.absoluteFill} />
</HeaderBackground>

Platform-Specific Behavior

iOS

  • Large Titles: Support for iOS 11+ large title headers
  • Back Button: Automatic label display with previous screen title
  • Typography: Uses iOS system font with appropriate weights
  • Animation: Smooth masked view transitions for back button labels
  • Safe Area: Automatic handling of status bar and notch areas

Android

  • Material Design: Follows Material Design 3 guidelines
  • Ripple Effects: Native material ripple on header buttons
  • Typography: Uses Roboto font family with Material Design weights
  • Elevation: Proper shadow elevation for header containers
  • Status Bar: Automatic status bar color coordination

Web

  • Accessibility: Proper ARIA labels and semantic HTML
  • Hover Effects: CSS hover states for interactive elements
  • Focus Management: Keyboard navigation support
  • Responsive: Adapts to different screen sizes and orientations

Install with Tessl CLI

npx tessl i tessl/npm-react-navigation--elements

docs

header-components.md

hooks-contexts.md

index.md

interactive-components.md

layout-components.md

utility-components.md

utility-functions.md

tile.json