Tabs

Author
Ex-Meta Staff Engineer
Languages

Build a tabs component that displays one panel of content at a time depending on the active tab element. Some HTML is provided for you as example contents.

Requirements

  • Clicking on a tab makes it the active tab. Add a visual indication (e.g. using blue text color) for the active tab to differentiate it from the non-active tabs.
  • At all times, only one panel's contents should be displayed — the one corresponding to the active tab's.

Notes

  • The focus of this question is on functionality, not the styling. There's no need to write any custom CSS except for highlighting the active tab.
  • You may modify the markup (e.g. adding ids, data attributes, replacing some tags, etc) and use client-side rendering instead.
  • You may want to think about ways to improve the user experience of the application and implement them (you get bonus credit for doing that during interviews).

Asked at these companies

Premium FeaturePurchase premium to see companies which ask this question.
View plans
SwagOverflow — Swag tailored for front end devsSponsor: SwagOverflow
SwagOverflow — Swag tailored for front end devs

Looking for a gift for a fellow dev, or a simple comfy t-shirt that expresses your passion for front end?

Check out SwagOverflow, your ultimate destination for dev-centric apparel and accessories. Whether you’re coding at your favorite café or speaking at a local meetup, our products will help you stand out in any crowd. Here’s why you’ll love SwagOverflow:

  • Unique, dev-Inspired designs: From HTML tags to CSS puns, show off your coding chops
  • Premium quality materials: Made to handle all-night coding sessions or weekend hackathons
  • Variety for every stack: React lover? TypeScript fanatic? We’ve got you covered
  • Perfect gifts for techies: Surprise a friend (or yourself) with front end flair
  • Community-focused: A portion of every purchase goes right back into supporting dev communities
Visit SwagOverflow today ->
SwagOverflow — Swag tailored for front end devsSponsor: SwagOverflow
SwagOverflow — Swag tailored for front end devs

Looking for a gift for a fellow dev, or a simple comfy t-shirt that expresses your passion for front end?

Check out SwagOverflow, your ultimate destination for dev-centric apparel and accessories. Whether you’re coding at your favorite café or speaking at a local meetup, our products will help you stand out in any crowd. Here’s why you’ll love SwagOverflow:

  • Unique, dev-Inspired designs: From HTML tags to CSS puns, show off your coding chops
  • Premium quality materials: Made to handle all-night coding sessions or weekend hackathons
  • Variety for every stack: React lover? TypeScript fanatic? We’ve got you covered
  • Perfect gifts for techies: Surprise a friend (or yourself) with front end flair
  • Community-focused: A portion of every purchase goes right back into supporting dev communities
Visit SwagOverflow today ->