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

              
                 <div class="container">
      <div class="side-menu">
        <nav id="navbar">
          <header>
            <h2>React Documentation</h2>
          </header>
          
          <ul>
            <li><a href="#Getting_Started" class="nav-link">Getting Started</a></li>
            <li><a href="#Hello_World" class="nav-link">Hello World</a></li>
            <li><a href="#Introducing_React_JSX" class="nav-link">Introducing React JSX</a></li>
            <li><a href="#Rendering_Elements" class="nav-link">Rendering Elements</a></li>
            <li><a href="#Component_and_Props" class="nav-link">Component and Props</a></li>
            <li><a href="#State_and_Lifecycle" class="nav-link">State and Lifecycle</a></li>
<!--             <li><a href="#" class="nav-link">Handling event</a></li>
            <li><a href="#" class="nav-link">conditional Rendering</a></li>
            <li><a href="#" class="nav-link">Lists and keys</a></li>
            <li><a href="#" class="nav-link">React Forms</a></li>
            <li><a href="#" class="nav-link">Lifting state up</a></li> -->
          </ul>
        </nav>
      </div>
      <div class="main-content">
        <div class="main-header"><h2>Welcome!! Enjoy Coding.</h2></div>
        <div class="content">
          <main id="main-doc">
            <!-- Getting started section -->
            <section class="main-section" id="Getting_Started">
              <header><h2>Getting Started</h2></header>
              <h4>What is React</h4>
              <p>
                React is a JavaScript library created by Facebook.React is a
                tool for building UI components.
              </p>
              <h4>How Does React Work</h4>
              <p>
                React creates a VIRTUAL DOM in memory. Instead of manipulating
                the browser's DOM directly, React creates a virtual DOM in
                memory, where it does all the necessary manipulating, before
                making the changes in the browser DOM.
              </p>
              <p>
                React only changes what needs to be changed! React finds out
                what changes have been made, and changes only what needs to be
                changed. You will learn the various aspects of how React does
                this in the rest of this tutorial.
              </p>
              <h4>History of React.js</h4>
              <ul>
                <li>Current version of React.JS is V16.8.6 (March 2019).</li>
                <li>
                  Initial Release to the Public (V0.3.0) was in July 2013.
                </li>
                <li>
                  React.JS was first used in 2011 for Facebook's Newsfeed
                  feature.
                </li>
                <li>Facebook Software Engineer, Jordan Walke, created it.</li>
                <li>
                  The create-react-app version 2.0 package was released in
                  October 2018.
                </li>
                <li>
                  Create-react-app version 2.0 supports Babel 7, webpack 4, and
                  Jest23.
                </li>
              </ul>
              <h4>Setting up a React.js Environment</h4>
              <p>
                If you have NPM and Node.js installed, you can create a React
                application by first installing the create-react-app.
              </p>
              <p>
                Install create-react-app by running this command in your
                terminal:
              </p>
              <code>C:\Users\Your Name>npm install -g create-react-app</code>
              <p>Congratulation. You Rock!</p>
            </section>

            <section class="main-section" id="Hello_World">
              <header>
                <h2>Hello World</h2>
              </header>
              
              <p>The smallest React example looks like this:</p>
              <div class="code_box">
                <code>
                  ReactDom.render(
                    &lt;h1&gt;Hello, World &lt;/h1&gt;
                    document.getElementById('root')
                  );
                </code>
              </div>
            </section>

            <!-- Introduction to JSX section -->
            <section class="main-section" id="Introducing_React_JSX">
              <header>
                <h2>Introducing React JSX</h2>
              </header>
   
              <p>Consider this variable declaration:</p>
             <div class="code_box">
                <code>
                  cont element = &lt;h2&gt;Hello, Profsain &lt;/h2&gt;;
                </code>
              </div>
              <p>This funny tag syntax is neither a string nor HTML.</p>
              <p>
                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>
              <h4>Why React JSX</h4>
              <p>
                React embraces the fact that rendering logic is inherently
                coupled with other UI logic: how events are handled, how the
                state changes over time, and how the data is prepared for
                display.
              </p>
              <p>
                Instead of artificially separating technologies by putting
                markup and logic in separate files, React separates concerns
                with loosely coupled units called “components” that contain
                both. We will come back to components in a further section, but
                if you’re not yet comfortable putting markup in JS, this talk
                might convince you otherwise.
              </p>
              <h4>Embedding Expressions in JSX</h4>
              <p>
                In the example below, we declare a variable called name and then
                use it inside JSX by wrapping it in curly braces:
              </p>
              <div class="code_box">
                <code>
                  const name = 'Profsain Husain';
                  const element = &lt;h2&gt;Hello, {name}&lt;/h2&gt;;

                  ReactDom.render(
                    element,
                    document.getElementById('root')
                  );
                </code>
              </div>
              <p>
                You can put any valid JavaScript expression inside the curly
                braces in JSX. For example, 2 + 2, user.firstName, or
                formatName(user) are all valid JavaScript expressions.
              </p>
            </section>

            <!-- Rendering Elements section -->
            <section class="main-section" id="Rendering_Elements">
              <header>
                <h2>Rendering Elements</h2>
              </header>
              
              <p>
                Elements are the smallest building blocks of React apps. An
                element describes what you want to see on the screen:
              </p>
              <div class="code_box">
                <code>
                  const element = &lt;p&gt;Welcome to React.js&lt;/p&gt;;
                </code>
              </div>
              <p>
                Unlike browser DOM elements, React elements are plain objects,
                and are cheap to create. React DOM takes care of updating the
                DOM to match the React elements.
              </p>
              <h4>Rendering an Element into the DOM</h4>
              <p>Let’s say there is a &lt;div&gt; somewhere in your HTML file:</p>
                <div class="code_box">
                  <code>
                    &lt;div id="root"&gt;&lt;/div&gt;
                  </code>
                </div>
                <p>We call this a “root” DOM node because everything inside it will be managed by React DOM.</p>
                <p>Applications built with just React usually have a single root DOM node. If you are integrating React into an existing app, you may have as many isolated root DOM nodes as you like.</p>
                <p>To render a React element into a root DOM node, pass both to ReactDOM.render():</p>
                <div class="code_box">
                  <code>
                    const element = &lt;h2&gt;I love React &lt;/h2&gt;;
                    ReactDom.render(element, document.getElementById('root'));
                  </code>
                </div>
            </section>

            <!-- Component and Props section -->
            <section class="main-section" id="Component_and_Props">
              <header>
                <h2>Component and Props</h2>
              </header>
              
              <p>Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components.</p>
              <p>Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.</p>
              <h4>Functional and Class Components</h4>
              <p>he simplest way to define a component is to write a JavaScript function:</p>
              <div class="code_box">
                <code>
                  function welcome(props) {
                    return &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;;
                  }
                </code>
              </div>
              <p>This function is a valid React component because it accepts a single “props” (which stands for properties) object argument with data and returns a React element. We call such components “function components” because they are literally JavaScript functions.</p>
            </section>

            <!-- State and Lifecycle section -->
            <section class="main-section" id="State_and_Lifecycle">
              <header>
                <h2>State and Lifecycle</h2>
              </header>
              
              <p>Consider the ticking clock example from one of the previous sections. In Rendering Elements, we have only learned one way to update the UI. We call ReactDOM.render() to change the rendered output:</p>
              <div class="code_box">
              
                <code>
                  function tick() {
                    const element = (
                      &lt;div&gt;
                        &lt;h1&gt;Hello, Profsain &lt;/h1&gt;
                        &lt;h2&gt;It is {new Date.toLocalTimeString()}.&lt;/h2&gt;
                      &lt;/div&gt;
                    );
                    ReactDom.render(
                      element,
                      document.getElementById('root')
                    );
                  }
                  setInterval(tick, 1000);
                </code>
              </div>
            </section>
          </main>
        </div>
      </div>
    </div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  list-style-type: none;
  text-decoration: none;
  font-family: sans-serif;
}

body {
  background-color: #f3f6f9;
}

.container {
  display: flex;
  position: relative;
}

.container .side-menu {
  width: 300px;
  height: 100%;
  padding: 30px 0px;
  background: #4b4274;
  position: fixed;
}

.container .side-menu h2 {
  color: #fff;
  text-transform: uppercase;
  text-align: left;
  margin-bottom: 30px;
  margin-left: 20px;
  font-size: 20px;
}

.container .side-menu ul li {
  padding: 16px;
  border-bottom: 2px solid #fff;
}

.container .side-menu ul li a {
  color: #f3f6f9;
  display: block;
}

.container .side-menu ul li:hover {
  background-color: #595f8d;
  color: rgb(248, 200, 123);
}

.container .side-menu ul li:hover a {
  color: rgb(248, 200, 123);
}

.container .side-menu ul li a .fas {
  width: 30px;
}

.container .side-menu .social-media {
  position: abolute;
  display: flex;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.container .side-menu .social-media a {
  display: block;
  width: 50px;
  height: 50px;
  background: #594f8d;
  line-height: 55px;
  margin: 0 6px;
  text-align: center;
  color: #bdb8d4;
  border-radius: 6px;
}

.container .main-content {
  width: 100%;
  margin-left: 300px;
}

.container .main-content .main-header {
  padding: 20px;
  background: #fff;
  color: #727272;
  border: 2px solid #bdb8d4;
}

.container .main-content .content {
  margin: 20px;
  color: #717171;
  line-height: 26px;
}

.main-section {
  margin-top: 46px;
  padding: 0 28px;
}

h4 {
  padding: 16px 0;
  font-weight: 800;
}
p {
  font-size: 18px;
}

.code_box {
  
  margin: 16px 0;
  padding: 22px;
  background-color: #686c8a;
  color: white;
  font-size: 18px;
  font-weight: 600;
  border-radius: 10px;
}

@media only screen and (max-width: 600px) {
  .container .side-menu {
    display: none;
  }

  .container .main-content {
    width: 100%;
    margin: 0 auto;
  }
  
/*   pre {
    width: 100%;
    font-size: 12px;
  } */
}

              
            
!

JS

              
                // !! IMPORTANT README:

// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place. 

/***********
INSTRUCTIONS:
  - Select the project you would 
    like to complete from the dropdown 
    menu.
  - Click the "RUN TESTS" button to
    run the tests against the blank 
    pen.
  - Click the "TESTS" button to see 
    the individual test cases. 
    (should all be failing at first)
  - Start coding! As you fulfill each
    test case, you will see them go   
    from red to green.
  - As you start to build out your 
    project, when tests are failing, 
    you should get helpful errors 
    along the way!
    ************/

// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!

// Once you have read the above messages, you can delete all comments. 

              
            
!
999px

Console