npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@material/react-top-app-bar

v0.15.0

Published

Material Components React Top App Bar

Downloads

1,055

Readme

React Top App Bar

A React version of an MDC Top App Bar.

Installation

npm install @material/react-top-app-bar

Usage

Styles

with Sass:

import '@material/react-top-app-bar/index.scss';
import '@material/react-material-icon/index.scss';

with CSS:

import '@material/react-top-app-bar/dist/top-app-bar.css';
import '@material/react-material-icon/dist/material-icon.css';

Javascript Instantiation

import TopAppBar, {
  TopAppBarFixedAdjust, 
  TopAppBarIcon,
  TopAppBarRow,
  TopAppBarSection,
  TopAppBarTitle,
} from '@material/react-top-app-bar';
import MaterialIcon from '@material/react-material-icon';

const MyComponent = () => {
  return (
    <div>
      <TopAppBar>
        <TopAppBarRow>
          <TopAppBarSection align='start'>
            <TopAppBarIcon navIcon tabIndex={0}>
              <MaterialIcon hasRipple icon='menu' onClick={() => console.log('click')}/>
            </TopAppBarIcon>
            <TopAppBarTitle>Miami, FL</TopAppBarTitle>
          </TopAppBarSection>
          <TopAppBarSection align='end' role='toolbar'>
            <TopAppBarIcon actionItem tabIndex={0}>
              <MaterialIcon 
                aria-label="print page" 
                hasRipple 
                icon='print' 
                onClick={() => console.log('print')}
              />
            </TopAppBarIcon>
          </TopAppBarSection>
        </TopAppBarRow>
      </TopAppBar>
      <TopAppBarFixedAdjust>
        My exciting content!
      </TopAppBarFixedAdjust>
    </div>
  );
}

Use the <TopAppBarFixedAdjust /> component to give your content top-padding, so it isn't hidden on page render.

Props

TopAppBar

Prop Name | Type | Description --- | --- | --- className | String | Classes to be applied to the root element. short | Boolean | Enables short variant. shortCollapsed | Boolean | Enables short collapsed variant. prominent | Boolean | Enables prominent variant. fixed | Boolean | Enables fixed variant. dense | Boolean | Enables dense variant. scrollTarget | React.RefObject | Sets scroll target to different DOM node (default is window) tag | String | Customizes the TopAppBar HTML tag. (default: <header>)

NOTES: As per design guidelines, prominent and dense variants should not be used with short or short collapsed. Additionally, dense variants should only be used on desktop. Additionally short top-app-bars should be used with no more than 1 action item.

TopAppBarRow

Prop Name | Type | Description --- | --- | --- className | String | Classes to be applied to the root element. tag | String | Customizes the TopAppBarRow tag. (default: <div>)

TopAppBarSection

Prop Name | Type | Description --- | --- | --- align | Sring ('start' or 'end') | optional property that aligns section content to either start or end of section className | String | Classes to be applied to the root element. tag | String | Customizes the TopAppBarSection tag. (default: <section>)

Note: if section contains action items it is recommended to add property role='toolbar' for a11y purposes

TopAppBarTitle

Prop Name | Type | Description --- | --- | --- className | String | Classes to be applied to the root element. tag | String | Customizes the TopAppBarTitle tag. (default: <span>)

TopAppBarIcon

Prop Name | Type | Description --- | --- | --- className | String | Classes to be applied to the root element. actionItem | Boolean | applies action-item class to icon navIcon | Boolean | applies nav-icon class to icon children | React.ReactElement | can be any icon. Material Icons are recommended

Notes: (1) consider adding aria-label to actionItem's. (2) you may need to manually add ripple or tabindex to icon. (3) Short top-app-bars should be used with no more than 1 action item.

TopAppBarFixedAdjust

Prop Name | Type | Description --- | --- | --- className | String | Classes to be applied to the root element. dense | Boolean | Enables dense variant. prominent | Boolean | Enables prominent variant. short | Boolean | Enables short variant. tag | String | Customizes the TopAppBarFixedAdjust tag (defaults to <main>)

NOTE: if not dense, prominent, or short will apply mdc-top-app-bar--fixed-adjust

Icons

Use of Material Icon's for Action Items and Navigation Icons are recommended, since the Ripple is included with the Component. Using custom Components will require you to wrap the Component with the withRipple HOC. If you do decide to build your own custom Component, it is recommended to use the hasRipple prop to toggle between icons with and without ripple. See the Material Icon's implementation to see how to implement the hasRipple prop within your custom Component.

Navigation Icon

The navigation icon can be a <a>, <i>, <svg>, <image>, <span>, etc., but again must be wrapped with the withRipple HOC.

  <TopAppBarIcon navIcon>
    <i className='material-icons'>menu</i>
  </TopAppBarIcon>

If you decide to use a React Component please see Integrating with Components.

Action Items

Similar to the navigation icon, it can be <a>, <i>, <svg>, <image>, <span>, etc., and must be wrapped with the withRipple HOC.

  <TopAppBarIcon actionItem>
    <i className='material-icons'>bookmark</i>
  </TopAppBarIcon>

If you decide to use a React Component please see Integrating with Components.

Sass Mixins

Sass mixins may be available to customize various aspects of the Components. Please refer to the MDC Web repository for more information on what mixins are available, and how to use them.

Advanced Sass Mixins

Usage with Icons

Please see our Best Practices doc when importing or using icon fonts.

Usage with Drawer

Please see the docs in drawer to integrate with Top app bar