Frontend School

Dynamic Artist Profile Tabs

Machine Coding
easy

Dynamic Artist Profile Tabs

Easy
React
TypeScript
UI
Tabs
Dynamic Content
State Management

Overview

Spotify artist profiles are central to how users discover and engage with their favorite artists. A key interaction pattern on these profiles is the use of tabs to categorize and display different types of content, such as songs, albums, and podcasts. This problem challenges you to build a simplified version of this tabbed interface, focusing on dynamic content rendering and state management.

What you need to do / Task

Your goal is to create a React component that displays a set of tabs and dynamically renders content based on the currently active tab.

  1. Implement a Tabs component: This component should accept an array of tab configurations, each containing a label and content.
  2. Dynamic Tab Rendering: Render the tab labels horizontally.
  3. Active Tab Management: When a tab is clicked, it should become the active tab, and its corresponding content should be displayed. Only one tab can be active at a time.
  4. Content Display: The content associated with the active tab should be rendered below the tab navigation. Use the provided mock data structure.

UI/UX expectations

  • Tab Layout: Tabs should be displayed horizontally, resembling navigation links.
  • Active State: The active tab should have a distinct visual style (e.g., different background color, bolder text, or an underline) to clearly indicate its selected state.
  • Content Area: The content for the active tab should be rendered in a distinct area below the tabs.
  • Basic Styling: Apply minimal CSS to make the tabs and content distinguishable. Focus on functionality over pixel-perfect design.

Acceptance criteria

  • The component renders all tab labels provided in the mock data.
  • Clicking any tab makes it visually active.
  • Clicking a tab hides the previously active tab's content and displays the newly active tab's content.
  • Only the content of the currently active tab is visible at any given time.
  • Upon initial render, the first tab is active by default, and its content is displayed.

Constraints

Constraints & assumptions

  • You must use React and TypeScript.
  • No external UI component libraries (e.g., Material UI, Ant Design, Chakra UI). Build the tab component from scratch using basic HTML elements and CSS.
  • The data structure for tabs will be provided and will not change during runtime.
  • Focus on the core functionality; advanced styling or animations are not required.

Out of scope

  • Client-side routing (e.g., changing URL paths based on tab selection).
  • Data fetching from an API; use the provided mock data.
  • Complex accessibility features beyond basic semantic HTML.

What interviewers evaluate

  • Correctness: Does the tab switching logic work as expected, showing the correct content?
  • Component Structure: Is the React component well-organized, maintainable, and does it use state effectively?
  • Dynamic Rendering: Is content correctly rendered based on the active tab?
  • Basic Styling: Is the UI clear and functional, even with minimal styling?

Loading editor...