Skip to content
LSD Framework
LSD primitive · token-aware authoring

Token Snap Drag

Drag a handle. Instead of writing pixel-noise, it snaps to the next slot on the design-token scale. A floating chip names the token. Pure raw-drag is available right beside it, for contrast — you can feel why one mode produces a system and the other produces drift.

snaps to --space-* scale chip · ticks · free + snap modes ↩ All components
01 · Snap-on · the scale catches the handle--space-xxs … --space-7xl
24px · width
24px · --space-2xl
current
24px --space-2xl
drift from token
0px
02 · Multi-axis · X snaps independently of Y--space + --size
width
96px --space-7xl
height
64px --space-7xl
03 · Token scale--space-* family
TokenValueUse case
--space-xxs2pxHairline · keyline
--space-xs4pxIcon padding · pill gap
--space-sm8pxCompact stack · chip gap
--space-md12pxCard-inner spacing
--space-lg16pxDefault rhythm · base unit
--space-xl20pxSidebar gutter
--space-2xl24pxCard padding
--space-3xl32pxSection gap
--space-4xl40pxHero padding
--space-5xl48pxSection vertical
--space-7xl64pxPage-section break
--space-9xl96pxHero vertical · landing
UsageAPI surface

Authoring contract

The host reads a token scale (declared in JS or DOM) and snaps the drag value to the nearest entry. Snap threshold defaults to ½ the gap between adjacent tokens. data-snap="off" falls back to raw pixel dragging. The chip floats above the drag handle, hidden by default, visible during the gesture.

HookValuesEffect
data-snapon · offEnable / disable token snap.
--tsd-w / --tsd-hnumber (px)Live values; host element reads these into width / height.
data-axis on handlex · yWhich dimension the handle controls.
JS eventtsd:snapFires with detail.px, token, axis.
prefers-reduced-motionTransition removed; snap still computes.
View HTML
<div class="lsd-tsd" data-snap="on" style="--tsd-w: 24;">
  <div class="lsd-tsd__rail">
    <div class="lsd-tsd__chip"><b>24px</b> · <code>--space-2xl</code></div>
    <div class="lsd-tsd__handle" data-handle></div>
  </div>
  <div class="lsd-tsd__ticks"></div>
</div>
LSD components · Token Snap Drag · primitive
↩ All components