Frontend School

Interactive Spreadsheet Grid

Machine Coding
easy

Interactive Spreadsheet Grid

Easy
UI
React
Frontend
Grid
State Management

Overview

Blinkit's internal tools often require displaying tabular data in an interactive way, similar to a spreadsheet. This problem simulates a core component of such a tool: a simple grid where users can select cells, observe their coordinates, and visualize the active selection. This exercise tests fundamental UI rendering and state management skills crucial for building interactive dashboards and data entry forms.

What you need to do / Task

Your task is to build a simple interactive grid component with the following features:

  1. Grid Rendering: Render a fixed grid of 5 rows and 5 columns.
  2. Cell Content: Each cell in the grid must display its row and column index (e.g., "R0C0", "R0C1", "R1C0", etc.).
  3. Cell Selection: When a cell is clicked, it should become the "selected" cell.
  4. Single Selection: Only one cell should be selected at any given time. Clicking a new cell should deselect the previously selected one.
  5. Visual Feedback: The currently selected cell must have a distinct visual appearance (e.g., a thicker, colored border, or different background).
  6. Coordinate Display: Above the grid, prominently display the coordinates of the currently selected cell (e.g., "Selected Cell: R2C3"). If no cell is selected (initial state), display "Selected Cell: None".

UI/UX expectations

  • The grid should be clearly structured and easy to visually parse.
  • Cells should be clearly distinguishable from each other.
  • The visual feedback for a selected cell should be immediate and obvious.
  • The displayed coordinates should update in real-time with cell selection.
  • Basic styling is expected to make the UI presentable.

Acceptance criteria

  • A 5x5 grid of interactive cells is rendered on the screen.
  • Each cell correctly displays its R{row_index}C{column_index} identifier.
  • Clicking any cell highlights it visually as the active selection.
  • Clicking a different cell deselects the previously active cell and highlights the newly clicked one.
  • The text label above the grid accurately reflects the coordinates of the currently selected cell.
  • When the application initially loads, no cell is selected, and the label displays "Selected Cell: None".

Constraints

Constraints & assumptions

  • The grid size is fixed at 5 rows and 5 columns. No dynamic resizing or configuration is required.
  • Focus on functional React components and hooks for state management.
  • The application should run in a modern web browser environment.
  • No complex data fetching or manipulation beyond coordinate display.

Out of scope

  • Keyboard navigation for cell selection.
  • Editing cell content or complex spreadsheet functionalities (e.g., formulas).
  • Dynamic grid sizing or user-configurable dimensions.
  • Performance optimizations for very large grids.
  • Full accessibility features beyond basic clickability.

What interviewers evaluate

  • Component Design: Ability to structure the UI into logical, reusable React components.
  • React Fundamentals: Correct application of useState for managing UI state and handling events.
  • Styling: Effective use of CSS to provide clear visual feedback for interactive elements.
  • Logic Implementation: Accuracy in implementing the cell selection and coordinate display logic.
  • Code Quality: Readability, maintainability, and adherence to basic React best practices.

Loading editor...