Pen Settings



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


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


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.


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.


                <div class="container">
  <div class="form form-stacked">
    <div class="form-block">
      <label class="label" for="board_content">Content</label>
      <div class="form-controls">
        <span class="button ion-code" title="Code block <pre><code>" data-button-type="addCode"></span>
        <span class="button ion-code-working" title="Inline code <code>" data-button-type="addInlineCode"></span>
        <span class="button" title="Strong <strong>" data-button-type="addStrong"><strong>b</strong></span>
        <span class="button" title="Emphasis <em>" data-button-type="addEmphasis"><strong><em>i</em></strong></span>
        <span class="button ion-link" title="Link <a>" data-button-type="addLink"></span>
        <span class="button ion-social-codepen-outline" title="Embed CodePen pen" data-button-type="embedCodePen"></span>
      <textarea placeholder="Ask a programming question or share a tip with other developers. Markdown is supported." class="textarea-tall" id="board_content"></textarea>

<div class="note">This was extracted from <a href="" target="_blank">CodeHive's</a> markdown WYSIWYG toolbar. In sharing it on CodePen, we hope for others to learn how we've implemented it. Feel free to fork it and make it awesomer.</div>


                @import "bourbon";

$light-gray:  #F5F5F5;
$blue:        #338EDA;
$white:       #FFF;
$mid-gray:    #D8D8D8;
$spacing:     1.5rem;
$ui-height:   2rem;

@mixin border-radius($value){
  @include border-top-radius($value);
  @include border-bottom-radius($value);

  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;

  line-height: 1.5;

  width: 600px;
  margin: 0 auto;

	font-size: 1rem;
	input[type="text"], input[type="email"], input[type="password"],
		background: $light-gray;
		border-color: $mid-gray;
		border-style: solid;
		@include border-radius(4px);
		border-width: 1px;

		box-shadow: none;
		display: inline-block;
		max-width: 100%;
		padding: $spacing/2;
		-webkit-appearance: none;
			background: $white;
			border-color: $blue;
			outline: 0;
	textarea, .textarea{
		min-height: 150px;
		border: none;
		outline: 0;
		min-height: 300px;

	input[type="text"], input[type="email"], input[type="password"],
		display: block;
		margin-bottom: $spacing;
		width: 100%;

	position: relative;

.form textarea{
	@include border-top-radius(0);

	padding: 0 $spacing/2;
	border-top: 1px solid $mid-gray;
	border-left: 1px solid $mid-gray;
	border-right: 1px solid $mid-gray;
	border-top-left-radius: 4px;
	border-top-right-radius: 4px;
		padding: 0 $spacing/1.5;
		font-size: 1.125rem;
			color: $blue;

  @include border-left-radius(4px);
  @include border-right-radius(4px);
  border: none;
  cursor: pointer;
  display: inline-block;
  min-height:   $ui-height;
  line-height:  $ui-height;

  font-size: em(14);
  font-family:      inherit;
  text-decoration:  none;

  @include appearance(none);

  padding: 0 $spacing/2;

  white-space: nowrap;
  vertical-align: middle;

	display: block;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: $spacing/4;
  font-size: 0.875rem;

  background: $mid-gray;
  font-size: 0.825rem;
  width: 250px;
  padding: $spacing;
  @include border-left-radius(2px);
	@include border-right-radius(2px);
  @include position(fixed, null null $spacing/2 $spacing/2);
  z-index: 100;
    color: $blue;


                buttonTypes = 
  addCode: "Enter code here"
  addInlineCode: "Enter inline code here"
  addStrong: "Strong text"
  addEmphasis: "Emphasized text"
  addLink: ""

buttonFunctions =
  addCode: "```\n#{buttonTypes.addCode}\n```\n\n"
  addInlineCode: "`#{buttonTypes.addInlineCode}` "
  addStrong: "**#{buttonTypes.addStrong}** "
  addEmphasis: "*#{buttonTypes.addEmphasis}* "
  addLink: "[Link title](#{buttonTypes.addLink}) "

matchString = (target, textAreaElement, limit) ->
  textArea = document.getElementById(textAreaElement.attr('id'))
  highlight = textArea.value.lastIndexOf(target, limit)
  if highlight >= 0
    textArea.selectionStart = highlight
    textArea.selectionEnd = highlight + target.length

generatePenEmbed = (link) ->
  nameBeg = ///.*\////
  nameEnd = ///\/pen.*///
  penBeg = ///.*/pen\////
  penEnd = ///\////
  name = link.replace nameBeg, ""
  name = name.replace nameEnd, ""
  pen = link.replace penBeg, ""
  pen = pen.replace penEnd, ""
  embed = "<p data-height='350' data-theme-id='0' data-slug-hash='#{pen}' data-default-tab='result' data-user='#{name}' class='codepen'>See the <a href='{name}/pen/#{pen}/'>Pen</a> by <a href='{name}'>@#{name}</a> on <a href=''>CodePen</a>.</p>"
  return embed
addMarkdown = (buttonType, textArea) ->
  text = textArea.val()
  caretPosition = document.getElementById(textArea.attr('id')).selectionStart
  if buttonType == "embedCodePen"
    penLink = prompt("Link to Pen")
    #TODO: Add some validation for CodePen link
    if penLink
      textArea.val(text.substring(0, caretPosition) + generatePenEmbed(penLink) + text.substring(caretPosition, text.length - 1))
  if buttonType of buttonTypes
    textArea.val(text.substring(0, caretPosition) + buttonFunctions[buttonType] + text.substring(caretPosition, text.length - 1))
    matchString(buttonTypes[buttonType], textArea, caretPosition + buttonTypes[buttonType].length - 1)
$('.form-controls .button').on 'click', () ->
  buttonType = $(this).data('button-type')
  textArea = $(this).parent().parent().find('textarea')
  addMarkdown(buttonType, textArea)