React Dojo

Search

Search concepts, exercises and quizzes

practicebasic

Tab component

A tabs component with 3 tabs. Clicking a tab shows its content and hides the others. Use state to track which tab is active.


Objectives

  1. 1.Declare activeTab state with initial value home
  2. 2.Create 3 buttons for tabs: home, about, contact
  3. 3.On click, set activeTab to the clicked tab
  4. 4.Show different content for each tab based on activeTab
  5. 5.Style the active tab differently from inactive ones
your code
Hint

Use conditional rendering: activeTab === 'home' && <HomeContent />

Related concepts

Was this helpful?
Sign in to give feedback