react-toolbox/components/tabs
Rubén Moya a59af9a67f
Merge pull request #1814 from react-toolbox/update-v2-react16
Update v2 to React 16
2018-03-03 11:57:48 +01:00
..
__tests__ Update tests to use Enzyme 3 2018-02-20 21:00:47 +01:00
Tab.d.ts Typescript definitions validation (#1163) 2017-09-01 17:51:41 +02:00
Tab.js Feature/tabs a11y (#1513) 2017-08-02 18:30:41 +02:00
TabContent.d.ts Restructure typescript definitions (#1114) 2017-01-18 08:37:37 +01:00
TabContent.js Fix eslint errors 2018-02-20 22:26:44 +01:00
Tabs.d.ts Import TabTheme interface at Tabs TS definition 2017-01-26 12:30:10 +01:00
Tabs.js Merge pull request #1773 from merraysy/merraysy-timepicker-dismiss-issue 2018-02-27 11:42:48 +01:00
config.css Feature/tabs a11y (#1513) 2017-08-02 18:30:41 +02:00
index.d.ts Restructure typescript definitions (#1114) 2017-01-18 08:37:37 +01:00
index.js Allow to change FontIcon for Tab by passing it into the factory (#1439) 2017-07-13 20:03:34 +02:00
readme.md Add ripple for Tabs. Fixes #377 2017-01-21 13:03:38 +01:00
theme.css Feature/tabs a11y (#1513) 2017-08-02 18:30:41 +02:00

readme.md

Tabs

Tabs make it easy to explore and switch between different views or functional aspects of an app or to browse categorized data sets. Tabs are composed with their content, but only the active tab's content is rendered. In the future, we may add the ability to render headers only, with event listeners.

import {Tab, Tabs} from 'react-toolbox';

class TabsTest extends React.Component {
  state = {
    index: 1,
    fixedIndex: 1,
    inverseIndex: 1
  };

  handleTabChange = (index) => {
    this.setState({index});
  };

  handleFixedTabChange = (index) => {
    this.setState({fixedIndex: index});
  };

  handleInverseTabChange = (index) => {
    this.setState({inverseIndex: index});
  };

  handleActive = () => {
    console.log('Special one activated');
  };

  render () {
    return (
      <section>
        <Tabs index={this.state.index} onChange={this.handleTabChange}>
          <Tab label='Primary'><small>Primary content</small></Tab>
          <Tab label='Secondary' onActive={this.handleActive}><small>Secondary content</small></Tab>
          <Tab label='Third' disabled><small>Disabled content</small></Tab>
          <Tab label='Fourth' hidden><small>Fourth content hidden</small></Tab>
          <Tab label='Fifth'><small>Fifth content</small></Tab>
        </Tabs>
        <h5>Fixed Tabs</h5>
        <Tabs index={this.state.fixedIndex} onChange={this.handleFixedTabChange} fixed>
          <Tab label='First'><small>First Content</small></Tab>
          <Tab label='Second'><small>Second Content</small></Tab>
          <Tab label='Third'><small>Third Content</small></Tab>
        </Tabs>
        <h5>Inverse Tabs</h5>
        <Tabs index={this.state.inverseIndex} onChange={this.handleInverseTabChange} inverse>
          <Tab label='First'><small>First Content</small></Tab>
          <Tab label='Second'><small>Second Content</small></Tab>
          <Tab label='Third'><small>Third Content</small></Tab>
          <Tab label='Disabled' disabled><small>Disabled Content</small></Tab>
        </Tabs>
      </section>
    );
  }
}

If you want to provide a theme via context, the component key is RTTabs.

Tabs

This component acts as the wrapper and the main controller of the content that is being displayed. It gets some properties that can be spread to the children.

Properties

Name Type Default Description
className String '' Additional class name to provide custom styling.
disableAnimatedBottomBorder Boolean false Disable the animation below the active tab.
fixed Boolean false If True, the tabs will be 'fixed tabs'.
hideMode enum('display','unmounted') unmounted unmounted mode will not mount the tab content of inactive tabs. display mode will mount but hide inactive tabs. Consider holding state outside of the Tabs component before using display mode
index Number 0 Current
inverse Boolean false If True, the tabs will have an inverse style.
onChange Function Callback function that is fired when the tab changes.

Theming

Name Description
active Added to the active tab content and header.
fixed Used to make the tabs 'fixed tabs'.
inverse Used to invert the colors.
navigation Used for the navigation element.
pointer Used for the moving underline element.
tabs Used as a root classname for the component.
tab Used for the tab content element.

Tab

Represent a single tab element and it should include some properties to describe the tab itself and get children elements as content.

Properties

Name Type Default Description
active Boolean false If true, the current component is visible.
activeClassName String '' Additional class name to provide custom styling for the active tab.
className String '' Additional class name to provide custom styling for each tab.
disabled Boolean false If true, the current component is not clickable.
hidden Boolean false If true, the current component is not visible.
icon String Icon for navigation header.
label String Label text for navigation header.
onActive Function Callback function that is fired when the tab is activated.
onClick Function Callback function that is fired when the tab is clicked.

It is required to provide either a label or an icon (or both).

Theme

Name Description
active Added to the navigation tab element in case it's active.
disabled Added to the navigation tab element in case it's disabled.
hidden Added to the navigation tab element in case it's hidden.
label Added to the navigation tab element in case it's active.
rippleWrapper Used for the ripple wrapper element.