Flexbox Playground is an interactive builder for CSS Flexbox layouts. You control every container-level property — flex-direction, justify-content, align-items, flex-wrap, and gap — and, separately, every item's own flex-grow, flex-shrink, flex-basis, element type, colors, border radius, box shadow, and padding. Every change reflects instantly in a live DOM preview built from real HTML and CSS, and the complete stylesheet is available to copy at any point.
Flexbox solves a problem CSS struggled with for two decades: distributing space among a row or column of items whose sizes are not known in advance. Before flexbox, centering something vertically or making three columns share leftover space evenly required float hacks, table-cell displays, or JavaScript. Flexbox does it with five or six declarations because it defines an actual algorithm — the browser resolves each item's final size by computing its flex-basis, then growing items with flex-grow to fill leftover space or shrinking items with flex-shrink when content overflows the container, all along a single axis defined by flex-direction.
The two axes are where most flexbox confusion starts. flex-direction: row makes the main axis horizontal, so justify-content controls horizontal spacing and align-items controls vertical alignment. Switch to flex-direction: column and the axes swap — justify-content now controls vertical spacing and align-items controls horizontal alignment. This playground lets you flip flex-direction and watch justify-content and align-items visibly swap roles, which is a faster way to build the mental model than reading a diagram.
The per-item panel matters because flexbox is not just a container property — flex-grow, flex-shrink, and flex-basis live on the children, and they interact with the container's wrap and gap settings in ways that are hard to predict without seeing them. Setting flex-grow: 1 on one item and leaving the rest at 0 gives that single item all the leftover space; setting flex-shrink: 0 stops an item from shrinking below its content size even when siblings compete for room. Element types (text, heading, button, image, card) exist so you can preview flexbox behavior against realistic content instead of blank colored boxes, since real text and images behave differently under grow/shrink than an empty div does.