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 id='app'></div>
              
            
!

CSS

              
                #containerdiv
  background-size: cover
  background-color: #5eb3ce

body
  margin: 0
  background-color: #5eb3ce  
  
h5
  background-color: #348fab
  border-style: solid
  border-color: teal
  border-width: thin
  display: block
  margin: 0
  
.editorheader
  width: 453.5px
  margin-left: 575px
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.25)
  
.previewheader
  width: 899.5px
  margin-left: 350px
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.25)
  
.previewtext
  border-style: solid
  border-color: teal
  border-width: thin
  background-color: lightblue
  width: 900px
  height: 1050px
  margin-left: 350px
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.55)

.editortext
  width: 450px
  height: 300px
  margin-left: 575px
  background-color: lightblue  
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.55)  
  
#fullscreenbuttoneditor
  float: right

#fullscreenbuttonpreviewer
  float: right

.fa-arrows-alt:hover 
  color: cyan 
  
.fa-compress:hover 
  color: cyan 

.maxscreeneditor
  width: 97%
  height: 725px
  margin-left: 23px
  background-color: lightblue
  border-color: black
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.55)
  
.maxscreeneditorheader
  width: 97%
  margin-left: 26px
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.55)
  
.maxscreenpreviewer
  width: 97%
  height: 100%
  margin-left: 23px
  background-color: lightblue
  border-color: black  
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.55)
  padding-top: 0.05px
  
.maxscreenpreviewerheader
  width: 97%
  margin-left: 22px
  box-shadow: 1px 1px 10px 2px rgba(0,0,0,.55)
  
.hidethecontent
  display: none

i
  margin-top: 1.5px
  margin-right: 2px
              
            
!

JS

              
                class Editor extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      markdownInput: defaultText,
      editorMax: false,
      previewerMax: false
    }
    
  this.handleChange = this.handleChange.bind(this);
  this.changeClassEditor = this.changeClassEditor.bind(this);
  this.changeClassPreviewer = this.changeClassPreviewer.bind(this);
  };
  
  handleChange(event) {
    this.setState({
      markdownInput: event.target.value
    });
  }

  changeClassEditor() {
    if (this.state.editorMax == false) {
      this.setState(prevState => ({ 
        editorMax: !prevState.editorMax 
      }));
    }
    if (this.state.editorMax == true) {
      this.setState(prevState => ({ 
        editorMax: !prevState.editorMax 
      }));
    }    
  }
  
  changeClassPreviewer() {
    if (this.state.previewerMax == false) {
      this.setState(prevState => ({ 
        previewerMax: !prevState.previewerMax 
      }));
    }
    if (this.state.previewerMax == true) {
      this.setState(prevState => ({ 
        previewerMax: !prevState.previewerMax 
      }));
    }      
  }  

  
  render() {
    return (
      (this.state.editorMax == true ? 
        <div id='containerdiv'>
          <br />
          <div id='editordiv'>
          <h5 id='editorheader' className='maxscreeneditorheader'>Editor<i id='fullscreenbuttoneditor' onClick={this.changeClassEditor} className="fa fa-compress" aria-hidden="true"></i></h5>
          <textarea id='editortext' className='maxscreeneditor' value={this.state.markdownInput} onChange={this.handleChange}/>
          </div>        
          <br />
          <div id='previewerdiv' className='hidethecontent'>
          <h5 id='previewheader'>Previewer<i id='fullscreenbuttonpreviewer' className="fa fa-arrows-alt" aria-hidden="true"></i></h5>
          <Preview markdownInput={this.state.markdownInput}/>
          </div>
        </div> 
       : this.state.previewerMax == true ?
        <div id='containerdiv'>
          <br />
          <div id='editordiv' className='hidethecontent'>
          <h5 id='editorheader'>Editor<i id='fullscreenbuttoneditor' onClick={this.changeClass} className="fa fa-arrows-alt" aria-hidden="true"></i></h5>
          <textarea id='editortext' value={this.state.markdownInput} onChange={this.handleChange}/>
          </div>        
          <br />
          <div id='previewerdiv'>
          <h5 id='previewheader' className='maxscreenpreviewerheader'>Previewer<i id='fullscreenbuttonpreviewer' onClick={this.changeClassPreviewer} className="fa fa-compress" aria-hidden="true"></i></h5>
          <Preview classNameForProp='maxscreenpreviewer' markdownInput={this.state.markdownInput}/>
          </div>
        </div> :       
        <div id='containerdiv'>
          <br />
          <div id='editordiv'>
          <h5 id='editorheader' className='editorheader'>Editor<i id='fullscreenbuttoneditor' onClick={this.changeClassEditor} className="fa fa-arrows-alt" aria-hidden="true"></i></h5>
          <textarea id='editortext' className='editortext' value={this.state.markdownInput} onChange={this.handleChange}/>
          </div>        
          <br />
          <div id='previewerdiv'>
          <h5 id='previewheader' className='previewheader'>Previewer<i id='fullscreenbuttonpreviewer' onClick={this.changeClassPreviewer} className="fa fa-arrows-alt" aria-hidden="true"></i></h5>
          <Preview classNameForProp='previewtext' markdownInput={this.state.markdownInput}/>
          </div>
        </div>) 
    );
  }
}
  

class Preview extends React.Component {
  constructor(props) {
    super(props);
  }
  
  getMarkdownText() {
    var rawMarkdownText = marked(this.props.markdownInput, {sanitize: true});
    return { __html: rawMarkdownText };
  }
      
  render() {
    return (
      <div className={this.props.classNameForProp} dangerouslySetInnerHTML={this.getMarkdownText()} />
    );
  };
}

var defaultText = 
`# 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 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. But the list goes on...
- Even if you use dashes or asterisks.
* And last but not least, let's not forget embedded images:

![React Logo w/ Text](https://goo.gl/Umyytc)
`
                      
ReactDOM.render(<Editor />, document.getElementById('app'));
              
            
!
999px

Console