A production dropdown starts with semantics, not coordinates. Decide whether the control selects a value, runs an action, accepts typed text, or only reveals content. Then design one explicit state machine for opening, navigation, commitment, dismissal, focus, and positioning. Use the native
<select>whenever it meets the product requirements.
“Dropdown” is how a popup looks. It does not tell an engineer what the popup means. A country field, an account-actions menu, an autocomplete, and a help disclosure can all open beneath a button. They need different roles, keyboard behavior, state, and form contracts.
This interview question asks you to design a reusable single-select primitive for a component library. The basic product has a labelled trigger, a popup list of options, keyboard and pointer input, disabled options, option groups, typeahead, form participation, and enough positioning logic to work inside real application layouts.
Start by choosing the right semantic family
The first design decision is whether to build anything custom.
Use a native <select> when the options are plain, the browser's mobile picker is welcome, and exact popup styling is not a requirement. Native form submission, constraint validation, keyboard behavior, and platform accessibility come with it.
If users choose one value from a fixed list and the closed control must expose that value, the custom version is usually a select-only combobox with a listbox popup. The W3C combobox pattern distinguishes this from an editable combobox. If the popup contains actions such as Rename or Delete, it is a menu button instead. If it contains links, buttons, and general content, neither listbox nor menu may be the right abstraction.
The public interview prompt
Design a dropdown and single-select primitive for a frontend design system. Explain:
- when the library should render a native select and when it should use a custom popup;
- the controlled and uncontrolled API;
- selected, active, open, disabled, and pending state;
- keyboard, pointer, touch, screen-reader, zoom, and right-to-left behavior;
- popup positioning, clipping, portals, stacking, and outside interaction;
- large option sets, typeahead, virtualization, and asynchronous options;
- form submission, validation, server rendering, and hydration;
- testing, observability, rollout, and failure containment.
Assume a single-select field with up to 200 local options in the normal case. Searching a remote catalog and multi-select behavior are separate primitives that may reuse lower-level pieces. The trigger must work in forms, dialogs, scroll containers, mobile layouts, and pages rendered on the server.
What the premium solution covers
The full solution works from the semantic decision through the production architecture. It includes original mobile-friendly diagrams, a state and event model, typed API contracts, positioning middleware, portal ownership, focus strategies, typeahead, form integration, performance budgets, degraded behavior, security boundaries, a test matrix, rollout metrics, an interview walkthrough, and a level-by-level scoring rubric.
The core invariant is small enough to remember: the closed trigger shows the committed value; opening creates a temporary active candidate; only an explicit commit changes the value. Escape, blur, scrolling, disabled options, controlled updates, and portal events all have to preserve that rule.