Tabs Component
React.js
medium
15 mins
Implement a Tabs Component that allows users to switch between different tab content sections. Each tab should be clickable, and clicking on a tab should update the displayed content accordingly.
Requirements
- The component should accept a list of tabs as props.
- Each tab should have a
titleandcontent. - The first tab should be selected by default.
- Clicking on a tab should update the displayed content.
- The component should be reusable and scalable.
Constraints
- Constraint 1: The
tabsprop is an array of objects, each containingtitleandcontent. - Constraint 2: Handle an empty
tabsarray gracefully by displaying "No tabs available". - Constraint 3: Handle cases where
titleis missing in a tab by displaying "Tab 1", "Tab 2", according to the tab number. - Constraint 4: Handle cases where
contentis missing in a tab by displaying "No content available".
Reference UI

Preview what you need to build
Companies:
meta
airbnb
swiggy
meesho
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
