0.11.6 • Published 6 years ago

@trendmicro/react-navs v0.11.6

Weekly downloads
360
License
MIT
Repository
github
Last release
6 years ago

react-navs build status Coverage Status

NPM

React Navs

Demo: https://trendmicro-frontend.github.io/react-navs

Installation

  1. Install the latest version of react and react-navs:

    npm install --save react @trendmicro/react-navs
  2. At this point you can import @trendmicro/react-navs and its styles in your application as follows:

    import {
        Nav,
        NavItem,
        NavDropdown, // optional
        MenuItem, // optional
        TabContent,
        TabPane
    } from '@trendmicro/react-navs';
    
    // Be sure to include styles at some point, probably during your bootstraping
    import '@trendmicro/react-navs/dist/react-navs.css';
    
    // [Optional] Include react-dropdown.css when using NavDropdown
    import '@trendmicro/react-dropdown/dist/react-dropdown.css'

Usage

Tabs

<Nav
    navStyle="tabs"
    activeKey={this.state.activeTab}
    onSelect={(eventKey, event) => {
        this.setState({ activeTab: eventKey });
    }}
    style={{
        borderBottomColor: 'transparent' // Make a transparent bottom border
    }}
>
    <NavItem eventKey={1}>Item 1</NavItem>
    <NavItem eventKey={2}>Item 2</NavItem>
    <NavItem eventKey={3}>Item 3</NavItem>
    <NavDropdown eventKey={4} title="NavItem 4">
        <MenuItem eventKey={4.1}>Action</MenuItem>
        <MenuItem eventKey={4.2}>Another action</MenuItem>
        <MenuItem divider />
        <MenuItem eventKey={4.3}>Separated link</MenuItem>
    </NavDropdown>
</Nav>
<TabContent activeKey={this.state.activeTab}>
    <TabPane eventKey={1}>Tab 1 content</TabPane>
    <TabPane eventKey={2}>Tab 2 content</TabPane>
    <TabPane eventKey={3}>Tab 3 content</TabPane>
    <TabPane eventKey={4.1}>Tab 4.1 content</TabPane>
    <TabPane eventKey={4.2}>Tab 4.2 content</TabPane>
    <TabPane eventKey={4.3}>Tab 4.3 content</TabPane>
</TabContent>

Light Tabs

<Nav
    navStyle="light-tabs"
    activeKey={this.state.activeTab}
    onSelect={(eventKey, event) => {
        this.setState({ activeTab: eventKey });
    }}
>
    <NavItem eventKey={1}>Item 1</NavItem>
    <NavItem eventKey={2}>Item 2</NavItem>
    <NavItem eventKey={3}>Item 3</NavItem>
    <NavDropdown eventKey={4} title="NavItem 4">
        <MenuItem eventKey={4.1}>Action</MenuItem>
        <MenuItem eventKey={4.2}>Another action</MenuItem>
        <MenuItem divider />
        <MenuItem eventKey={4.3}>Separated link</MenuItem>
    </NavDropdown>
</Nav>
<TabContent activeKey={this.state.activeTab}>
    <TabPane eventKey={1}>Tab 1 content</TabPane>
    <TabPane eventKey={2}>Tab 2 content</TabPane>
    <TabPane eventKey={3}>Tab 3 content</TabPane>
    <TabPane eventKey={4.1}>Tab 4.1 content</TabPane>
    <TabPane eventKey={4.2}>Tab 4.2 content</TabPane>
    <TabPane eventKey={4.3}>Tab 4.3 content</TabPane>
</TabContent>

Panel Tabs

<Nav
    navStyle="panel-tabs"
    activeKey={this.state.activeTab}
    onSelect={(eventKey, event) => {
        this.setState({ activeTab: eventKey });
    }}
>
    <NavItem eventKey={1}>Item 1</NavItem>
    <NavItem eventKey={2}>Item 2</NavItem>
    <NavItem eventKey={3}>Item 3</NavItem>
    <NavDropdown eventKey={4} title="NavItem 4">
        <MenuItem eventKey={4.1}>Action</MenuItem>
        <MenuItem eventKey={4.2}>Another action</MenuItem>
        <MenuItem divider />
        <MenuItem eventKey={4.3}>Separated link</MenuItem>
    </NavDropdown>
</Nav>
<TabContent activeKey={this.state.activeTab}>
    <TabPane eventKey={1}>Tab 1 content</TabPane>
    <TabPane eventKey={2}>Tab 2 content</TabPane>
    <TabPane eventKey={3}>Tab 3 content</TabPane>
    <TabPane eventKey={4.1}>Tab 4.1 content</TabPane>
    <TabPane eventKey={4.2}>Tab 4.2 content</TabPane>
    <TabPane eventKey={4.3}>Tab 4.3 content</TabPane>
</TabContent>

API

Properties

Nav

NameTypeDefaultDescription
activeHrefstringMarks the child NavItem with a matching href prop as active.
activeKeyanyMarks the NavItem with a matching eventKey as active. Has a higher precedence over activeHref.
navStyleOne of:'tabs''light-tabs''panel-tabs''navbar''tabs'Component visual or contextual style variants.
justifiedbooleanfalseMake tabs equal widths of their parent at screens wider than 768px. On smaller screens, the nav links are stacked.
stackedbooleanfalsePosition NavItem vertically.
onSelectfunction(eventKey, event)A callback fired when a NavItem is selected.
rolestringARIA role for the Nav.

NavItem

NameTypeDefaultDescription
activebooleanfalseHighlight the nav item as active.
disabledbooleanfalseWhether or not component is disabled.
eventKeyanyValue passed to the onSelect handler, useful for identifying the selected nav item.
hrefstring
onClickfunction(event)Callback fired when the nav item is clicked.
onSelectfunction(eventKey, event)Callback fired when the nav item is selected.
rolestringARIA role for the NavItem.

NavDropdown

NameTypeDefaultDescription
componentClassstringcomponentA custom element for this component
dropupbooleanfalseThe menu will open above the dropdown button, instead of below it.
disabledbooleanfalseWhether or not component is disabled.
pullRightbooleanfalseAlign the menu to the right side of the NavDropdown toggle.
openbooleanfalseWhether or not the dropdown is visible.
onClosefunction(event)A callback fired when the dropdown closes.
onTogglefunction(boolean)A callback fired when the dropdown wishes to change visibility. Called with the requested open value.
onSelectfunction(eventKey, event)A callback fired when a menu item is selected.
rolestringIf 'menuitem', causes the dropdown to behave like a menu item rather than a menu button.
rootCloseEventOne of:'click''mousedown'Which event when fired outside the component will cause it to be closed.
activebooleanfalseHighlight the nav dropdown as active.
titlenode
noCaretbooleanfalseWhether to prevent a caret from being rendered next to the title.

MenuItem

NameTypeDefaultDescription
activebooleanfalseHighlight the menu item as active.
disabledbooleanfalseDisable the menu item, making it unselectable.
dividerbooleanfalseStyle the menu item as a horizontal rule, providing visual separation between groups of menu items.
eventKeyanyValue passed to the onSelect handler, useful for identifying the selected menu item.
headerbooleanfalseStyle the menu item as a header label, useful for describing a group of menu items.
hrefstringHTML href attribute corresponding to a.href.
onClickfunction(event)Callback fired when the menu item is clicked.
onSelectfunction(eventKey, event)Callback fired when the menu item is selected.

TabContent

NameTypeDefaultDescription
activeKeyany

TabPane

NameTypeDefaultDescription
eventKeyany
lazybooleanfalseIf true, the TabPane will be unmounted when inactive.

License

MIT

0.11.6

6 years ago

0.11.5

6 years ago

0.11.4

6 years ago

0.11.3

6 years ago

0.11.2

6 years ago

0.11.1

6 years ago

0.11.0

6 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.6

7 years ago

0.8.5

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago