Socket
Socket
Sign inDemoInstall

react-swipeable-tabs

Package Overview
Dependencies
36
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-swipeable-tabs

React Swipeable tabs


Version published
Weekly downloads
134
decreased by-25.56%
Maintainers
2
Install size
7.95 MB
Created
Weekly downloads
 

Readme

Source

react-swipeable-tabs

Installing

$ npm install react-swipeable-tabs --save

Demos

Example

import React from 'react';
import SwipeableTabs from 'react-swipeable-tabs';

export default class TestTabs extends React.Component {
  componentWillMount() {
    this.setState({
      activeItemIndex: 2,
      items: [
        { title: "Item 1" },
        { title: "Item 2" },
        { title: "Item 3" },
        { title: "Item 4" },
        { title: "Item 5" },
        { title: "Item 6" },
        { title: "Item 7" },
        { title: "Item 8" },
        { title: "Item 9" },
        { title: "Item 10" },
        { title: "Item 11" },
        { title: "Item 12" },
      ]
    });
  }

  render() {
    return (
      <SwipeableTabs
        noFirstLeftPadding={false}
        noLastRightPadding={false}
        fitItems={false}
        alignCenter={false}
        borderWidthRatio={1}
        activeItemIndex={this.state.activeItemIndex}
        onItemClick={(item, index) => this.setState({ activeItemIndex: index })}
        items={this.state.items}
        borderPosition="top"
        borderThickness={2}
        borderColor="#4dc4c0"
        activeStyle={{
          color: '#4dc4c0'
        }}
      />
    );  
  }
} 
PropertyTypeDefaultDescription
items*arrayOf (element)Array of tabs to render.
onItemClick*funcWhen an item is clicked, this is called with (item, index).
activeItemIndexnumber0This is only useful if you want to control the active item index from outside.
itemClassNamestringItem class name.
itemStyleobject{}Item style.
activeStyleobject{}Active item style.
alignCenterbooltrueWhether or not to align center if items total width smaller than container width.
fitItemsboolfalseThis option will fit all items on desktop
noFirstLeftPaddingboolfalseThis prop defines if the first item doesnt have left padding.

We use this to calculate the border position for the first element.
noLastRightPaddingboolfalseThis prop defines if the last item doesnt have right padding.

We use this to calculate the border position for the last element.
borderPositionenum ('top', 'bottom')'bottom'Border position.
borderColorstring'#333'Border color.
borderThicknessnumber2Border thickness in pixels.
borderWidthRationumber1Border width ratio from the tab width.

Setting this to 1 will set border width to exactly the tab width.
safeMarginnumber100This value is used when user tries to drag the tabs far to right or left.

Setting this to 100 for example user will be able to drag the tabs 100px

far to right and left.
initialTranslationnumber0Initial translation. Ignore this.
stiffnessnumber170React motion configurations.

More about this here
dampingnumber26React motion configurations.

More about this here
resistanceCoeffiecentnumber0.5Drag resistance coeffiecent.

Higher resitance tougher the user can drag the tabs.
gravityAccelarionnumber9.8Gravity acceleration.

Higher resitance tougher the user can drag the tabs.
dragCoefficientnumber0.04Learn more

Contributing

To contribute, follow these steps:

  • Fork this repo.
  • Clone your fork.
  • Run npm install
  • Run npm start
  • Goto localhost:3000
  • Add your patch then push to your fork and submit a pull request

License

MIT

Keywords

FAQs

Last updated on 20 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc