2.6.5 • Published 3 years ago

create-react-nav v2.6.5

Weekly downloads
149
License
-
Repository
github
Last release
3 years ago

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

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

Limitation of create-react-nav

  1. It doesn't have subnavigation system.
  2. It doesn't have NEXT.JS support.
  3. 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} />

Add Text Logo

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 :

  1. You may have to use "!important" keyword for most of the style attributes.
  2. 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

2.6.5

3 years ago

2.6.3

3 years ago

2.6.2

3 years ago

2.6.4

3 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.9

4 years ago

2.5.8

4 years ago

2.5.7

4 years ago

2.5.6

4 years ago

2.5.4

4 years ago

2.5.5

4 years ago

2.5.3

4 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.9

4 years ago

2.4.8

4 years ago

2.4.7

4 years ago

2.4.6

4 years ago

2.4.5

4 years ago

2.4.4

4 years ago

2.4.3

4 years ago

2.4.2

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.9

4 years ago

2.3.8

4 years ago

2.3.7

4 years ago

2.3.6

4 years ago

2.3.5

4 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.9

4 years ago

2.1.9

4 years ago

2.1.8

4 years ago

2.1.6

4 years ago

2.1.7

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago