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

              
                <style>
  @import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Assistant:wght@200;300;400;500;600;700;800&display=swap');
</style>

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

CSS

              
                body {
  background-image: linear-gradient(
    335deg,
    rgba(199, 197, 255, 1) 20%,
    rgba(255, 230, 251, 1) 55%,
    rgba(134, 255, 231, 1) 100%
  );
  bakground-repeat: no-repeat;
  background-size: cover;
  font-family: "Assistant", sans-serif;
  overflow-y: scroll;
  color: rgba(36, 36, 36);
  font-size: 18px;
}

h1 {
  font-size: 48px;
  font-weight: 700;
  font-family: "Abril FatFace", sans-serif;
  text-transform: uppercase;
  margin-bottom: 10px;
  text-align: center;
}

h2 {
  display: inline-block;
  width: 100%;
  font-size: 36px;
  font-weight: 600;
  border-top: 2px solid rgba(36, 36, 36, 0.3);
  padding-top: 15px;
  margin-bottom: 10px;
  text-align: center;
}

h3 {
  font-size: 24px;
  font-weight: 500;
}

code {
  background: rgba(255, 255, 255, 0.51);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10.6px);
  -webkit-backdrop-filter: blur(10.6px);
  padding: 5px;
  border-radius: 5px;
  font-size: 16px;
}

pre > code {
  background: unset;
  box-shadow: unset;
}

pre {
  display: block;
  background: rgba(255, 255, 255, 0.51);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10.6px);
  -webkit-backdrop-filter: blur(10.6px);
  padding: 10px 20px;
  border-radius: 5px;
}

strong {
  font-weight: 700;
  font-size: 19px;
}

em {
  font-weight: 200;
}

strong > em {
  font-weight: 700;
}

del {
  color: rgba(36, 36, 36, 0.4);
}

a:link {
  text-decoration: none;
  color: #3a98ab;
  font-weight: 600;
}

a:visited {
  text-decoration: none;
  color: #1b444d;
}
a:hover {
  text-decoration: underline;
}

blockquote {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10.6px);
  -webkit-backdrop-filter: blur(10.6px);
  padding: 5px 20px;
  border-left: 5px solid rgba(98, 3, 252, 0.2);
  font-weight: 700;
  font-family: "Assistant", sans-serif;
  color: rgba(36, 36, 36);
  font-style: italic;
}

li {
  padding: 5px;
}

img {
  display: inline-block;
  max-width: 100%;
  width: 100%;
  object-fit: cover;
}

.content {
  display: flex;
  flex-direction: column;
}

#editor {
  margin: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.31);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10.6px);
  -webkit-backdrop-filter: blur(10.6px);
  border: transparent;
  resize: vertical;
  height: 50em;
}

#editor:focus {
  outline: transparent;
  box-shadow: 0px 0px 2px 2px rgba(255, 255, 255, 0.8);
}

#preview {
  margin: 10px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.31);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10.6px);
  -webkit-backdrop-filter: blur(10.6px);
}

.footer {
  margin: 5px;
  padding: 5px;
  display: flex;
  justify-content: flex-end;
  font-size: 16px;
}

.heart:before {
  content: "\2665";
  color: red;
  margin: 0 5px;
}

@media only screen and (min-width: 1000px) {
  .content {
    flex-direction: row;
  }
  #preview {
    width: 60%;
  }
  #editor {
    width: 40%;
    position: sticky;
    top: 19px;
    bottom: 0;
  }
}

              
            
!

JS

              
                import * as React from "https://cdn.skypack.dev/react@17.0.1";
import * as marked from "https://cdn.skypack.dev/marked@4.0.7";
import { render } from "https://cdn.skypack.dev/react-dom@17.0.1";

const { useState, useRef, useEffect, Fragment } = React;

const Editor = ({ preload, initial }) => {
  return (
    <textArea id="editor" onChange={preload}>
      {initial}
    </textArea>
  );
};

const Previewer = ({ output }) => {
  const inner = useRef(null);

  const parsed = () => marked.parse(output, { breaks: true });

  useEffect(() => {
    inner.current.innerHTML = parsed();
  }, [output]);

  return <div id="preview" ref={inner}></div>;
};

const MarkDownPreviewer = () => {
  const initialMarkdown = `# Markdown previewer!
  \n ## Edit directly in the editor  
  \n
  \n Exagerate your **text** by making it bold. 
  \n How about _italiciziing_ your text. 
  \n ...Or **_why not do both_**
  \n ~~Or hide it but still keep it readable~~
  \n
  \n Insert a [suprise link](youtube.com) to whatever sites you please. 
  \n 
  \n You can add a code block \`<div></div>\` inline like so.
  \n  
  \n A multiline code block requires 3 backticks \` \`\`\` \` before and after your multiline code block.
  \n \`\`\` 
  // multiline code block
  
  function() {
    //code here
  }
  \`\`\` 
  \n Do you have a quote close to your heart?
  \n > " One love, one heart, one destiny " 
     _- Bob Marley_
  \n 
  \n A bulletted list is easy:
  - first
    - second
      - third layer
  \n 
  \n Make your list orderly:
  1) add a number
    a) or a letter and indent
  1) and you're gucci.
  \n
  \n ### Enjoy this cat image! 
  \n _Meow._
  \n ![cat and mouse](https://freesvg.org/img/1553089268.png)
  \n sponsored by:
  \n ![free code camp logo](https://cdn.freecodecamp.org/testable-projects-fcc/images/fcc_secondary.svg)
  `;
  const [previewText, setPreviewText] = useState("");
  const [editorText, setEditorText] = useState("");

  const handleText = (e) => {
    const value = e.target.value;
    setPreviewText(() => value);
  };

  useEffect(() => {
    setPreviewText(() => initialMarkdown);
    setEditorText(() => initialMarkdown);
  }, []);

  return (
    <div class="container">
      <div class="content">
        <Editor preload={handleText} initial={editorText} />

        <Previewer output={previewText} />
      </div>
      <div class="footer">
        by Katrina <span class="heart"></span> 2021
      </div>
    </div>
  );
};

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

              
            
!
999px

Console