Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                <div id="root"></div>
              
            
!

CSS

              
                
              
            
!

JS

              
                const { useState, useEffect,  } = React;
const { useSpring, animated, config } = ReactSpring;
const { useDrag } = ReactUseGesture;

function App() {
  const [{ x, velocity }, set] = useSpring(() => ({
    x: -30,
    velocity: 0,
  }));
  const bind = useDrag(
    ({ movement: [x], velocity, down, direction: [dx] }) => {
      if (!down) {
        set({ x, velocity: 0 });
      } else {
        set({ x, velocity: velocity * dx });
      }
    },
    {
      initial: () => [x.get(), 0],
      bounds: { left: -30, right: 150, top: 0, bottom: 0 },
      rubberband: false,
    }
  );

  const appStyle = {
    alignItems: "center",
    backgroundColor: "#fff",
    display: "flex",
    height: "100vh",
    justifyContent: "center",
    margin: 0,
  };

  const containerStyle = {
    width: 200,
    position: "relative",
  };

  const barStyle = {
    backgroundColor: "#333",
    height: 3,
    position: "relative",
    top: 21,
    width: "100%",
  };

  const knobStyle = {
    backgroundColor: "#333",
    borderRadius: 8,
    height: 20,
    position: "absolute",
    top: 0,
    width: 40,
    x,
  };

  return (
    <div style={appStyle}>
      <div style={containerStyle}>
        <div style={barStyle}></div>
        <animated.svg
          style={{ x, cursor: "pointer" }}
          {...bind()}
          viewBox="0 0 80 40"
          height="40"
          width="80"
        >
          <animated.path
            d={
              velocity &&
              velocity.to({
                range: [-0.2, 0, 0.2],
                output: [
                  "M 80,20 C 63.368724,20 53.321068,27.492534 50.606602,30.207 47.892136,32.921466 44.142136,35 40,35 35.857864,35 32.107864,33.321068 29.393398,30.606602 26.678932,27.892136 26,24.142136 26,20 26,15.857864 26.678932,12.107864 29.393398,9.393398 32.107864,6.678932 35.857864,5 40,5 44.142136,5 47.892136,7.078534 50.606602,9.793 53.321068,12.507466 63.368724,20 80,20 Z",
                  "M 50,20 C 50,22.761424 48.880712,25.261424 47.071068,27.071068 45.261424,28.880712 42.761424,30 40,30 37.238576,30 34.738576,28.880712 32.928932,27.071068 31.119288,25.261424 30,22.761424 30,20 30,17.238576 31.119288,14.738576 32.928932,12.928932 34.738576,11.119288 37.238576,10 40,10 42.761424,10 45.261424,11.119288 47.071068,12.928932 48.880712,14.738576 50,17.238576 50,20 Z",
                  "M 54,20 C 54,24.142136 53.321068,27.892136 50.606602,30.606602 47.892136,33.321068 44.142136,35 40,35 35.857864,35 32.107864,32.921466 29.393398,30.207 26.678932,27.492534 16.636814,20 0,20 16.636813,20 26.678932,12.507466 29.393398,9.793 32.107864,7.078534 35.857864,5 40,5 44.142136,5 47.892136,6.678932 50.606602,9.393398 53.321068,12.107864 54,15.857864 54,20 Z",
                ],
                extrapolate: "clamp",
              })
            }
          />
        </animated.svg>
      </div>
    </div>
  );
}

ReactDOM.render(
  <App />,
  document.getElementById("root")
);

              
            
!
999px

Console