Frontend School

Multi-Step Product Configuration Wizard

Machine Coding
medium

Multi-Step Product Configuration Wizard

Medium
React
State Management
UI Components
Stepper
Forms

Overview

Imagine building a feature for Flipkart that allows users to customize a product before adding it to their cart, like configuring a laptop with specific RAM, storage, and operating system options. Such a process often involves multiple sequential decisions, which are best guided through a multi-step wizard. This problem focuses on building a reusable Stepper component that provides a structured, guided user experience for such configuration flows.

What you need to do / Task

Your primary task is to implement a flexible and reusable Stepper component in React. This component will orchestrate a series of steps, displaying their titles, rendering the content of the current active step, and providing navigation controls.

  1. Implement the Stepper Component: Create a functional React component named Stepper that accepts an array of step objects as props. Each step object should have at least a title (string) and a component (a React component to render for that step).
  2. Step Navigation: Implement "Previous" and "Next" buttons to navigate between steps.
  3. State Management: The Stepper component should manage its internal state to keep track of the currentStep index.
  4. Conditional Navigation: Disable the "Previous" button when on the first step and the "Next" button when on the last step.
  5. Dynamic Content Rendering: The content area of the Stepper should dynamically render the React component associated with the currentStep.
  6. Highlight Active Step: Visually indicate which step is currently active in the step header.

UI/UX expectations

  • Stepper Header: Display a row of step titles at the top. The current step's title should be visually distinct (e.g., bold, different color, or an indicator).
  • Content Area: Below the step titles, there should be a dedicated area where the content component for the active step is rendered.
  • Navigation Controls: At the bottom, place two buttons: "Previous" and "Next". These buttons should be clearly labeled and their disabled states should be visually apparent.
  • Basic Styling: Apply minimal CSS to make the layout clear and functional. Focus on structural layout rather than pixel-perfect aesthetics.

Acceptance criteria

  • The Stepper component renders with all provided step titles in the header.
  • Clicking the "Next" button successfully advances the currentStep and renders the content of the subsequent step.
  • Clicking the "Previous" button successfully decrements the currentStep and renders the content of the prior step.
  • The "Previous" button is disabled when the currentStep is the first step (index 0).
  • The "Next" button is disabled when the currentStep is the last step.
  • The content component corresponding to the currentStep is correctly rendered in the content area.
  • The active step in the header is visually highlighted.

Constraints

Constraints & assumptions

  • You must use React for this problem.
  • Do not use any external UI component libraries (e.g., Material UI, Ant Design, Bootstrap components). Build all UI components from scratch.
  • Assume step content components are simple functional components that do not require complex props from the Stepper itself.
  • The maximum number of steps will be small (e.g., 2-5 steps).
  • Focus on the core Stepper logic and UI, not complex form validation within individual step content components.

Out of scope

  • Advanced accessibility features (beyond basic button disabling).
  • URL routing or deep linking to specific steps.
  • Complex data submission or API integration for the entire wizard flow.
  • Persisting step state across page refreshes.

What interviewers evaluate

  • Correctness and Completeness: Does the Stepper component function as described, accurately managing step state and rendering content?
  • Component Design: Is the Stepper component modular, reusable, and well-structured, adhering to React best practices?
  • State Management: How effectively is the internal state of the Stepper managed to control navigation and content rendering?
  • UI/UX Adherence: Are the basic UI/UX expectations met, including navigation controls and active step indication?
  • Code Quality: Is the code clean, readable, and maintainable, with appropriate use of props, state, and event handlers?

Loading editor...