14.2.2 • Published 16 days ago

@rmwc/top-app-bar v14.2.2

Weekly downloads
3,941
License
MIT
Repository
github
Last release
16 days ago

Top App Bar

Top App Bar acts as a container for items such as application title, navigation icon, and action items.

  • Module @rmwc/top-app-bar
  • Import styles:
    • Using CSS Loader
      • import '@rmwc/top-app-bar/styles';
    • Or include stylesheets
      • '@material/top-app-bar/dist/mdc.top-app-bar.css'
      • '@material/icon-button/dist/mdc.icon-button.css'
      • '@material/ripple/dist/mdc.ripple.css'
      • '@rmwc/icon/icon.css'
  • MDC Docs: https://material.io/develop/web/components/top-app-bar/

Whats the difference between the TopAppBar and Toolbar? Toolbar is technically deprecated (although it still works just fine). TopAppBar functionality continues to be worked on by the material-components-web team.

Basic Usage

<>
  <TopAppBar>
    <TopAppBarRow>
      <TopAppBarSection>
        <TopAppBarTitle>Default</TopAppBarTitle>
      </TopAppBarSection>
    </TopAppBarRow>
  </TopAppBar>
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>
<>
  <TopAppBar>
    <TopAppBarRow>
      <TopAppBarSection alignStart>
        <TopAppBarNavigationIcon icon="menu" />
        <TopAppBarTitle>All Features</TopAppBarTitle>
      </TopAppBarSection>
      <TopAppBarSection alignEnd>
        <TopAppBarActionItem icon="favorite" />
        <TopAppBarActionItem icon="star" />
        <TopAppBarActionItem icon="mood" />
      </TopAppBarSection>
    </TopAppBarRow>
    <TopAppBarRow>
      <TopAppBarSection alignStart>
        <TopAppBarTitle>Another Row</TopAppBarTitle>
      </TopAppBarSection>
    </TopAppBarRow>
  </TopAppBar>
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>

Simplified Usage

You can use the SimpleTopAppBar component which contains a default template already laid out for you. Specify any actions you want as an array of props

<>
  <SimpleTopAppBar
    title="test"
    navigationIcon
    onNav={() => console.log('Navigate')}
    actionItems={[
      {
        icon: 'file_download',
        onClick: () => console.log('Do Something')
      },
      { icon: 'print', onClick: () => console.log('Do Something') },
      { icon: 'bookmark', onClick: () => console.log('Do Something') }
    ]}
  />
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>

Variants

<>
  <TopAppBar fixed>
    <TopAppBarRow>
      <TopAppBarSection>
        <TopAppBarTitle>Fixed</TopAppBarTitle>
      </TopAppBarSection>
    </TopAppBarRow>
  </TopAppBar>
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>
<>
  <TopAppBar dense>
    <TopAppBarRow>
      <TopAppBarSection>
        <TopAppBarTitle>Dense</TopAppBarTitle>
      </TopAppBarSection>
    </TopAppBarRow>
  </TopAppBar>
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>
<>
  {/** Additionally you can specify shortCollapsed to have it always minimized */}
  <TopAppBar short>
    <TopAppBarRow>
      <TopAppBarSection>
        <TopAppBarNavigationIcon icon="menu" />
        <TopAppBarTitle>Short</TopAppBarTitle>
      </TopAppBarSection>
      <TopAppBarSection alignEnd>
        <TopAppBarActionItem icon="favorite" />
      </TopAppBarSection>
    </TopAppBarRow>
  </TopAppBar>
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>
<>
  <TopAppBar prominent>
    <TopAppBarRow>
      <TopAppBarSection>
        <TopAppBarTitle>Prominent</TopAppBarTitle>
      </TopAppBarSection>
    </TopAppBarRow>
  </TopAppBar>
  <TopAppBarFixedAdjust />

  <div style={{ height: '100rem', padding: '1rem' }}>Scroll Me</div>
</>

TopAppBar


TopAppBar


Props

NameTypeDescription
densebooleanStyles the top app bar to be dense.
fixedbooleanStyles the top app bar as a fixed top app bar.
foundationRefRef<null \| MDCTopAppBarFoundation<>>Advanced: A reference to the MDCFoundation.
onNav(evt: TopAppBarOnNavEventT) => voidEmits when the navigation icon is clicked.
prominentbooleanStyles the top app bar as a prominent top app bar.
scrollTargetnull \| Element<>Set a scrollTarget other than the window when you are using the TopAppBar inside of a nested scrolling DOM Element. Please note that you should store your scrollTarget in a stateful variable. See example https://codesandbox.io/s/reverent-austin-16zzi.
shortbooleanStyles the top app bar as a short top app bar.
shortCollapsedbooleanStyles the top app bar to always be collapsed.

TopAppBarRow

A row for the app bar.

TopAppBarSection

A section for the app bar.

Props

NameTypeDescription
alignEndbooleanAligns the section to the end.
alignStartbooleanAligns the section to the start.

TopAppBarTitle

A title for the top app bar.

TopAppBarNavigationIcon

A navigation icon for the top app bar. This is an instance of the Icon component.

TopAppBarActionItem

Action items for the top app bar. This is an instance of the Icon component.

TopAppBarFixedAdjust

An optional component to fill the space when the TopAppBar is fixed. Place it directly after the TopAppBar.

Props

NameTypeDescription
densebooleanClass used to style the content below the dense top app bar to prevent the top app bar from covering it.
denseProminentbooleanClass used to style the content below the top app bar when styled as both prominent and dense, to prevent the top app bar from covering it.
prominentbooleanClass used to style the content below the prominent top app bar to prevent the top app bar from covering it.
shortbooleanClass used to style the content below the short top app bar to prevent the top app bar from covering it.

SimpleTopAppBar

A simplified syntax for creating an AppBar.

Props

NameTypeDescription
actionItemsObject[]An array of props that will be used to create TopAppBarActionItems.
densebooleanStyles the top app bar to be dense.
endContentReactNodeAdditional content to place in the end section.
fixedbooleanStyles the top app bar as a fixed top app bar.
foundationRefRef<null \| MDCTopAppBarFoundation<>>Advanced: A reference to the MDCFoundation.
navigationIconboolean \| ObjectProps for the NavigationIcon, which is an instance of the Icon component. You can also set this to

true and use the onNav prop to handle interactions. | | onNav | (evt: TopAppBarOnNavEventT) => void | Emits when the navigation icon is clicked. | | prominent | boolean | Styles the top app bar as a prominent top app bar. | | scrollTarget | null \| Element<> | Set a scrollTarget other than the window when you are using the TopAppBar inside of a nested scrolling DOM Element. Please note that you should store your scrollTarget in a stateful variable. See example https://codesandbox.io/s/reverent-austin-16zzi. | | short | boolean | Styles the top app bar as a short top app bar. | | shortCollapsed | boolean | Styles the top app bar to always be collapsed. | | startContent | ReactNode | Additional content to place in the start section. | | title | ReactNode | The title for the App Bar. |

14.2.2

16 days ago

14.2.0

23 days ago

14.2.1

22 days ago

14.1.5

24 days ago

14.1.4

1 month ago

14.1.3

2 months ago

14.1.2

2 months ago

14.1.1

2 months ago

14.1.0

2 months ago

14.0.12

2 months ago

14.0.11

3 months ago

14.0.10

3 months ago

14.0.9

3 months ago

14.0.8

3 months ago

14.0.7

4 months ago

14.0.6

4 months ago

14.0.5

4 months ago

14.0.4

5 months ago

14.0.1-alpha.0

8 months ago

14.0.2-alpha.3

7 months ago

14.0.2-alpha.0

8 months ago

14.0.2-alpha.1

7 months ago

14.0.2-alpha.6

6 months ago

14.0.2-alpha.7

6 months ago

14.0.2-alpha.4

7 months ago

14.0.2-alpha.5

6 months ago

14.0.0

6 months ago

14.0.1

5 months ago

14.0.0-alpha.0

9 months ago

14.0.2

5 months ago

14.0.3

5 months ago

8.0.8

11 months ago

8.0.7

1 year ago

8.0.6

1 year ago

8.0.5

1 year ago

8.0.4

1 year ago

8.0.3

2 years ago

8.0.2

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

7.0.0

2 years ago

6.1.4

4 years ago

6.1.3

4 years ago

6.1.2

4 years ago

6.0.14

4 years ago

6.0.13

4 years ago

6.0.12

4 years ago

6.0.11

4 years ago

6.0.10

4 years ago

6.0.9

4 years ago

6.0.5

4 years ago

6.0.4

4 years ago

6.0.3

4 years ago

6.0.2

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

6.0.0-rc.4

4 years ago

6.0.0-rc.3

4 years ago

6.0.0-rc.2

4 years ago

6.0.0-rc.1

4 years ago

6.0.0-rc.0

4 years ago

6.0.0-alpha.16

4 years ago

6.0.0-alpha.14

4 years ago

6.0.0-alpha.15

4 years ago

6.0.0-alpha.13

4 years ago

6.0.0-alpha.12

4 years ago

6.0.0-alpha.11

4 years ago

6.0.0-alpha.7

4 years ago

5.7.2

4 years ago

6.0.0-alpha.6

4 years ago

6.0.0-alpha.5

4 years ago

6.0.0-alpha.3

4 years ago

5.7.0

5 years ago

5.6.0

5 years ago

5.5.2

5 years ago

5.5.1

5 years ago

5.5.0

5 years ago

5.4.3

5 years ago

5.4.2

5 years ago

5.4.1

5 years ago

5.4.0

5 years ago

5.3.1

5 years ago

5.3.0

5 years ago

5.2.2

5 years ago

5.2.1

5 years ago

5.2.0

5 years ago

5.2.0-alpha.0

5 years ago

5.1.8

5 years ago

5.1.7

5 years ago

5.1.6

5 years ago

5.1.5

5 years ago

5.1.4

5 years ago

5.1.3

5 years ago

5.1.2

5 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.30-rc.0

5 years ago

5.0.29-rc.0

5 years ago

5.0.28-rc.0

5 years ago

5.0.27-rc.0

5 years ago

5.0.26-rc.0

5 years ago

5.0.25-rc.0

5 years ago

5.0.24-rc.0

5 years ago

5.0.23-rc.0

5 years ago

5.0.23-alpha.0

5 years ago

5.0.22-alpha.0

5 years ago

5.0.21-alpha.0

5 years ago

5.0.20-alpha.0

5 years ago

5.0.19-alpha.0

5 years ago

5.0.18-alpha.0

5 years ago

5.0.17-alpha.0

5 years ago

5.0.16-alpha.0

5 years ago

5.0.15-alpha.0

5 years ago

5.0.14-alpha.0

5 years ago

5.0.13-alpha.0

5 years ago

5.0.12-alpha.0

5 years ago

5.0.8-alpha.0

5 years ago

5.0.7-alpha.0

5 years ago

5.0.6-alpha.0

5 years ago

5.0.5-alpha.0

5 years ago

5.0.4-alpha.0

5 years ago

5.0.3-alpha.0

5 years ago

5.0.2-alpha.0

5 years ago

5.0.1-alpha.0

5 years ago

5.0.0-alpha.0

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.11

5 years ago

3.0.10

5 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.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.0

6 years ago

2.2.2

6 years ago

2.2.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-alpha.7

6 years ago

2.0.0-alpha.6

6 years ago

2.0.0-alpha.5

6 years ago

2.0.0-alpha.4

6 years ago

2.0.0-alpha.3

6 years ago

2.0.0-alpha.2

6 years ago

2.0.0-alpha.1

6 years ago

2.0.0-alpha.0

6 years ago

1.10.1-alpha.0

6 years ago

1.10.0-alpha.0

6 years ago