slideVars

Interactive UI controls for your CSS --custom-properties, automatically. From your pals at .

npm install @codepen/slidevars
import { slideVars } from "@codepen/slidevars"; slideVars.init(); // That's it!

Basic Usage Pen ↗ · GitHub · npm

Live Demo

Click the button in the top right to open the controls. Move the sliders (and pick colors) to see the changes reflected in the demo below.

Auto-Detection Example

Just define CSS variables in your stylesheet. SlideVars figures out the rest:

Auto!
/* Your CSS */ 
:root { 
  --size: ; 
  --bg: ;
  --border-radius: ; 
  --rotation: ; 
  --shadow-size: ;
}
/* Your JavaScript */ import { slideVars } from "@codepen/slidevars"; slideVars.init(); // Auto-detects all variables!

Advanced: Manual Placement

You can manually place the <slide-vars> element wherever you want HTML (rather than it being auto-injected into the bottom of the <body>). Children will be slotted into the top of the control panel.

<slide-vars> <p>Welcome to the fun zone.</p> </slide-vars>

Supported Values

Length Units

Auto-detected sliders support all CSS numeric data types with intelligent default ranges:

💡 Smart Adaptation: Ranges automatically expand if the current value is outside the defaults.

Color Values

Auto-detected color variables support:

Note: newer color syntaxes (like oklch() / color()) aren’t currently auto-detected.

API Reference

slideVars.init(config?, options?)

Initialize the component with optional configuration.

Options:

Programmatic Control

slideVars.open(); // Open the controls panel slideVars.close(); // Close the controls panel slideVars.toggle(); // Toggle open/closed slideVars.destroy(); // Remove component from DOM