StringTune/Docs

API Reference

CSS Variables

Variables written by built-in modules and how they are intended to be consumed.

CSS Variables

This page covers public CSS variables that are intentionally usable from your own CSS.

If a module only writes inline styles, classes, or DOM attributes, it does not belong here.

Important Boundary

Not every built-in module writes CSS variables.

Examples:

  • StringParallax writes inline transform
  • StringAnchor writes inline transform-origin
  • StringForm writes classes and error DOM
  • StringLoading, StringLazy, StringResponsive, StringScrollContainer, and StringScroller do not expose public CSS variable output

There is no public --parallax variable in the current runtime.

Scroll Progress And Motion

VariableWritten byValueNotes
--progressStringProgress by defaulteased 0..1 numberThe actual variable name can be changed with string-key.
--progress-sliceStringProgressPartremapped 0..1 numberWritten directly on the slice element.
--lerpStringLerpscroll lerp deltaWritten to the source element and mirrors.
--glideStringGlidenormalized displacement valueWritten to the source element and mirrors. The same module also writes inline transform.

Cursor Target Variables

These variables are written to elements marked with string="cursor".

VariableWritten byValueNotes
--xStringCursorlocal horizontal cursor positionMeaning depends on string-alignment.
--yStringCursorlocal vertical cursor positionMeaning depends on string-alignment.
--x-pxStringCursor when enabledlocal pixel XOnly written if string-cursor-vars requests xpx.
--y-pxStringCursor when enabledlocal pixel YOnly written if string-cursor-vars requests ypx.
--dxStringCursor when enabledlocal X deltaOnly written if string-cursor-vars requests dx.
--dyStringCursor when enabledlocal Y deltaOnly written if string-cursor-vars requests dy.
--angleStringCursor when enabledmovement angle in radiansOnly written if string-cursor-vars requests angle.
--angle-degStringCursor when enabledmovement angle in degreesOnly written if string-cursor-vars requests angle-deg.

Cursor Portal Variables

These variables are written to floating portal elements marked with string-cursor="...".

VariableWritten byValueNotes
--xStringCursorviewport X positionConsume with pixel math such as translate3d(calc(var(--x) * 1px), ...).
--yStringCursorviewport Y positionConsume with pixel math.
--x-lerpStringCursorportal follow velocity on XSmoothed portal motion, not target-local motion.
--y-lerpStringCursorportal follow velocity on YSmoothed portal motion, not target-local motion.

Interaction Variables

VariableWritten byValueNotes
--magnetic-xStringMagneticsmoothed X offsetWritten to the source element and mirrors.
--magnetic-yStringMagneticsmoothed Y offsetWritten to the source element and mirrors.
--push-xStringImpulsetranslated X offsetWritten to the source element and mirrors.
--push-yStringImpulsetranslated Y offsetWritten to the source element and mirrors.
--push-rotationStringImpulserotation in degreesWritten to the source element and mirrors.
--spotlight-angleStringSpotlightangle in degreesWritten to the source element and mirrors.
--spotlight-distanceStringSpotlightpointer distanceWritten to the source element and mirrors.

Text Split Variables

StringSplit writes variables to generated wrappers and sometimes to the source element itself.

Variable familyWritten bySurface
--line-index, --word-totalStringSplitgenerated .-s-line wrappers
--word-index, --char-totalStringSplitgenerated .-s-word wrappers
--char-index, --kerningStringSplitgenerated .-s-char wrappers
--char-global-total, --word-global-total, --line-global-totalStringSplitsource element
--fit-font-size, --fit-scale-y, --fit-aspect-ratioStringSplit when fit is activesource element and fit-aware wrappers

Because StringSplit rebuilds DOM, those variables are tied to generated wrapper nodes, not only to the original source element.

Consumption Patterns

Typical usage looks like this:

CSS
.card {
  transform: translateY(calc(var(--glide, 0) * 32px));
}

.cursor-target {
  transform: translate(
    calc(var(--magnetic-x, 0) * 1px),
    calc(var(--magnetic-y, 0) * 1px)
  );
}

.progress-rotate {
  transform: rotate(calc(var(--progress, 0) * 1turn));
}

Where To Go Next

  • For event payloads paired with these variables, see Event Channels.
  • For routing and mirror-related input such as string-key and string-copy-from, see Common Attributes.
  • For full per-module output contracts, use the relevant module pages in Built-in Modules.