Give content room
Selected frame
Edits top, right, bottom, and left spacing with linked or independent native number fields and explicit units.
Selected frame
Three ways in. They share one source, so the pixels match whichever you pick.
npm install @noorddev/vlak-react
// once, next to your app's root
import "@noorddev/vlak-react/css";
import { SpacingControl } from "@noorddev/vlak-react";Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/spacing-control.
npx @noorddev/vlak-cli add spacing-control
The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.
npx shadcn add https://vlak.dev/r/spacing-control.json
The same registry item, installed by shadcn's CLI.
<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />
No React. Link vlak.css and use the markup and classes below.
import { SpacingControl } from "@noorddev/vlak-react";
<SpacingControl label="Padding" name="padding" unit="px" min={0} defaultValue={{ top: 16, right: 24, bottom: 16, left: 24 }} />Four native numeric fields; linking applies the next edit to every side.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | ReactNode | ||
value | SpacingValue | ||
defaultValue | SpacingValue | initial | |
onValueChange | (value: SpacingValue) => void | ||
linked | boolean | ||
defaultLinked | boolean | false | |
onLinkedChange | (linked: boolean) => void | ||
unit | string | "px" | |
min | number | ||
max | number | ||
step | number | 1 | |
readOnly | boolean |
Also accepts Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "defaultValue" | "onChange">.
| Keys | Does |
|---|---|
| Tab | Moves through four number inputs and the link action. |
| Arrow up, Arrow down | Uses native number stepping with supplied min, max, and step. |
| Enter, Space | Toggles Link sides on the focused action. |
<fieldset class="rs-spacing-control"><legend class="rs-spacing-control-label">Padding</legend><div class="rs-spacing-control-fields"><label class="rs-spacing-control-field">Top (px)<input class="rs-input rs-input-full rs-spacing-control-input" type="number" value="16" /></label><label class="rs-spacing-control-field">Right (px)<input class="rs-input rs-input-full rs-spacing-control-input" type="number" value="24" /></label><label class="rs-spacing-control-field">Bottom (px)<input class="rs-input rs-input-full rs-spacing-control-input" type="number" value="16" /></label><label class="rs-spacing-control-field">Left (px)<input class="rs-input rs-input-full rs-spacing-control-input" type="number" value="24" /></label></div></fieldset>