0.15.0 • Published 5 years ago

@material/react-tab-indicator v0.15.0

Weekly downloads
1,721
License
MIT
Repository
github
Last release
5 years ago

React Tab Indicator

A React version of an MDC Tab Indicator.

Installation

npm install @material/react-tab-indicator

Usage

Styles

with Sass:

import '@material/react-tab-indicator/index.scss';

with CSS:

import '@material/react-tab-indicator/dist/tab-indicator.css';

Javascript Instantiation

With an Underline (default)

import React from 'react';
import TabIndicator from '@material/react-tab-indicator';

class MyApp extends React.Component {
  state = {active: false};

  render() {
    return (
      <div>
        <TabIndicator active={this.state.active} />
      </div>
    );
  }
}

With Icon

If you want the underline instead of an icon, pass the icon element as a child of the Tab Indicator component.

import React from 'react';
import TabIndicator from '@material/react-tab-indicator';
import MaterialIcon from '@material/react-material-icon';

class MyApp extends React.Component {
  state = {active: false};

  render() {
    return (
      <div>
        <TabIndicator
          active={this.state.active}
          icon
        >
          <MaterialIcon icon='star' />
        </TabIndicator>
      </div>
    );
  }
}

Props

Prop NameTypeDescription
activebooleanIf true will activate the indicator.
classNamestringClasses to appear on className attribute of root element.
fadebooleanIf enabled will use the fade animation for transitioning to other tabs.
iconbooleanIndicates that the indicator is an icon instead of an underline.
previousIndicatorClientRectClientRectThe indicator's clientRect that was previously activated.
onTransitionEndfunctiontransitionend event callback handler.

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.