React JS Bootstrap Tabs Component Example
Sep 12, 2022 . Admin
Hello Artisan,
This article is focused on react js bootstrap tab example. In this article, we will implement a react js bootstrap tabs component example. I explained simply step by step react bootstrap tab not working. It's a simple example of how to use bootstrap tab in react.js. Here, Create a basic example of reactjs bootstrap tab example.
Bootstrap is a wold best design framework right now. Currently bootstrap 4 and bootstrap 5 version is running. Bootstrap provides alerts, buttons, badge, card, modal, forms, collapse, navs, pagination etc.
In this post, i will show you step by step how to use bootstrap tabs component in reactjs app. we will create new react js project and install "react-bootstrap and bootstrap" npm packages for bootstrap, then we will use bootstrap tab with Heading, Body and Footer component. so let's follow below command:
Step 1: Create React JS AppIn this step, open your terminal and execute the following command on your terminal to create a new react app:
npx create-react-app bootstrap-appStep 2: Install React-Bootstrap
In this step, we will install bootstrap and react-bootstrap npm package for bootstrap design component. let's run below command:
npm install react-bootstrap bootstrapStep 3: Import Bootstrap CSS File
In this step, we will import bootstrap css file in index.js file of react js app. so let's add it.
src/index.jsimport React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; import 'bootstrap/dist/css/bootstrap.min.css'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <React.StrictMode> <App /> </React.StrictMode> ); reportWebVitals();Step 4: Update App.js Component
Here, we will use bootstrap design class and modal component for demo. so just update App.js file as the below:
src/App.jsimport Container from 'react-bootstrap/Container'; import Tab from 'react-bootstrap/Tab'; import Tabs from 'react-bootstrap/Tabs'; function App() { return ( <Container> <h1>React JS Bootstrap Tab Component Example - MyWebtuts.com</h1> <Tabs defaultActiveKey="profile" id="uncontrolled-tab-example" className="mb-3" > <Tab eventKey="home" title="Home"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </Tab> <Tab eventKey="profile" title="Profile"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </Tab> <Tab eventKey="contact" title="Contact" disabled> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </Tab> </Tabs> </Container> ); } export default App;Step 5: Run React JS App
All the required steps have been done, now you have to type the given below command and hit enter to run the React app:
ng serve
Now, Go to your web browser, type the given URL and view the app output:
http://localhost:3000
In the last step run your project using bellow command.
OutputI hope it can help you...