1.1.9 • Published 1 year ago

react-touchable-tab-view v1.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-touchable-tab-view

Add it to your project

  1. Run npm install react-touchable-tab-view --save or yarn add react-touchable-tab-view --save
  2. import TouchableTabView from 'react-touchable-tab-view'

Basic usage

import TouchableTabView from 'react-touchable-tab-view'

const App = () => {

  const renderTabBar = ({ tabs, onChangeTab, currentTab }) => {
    return (
      <div>
        {tabs.map((tab, tabIndex) => (
          <span
            key={tabIndex}
            style={{ marginRight: 10 }}
            onClick={() => onChangeTab(tabIndex)}
          >
            <i className={tab.icon} />
            {tab.label}
          </span>
        ))}
      </div>
    )
  }

  return (
    <TouchableTabView renderTabBar={renderTabBar}>
      <ReactPage tabLabel='React' tabIcon='icon-react' className='h-full' />
      <FlowPage tabLabel='Flow' tabIcon='icon-flow' className='h-full' />
      <JestPage tabLabel='Jest' tabIcon='icon-jest' className='h-full' />
    </TouchableTabView>
  );
}

Props

  • renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component to use as the tab bar. The component has onChangeTab, tabs, currentTab.
  • tabBarPosition (String) Defaults to 'top'.
    • "bottom" to position the tab bar below content.
  • onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the tab that is selected
  • initialTab (Integer) - the index of the initially selected tab, defaults to 0 === first tab.
  • children (ReactComponents) - each top-level child component should have a tabLabel and tabIcon prop that can be used by the tab bar component to render out the labels. The default tab bar expects it to be a string, but you can use anything you want if you make a custom tab bar.

MIT Licensed

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago