Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@asphalt-react/sidebar

Package Overview
Dependencies
Maintainers
5
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asphalt-react/sidebar

Sidebar component presents a navigation menu

npmnpm
Version
2.0.0-alpha.8
Version published
Maintainers
5
Created
Source

Sidebar

Sidebar is used to display vertical primary navigation. It represents a list of links that can either take the user to another page or to another section on same page.

It is contructed using 3 sections:

  • Header: Application logo can be added using the logo prop.
  • Navigation: Contains all the links for navigation. Links can be added using NavItem, <NavItemMenu> and <SubItem/> component.
  • Footer: Avatar can be used here for user profile and ActionList to add some extra actions. They can be passed using footer prop.

Sidebar is fully responsive and can be added to the application in several variants which are linear, nested(single level), links with/without icon, links grouped together based on related category. You can use the component <SubItem/> inside <NavItemMenu> to achieve nested links. For grouped links in sidebar, use component <NavItem/> or <NavItemMenu/> inside <NavGroup/>. To set an item selected in sidebar, we suggest you to update state URL and pass active prop to the respective link component. Sidebar takes the height of the parent in which its rendered.

Touch Interactions

In small screen, Sidebar gets close on select an item and navigates to the respective page/url. You can opt to change the default behaviour by passing prop autoClose={false} to the nav item.

Usage

import Sidebar, { Nav, NavItem } from "@asphalt-react/sidebar"

function App () {

  return (
    <Sidebar>
      <Nav>
        <NavItem tagProps={{ href: "/" }} active>Home</NavItem>
        <NavItem tagProps={{ href: "/Dashboard" }}>Dashboard</NavItem>
      </Nav>
    </Sidebar>
  );
}

export default App;

Props

children

React node to render in the Sidebar content

typerequireddefault
nodetrueN/A

Logo to be rendered inside Sidebar header

typerequireddefault
nodefalseN/A

Content to display at the bottom of Sidebar

typerequireddefault
nodefalseN/A

onSelect

onSelect is called when users select an item.

The argument is an object of shape

{
  event: React synthetic event
}

Note: This prop has been deprecated & will be removed in the next major version

typerequireddefault
funcfalseN/A

Nav

This component is used to render container for all the nav links in Sidebar.

Props

children

React nodes to render in the Nav content

typerequireddefault
nodetrueN/A

NavItem

Using NavItem component, links can be added to the Sidebar. Navitem renders an <a> tag as default.

⚠️ The NavItem component is different from the one in @asphalt-react/appbar

Props

children

React node to be shown as caption for the link

typerequireddefault
anyfalseN/A

as

Html element/React component to be rendered

typerequireddefault
elementTypefalse"a"

tagProps

Props for the NavItem element being rendered. Attributes like href, name can be passed

typerequireddefault
objectfalse{ href: "#" }

active

Determines if NavItem is currently selected

typerequireddefault
boolfalseN/A

qualifier

Renders an icon or text before the NavItem caption

typerequireddefault
unionfalsenull

autoClose

Set to false to avoid auto closing the sidebar on select the item in small screen

typerequireddefault
boolfalsetrue

NavItemMenu

This component is used to display a menu in the nav. It supports single level nesting. Sub items link can added inside menu using <SubItem/> component.

Props

children

React node to render as subitems in the NavMenu content

typerequireddefault
anyfalseN/A

as

Html element/React component to be rendered

typerequireddefault
elementTypefalse"a"

tagProps

Props for the NavItemMenu element being rendered. Attributes like href, name can be passed

typerequireddefault
objectfalse{ href: "#" }

caption

Caption for NavItemMenu

typerequireddefault
anyfalseN/A

active

Determines if item is currently selected

typerequireddefault
boolfalseN/A

qualifier

Renders an icon or text before the NavItemMenu caption

typerequireddefault
unionfalsenull

autoClose

Set to false to avoid auto closing the sidebar on select the item in small screen

typerequireddefault
boolfalsetrue

SubItem

This component is used to renders subitem link inside NavItemMenu

Props

children

React node to render as text content for the link

typerequireddefault
nodefalseN/A

as

Html element/React component to be rendered

typerequireddefault
elementTypefalse"a"

active

Determines if item is currently selected

typerequireddefault
boolfalseN/A

tagProps

Props for the SubItem element being rendered. Attributes like href, name can be passed

typerequireddefault
objectfalse{ href: "#" }

autoClose

Set to false to avoid auto closing the sidebar on select the item

typerequireddefault
boolfalsetrue

NavGroup

Using NavGroup component, you can group together a list of nav items based on related category. Links can be provided using component <NavItem/> or <NavItemMenu/> passed inside this component as children and group heading using prop heading.

Props

children

React nodes to render as nav items in the NavGroup

typerequireddefault
nodetrueN/A

heading

Heading of the NavGroup

typerequireddefault
nodetrueN/A

Keywords

asphalt

FAQs

Package last updated on 09 Nov 2022

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