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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

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

Packages

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.

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

              
                <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js" defer></script>
<nav class="nav" id="navbar">
  <header class="heading-primary nav__title">
    <h1 class="heading-primary">React Documentation</h1>
  </header>
  <ul class="nav__list">
    <li class="nav__item">
      <a href="#Introduction" class="nav__link nav-link">Introduction</a>
    </li>
    <li class="nav__item">
      <a href="#Hello_World" class="nav__link nav-link">Hello World</a>
    </li>
    <li class="nav__item">
      <a href="#Introducing_JSX" class="nav__link nav-link">
        Introducing JSX</a>
    </li>
    <li class="nav__item">
      <a href="#Rendering_Elements" class="nav__link nav-link">
        Rendering Elements</a>
    </li>
    <li class="nav__item">
      <a href="#Components_and_Props" class="nav__link nav-link">
        Components and Props</a>
    </li>
    <li class="nav__item">
      <a href="#State_and_Lifecycle" class="nav__link nav-link">
        State and Lifecycle</a>
    </li>
    <li class="nav__item">
      <a href="#Handling_Events" class="nav__link nav-link">
        Handling Events</a>
    </li>
    <li class="nav__item">
      <a href="#Conditional_Rendering" class="nav__link nav-link">
        Conditional Rendering</a>
    </li>
    <li class="nav__item">
      <a href="#Lists_and_Keys" class="nav__link nav-link">
        Lists and Keys</a>
    </li>
    <li class="nav__item">
      <a href="#Forms" class="nav__link nav-link"> Forms</a>
    </li>
    <li class="nav__item">
      <a href="#Lifting_State_Up" class="nav__link nav-link">
        Lifting State Up</a>
    </li>
    <li class="nav__item">
      <a href="#Composition_vs_Inheritance" class="nav__link nav-link">
        Composition vs Inheritance</a>
    </li>
    <li class="nav__item">
      <a href="#Thinking_in_React" class="nav__link nav-link">
        Thinking In React</a>
    </li>
  </ul>
</nav>
<main class="main" id="main-doc">
  <section class="main__section main-section" id="Introduction">
    <header>
      <h2 class="heading-secondary">Introduction</h2>
    </header>
    <p class="main__section__para">
      React makes it painless to create interactive UIs. Design simple views
      for each state in your application, and React will efficiently update
      and render just the right components when your data changes.
      Declarative views make your code more predictable and easier to debug.
    </p>
    <ul class="main__section__list">
      <li>Easy to learn and use</li>
      <li>Reusable components</li>
      <li>Great tool set for developers</li>
      <li>Fast rendering with virtual DOM</li>
      <li>Testability</li>
    </ul>
  </section>
  <section class="main__section main-section" id="Hello_World">
    <header>
      <h2 class="heading-secondary">Hello World</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Introducing_JSX">
    <header>
      <h2 class="heading-secondary">Introducing JSX</h2>
    </header>
    <p class="main__section__para">Consider this variable declaration:</p>
    <code class="main__section__code">const element = &lt;h1&gt;Hello, world!&lt;/h1&gt; ;</code>
    <p class="main__section__para">
      This funny tag syntax is neither a string nor HTML.
    </p>
    <p class="main__section__para">
      It is called JSX, and it is a syntax extension to JavaScript. We
      recommend using it with React to describe what the UI should look
      like. JSX may remind you of a template language, but it comes with the
      full power of JavaScript.
    </p>
  </section>
  <section class="main__section main-section" id="Rendering_Elements">
    <header>
      <h2 class="heading-secondary">Rendering Elements</h2>
    </header>
    <p class="main__section__para">
      Elements are the smallest building blocks of React apps.
    </p>
    <p class="main__section__para">
      An element describes what you want to see on the screen:.
    </p>
    <code class="main__section__code">const element = &lt;h1&gt;Hello, world&lt;/h1&gt; ;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Components_and_Props">
    <header>
      <h2 class="heading-secondary">Components and Props</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="State_and_Lifecycle">
    <header>
      <h2 class="heading-secondary">State and Lifecycle</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Handling_Events">
    <header>
      <h2 class="heading-secondary">Handling Events</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Conditional_Rendering">
    <header>
      <h2 class="heading-secondary">Conditional Rendering</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Lists_and_Keys">
    <header>
      <h2 class="heading-secondary">Lists and Keys</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Forms">
    <header>
      <h2 class="heading-secondary">Forms</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Lifting_State_Up">
    <header>
      <h2 class="heading-secondary">Lifting State Up</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Composition_vs_Inheritance">
    <header>
      <h2 class="heading-secondary">Composition vs Inheritance</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
  <section class="main__section main-section" id="Thinking_in_React">
    <header>
      <h2 class="heading-secondary">Thinking in React</h2>
    </header>
    <p class="main__section__para">
      The smallest React example looks like this:
    </p>
    <code class="main__section__code">ReactDOM.render&lpar; &lt;h1&gt; Hello, world! &lt;/h1&gt; ,
      document.getElementById &lpar;'root'&rpar; &rpar;;</code>
    <p class="main__section__para">
      It displays a heading saying “Hello, world!” on the page.
    </p>
  </section>
</main>
              
            
!

CSS

              
                // BASE

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

$bp-medium: 43.75em; // 800px
$bp-big: 60em; // 1000px

html {
  font-size: 62.5%;
  box-sizing: border-box;
  scroll-behavior: smooth;
  @media only screen and(max-width: $bp-big) {
    font-size: 50%;
  }
}

*,
*::before,
*::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

:root {
  --heading-primary: rgb(14, 47, 73);
  --heading-secondary: #1c5b80;
}

body {
  font-size: 2rem;
  font-family: "Poppins", sans-serif;
  @media only screen and(max-width: $bp-medium) {
    display: flex;
    flex-direction: column;
  }
}

// TYPOGRAPHY
.heading-primary {
  color: var(--heading-primary);
  font-size: 2.5rem;
  font-weight: 700;
}

.heading-secondary {
  color: var(--heading-secondary);
  font-weight: 700;
  font-size: 2.5rem;
}

.nav {
  height: 100vh;
  padding: 3rem;
  border-radius: 5px;
  margin: 3px;
  position: fixed;
  width: 40rem;
  overflow: auto;

  @media only screen and(max-width: $bp-medium) {
    width: 100%;
    height: 20rem;
    z-index: 2;
    margin: 0;
    background-color: white;
    border-radius: 0;
    border-bottom: 1px solid black;
    position: static;
  }

  &__list {
    list-style: none;
  }

  &__title {
    margin-bottom: 2rem;
  }

  &__link {
    text-decoration: none;
    color: var(--heading-secondary);
    display: inline-block;
    padding: 1.5rem;
    margin: 2px;
    font-weight: 500;
    width: 100%;
    box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.158);
  }
}

.main {
  background-color: rgb(247, 246, 245);
  margin-left: 40rem;
  padding: 3vw;

  @media only screen and(max-width: $bp-medium) {
    width: 100%;
    margin: 0;
  }

  &__section {
    margin: 1rem;
    padding: 1rem;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);

    &__list {
      margin: 1rem;
      background-color: rgb(238, 238, 238);
      padding: 1rem;
      list-style-position: inside;
    }

    &__code {
      display: inline-block;
      padding: 1rem;
      background-color: rgb(71, 71, 71);
      border-radius: 3px;
      color: rgb(231, 231, 231);
      max-width: 100%;
    }

    &__para {
      margin: 1rem;
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console