Ant Design Library has this component pre-built, and it is very easy to integrate as well. Tabs Component to used as Tabs make it easy to switch between different views. We can use the following approach in ReactJS to use the Ant Design Tabs Component.
Tabs Props:
activeKey: It is used to denote the current TabPane's key.
addIcon: It is used for the customize add icon.
animated: It is used to indicate whether to change tabs with animation.
centered: It is used to centers the tabs.
defaultActiveKey: It is used to denote the initial active TabPane's key.
hideAdd: It is used to indicate whether to hide plus icon or not.
moreIcon: It is used for the custom icon of ellipsis.
renderTabBar: It is used to replace the TabBar.
size: It is used to denote the tab bar size.
tabBarExtraContent: It is used to denote the extra content in the tab bar.
tabBarGutter: It is used to denote the gap between tabs.
tabBarStyle: It is used for the Tab bar-style object.
tabPosition: It is used to position the tabs.
type: It is used to denote the basic style of tabs.
onChange: It is a callback function that is triggered when the active tab is changed.
onEdit: It is a callback function that is triggered when the tab is added or removed.
onTabClick: It is a callback function that is triggered when the tab is clicked.
onTabScroll: It is a callback function that is triggered when the tab scrolls.
Tabs.TabPane Props:
closeIcon: It is used for customize close icon in TabPane's head.
forceRender: It is used for the forced render of content in tabs.
key: It is used to denote the TabPane's key.
tab: It is used to show text in TabPane's head.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install therequiredmodule using the following command:
npm install antd
Project Structure: It will look like the following.