CSS EXPERIMENT

CSS Logic Lab

Everything this lab demonstrates, on one page: drag the stage's corner, and the state readout, the card, and the pipeline diagram below all read the same number. No slider, no JavaScript, just resize: horizontal and @container.

Drag the corner ↘ to change the available width.

STATE SIGNAL

Adaptive Data Card

STATE 0 STATE 1 STATE 2 STATE 3 STATE 4
NameAcme Corp
Price$182.30
24h Change+1.2%
Volume4.1M
Market Cap$2.9T
Information capacity 1 / 5 2 / 5 3 / 5 4 / 5 5 / 5
WIDTH ultra-small compact normal spacious huge
QUANTIZE @container
STATE 0 1 2 3 4
CAPACITY 1 2 3 4 5
UI 1 column 2 columns 3 columns 4 columns 5 columns

1. Threshold logic

What's actually setting --state on this page, not a simplified stand-in for it.

.pipeline {
  --state: 0;
  transition: --state .2s ease-out;

  @container (width >= 320px) { --state: 1; }
  @container (width >= 560px) { --state: 2; }
  @container (width >= 800px) { --state: 3; }
  @container (width >= 1040px) { --state: 4; }
}

2. Turn state into behavior

One derived signal, --capacity, feeding both a grid track count and a boolean toggle.

.component {
  --capacity: calc(var(--state) + 1);
}

.metrics {
  grid-template-columns:
    repeat(var(--capacity), 1fr);
}

.t1 { display: none; }

@container (width >= 320px) {
  .t1 { display: block; }
}

3. Think in signals

The same signal, built out elsewhere in this lab