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.


                <div id="root">
  <!-- This element's contents will be replaced with your component. -->


                body {
  font-family: sans-serif;
#container {
  height: 100vh;
  width: 100vw;

section {
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  position: absolute;
  font-size: 6em;
  font-weight: 600;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;

#section-1 {
  background: #87c38f;
#section-2 {
  background: #da2c38;
  visibility: hidden;
#section-3 {
  background: #226f54;
  visibility: hidden;
.rotate-me {
  font-size: 0.4em;



function useSelector() {
  const ref = React.useRef();
  const q = React.useMemo(() => gsap.utils.selector(ref), [ref]);
  return [q, ref];
function App() {
  const [q, ref] = useSelector();

  React.useLayoutEffect(() => {

    let rotateAnimationLoop =".rotate-me"), { rotation: 360, ease: "none", repeat: -1, duration: 6, paused: true });
    //section animation and scrolltrigger
    let animationObj = gsap
        scrollTrigger: {
          trigger: "#container",
          pin: true,
          pinType: "fixed",
          start: "top top",
          end: "3500 bottom",
          scrub: true,
          snap: "labelsDirectional"
      .to(q("#section-2"), { autoAlpha: 1, duration: 4 })
      .to(q("#section-3"), { autoAlpha: 1, duration: 4 })
      .add(() => animationObj.scrollTrigger.direction > 0 ? : rotateAnimationLoop.pause(), "section-1+=0.01")
      .add(() => animationObj.scrollTrigger.direction > 0 ? rotateAnimationLoop.pause() :, "section-3-=0.01")
    //end section animation and scrolltrigger

  }, []);

  return (
    <div id="container" ref={ref}>
      <Section id="section-1">section 1 content</Section>
      <Section id="section-2">
          <div>section 2 content</div>
          <div className="rotate-me">play me when my section is visible</div>
      <Section id="section-3">section 3 content</Section>

function Section({ id = null, children }) {
  return (
    <section id={id}>

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