Nav

Navs - 图1

  1. import React from 'react';
  2. import { Nav, NavItem, NavLink } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <div>
  7. <p>List Based</p>
  8. <Nav>
  9. <NavItem>
  10. <NavLink href="#">Link</NavLink>
  11. </NavItem>
  12. <NavItem>
  13. <NavLink href="#">Link</NavLink>
  14. </NavItem>
  15. <NavItem>
  16. <NavLink href="#">Another Link</NavLink>
  17. </NavItem>
  18. <NavItem>
  19. <NavLink disabled href="#">Disabled Link</NavLink>
  20. </NavItem>
  21. </Nav>
  22. <hr />
  23. <p>Link Based</p>
  24. <Nav>
  25. <NavLink href="#">Link</NavLink> <NavLink href="#">Link</NavLink> <NavLink href="#">Another Link</NavLink> <NavLink disabled href="#">Disabled Link</NavLink>
  26. </Nav>
  27. </div>
  28. );
  29. }
  30. }

Nav Properties

  1. Nav.propTypes = {
  2. tabs: PropTypes.bool,
  3. pills: PropTypes.bool,
  4. card: PropTypes.bool,
  5. justified: PropTypes.bool,
  6. fill: PropTypes.bool,
  7. vertical: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
  8. horizontal: PropTypes.string,
  9. navbar: PropTypes.bool,
  10. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
  11. // pass in custom element to use
  12. }

NavItem Properties

  1. NavItem.propTypes = {
  2. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  3. active: PropTypes.bool,
  4. // pass in custom element to use
  5. }
  1. NavLink.propTypes = {
  2. disabled: PropTypes.bool,
  3. active: PropTypes.bool,
  4. // pass in custom element to use
  5. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  6. // ref will only get you a reference to the NavLink component, use innerRef to get a reference to the DOM element (for things like focus management).
  7. innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
  8. }

Vertical

Navs - 图2

  1. import React from 'react';
  2. import { Nav, NavItem, NavLink } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <div>
  7. <p>List Based</p>
  8. <Nav vertical>
  9. <NavItem>
  10. <NavLink href="#">Link</NavLink>
  11. </NavItem>
  12. <NavItem>
  13. <NavLink href="#">Link</NavLink>
  14. </NavItem>
  15. <NavItem>
  16. <NavLink href="#">Another Link</NavLink>
  17. </NavItem>
  18. <NavItem>
  19. <NavLink disabled href="#">Disabled Link</NavLink>
  20. </NavItem>
  21. </Nav>
  22. <hr />
  23. <p>Link based</p>
  24. <Nav vertical>
  25. <NavLink href="#">Link</NavLink> <NavLink href="#">Link</NavLink> <NavLink href="#">Another Link</NavLink> <NavLink disabled href="#">Disabled Link</NavLink>
  26. </Nav>
  27. </div>
  28. );
  29. }
  30. }

Tabs

Navs - 图3

  1. import React from 'react';
  2. import { Nav, NavItem, Dropdown, DropdownItem, DropdownToggle, DropdownMenu, NavLink } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. constructor(props) {
  5. super(props);
  6. this.toggle = this.toggle.bind(this);
  7. this.state = {
  8. dropdownOpen: false
  9. };
  10. }
  11. toggle() {
  12. this.setState({
  13. dropdownOpen: !this.state.dropdownOpen
  14. });
  15. }
  16. render() {
  17. return (
  18. <div>
  19. <Nav tabs>
  20. <NavItem>
  21. <NavLink href="#" active>Link</NavLink>
  22. </NavItem>
  23. <Dropdown nav isOpen={this.state.dropdownOpen} toggle={this.toggle}>
  24. <DropdownToggle nav caret>
  25. Dropdown
  26. </DropdownToggle>
  27. <DropdownMenu>
  28. <DropdownItem header>Header</DropdownItem>
  29. <DropdownItem disabled>Action</DropdownItem>
  30. <DropdownItem>Another Action</DropdownItem>
  31. <DropdownItem divider />
  32. <DropdownItem>Another Action</DropdownItem>
  33. </DropdownMenu>
  34. </Dropdown>
  35. <NavItem>
  36. <NavLink href="#">Link</NavLink>
  37. </NavItem>
  38. <NavItem>
  39. <NavLink href="#">Another Link</NavLink>
  40. </NavItem>
  41. <NavItem>
  42. <NavLink disabled href="#">Disabled Link</NavLink>
  43. </NavItem>
  44. </Nav>
  45. </div>
  46. );
  47. }
  48. }

Pills

Navs - 图4

  1. import React from 'react';
  2. import { Nav, NavItem, Dropdown, DropdownItem, DropdownToggle, DropdownMenu, NavLink } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. constructor(props) {
  5. super(props);
  6. this.toggle = this.toggle.bind(this);
  7. this.state = {
  8. dropdownOpen: false
  9. };
  10. }
  11. toggle() {
  12. this.setState({
  13. dropdownOpen: !this.state.dropdownOpen
  14. });
  15. }
  16. render() {
  17. return (
  18. <div>
  19. <Nav pills>
  20. <NavItem>
  21. <NavLink href="#" active>Link</NavLink>
  22. </NavItem>
  23. <Dropdown nav isOpen={this.state.dropdownOpen} toggle={this.toggle}>
  24. <DropdownToggle nav caret>
  25. Dropdown
  26. </DropdownToggle>
  27. <DropdownMenu>
  28. <DropdownItem header>Header</DropdownItem>
  29. <DropdownItem disabled>Action</DropdownItem>
  30. <DropdownItem>Another Action</DropdownItem>
  31. <DropdownItem divider />
  32. <DropdownItem>Another Action</DropdownItem>
  33. </DropdownMenu>
  34. </Dropdown>
  35. <NavItem>
  36. <NavLink href="#">Link</NavLink>
  37. </NavItem>
  38. <NavItem>
  39. <NavLink href="#">Another Link</NavLink>
  40. </NavItem>
  41. <NavItem>
  42. <NavLink disabled href="#">Disabled Link</NavLink>
  43. </NavItem>
  44. </Nav>
  45. </div>
  46. );
  47. }
  48. }