
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
reactjs-bottom-navigation
Advanced tools
A flexible bottom navigation component for React applications
React bottom navigation component
"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.
npm install --save reactjs-bottom-navigation
Props | Type | Default | Description |
---|---|---|---|
items | BottomNavigationItem[] | - | The array of items to display in the navigation |
selected | number | null | (optional) The index of the currently selected item |
onItemClick | function | - | (optional) Triggered when an item is clicked, returns the clicked item |
activeBgColor | string | - | (optional) Custom active background color code |
activeTextColor | string | black | (optional) Custom active text color code |
hideOnScroll | boolean | false | (optional) Hides the navigation bar when scrolling |
style | React.CSSProperties | {} | (optional) Custom styles for the navigation container |
className | string | "" | (optional) Custom class name for the navigation container |
All item properties are optional. If no property is provided, the item will occupy space but remain empty.
Prop | Type | Description |
---|---|---|
title | string | (optional) Item title |
icon | JSX.Element | (optional) Item icon |
activeIcon | JSX.Element | (optional) Item active icon |
onClick | function | (optional) Triggered when the item is clicked, returns the clicked item |
render | ({ isActive: boolean; id: number }) => JSX.Element | (optional) Custom render function for the item |
active | boolean | (optional) Custom active state control. If not provided, falls back to selected index behavior |
To use the component, provide an array of items
representing the navigation options in the bar. Each item can include a title
, an icon
, or custom content using the render
function.
Example:
import React, { useState } from "react";
import { BottomNavigation } from "reactjs-bottom-navigation";
function App() {
const bottomNavItems = [
{
title: "Home",
onClick: ({ id }) => alert("Menu clicked " + id),
icon: <HomeIcon />,
activeIcon: <HomeIcon color="#fff" />
},
{
title: "Search",
},
{
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"
hideOnScroll={true}
className="custom-bottom-nav"
style={{ position: "fixed", bottom: 0, width: "100%" }}
/>
</div>
);
}
export default App;
The component offers multiple ways to customize:
bottom-nav
bottom-nav-item
bottom-nav-item-title
active
class to bottom-nav-item
You can use activeBgColor
, activeTextColor
, and the className
prop to further customize the appearance.
Use the hideOnScroll
prop to automatically hide the navigation bar when scrolling down.
Use the render
method in items
to define custom content for each navigation item.
MIT © hoseinhamzei
FAQs
Did you know?
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.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.