React Tabs
How do I make an react tabs?
What is a react tabs? How do you make a react tabs? This script and codes were developed by Tushar Mehrotra on 06 January 2023, Friday.
React Tabs - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React Tabs</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="root"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
React Tabs - Script Codes CSS Codes
.flex-container { display: flex; height: 100vh; justify-content: center; align-items: center;
}
.tab { text-decoration: none; padding: 15px; background: #f6f6f6; border: 1px solid #dfe5ed; color: #000;
}
.tab-selected { background: #1d9fdb; color: #fff;
}
.content { display: none;
}
.content-selected { display: block;
}
React Tabs - Script Codes JS Codes
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var App = function (_React$Component) { _inherits(App, _React$Component); function App(props) { _classCallCheck(this, App); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { data: [{ title: 'first tab', content: 'first tab content' }, { title: 'Second tab', content: 'Second tab content' }], active: 0 }; return _this; } App.prototype.handleClick = function handleClick(index) { this.setState({ active: index }); }; App.prototype.render = function render() { return React.createElement( 'div', { className: 'flex-container' }, React.createElement(Tabs, { tabs: this.state.data, active: this.state.active, onTabClick: this.handleClick.bind(this) }), React.createElement(Content, { tabs: this.state.data, active: this.state.active }) ); }; return App;
}(React.Component);
var Tabs = function (_React$Component2) { _inherits(Tabs, _React$Component2); function Tabs() { _classCallCheck(this, Tabs); return _possibleConstructorReturn(this, _React$Component2.apply(this, arguments)); } Tabs.prototype.supplyIndex = function supplyIndex(index) { this.props.onTabClick(index); }; Tabs.prototype.render = function render() { var _this3 = this; var active = this.props.active; var tabs = this.props.tabs.map(function (tab, index) { return React.createElement( 'a', { href: '#', key: index, className: 'tab ' + (active === index ? 'tab-selected' : ''), onClick: _this3.supplyIndex.bind(_this3, index) }, tab.title ); }); return React.createElement( 'div', null, tabs ); }; return Tabs;
}(React.Component);
var Content = function (_React$Component3) { _inherits(Content, _React$Component3); function Content() { _classCallCheck(this, Content); return _possibleConstructorReturn(this, _React$Component3.apply(this, arguments)); } Content.prototype.render = function render() { var active = this.props.active; var content = this.props.tabs.map(function (content, index) { return React.createElement( 'div', { key: index, className: 'content ' + (active === index ? 'content-selected' : '') }, content.content ); }); return React.createElement( 'div', null, content ); }; return Content;
}(React.Component);
ReactDOM.render(React.createElement(App, null), document.querySelector("#root"));
Developer | Tushar Mehrotra |
Username | MTushar |
Uploaded | January 06, 2023 |
Rating | 3 |
Size | 3,390 Kb |
Views | 10,120 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
MixItUp With Ajax | 2,689 Kb |
Angular ToDo App | 2,863 Kb |
Full Page JS jQuery Plugin | 2,029 Kb |
React JS add project | 3,543 Kb |
Codepen Pens | 3,066 Kb |
Form Email validation | 2,148 Kb |
AngularJS Directives | 2,734 Kb |
Simple chatbot javascript | 2,442 Kb |
Show Hide Alert with Angular JS | 2,360 Kb |
A Pen by Tushar Mehrotra | 2,043 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Weather App | OmranAbazid | 2,596 Kb |
Twitch API | Coderpilot | 3,412 Kb |
Objects | Bonzaipenguin | 2,616 Kb |
Wikipedia Viewer | Codinger | 4,681 Kb |
Sass random color animation | Jotavejv | 4,827 Kb |
Price Comparison Table | Orrinward | 3,459 Kb |
Pomodoro Clock | Yas46 | 3,328 Kb |
CSS3 Form | Tusharbandal | 1,836 Kb |
Experiment | Toddmoy | 2,849 Kb |
Disable JavaScript execution from console | Ludviglindblom | 2,534 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!