0.27.0 • Published 2 years ago

@material/mwc-top-app-bar-fixed v0.27.0

Weekly downloads
1,733
License
Apache-2.0
Repository
github
Last release
2 years ago

<mwc-top-app-bar-fixed> Published on npm

IMPORTANT: The Material Web Components are a work in progress and subject to major changes until 1.0 release.

Fixed Top App Bars are a container for items such as application title, navigation icon, and action items that are always visible.

npm.io

For a version of this component that scrolls, see <mwc-top-app-bar>

Material Design Guidelines: App Bars: Top

Demo

Installation

npm install @material/mwc-top-app-bar-fixed

NOTE: The Material Web Components are distributed as ES2017 JavaScript Modules, and use the Custom Elements API. They are compatible with all modern browsers including Chrome, Firefox, Safari, Edge, and IE11, but an additional tooling step is required to resolve bare module specifiers, as well as transpilation and polyfills for IE11. See here for detailed instructions.

Example Usage

Standard

<mwc-top-app-bar-fixed>
    <mwc-icon-button icon="menu" slot="navigationIcon"></mwc-icon-button>
    <div slot="title">Title</div>
    <mwc-icon-button icon="file_download" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="print" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="favorite" slot="actionItems"></mwc-icon-button>
    <div><!-- content --></div>
</mwc-top-app-bar-fixed>

Center Title

<mwc-top-app-bar-fixed centerTitle>
    <mwc-icon-button icon="menu" slot="navigationIcon"></mwc-icon-button>
    <div slot="title">Title</div>
    <mwc-icon-button icon="favorite" slot="actionItems"></mwc-icon-button>
    <div><!-- content --></div>
</mwc-top-app-bar-fixed>

Dense

<mwc-top-app-bar-fixed dense>
    <mwc-icon-button icon="menu" slot="navigationIcon"></mwc-icon-button>
    <div slot="title">Title</div>
    <mwc-icon-button icon="file_download" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="print" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="favorite" slot="actionItems"></mwc-icon-button>
    <div><!-- content --></div>
</mwc-top-app-bar-fixed>

Prominent

<mwc-top-app-bar-fixed prominent>
    <mwc-icon-button icon="menu" slot="navigationIcon"></mwc-icon-button>
    <div slot="title">Title</div>
    <mwc-icon-button icon="file_download" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="print" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="favorite" slot="actionItems"></mwc-icon-button>
    <div><!-- content --></div>
</mwc-top-app-bar-fixed>

Prominent and Dense

<mwc-top-app-bar-fixed prominent dense>
    <mwc-icon-button icon="menu" slot="navigationIcon"></mwc-icon-button>
    <div slot="title">Title</div>
    <mwc-icon-button icon="file_download" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="print" slot="actionItems"></mwc-icon-button>
    <mwc-icon-button icon="favorite" slot="actionItems"></mwc-icon-button>
    <div><!-- content --></div>
</mwc-top-app-bar-fixed>

Customize Colors

mwc-top-app-bar-fixed {
  --mdc-theme-primary: orange;
  --mdc-theme-on-primary: black;
}

API

Slots

NameDescription
actionItemsA number of <mwc-icon-button> elements to use for action icons on the right side. NOTE: If using with mwc-drawer, please read note under Standard drawer example.
navigationIconOne <mwc-icon-button> element to use for the left icon.
titleA <div> or <span> that will be used as the title text.
defaultScrollable content to display under the bar. This may be the entire application.

Properties/Attributes

NameTypeDefaultDescription
centerTitlebooleanfalseCenters the title horizontally. Only meant to be used with 0 or 1 actionItems.
densebooleanfalseMakes the bar a little smaller for higher density applications.
prominentbooleanfalseMakes the bar much taller, can be combined with dense.
scrollTargetHTMLElement | WindowwindowElement used to listen for scroll events.

Methods

None

Events

NameDetailDescription
MDCTopAppBar:nav{}Fired when the navigationIcon is clicked.

CSS Custom Properties

NameDefaultDescription
--mdc-top-app-bar-fixed-box-shadowmdc elevation 4Sets the box shadow of the fixed top app bar when scrolling.
--mdc-top-app-bar-width100%Width of the top-app-bar in relation to the Window.

Elevation values

Elevation LevelCSS Value
40px 2px 4px -1px rgba(0, 0, 0, 0.2), 0px 4px 5px 0px rgba(0, 0, 0, 0.14), 0px 1px 10px 0px rgba(0, 0, 0, 0.12)

Global Custom Properties

This component exposes the following global theming custom properties.

NameDefaultDescription
--mdc-theme-primaryBackground color of the bar.
--mdc-theme-on-primaryText color of the title, and icon colors.
--mdc-typography-headline6-<PROPERTY>Styles the typography of the top-app-bar title.

Additional references

0.27.0

2 years ago

0.26.1

2 years ago

0.26.0

2 years ago

0.25.3

3 years ago

0.25.2

3 years ago

0.25.1

3 years ago

0.23.0

3 years ago

0.22.1

3 years ago

0.21.0

3 years ago

0.20.0

3 years ago

0.19.1

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.17.2

4 years ago

0.17.0

4 years ago

0.16.1

4 years ago

0.15.0

4 years ago

0.14.1

4 years ago

0.14.0

4 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.11.0

4 years ago

0.11.1

4 years ago

0.10.0

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago