Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reactjs-bottom-navigation

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactjs-bottom-navigation

  • 2.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
198
increased by3.66%
Maintainers
1
Weekly downloads
 
Created
Source

reactjs-bottom-navigation

React bottom navigation component

JavaScript Style Guide

Introduction

enter image description here

"ReactJS Bottom Navigation" is a lightweight and flexible component that provides a customizable bottom navigation experience for your React applications. This component has been fully re-implemented in TypeScript in version 2, providing a more robust and type-safe development experience. With a range of options to customize it.

Installation


  

npm install  --save  reactjs-bottom-navigation

  

Props

PropsTypedefaultdescription
itemsBottomNavigationItem[]-The array of items to display in the navigation
selectednumbernull(optional) The index of the currently selected item, used for setting a default active item and/or controlling active state manually
onItemClickfunction-(optional)triggers when an item is clicked and it returns the item
activeBgColorstring-(optional) custom active background color code
activeTextColorstringblackcustom active text color code

Item Structure

all item properties are optional, if no property is provided the item will take space and it will be empty

PropTypedescription
titlestring(optional) item title
iconJSX.Element(optional) item icon
activeIconJSX.Element(optional) item active icon
onClickfunction(optional) triggers when the item is clicked and it returns the item
render({ isActive: boolean; id: number }) => JSX.Element(optional) will replace title and icons if provided, used for rendering custom content inside bottom navigation items

Usage

To use the component, you need to provide an array of "items" which represent the individual navigation options in the bottom navigation bar. Each item can have a "title", an "icon", or both. You can also provide a custom rendering function to create your own content for the item.

Example (TypeScript):


import  React  from  "react";
import {
BottomNavigation, BottomNavigationItemType,
} from  "reactjs-bottom-navigation";

function  App() {

const  bottomNavItems: BottomNavigationItemType[] = [
	{
		title:  "Home",
		onClick: ({ id }) =>  alert("menu clicked " + id),
		icon: <HomeIcon />, // just for example
		activeIcon: <HomeIcon color="#fff" />
	},

	// items can have either title, icon or both or neither!
	{
	},
	{
		title:  "Search",
	},
	// the render method enables custom item content
	{
		render: ({ isActive, id }) =>  isActive ? <strong>{id}</strong> : <span>{id}</span>,
	},
];

  

return (
<div>
	<BottomNavigation
		items={bottomNavItems}
		selected={0}
		onItemClick={(item) =>  console.log(item)}
		activeBgColor="slateBlue"
		activeTextColor="white"
	/>
</div>
);

}


export  default  App;

Customization

the component elements have the following class names which you can assign new styles to them:

Bottom Navigation: bottom-nav Items: bottom-nav-item titles: bottom-nav-item–title you can also use "activeBgColor" and "activeTextColor" props and the item render method

License

MIT © hoseinhamzei

FAQs

Package last updated on 10 May 2023

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