Skip to content
Sandny Blog
  • Home
  • Java
  • JavaScript
  • AWS
  • Embedded
  • About
JavaScript

Simple Tab View Using react-tabs

  • October 28, 2019November 3, 2019
  • by Coder Kai

This article will guide you on how to create a simple tab component using the react-tabs library.

Install react-tabs using

yarn add react-tabs    why yarn ?

Basic Example 1

import React from "react";  // 'React' must import from the react 
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import 'react-tabs/style/react-tabs.css';

const tabView = (
    <Tabs >
        <TabList>
            <Tab >Tab 1</Tab>
            <Tab >Tab 2</Tab>
        </TabList>

        <TabPanel>
            <h2>content 1</h2>
        </TabPanel>
        <TabPanel>
            <h2>content 2</h2>
        </TabPanel>
    </Tabs>
);

export default tabView;'

 

Note:React must be in the scope.

Basic Example 2

import React from "react";
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import 'react-tabs/style/react-tabs.css';

const tabView1 = (
    <Tabs defaultIndex={1} >  {/* defaultIndex define initial selected tab index .index start from 0 */}
        <TabList>
            <Tab>Tab 1</Tab>
            <Tab>Tab 2</Tab>
            <Tab disabled={true}>Tab 3</Tab> {/*  when disabled=true tab will be disabled */}
        </TabList>

        <TabPanel>
            <h2>content 1</h2>
        </TabPanel>
        <TabPanel>
            <h2>content 2</h2>
        </TabPanel>
        <TabPanel>
            <h2>content 3</h2>
        </TabPanel>
    </Tabs>
);

export default tabView1;
Note:You can use regular /* Block Comments */ as java 
script but they need to be wrapped in curly braces.
The Common Errors that beginner React Developers Make
Difference Between npx and npm
Coder Kai
A humble developer
example tab view using reactjs react react-tabs ReactJS tab tab compone tab view Tab View Using react-tabs Tabs React component

Related articles

Multiple refs for an array of React Elements
Using multiple refs for an…
Immutable and Mutable Values in Javascript
07. Immutable and Mutable Values…
wrapper objects in javascript
06. Wrapper objects in Javascript
globals undefined and null values in javascript
05 Global, null and undefined…
Javascript Booleans and Equality
04. Javascript Guide Booleans and…
How to add Chakra UI Animations
Chakra UI Animations
SSL Websocket using Nginx Proxy
SSL Websocket proxy with Nginx…
Change python version correctly
Python is not setting correct…
optimize React.js load time
How to optimize React.js app…
Multiple refs for an array of React Elements
How to use IntersectionObserver to…
Multiple refs for an array of React Elements
How to dismiss dropdowns when…
Javascript guide Strings
03. Javascript Guide – Strings
How to fetch data with useEffect
How to fetch data with…
add styles to stripe elements
How to add styles to…
Typescript
How to use Typescript with…
how to optimize react-native map view
How to optimize react-native map…
debounce with react hooks
Avoid multiple clicks using debounce…
Numbers inJavascript
02. Javascript Guide – Numbers
Introduction to Javascript
01. Javascript Guide – Introduction…
Nginx Load Balancer with docker…

Simple Tab View Using react-tabs

  • October 28, 2019October 28, 2019
  • by Coder Kai

This article will guide you on how to create a simple tab component using the react-tabs library.

Install react-tabs using

yarn add react-tabs    why yarn ?

Basic Example 1

import React from "react";  // 'React' must import from the react 
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import 'react-tabs/style/react-tabs.css';

const tabView = (
    <Tabs >
        <TabList>
            <Tab >Tab 1</Tab>
            <Tab >Tab 2</Tab>
        </TabList>

        <TabPanel>
            <h2>content 1</h2>
        </TabPanel>
        <TabPanel>
            <h2>content 2</h2>
        </TabPanel>
    </Tabs>
);

export default tabView;'

(more…)

Terms of service
Javascript Comprehensive Guide
Coder Kai
A humble developer

Related articles

Create Lambda function with Terraform
How to create Lambda function…
Create Lambda function with Terraform
How to read AWS credential…
Multiple refs for an array of React Elements
Using multiple refs for an…
Immutable and Mutable Values in Javascript
07. Immutable and Mutable Values…
wrapper objects in javascript
06. Wrapper objects in Javascript
globals undefined and null values in javascript
05 Global, null and undefined…
Javascript Booleans and Equality
04. Javascript Guide Booleans and…
How to add Chakra UI Animations
Chakra UI Animations
Copy files from S3 to PostgreSQL RDS
How to copy files from…
Pandas Dataframe to a file and read back
How to save pandas Dataframe…
SSL Websocket using Nginx Proxy
SSL Websocket proxy with Nginx…
Change python version correctly
Python is not setting correct…
optimize React.js load time
How to optimize React.js app…
String.lines()
How to convert a string…
Multiple refs for an array of React Elements
How to use IntersectionObserver to…
Minimum supported Gradle Version
Minimum supported Gradle version is…
Multiple refs for an array of React Elements
How to dismiss dropdowns when…
Javascript guide Strings
03. Javascript Guide – Strings
How to fetch data with useEffect
How to fetch data with…
add styles to stripe elements
How to add styles to…

Categories

  • android 3
  • Apollo Client 1
  • AWS 8
    • AppSync 5
    • EC2 1
    • EKS 1
    • Route53 1
    • S3 1
  • AWS Amplify 1
  • Chakra UI 1
  • Docker 1
  • Embedded 1
  • EmberJS 1
  • FCM 1
  • Godaddy 1
  • GraphQL 3
  • ios 1
  • Jasper 1
  • Java 10
    • Java 11 1
    • Java 14 1
  • JavaEE 2
  • JavaScript 39
    • Express.js 4
    • Javascript Guide 7
    • Node.js 3
    • react-native 4
    • React.js 17
    • Typescript 1
  • Kubernetes 1
  • machine learning 1
  • Maven 2
  • OCaml 3
  • PostgreSQL 1
  • Python 2
  • react-native 4
  • ReactJS 3
  • sass 1
  • Server 6
  • spark 1
  • Terraform 2
  • Ubuntu 4
  • Uncategorized 1
  • webpack 2

Recent Comments

  • Pamela587 on Chakra UI Animations
  • Alicia1760 on Chakra UI Animations
  • vneuweluso on How to add styles to stripe elements without using CardElement

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Archives

  • October 2022 3
  • September 2022 7
  • May 2022 1
  • December 2021 1
  • August 2021 1
  • July 2021 6
  • June 2021 3
  • February 2021 1
  • July 2020 1
  • December 2019 5
  • November 2019 6
  • October 2019 3
  • August 2019 1
  • March 2019 1
  • February 2019 1
  • January 2019 2
  • December 2018 1
  • September 2018 2
  • August 2018 1
  • June 2018 1
  • February 2018 1
  • November 2017 2
  • October 2017 5
  • September 2017 1
  • June 2017 1
  • May 2017 10
Sandny Blog space
Theme by Colorlib Powered by WordPress