Cluster layout

클러스터 레이아웃

Wraps items of varying width — tags, buttons — with a uniform gap in every direction. Just flex-wrap plus gap.

Also known as: Every Layout Cluster
···
html
<div class="stage" id="stage">
  <div class="cluster">
    <span class="chip">Design</span><span class="chip">Frontend</span><span class="chip">Motion</span>
    <span class="chip">A11y</span><span class="chip">Typography</span><span class="chip">Color</span>
  </div>
</div>
css
.stage{width:46%;min-width:170px;max-width:92%;border:2px dashed var(--muted);border-radius:10px;padding:10px;
  transition:width 2.8s cubic-bezier(.4,0,.2,1);box-sizing:border-box}
.stage.wide{width:92%}
.cluster{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:flex-start}
.chip{padding:5px 10px;border-radius:999px;background:var(--accent);color:#fff;font-size:clamp(9px,1.8vmin,11px);
  font-weight:700;white-space:nowrap}
.chip:nth-child(even){background:var(--accent-3)}
js
const stage = document.getElementById('stage');
setInterval(() => stage.classList.toggle('wide'), 2200);

A familiar headache with tag lists or button groups: you don't know the count or the widths in advance. Build it with inline-block plus margin-right and the vertical gap at a wrap point rarely matches the horizontal one, and the last item is left with an unwanted margin. display: flex; flex-wrap: wrap; gap: var(--space) removes the whole problem in one line, since gap applies identically in every direction, including across wraps.

Every Layout adds justify-content and align-items: center to define how the items "cluster." Whether they hug the left edge or gather in the center depends on the content — filter chips usually read better left-aligned, while a hero section's CTA button group often looks right centered.

The key is never fixing item width. Each item takes only as much space as its own content needs, and the container wraps them to a new line automatically once it runs out of room — no calculation of "how many fit per row" required.

When to use

Use it whenever several width-varying items — filter chips, tags, a row of social icons, a CTA button group — need to read as one loose cluster.