1.0.7 • Published 12 months ago

react-native-tab-strip v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

react-native-tab-strip

npm

Monthly Downloads

An animated tab bar component for React Native.

Getting started

Install the library using your package manager:

pnpm:

pnpm install --save react-native-tab-strip

yarn:

yarn add react-native-tab-strip

npm:

npm install --save react-native-tab-strip

Image Demo Here's a quick demo of react-native-tab-strip:

Android vs iOS

react-native-tab-strip is a versatile and animated tab bar component designed for React Native applications. It provides an intuitive interface for navigating between tabs with customizable styles and smooth

animations.

Key Features Animated Tab Bar: Enhance user experience with smooth animations when switching tabs.

Customizable: Tailor the appearance of the tab bar to fit your app's design using various styling options. Event Handling: Easily manage tab press events with a simple callback function.

Flexible Integration: Integrate seamlessly into new or existing React Native projects.

Usage Example

import AnimatedTabBar from "react-native-tab-strip";

Usage

Start by importing the library:

Use AnimatedTabBar to render a Tab bar .

Programmatically changing selected index

import AnimatedTabBar from "react-native-tab-strip";

return (
  <AnimatedTabBar
    // required
    data={[{ title: "Tab 1" }, { title: "Tab 2" }]}
    // required
    itemWidth={100}
    onTabPress={(item, index) => {
      console.log(item, "this is item", index);
    }}
  />
);

Data:

The data prop is an array of objects, and each object must contain a mandatory property named title. This title will be displayed on the tab item.

<AnimatedTabBar
  // Required: Array of tab data objects, each containing a 'title' property
  data={data}
  // Callback function invoked when a tab is pressed (Optional)
  onTabPress={(item, index) => {
    console.log(`Pressed tab ${index + 1}: ${item} `);
  }}
  // Width of each tab item (Required)
  itemWidth={170}
  // Background color of the tab bar (Optional)
  tabBarBackground="#ffff"
  // Color of the active tab item (Optional)
  tabBarActiveItemColor="#f1f1f1"
  // Color of inactive tab items (Optional)
  tabBarInactiveItemColor="white"
  // Text color of active tab items (Optional)
  tabBarActiveTxtColor="black"
  // Text color of inactive tab items (Optional)
  tabBarInactiveTxtColor="black"
  // Main container style of the tab bar (Optional)
  mainScrollContainerStyle={{}}
  // Optional styles for the main container of the top bar
  containerStyle={{}}
  // Optional styles for the selected item container
  selectedItemContainerStyle={{}}
  // Optional styles for each tab item container
  itemContainerStyle={{}}
  // Optional text style for the selected tab item
  selectedTxtStyle={{}}
  // Optional text style for each tab item
  txtStyle={{}}
/>

Use code with caution.

Available Props

data

Array of objects defining each tab. Each object must have a title property (string).

TypeRequired
object[]Yes

itemWidth

Width of each tab item.

TypeRequired
numberYes

onTabPress

Callback function invoked when a tab is pressed. Receives the pressed tab data object and its index (zero-based) as arguments.

TypeRequired
functionNo

tabBarBackground

Background color of the tab bar.

TypeRequired
stringNo

tabBarActiveItemColor

Color of the active tab item.

TypeRequired
stringNo

tabBarInactiveItemColor

Color of inactive tab items.

TypeRequired
stringNo

tabBarActiveTxtColor

Text color of active tab items.

TypeRequired
stringNo

tabBarInactiveTxtColor

Text color of inactive tab items.

TypeRequired
stringNo

mainScrollContainerStyle

Style object applied to the main container of the tab bar.

TypeRequired
objectNo

containerStyle

Style object applied to the container of the selected tab item.

TypeRequired
objectNo

selectedItemContainerStyle

Style object applied to the container of each tab item.

TypeRequired
objectNo

itemContainerStyle

Style object applied to the text element of each tab item.

TypeRequired
objectNo

selectedTxtStyle

Style object applied to the text element of the selected tab item.

TypeRequired
objectNo

txtStyle

Style object applied to the text element of each tab item.

TypeRequired
objectNo
1.0.7

12 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago