A number field you change by dragging its label.
Drag to scrub, type a value or a bit of math, or step it with the arrow keys. It's the field from a design tool's inspector, for anyone building editors and creative apps.
Installation#
Install the package from your command line.
pnpm add soupconCreate a Soupcon#
Give it a label, a value and a way to change that value. The field is always controlled.
width.tsx
import { useState } from "react";
import { Soupcon } from "soupcon/react";
export function Width() {
const [width, setWidth] = useState(160);
return (
<Soupcon label="W" value={width} onValueChange={setWidth} min={0} unit="px" />
);
}Style it#
soupcon ships no CSS. className goes on the root, and each part has a data attribute to target.
[data-soupcon-root] {
display: flex;
align-items: center;
}
[data-soupcon-root][data-scrubbing] {
background: #eee;
}The only styles it sets are the inline ones dragging needs. See Styling for the parts and states.