Flexbox is a one-dimensional layout model for aligning items along a main axis and cross axis; CSS Grid is a two-dimensional layout model that places items into rows and columns with explicit tracks and alignment controls.
In simpler words
Flex is for a row or a column of items (nav, toolbars, card rows). Grid is for full page or card grids with rows and columns together. Use justify-* and align-* to distribute and center; prefer gap over margin hacks.
Flex direction, wrapping, justify-content, align-items, gap; Grid tracks and simple alignment; choosing flex vs grid.
After this you can
Center a card, space a toolbar, and build a two-column layout with the correct model.
Explain the trade-off to a teammate using a small example.
Name at least one common bug pattern for this topic.
Understand Flexbox & Grid alignment
Flex direction, wrapping, justify-content, align-items, gap; Grid tracks and simple alignment; choosing flex vs grid.
Start by identifying which value or browser behavior changes. Then describe the UI from that current input instead of editing the DOM as a separate source of truth.
Read the example from data and control flow to the resulting UI. Keep the component boundary small.
Apply Flexbox & Grid alignment
Keep rendering as a calculation. Put user-triggered changes in event handlers, preserve UI memory in state, and reserve external synchronization for Effects or the server-state layer.
Name values by their UI meaning, test the loading and error path when data is remote, and avoid keeping two editable copies of the same value.
Ask before adding code: is this local UI memory, shared client state, or Nest-owned server state?
Where bugs hide
Definition
High-bug areas are places where a small API misuse looks correct but produces stale UI, duplicate work, or silent failures.
In simpler words
Each mistake below shows Wrong vs Right code — compare them side by side.
When something misbehaves, match the symptom to a pattern below before rewriting the feature.
Prefer fixing the ownership or update path over adding another Effect or sync step.