🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

create-react-nav

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-react-nav

Create your react app menu bar more easily with `create-react-nav`

latest
Source
npmnpm
Version
2.6.5
Version published
Maintainers
1
Created
Source

Create-React-Nav · React Navigation Bar Creator · GitHub license npm version

Create your react app menu bar more easily with create-react-nav

Why create-react-nav

  • You don't need extra dependencies like react-router-dom.
  • You don't need to write extra code.
  • Getting more comfort with the navigation system
  • Super easy to maintain.

Limitation of create-react-nav

  • It doesn't have subnavigation system.
  • It doesn't have NEXT.JS support.
  • It doesn't have Gatsby support.

example:

Installation

Use the package manager npm to install create-react-nav.

npm install create-react-nav

Usages

Step-1 (Import the Library)

import Navbar from "create-react-nav";

Step-2 (Use the Component)

const links = [
  [ "...ROUTER_PATH..." , "...PAGE_NAME..." , ...COMPONENT_NAME... ],
  [ "...ROUTER_PATH..." , "...PAGE_NAME..." , ...COMPONENT_NAME... ]
];

<Navbar routes={links}/>

Note : Leave the PAGE_NAME empty not to add the route to navbar

Basic Configuration (optional)

Add Trigger Icon

This is the button which works as a trigger to open hidden navigation bar when you are using mobile or smaller devices.

<Navbar triggerIcon="light" routes={links} />

Some integrated Trigger Icon

  • dark
  • light

Note : You Can Use Your Own Custom Icon By Adding The Source

Add Logo Image

This is your app logo which will appear on the top of the navigation bar
<Navbar logoImg="...SOURCE_PATH_OF_YOUR_LOGO..." routes={links} />
This is your app name which will appear on the top of the navigation bar
<Navbar logoTxt="...USE_ANY_TEXT_AS_LOGO..." routes={links} />

Api

ApiTypeDescription
routesArray of multiple ArraysRequired three properties first one is the route path, second one is the title for the page and third one is the component
triggerIconStringtrigger icon for the navigaton bar (mobile device)
logoImgStringSource link of your logo
logoTxtStringText logo which basically refers your website name
yToggleStringboolean as string to toggle the nav by y axis

Styling (optional)

Class Names to customize or over write the styles given from create-react-nav.

Class NameDescription
.NavbarStyle of the navigation bar
.AppbarStyle of the app bar in mobile mode
a.NavItemsStyle of all the links (Don't need to use '!important')
a.selectedStyle Of the active navigation link (Don't need to use '!important')
.Appbar spanStyle of Text logo
.selected::afterStyle of active page indicator (For Desktop mode)
.NavItems::afterStyle of all page indicator

How does active class workes in create-react-nav?

Basically the ".NavItems::after" has 0% of width. When you click on a Nav we add "selected" class and then it's got 100% width and you see the indicator is apearing.

Note :

  • You may have to use "!important" keyword for most of the style attributes.
  • To change the style for mobile screen use max-width to 700px.

Example (CSS)

.Navbar {
  background-color: white !important;
}

.NavItems::after {
  background-color: red !important;
}

@media only screen and (max-width: 700px) {
  .selected {
    color: white !important;
    background-color: red !important;
  }
}

Get access of react-router-dom

create-react-nav

import { navigation } from "create-react-nav";
const history = navigation.useHistory()

react-router-dom

import { useHistory } from "react-router-dom";
const history = useHistory()

Example (JSX)

import React from "react";
import Home from "./files/home";
import About from "./files/about";
import Navbar from "create-react-nav";

const App = () => {
  const links = [
    ["/", "Home", Home],
    ["/about", "About", About],
  ];

  return <Navbar logoTxt="hello" yToggle="true" routes={links} />;
};

export default App;

Note : Place the Navbar component where you want to do page routing.

License

MIT

Keywords

navigation

FAQs

Package last updated on 21 May 2021

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