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"></script>


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

CSS

              
                body{
	margin: 0;
	padding:0;
	box-sizing: border-box;
	background-color: #7caab68c;
}

.Can{
	display:flex;
	width:100%;
	justify-content: space-around;
	margin: 10px;
}
.Box{
	  width:100%; 
}
.Box_1{
	width:30%;
}
.Box_2{
	width:50%;
	flex-shrink:1;
}
.Box > h3{
	margin:0;
	padding:10px;
	text-align:center;
	background-color:#e0b62ccf;
	color: #48471ed6
}

.TextArea{
	height:400px;
	box-sizing:border-box;
	width:100%;
	padding:10px;
	color:#20C20E;
	background-color:#000000;
}

@media screen and (max-width:700px){
.Box_1, .Box_2{
 width: 100%;
}
.Can{
	flex-direction: column;
}

}

.Preview{
	height:100vh;
	width:100%;
	box-sizing:border-box;
	background-color: #fafafa;
	color:#272121fa;
	padding:20px;
	overflow-y:scroll;
}
              
            
!

JS

              
                import marked from "https://cdn.skypack.dev/marked@1.2.7"


const Markup = () => {
	const [markupText, setMarkupText] = React.useState(``);

  	React.useEffect(()=>{
		setMarkupText(
			`# Welcome to my React Markdown Previewer!   
  ## This is a sub-heading...
  ### And here\'s some other cool stuff:
Heres some code,\`<div></div>\`, between 2 backticks.
${"```"}
		// this is multi-line code:
		
		function anotherExample(firstLine, lastLine) {
			if (firstLine == ${'```'} && lastLine == ${'```'}) {
				return multiLineCode;
			}
		}
 ${"```"}
		
You can also make text **bold**... whoa!
		Or _italic_.
		Or... wait for it... **_both!_**
		And feel free to go crazy ~~crossing stuff out~~.
		
There's also [links](https://www.freecodecamp.com), and
> Block Quotes!
		

		
- And of course there are lists.
- Some are bulleted.
- With different indentation levels.
- That look like this.
		
		
1. And there are numbererd lists too.
1. Use just 1s if you want!
1. And last but not least, let's not forget embedded images:
		
![React Logo w/ Text]('https://goo.gl/Umyytc')`);

	},[])
  
  
	const handleChange = (event) =>{
		setMarkupText(event.target.value)
	}
	return (
	<div className="Can">
		<div className={`Box Box_1`}>
      <h3>Markup Editor </h3>
			<form >
				<textarea value={markupText} onChange={handleChange} id="editor" className="TextArea"/>
			</form>
		</div>
		<div className={`Box Box_2`}>
        <h3>Preview Editor</h3>
        <Previewer preview={markupText}  />
    </div>
	</div>
	)
}

const Previewer = (props) => {
	const createPreview = () => {
   const rawMarkdown= marked(props.preview, {gfm:true, breaks:true});
		return {__html :rawMarkdown }
	}
	return (
		<div id="preview" dangerouslySetInnerHTML={createPreview()} className="Preview"/>
			
	)
}


function App() {
  return (
    <div className="App"  >
			<Markup/>
    </div>
  );
}

ReactDOM.render(<App/>, document.getElementById("root"))
              
            
!
999px

Console