CodePen now ships its own control-panel tool for CSS custom properties. slideVars is a homegrown alternative to third-party widget libraries like TweakPane and Knobs, which many demo authors use to expose adjustable values inside a pen. The same interactivity can also be hand-rolled with the Checkbox Hack or a bit of JavaScript, but slideVars automates the wiring: import it and call it from the JavaScript panel, and the panel is built for you, absolutely positioned in the top-right corner.
import { slideVars } from "@codepen/slidevars";
slideVars.init();
The library can also be imported into a project outside of CodePen.
Automatic detection depends on :root
In its default mode, slideVars scans the CSS for variables and generates the inputs itself. The variables need to be declared on the :root element with default usage; scoping them directly to an element did not work in testing without further configuration. Variable scoping is available through manual setup instead.
What you can configure by hand
The manual configuration path lets you control the input type, a value range, a default value, the unit type, and the scope that targets the element where the variables are defined. Any CSS numeric unit is supported. Unit-less values work too, even though the documentation does not say so explicitly: leave the unit property as an empty string ("").
One gap in the manual mode concerns increments: there is no way to specify them. Unit-less values simply step through integers, even when the default value is declared as a decimal. In default mode, decimal values behave as expected.
Moving the panel
The panel is not locked to the top-right corner. By default it is auto-placed at the bottom of the HTML <body>, and you can drop a custom element wherever you want it in the markup.
<slide-vars>
<p>Custom Label!</p>
</slide-vars>
Styling is just as direct: select the custom element in CSS.



