KatInterview

Build a Mobile-First Grid and Resilient Signup Form in Plain CSS

System DesignModel answer
HardModel answerSystem Designcssresponsive-designaccessibility

Last updated

Create your own responsive utility-class grid, an accessible navbar and form, then add robust validation, async submit states, retry rules and telemetry, with no CSS framework.

Task

Build a small page that demonstrates a hand-written, utility-first CSS system. You may not import any CSS framework or library. Everything should be your own code: HTML, CSS and, where necessary, a little JavaScript.

Part 1: Utility system and layout

Design reusable classes for:

  • Layout: a centered container, a row, and column classes (col-*) driven by a 12-unit grid.
  • Breakpoints: mobile-first, with at least three tiers (for example small, medium, large). A column with no breakpoint prefix applies everywhere, and larger breakpoints override smaller ones.
  • Gutters: configurable spacing between columns, including a "no gutter" modifier.
  • Nesting: a row placed inside a column must still line up correctly.
  • Helpers: spacing (margin/padding), typography (size, weight, alignment), and a visually-hidden class.

Part 2: Accessible components

Using those utilities, build:

  • a navbar that collapses to a toggle button on narrow screens,
  • buttons,
  • text inputs with labels,
  • inline validation messages.

Use semantic HTML and make the page usable by keyboard and screen reader users.

Part 3: Failure handling for the form

Extend the form so that it handles problems gracefully:

  1. Invalid input: client-side validation with clear, field-level messages.
  2. Async submission failures: the user must see distinct states for loading, success, retryable error (for example network failure or a 5xx response) and non-retryable error (for example a 4xx or a server-side validation rejection).
  3. Telemetry: describe and implement what you would record about validation failures, submit attempts, outcomes and latency.

What to deliver

Provide the code (or well-structured excerpts) and explain the design decisions: how columns are sized, how breakpoints resolve, how nesting and gutters work, how accessibility is achieved, and how the submission state machine behaves.

Hints

Hint 1

Let each column class set only a custom property such as --span, and have one shared rule convert it to a width with calc(var(--span) / 12 * 100%). Breakpoint variants then only need to change that variable.

Hint 2

For gutters, give columns horizontal padding of half the gutter and give the row the opposite negative margin. Because a nested row sits inside a padded column, the same trick keeps nested content aligned.

Hint 3

Treat submission as a small state machine (idle, submitting, success, retryable-error, fatal-error). Guard against double submits with an in-flight flag rather than the native disabled attribute, announce changes in an aria-live region, and reuse an idempotency key on retries.

Hint 4

Classify errors by cause: network failures, timeouts and 5xx are retryable (with backoff); 4xx and 422 are not, and 422 should map messages back onto specific fields.