Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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.


Auto Save

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.


                <div id="myApp"></div>


                body {
  margin : 0;


                var Surface = Samsara.DOM.Surface;
var Context = Samsara.DOM.Context;
var Transform = Samsara.Core.Transform;
var MouseInput = Samsara.Inputs.MouseInput;
var Accumulator = Samsara.Streams.Accumulator;

var mouseInput = new MouseInput({
    direction : MouseInput.DIRECTION.X

// An accumulator is a stream that adds up all values it subscribes to over time
var displacement = new Accumulator(0);

// Send the deltas of the mouse movement to the displacement accumulator

var redSize ={
    var length = value + 100;  
    return [length, length];

var redSurface = new Surface({
    content : 'drag me',
    size : redSize,
    properties : {
      background : 'red',
      cursor : 'ew-resize'

var blueTransform ={
    return Transform.translateX(size[0]);

var blueSurface = new Surface({
    size : [100, 100],
    properties : {background : 'blue'}

var context = new Context();

// The mouse input listens to mouse events on the redSurface

var dragDisplacement ={
    return Transform.translateX(value);

// Both surfaces are affected by translating by the mouse displacement
var dragNode = context.add({transform : dragDisplacement});

dragNode.add({transform : blueTransform}).add(blueSurface)