Frontend School

Build a React Highly-Available Multi-Select Chip Input

Machine Coding
medium

Build a React Highly-Available Multi-Select Chip Input

Medium
React
Machine Coding
frontend-interview
a11y
Forms
UI Components

Overview

Build a robust, accessible Multi-Select Input component where selected items are displayed as 'Chips' or 'Pills' within the input area. This task evaluates your ability to manage complex UI states, keyboard navigation, and synchronization between a dropdown list and an input field. It is a common pattern used in email clients and tagging systems.

What you need to do / Task

  1. Input & Filtering: Create an input field that filters a provided list of options as the user types.
  2. Selection Logic: Clicking an option or pressing 'Enter' on a highlighted item adds it as a 'Chip' inside the input.
  3. Chip Management: Users must be able to remove chips by clicking an 'X' icon or pressing 'Backspace' when the input is empty.
  4. Dropdown Toggle: The dropdown should appear when the input is focused and disappear when clicking outside.

UI/UX expectations

  • Layout: Chips should wrap gracefully within the input container if they exceed the width.
  • Feedback: Highlight the 'active' suggestion in the dropdown during keyboard navigation.
  • Empty State: Show a 'No results found' message if the filter matches nothing.

Acceptance criteria

  • [ ] Selected items must not appear in the suggestion dropdown.
  • [ ] Pressing 'Backspace' when the text input is empty should remove the last added chip.
  • [ ] The component must be navigable via Arrow Keys (Up/Down) and selectable via Enter.
  • [ ] Clicking the 'X' on a chip removes it from the selection and returns it to the available pool.

Clarifications

  • Do I need an API? No, use the provided static mock data.
  • Can I use a library? No external UI libraries like Radix or HeadlessUI; build the logic from scratch.

Constraints

Constraints & assumptions

  • The component should be written in React (TypeScript).
  • Avoid duplicate selections; once an item is a chip, it is hidden from the list.
  • The dropdown should be positioned absolutely relative to the input container.

What graders evaluate

  • State Management: How cleanly you handle the filtered list vs. selected list.
  • Keyboard Accessibility: Use of onKeyDown for seamless navigation.
  • Code Cleanliness: Component modularity and prop naming.

Loading editor...