Navbar

The NavBar holds the navigation for Nulogy applications and a global search.

import {NavBar} from "@nulogy/components";

const primaryMenu = [
  {
    name: 'Dashboard',
    items: [
      { name: 'Customers', href: '/' },
      { name: 'Invoices', href: '/' },
    ],
  },
  { name: 'Link', href: '/' },
];

const secondaryMenu = [
  {
    name: 'Settings',
    items: [
      { name: 'Permissions', href: '/' },
      { name: 'Manage account', href: '/' },
    ],
  },
];

const search = {
  onSubmit: () => {},
};

<NavBar menuData={ { primaryMenu, secondaryMenu, search } } />

Variations

Primary menu only

<NavBar menuData={ { primaryMenu } } />

With search

<NavBar menuData={ { primaryMenu, search } } />

With secondary menu

<NavBar menuData={ { primaryMenu, secondaryMenu, search } } />

Props

NameTypeDefaultDescription

menuData

object

null

Data used to build link heirarchy and search functionality. See menuData Prop section below.

subtext

string

null

The subtext under the logo.

brandingLinkHref

string

/

The link href for the logo.

breakpointUpper

number

1024

Provides the breakpoint where menu items will be collapsed into a dropdown menu.

breakpointLower

number

768

Provides the breakpoint where the logo is collapsed from wordmark to lettermark.

themeColor

string

blue

Color themeing of NavBar component, either "blue" or "white".

menuData Prop

The menuData prop is used to provide links to the NavBar, assemble their heirarchy, and provide the search field's onSubmit handler. The direct children in the menuData object are shown below:

const menuData = {
  primaryMenu: [],
  secondaryMenu: [],
  search: {
    onSubmit: () => (),
  },
}
KeyTypeDescription
primaryMenuarray of menu item objectsData to the main navigation menu, aligned to the left of the NavBar.
secondaryMenuarray of menu item objectsData to the secondary navigation menu, aligned to the right of the NavBar.
searchobjectObject's onSubmit key provides onSubmit to search.

Not providing data for primaryMenu, secondaryMenu or search will result in those components not being included.

Adding menu items

Both primaryMenu and secondaryMenu expect an array of objects. Each object represents a link or a heading to a group of links under it, with the following shape:

const primaryMenu = [
  {
    name = "string",
    href = "/",      // optional
    render = ()=>(), // optional
    items = [],      // optional
  },
]

Each menu item object requires a "name" key. The "name" key will be used as the label for the menu item unless a "render" key is used. Adding "items" to the menu item object will render a dropdown with the specified items.

Menu items can be nested within eachother using the items key for as many levels of heirarchy that is needed.

KeyTypeDescription
namestring | node (required)Unique identifier for the menu item.
ariaLabelstringAdd an aria-label if the `name` value is not a readable label, like an icon.
hrefstringURL or link to an element similar to a standard <a> tag, this causes the menu item to render as a link within the NavBar.
itemsarrayArray of menu item objects. This causes the menu item to render as a dropdown in desktop view or as a heading in mobile view.
renderfunctionFunction that returns JSX. This causes the menu item to render as the JSX provided wrapped in a component that provides styling and an onClick handler to close the menu. NOTE: Do not use `href` and `items` keys if you intend to use the render function.