4.0.6 • Published 5 years ago

react-sidenav v4.0.6

Weekly downloads
2,359
License
MIT
Repository
github
Last release
5 years ago

react-sidenav

Build Status coverage report npm version

Side Navigation Component for React

Alt Img

Requirements

react-sidenav are exported as an es module thus you would need a bundler to use it. It is also written in Typescript so it can be directly used with a typescript project as well.

Peer Dependencies

React 16.8

NavContext

As the current version of react-sidenav does not have any fixed rendering template, the user is free to render Nav items as they see fit. To render conditionally an item can get the context which contains the following attributes:

propertytypedescription
selectedbooleanif this Nav item is selected
idstringthe id of the Nav as per props.id
pathIdstringThe path id, will be parentIdprops.id if rendered with a parent
levelnumberThe level of the Nav, starts with 1
isLeafbooleanIf true, then this Nav has no children

Below is an example on how to use it.

    const Item = () => {
      const context = React.useContext(NavContext);
      return (
        <div style={{ color: context.selected: 'pink': 'inherit'}}>{ props.children }</div>
      )
    }
  
    <SideNav>
      <Nav id="1">
        <Item>Link 1</Item>
      </Nav>
      <Nav id="2">
        <Item>Link 2</Item>
      </Nav>
      <Nav id="3">
        <Item>Link 3</Item>
      </Nav>
    </SideNav>
  

SideNav Properties

propertytypedescriptionisRequired
onSelectionfunction: ({id, path, payload}) => voida function that gets called when a navigation has been clickedfalse
defaultSelectedPathstringthe default selectionfalse
modecompact, normalchanges rendering style of childrenfalse, defaults to normal
childrenToggleModehover, clickchanges how children are expandedfalse, defaults to hover
childrenToggleIndicatorReact Componentthe toggle indicator to render. The collapse, expand state is passed or you can use the NavGroupContext to get the collapse/expand statefalse

Nav Properties

propertytypedescriptionisRequired
ida function that gets called when a navigation has been clickedtrue
payloadanypassed to the listener when this nav is clickedfalse

Development

Please checkout example on CodeSandbox and the src/playground directory for now while all the documentation/testing is being completed.

Sponsors

JetBrains

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

4.0.0-beta5

5 years ago

4.0.0-beta3

5 years ago

4.0.0-beta2

5 years ago

4.0.0-beta1

5 years ago

3.1.9

5 years ago

3.1.7

5 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.3

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.21

6 years ago

3.0.13

6 years ago

3.0.9

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

3.0.0-pre7

6 years ago

3.0.0-pre6

6 years ago

3.0.0-pre5

6 years ago

3.0.0-pre4

6 years ago

3.0.0-pre3

6 years ago

3.0.0-pre2

6 years ago

3.0.0-pre1

6 years ago

2.1.3

6 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago