diff --git a/docs/src/app/components/pages/components/tabs.jsx b/docs/src/app/components/pages/components/tabs.jsx index 882cf795b4ecc8..3eff6e4cefabc3 100644 --- a/docs/src/app/components/pages/components/tabs.jsx +++ b/docs/src/app/components/pages/components/tabs.jsx @@ -57,6 +57,12 @@ var TabsPage = React.createClass({ { name: 'Tabs Props', infoArray: [ + { + name: 'initialSelectedIndex', + type: 'number', + header: 'optional', + desc: 'Specify initial visible tab index. Initial selected index is set by default to 0. If initialSelectedIndex is set but larger than the total amount of specified tabs, initialSelectedIndex will revert back to default' + }, { name: 'tabWidth', type: 'number', diff --git a/src/js/tabs/tabs.jsx b/src/js/tabs/tabs.jsx index 92417549dd4bcc..2484d6a1470d35 100644 --- a/src/js/tabs/tabs.jsx +++ b/src/js/tabs/tabs.jsx @@ -6,12 +6,18 @@ var InkBar = require('../ink-bar'); var Tabs = React.createClass({ propTypes: { - onActive: React.PropTypes.func + initialSelectedIndex: React.PropTypes.number, + onActive: React.PropTypes.func, + tabWidth: React.PropTypes.number }, getInitialState: function(){ + var selectedIndex = 0; + if (this.props.initialSelectedIndex && this.props.initialSelectedIndex < this.props.children.length) { + selectedIndex = this.props.initialSelectedIndex; + } return { - selectedIndex: 0 + selectedIndex: selectedIndex }; },