menu
Dark Mode
backgroundLayer 1
preact-material-components
Components and their props
  • Tab Bar
    • no specific props
  • Tab
    • active true/false
      Sets the tab active along with `activeTabIndex` prop.
  • TabLabel
    • no specific props
  • TabIcon
    • no specific props
Sample code
import {h, Component} from 'preact';
import TabBar from 'preact-material-components/TabBar';
import 'preact-material-components/TabBar/style.css';

export default class TabBarPage extends Component {
  render() {
    return (
      <div>
        <TabBar>
          <TabBar.Tab active>
            <TabBar.TabLabel>Tab1</TabBar.TabLabel>
          </TabBar.Tab>
          <TabBar.Tab>
            <TabBar.TabLabel>Tab2</TabBar.TabLabel>
          </TabBar.Tab>
          <TabBar.Tab>
            <TabBar.TabLabel>Tab3</TabBar.TabLabel>
          </TabBar.Tab>
        </TabBar>
      </div>
    );
  }
}
Original documentation
This component encapsulates mdc-tab-bar, you can refer to its documentation here.
Demo
Default.
Icons.
import {h, Component} from 'preact';
import TabBar from 'preact-material-components/TabBar';
import 'preact-material-components/TabBar/style.css';

export default class TabBarPage extends Component {
  render() {
    return (
      <div>
        <TabBar>
          <TabBar.Tab active>
            <TabBar.TabLabel>Tab1</TabBar.TabLabel>
          </TabBar.Tab>
          <TabBar.Tab>
            <TabBar.TabLabel>Tab2</TabBar.TabLabel>
          </TabBar.Tab>
          <TabBar.Tab>
            <TabBar.TabLabel>Tab3</TabBar.TabLabel>
          </TabBar.Tab>
        </TabBar>
      </div>
    );
  }
}
Scroller.