Styling

The same field, in any look.

soupcon ships no CSS. className goes on the root, and each part inside it has a data attribute to target. Here's one pair of fields in five styles.

Site#

The look of this site. A muted letter you drag, then the value.

Glass#

A translucent fill with backdrop-blur. It needs something colorful behind it.

Neobrutalist#

Thick borders and a hard offset shadow. The shadow grows while you drag.

Terminal#

Monospace and sharp corners. label takes any node, so it can be a bit of text like $w.

Soft#

Large radii and a wide, diffuse shadow that deepens while you drag.

Parts#

PartSelector
Root[data-soupcon-root]
Drag handle[data-soupcon-label]
Input[data-soupcon-input]
Unit[data-soupcon-unit]

With Tailwind, the parts are direct children of the root, so *: reaches them.

<Soupcon className="*:data-soupcon-label:w-7 *:data-soupcon-input:font-mono" />

Style by state#

The root has a data-scrubbing, data-editing, data-disabled or data-readonly attribute while each is true.

<Soupcon className="data-scrubbing:bg-neutral-200 data-disabled:opacity-50" />

Good to know#