New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expo-header

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-header

A full functional Header for React Native

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

AppHeader Component for React Native

The AppHeader component is a customizable and animated header component designed for React Native applications. It supports dynamic titles, interactive buttons, and integrations with React Navigation.

Features

  • Customizable left and right components/icons.
  • Dynamic header title based on the current route or a custom title.
  • Animated button press effects using react-native-reanimated.
  • Integrates seamlessly with React Navigation's Drawer and other navigators.
  • Flexible styling options for the header and its elements.

Installation

To use the AppHeader component in your project, ensure you have the following dependencies installed:

npm i expo-header

Please ensure that those packages are installed.

react-navigation @react-navigation/native react-native-reanimated

AppHeader Component

Usage

Here's an example of how to use the AppHeader component in your project:

import React from "react";
import { View, Text } from "react-native";
import AppHeader from "expo-header";

const ExampleScreen = () => {
  return (
    <View style={{ flex: 1 }}>
      <AppHeader
        headerTitle="Home"
        onLeftPress={() => console.log("Left button pressed!")}
        onRightPress={() => console.log("Right button pressed!")}
        leftIcon="menu"
        rightIcon="notifications"
      />
      <Text style={{ flex: 1, textAlign: "center", marginTop: 20 }}>
        Welcome to the example screen!
      </Text>
    </View>
  );
};

export default ExampleScreen;

Props

AppHeader

Prop NameTypeDefault ValueDescription
headerTitlestringCurrent routeTitle of the header. If not provided, the current route name is used.
onLeftPress() => voidOpens drawerFunction to execute when the left button is pressed.
onRightPress() => voidAlerts a messageFunction to execute when the right button is pressed.
leftIconstring"menu"Icon name for the left button.
rightIconstringundefinedIcon name for the right button.
leftIconFamilystring"MaterialIcons"Icon family for the left button.
rightIconFamilystring"MaterialIcons"Icon family for the right button.
leftIconSizenumber28Size of the left button icon.
rightIconSizenumber28Size of the right button icon.
leftIconColorstring"#007AFF"Color of the left button icon.
rightIconColorstring"#007AFF"Color of the right button icon.
LeftComponentReact.ComponentundefinedCustom component for the left side. Overrides leftIcon props.
RightComponentReact.ComponentundefinedCustom component for the right side. Overrides rightIcon props.
headerStyleViewStyle{}Style for the header container.
leftPressDisablebooleanfalseDisables the left button interaction.
rightPressDisablebooleanfalseDisables the right button interaction.

Customization

You can override any default styles by providing your own styles through the headerStyle, leftIconStyle, rightIconStyle, or titleStyle props.

Example:

<AppHeader
  headerTitle="Profile"
  headerStyle={{ backgroundColor: "#f8f8f8", elevation: 5 }}
  titleStyle={{ color: "#333", fontWeight: "bold" }}
/>

Animations

The AppHeader uses react-native-reanimated to provide smooth press animations for its buttons. Customize these animations in the AnimatedTouchable component if needed.

License

This package is open-sourced under the MIT License. Feel free to use and modify it as per your needs.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to enhance the functionality of this package.

Acknowledgements

  • Built with ❤️ and react-native-reanimated.
  • Icon rendering powered by the react-native-vector-icons package.

Keywords

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc