Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>Updates an object's values on mousemove</h1>
<p>the ball is just there to make the changes visible</p>
<div id="ball"></div>


                #ball {
  width: 50px;
  height: 50px;
  position: fixed;
  top: 0;
  left: 0;
  background: hsl(100, 100%, 80%);
  transform: translate(-50%, -50%);
  border-radius: 50%;


                let ball = document.getElementById('ball');
let mousePos = {
  x: 0,
  y: 0
let tween = new TweenMax(mousePos, 0.8, {
  x: window.innerWidth / 2,
  y: window.innerHeight / 2,
  onUpdate: () => reactToTweenUpdate(),
  ease: Power4.easeOut

// applies the changes
// for this pen, I am applying the values to 
// the div#ball, just to demo what I want
function reactToTweenUpdate() { = `${mousePos.x}px`; = `${mousePos.y}px`;
// registers the mouse move handler.
// would be replaced with 'devicemotion' on mobile devices
window.addEventListener('mousemove', e => {
    x: e.clientX,
    y: e.clientY
  }, true)