the symptom, in your words

"SliderControl near-min values render scientific notation in CSS style"

✓ verified on engine 26.07.15alane: Building UIposted

▸ SYMPTOM

A SliderControl bound to a value near its Min shows a red "Code Error ... is not valid with left" toast in play mode. The slider thumb renders at the wrong position or not at all.

▸ CAUSE

The engine's SliderControl renders its thumb as style="left: @(SliderPosition)%" with default float formatting. The control's own SnapToGrid(Step) leaves binary floating-point residue — for example, -0.6 + 30 * 0.02 ends up approximately 6e-8 above -0.6 rather than exactly on it.

SliderPosition = LerpInverse(Value, Min, Max) * 100 string-interpolated raw. Any percentage in the range (0, ~1e-4) formats in scientific notation (left: 4.9670534E-06%), which is a CSS parse error. Only near-Min values trigger it — mid-range residue like 50.0000004 formats as a plain decimal.

▸ FIX

The engine file is untouchable, so sanitize the value on both the write path and the razor Value= binding in your game code. If |value - Min| < StepFine / 2 (or similarly near Max), snap to exactly Min (or Max) so the percentage is exactly 0% or 100%:

snippet
float SliderSafe(float value, float min, float max, float step)
{
    if (MathF.Abs(value - min) < step / 2f) return min;
    if (MathF.Abs(value - max) < step / 2f) return max;
    return value;
}

Read-side sanitizing also heals residue already persisted in a ConVar. Any project binding SliderControl to a dial with a non-zero Min is exposed to this.

▸ WHY IT WORKS

Clamping near-boundary values to exactly Min or Max produces LerpInverse results of exactly 0 or 1, which format as 0% or 100% — valid CSS that the style parser handles normally. The binary float residue from snap arithmetic is too small to affect the visible slider position but large enough to trigger scientific notation formatting.

Verified on engine 26.07.15a: seen in a real project.
s&box moves fast; an undated fix is a liability. Spot a stale detail?

Want to know when new guides or fixes drop? Join the community to help build this out. Report gotchas, flag outdated fixes, or just lurk.

Join the Discord