@cloudflare/component-tabs

6.0.11 • Public • Published

@cloudflare/component-tabs

Cloudflare Tabs Component

Installation

Installation with yarn is recommended

$ yarn add @cloudflare/component-tabs

Usage

import React from 'react';
import { Tabs, TabsItem, TabsPanel } from '../../src';
import { createComponent } from '@cloudflare/style-container';

const Tab = createComponent(
  () => ({
    backgroundColor: '#FFFFF0'
  }),
  TabsItem
);

class TabsComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      active: 'one'
    };
  }

  handleTabChange(id) {
    this.setState({ active: id });
  }

  render() {
    return (
      <Tabs
        active={this.state.active}
        tabs={[
          { id: 'one', label: 'Tab One' },
          {
            id: 'two',
            label: 'Tab Two: Custom Header',
            component: Tab
          },
          { id: 'three', label: 'Tab Three' }
        ]}
        onChange={this.handleTabChange.bind(this)}
      >
        <TabsPanel id="one">
          <h1>Tab One</h1>
        </TabsPanel>

        <TabsPanel id="two">
          <h1>Tab Two</h1>
        </TabsPanel>

        <TabsPanel id="three">
          <h1>Tab Three</h1>
        </TabsPanel>
      </Tabs>
    );
  }
}

export default TabsComponent;

Readme

Keywords

none

Package Sidebar

Install

npm i @cloudflare/component-tabs

Weekly Downloads

4,437

Version

6.0.11

License

BSD-3-Clause

Unpacked Size

226 kB

Total Files

15

Last publish

Collaborators

  • cf-media-manager
  • jacobbednarz
  • celso
  • cf-radar
  • dash_service_account
  • g4brym
  • snigdha34
  • wrangler-publisher
  • marksteyn
  • chiminator
  • sgoodhew_cf
  • terinjokes
  • third774
  • jsteinberger
  • jasnell
  • asapzacy
  • pcostanzo
  • gregbrimble
  • geelen
  • rexscaria
  • dcruz_cf
  • xuranwang
  • jculvey
  • sejoker
  • vasturiano
  • cf-ci-write
  • segments-write
  • thibmeu
  • xortive
  • gurjinder
  • cf-ci2
  • lvalenta
  • worenga