Toolbar / Tabbar - 图1

Toolbar React Component

Toolbar is a fixed (with Fixed and Through layout types) area at the bottom of a screen that contains navigation elements. Toolbar does not have any parts, just plain links inside

Toolbar React component represents Toolbar component.

Toolbar Components

There are following components included:

  • **Toolbar** / **F7Toolbar**

Toolbar Properties

PropTypeDefaultDescription
<Toolbar> properties
innerbooleantrueWhen enabled (by default), it will put all the content within internal toolbar-inner element. Disable it only in case you want to put totally custom layout inside
bottomMdbooleanfalseDefines whether the Toolbar should be on bottom or not (MD theme only)
tabbarbooleanfalseDefines whether the Toolbar is also a Tabbar or not
labelsbooleanfalseEnables Tabbar with labels (affects only when tabbar: true)
scrollablebooleanfalseEnables scrollable Tabbar (affects only when tabbar: true)
noShadowbooleanDisable shadow rendering for Material theme
noHairlinebooleanfalseDisable toolbar/tabbar top thin border (hairline) for iOS theme
hiddenbooleanfalseMakes toolbar hidden

Toolbar Methods

<Toolbar> methods
.hide(animate)Hide toolbar
.show(animate)Show toolbar

Toolbar Slots

Toolbar React component (<Toolbar>) has additional slots for custom elements:

  • **default** - element will be inserted as a child of <div class="toolbar-inner"> element
  • **before-inner** - element will be inserted right before <div class="toolbar-inner"> element
  • **after-inner** - element will be inserted right after <div class="toolbar-inner"> element
  1. <Toolbar>
  2. <div slot="before-inner">Before Inner</div>
  3. <div slot="after-inner">After Inner</div>
  4. {/* Goes to default slot: */}
  5. <Link>Left Link</Link>
  6. <Link>Right Link</Link>
  7. </Toolbar>
  8. {/* Renders to: */}
  9. <div class="toolbar">
  10. <div>Before Inner</div>
  11. <div class="toolbar-inner">
  12. <a href="#" class="link">Left Link</a>
  13. <a href="#" class="link">Right Link</a>
  14. </div>
  15. <div>After Inner</div>
  16. </div>

Examples

Toolbar

  1. export default class extends React.Component{
  2. constructor() {
  3. this.state = {
  4. isBottom: false,
  5. };
  6. }
  7. render() {
  8. return (
  9. <Page>
  10. <Navbar title="Toolbar" backLink="Back"></Navbar>
  11. <Toolbar bottomMd={this.state.isBottom}>
  12. <Link>Left Link</Link>
  13. <Link>Right Link</Link>
  14. </Toolbar>
  15. {this.$theme.md && (
  16. <BlockTitle>Toolbar Position</BlockTitle>
  17. )}
  18. {this.$theme.md && (
  19. <Block>
  20. <p>Material (MD) theme toolbar supports both top and bottom positions. Click the following button to change its position.</p>
  21. <p>
  22. <Button raised onClick={() => this.setState({isBottom: !this.state.isBottom})}>Toggle Toolbar Position</Button>
  23. </p>
  24. </Block>
  25. )}
  26. <Block>
  27. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam enim quia molestiae facilis laudantium voluptates obcaecati officia cum, sit libero commodi...</p>
  28. </Block>
  29. </Page>
  30. )
  31. }
  32. }

Tabbar

  1. export default class extends React.Component{
  2. constructor() {
  3. this.state = {
  4. isBottom: false,
  5. };
  6. }
  7. render() {
  8. return (
  9. <Page pageContent={false}>
  10. <Navbar title="Tabbar" backLink="Back">
  11. {this.$theme.md && (
  12. <NavRight>
  13. <Link iconMaterial="compare_arrows" onClick={() => this.setState({isBottom: !this.state.isBottom})}></Link>
  14. </NavRight>
  15. )}
  16. </Navbar>
  17. <Toolbar tabbar bottomMd={this.state.isBottom}>
  18. <Link tabLink="#tab-1" tabLinkActive>Tab 1</Link>
  19. <Link tabLink="#tab-2">Tab 2</Link>
  20. <Link tabLink="#tab-3">Tab 3</Link>
  21. </Toolbar>
  22. <Tabs>
  23. <Tab id="tab-1" className="page-content" tabActive>
  24. <Block>
  25. <p>Tab 1 content</p>
  26. ...
  27. </Block>
  28. </Tab>
  29. <Tab id="tab-2" className="page-content">
  30. <Block>
  31. <p>Tab 2 content</p>
  32. ...
  33. </Block>
  34. </Tab>
  35. <Tab id="tab-3" className="page-content">
  36. <Block>
  37. <p>Tab 3 content</p>
  38. ...
  39. </Block>
  40. </Tab>
  41. </Tabs>
  42. </Page>
  43. )
  44. }

Tabbar Labels

  1. export default class extends React.Component{
  2. constructor() {
  3. this.state = {
  4. isBottom: false,
  5. };
  6. }
  7. render() {
  8. return (
  9. <Page pageContent={false}>
  10. <Navbar title="Tabbar Labels" backLink="Back">
  11. {this.$theme.md && (
  12. <NavRight>
  13. <Link iconMaterial="compare_arrows" onClick={() => this.setState({isBottom: !this.state.isBottom})}></Link>
  14. </NavRight>
  15. )}
  16. </Navbar>
  17. <Toolbar tabbar labels bottomMd={this.state.isBottom}>
  18. <Link tabLink="#tab-1" tabLinkActive text="Tab 1" iconIos="f7:email_fill" iconMd="material:email"></Link>
  19. <Link tabLink="#tab-2" text="Tab 2" iconIos="f7:today_fill" iconMd="material:today"></Link>
  20. <Link tabLink="#tab-3" text="Tab 3" iconIos="f7:cloud_fill" iconMd="material:file_upload"></Link>
  21. </Toolbar>
  22. <Tabs>
  23. <Tab id="tab-1" className="page-content" tabActive>
  24. <Block>
  25. <p>Tab 1 content</p>
  26. ...
  27. </Block>
  28. </Tab>
  29. <Tab id="tab-2" className="page-content">
  30. <Block>
  31. <p>Tab 2 content</p>
  32. ...
  33. </Block>
  34. </Tab>
  35. <Tab id="tab-3" className="page-content">
  36. <Block>
  37. <p>Tab 3 content</p>
  38. ...
  39. </Block>
  40. </Tab>
  41. </Tabs>
  42. </Page>
  43. )
  44. }
  45. }

Tabbar Scrollable

  1. export default class extends React.Component{
  2. constructor() {
  3. this.state = {
  4. isBottom: false,
  5. };
  6. }
  7. render() {
  8. const tabs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  9. return (
  10. <Page pageContent={false}>
  11. <Navbar title="Tabbar Scrollable" backLink="Back">
  12. {this.$theme.md && (
  13. <NavRight>
  14. <Link iconMaterial="compare_arrows" onClick={() => this.setState({isBottom: !this.state.isBottom})}></Link>
  15. </NavRight>
  16. )}
  17. </Navbar>
  18. <Toolbar tabbar scrollable bottomMd={this.state.isBottom}>
  19. {tabs.map((tab, index) => (
  20. <Link
  21. key={tab}
  22. tabLink={`#tab-${tab}`}
  23. tabLinkActive={index === 0}
  24. >Tab {tab}</Link>
  25. ))}
  26. </Toolbar>
  27. <Tabs>
  28. {tabs.map((tab, index) => (
  29. <Tab
  30. key={tab}
  31. id={`tab-${tab}`}
  32. className="page-content"
  33. tabActive={index === 0}
  34. >
  35. <Block>
  36. <p><b>Tab {tab} content</b></p>
  37. ...
  38. </Block>
  39. </Tab>
  40. ))}
  41. </Tabs>
  42. </Page>
  43. )
  44. }
  45. }

Hide Toolbar On Scroll

  1. export default () => (
  2. <Page hideToolbarOnScroll>
  3. <Navbar title="Hide Toolbar On Scroll" backLink="Back"></Navbar>
  4. <Toolbar bottom-md>
  5. <Link>Left Link</Link>
  6. <Link>Right Link</Link>
  7. </Toolbar>
  8. <Block strong>
  9. <p>Toolbar will be hidden if you scroll bottom</p>
  10. </Block>
  11. <Block>
  12. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos maxime incidunt id ab culpa ipsa omnis eos, vel excepturi officiis neque illum perferendis dolorum magnam rerum natus dolore nulla ex.</p>
  13. ...
  14. </Block>
  15. </Page>
  16. );