Shards React
Shards React

Shards React

Documentation

Nav

The Nav component allows you to build all types of navigation components.

Basic Demo

Creating navs can be easily achieved using the Nav component together with the NavItem component.

import React from "react";
import { Nav, NavItem, NavLink } from "shards-react";

export default function NavExample() {
  return (
    <Nav>
      <NavItem>
        <NavLink active href="#">
          Active
        </NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Another Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink disabled href="#">
          Disabled Link
        </NavLink>
      </NavItem>
    </Nav>
  );
}

Tabs Style

Using the tabs prop, you can style the navs to look like tabs.

import React from "react";
import { Nav, NavItem, NavLink } from "shards-react";

export default function NavTabsExample() {
  return (
    <Nav tabs>
      <NavItem>
        <NavLink active href="#">
          Active
        </NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Another Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink disabled href="#">
          Disabled Link
        </NavLink>
      </NavItem>
    </Nav>
  );
}

Pills Style

Using the pills prop you can style the navs to look like pills.

import React from "react";
import { Nav, NavItem, NavLink } from "shards-react";

export default function NavPillsExample() {
  return (
    <Nav pills>
      <NavItem>
        <NavLink active href="#">
          Active
        </NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Another Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink disabled href="#">
          Disabled Link
        </NavLink>
      </NavItem>
    </Nav>
  );
}

Fill Style

Using the fill prop, you can force the nav content to extend the full available width.

import React from "react";
import { Nav, NavItem, NavLink } from "shards-react";

export default function NavPillsExample() {
  return (
    <Nav fill>
      <NavItem>
        <NavLink href="#">Active</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Another Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink disabled href="#">
          Disabled Link
        </NavLink>
      </NavItem>
    </Nav>
  );
}

Justified

Using the justified prop, you can define equal-width nav elements.

import React from "react";
import { Nav, NavItem, NavLink } from "shards-react";

export default function NavPillsExample() {
  return (
    <Nav justified>
      <NavItem>
        <NavLink href="#">Active</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink href="#">Another Link</NavLink>
      </NavItem>
      <NavItem>
        <NavLink disabled href="#">
          Disabled Link
        </NavLink>
      </NavItem>
    </Nav>
  );
}

Props

The following props are available for the Nav component.

PropDescriptionTypeDefaultRequired
classNameThe class name.String-No
navbarWhether it is located inside a Navbar, or not.Bool-No
horizontalJustify content horizontally.String-No
tabsWhether it should be displayed as tabs, or not.Bool-No
cardWhether it is located inside a card, or not.Bool-No
pillsWhether it should be displayed as pills, or not.Bool-No
justifiedWhether it is justified, or not.Bool-No
fillWhether it should fill the entire space, or not.Bool-No
verticalWhether it is vertical, or not.BoolStringfalseNo
tagThe component's tag type.FuncString"ul"No

Subcomponents

The following subcomponents are available for the Nav component.

<NavItem/>

PropDescriptionTypeDefaultRequired
activeWhether it is active, or not.Bool-No
disabledWhether it is disabled, or not.Bool-No
classNameThe class name.String-No
tagThe component's tag type.FuncString"li"No

<NavLink/>

PropDescriptionTypeDefaultRequired
disabledWhether it is disabled, or not.Bool-No
activeWhether it is active, or not.Bool-No
classNameThe class name.String-No
onClickThe function that should be triggered on click.Func-No
hrefThe href attribute value.Any-No
tagThe component's tag type.FuncString"a"No
innerRefThe inner ref.ObjectFuncString-No