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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <body style="height: 100%; background: #000; padding: 20px;">
	<div class="col-sm-12">
		<div class="row">
			<div class="col-sm-12" style="color: #777aaa; margin-bottom: 10px;">
				<h1>BerryDark</h1>
				<p>Custom CodeMirror Theme</p>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-4">
				<div class="myEditor" lang-lg="javascript" lang-sm="js" style="border-radius: 5px; overflow: hidden; margin-bottom: 20px;">
					<textarea class="editor" style="display: none;">var str = "Hello,World!"; console.log("hello, there!"); $(document).on('click', '.btn', function() { $(this).toggleClass('active'); }); </textarea> 
					<div class="CodeMirror-vscrollbar-filler"></div> 
					<div class="CodeMirror-hscrollbar-filler"></div>
				</div>
			</div>
			<div class="col-sm-4">
				<div class="myEditor" lang-lg="htmlmixed" lang-sm="html" style="border-radius: 5px; overflow: hidden; margin-bottom: 20px;">
					<textarea class="editor" style="display: none;"><div class="something"><ul><li>one</li><li>two</li><li>three</li></ul></div></textarea> 
					<div class="CodeMirror-vscrollbar-filler"></div> 
					<div class="CodeMirror-hscrollbar-filler"></div>
				</div>
			</div>
			<div class="col-sm-4">
				<div class="myEditor" lang-lg="css" lang-sm="css" style="border-radius: 5px; overflow: hidden; margin-bottom: 20px;">
					<textarea class="editor" style="display: none;">body { background: #fff; } .active { background: purple !important; } .something { background: blue; }.something-else {  }</textarea> 
					<div class="CodeMirror-vscrollbar-filler"></div> 
					<div class="CodeMirror-hscrollbar-filler"></div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-12" style="color: #777aaa; margin-top: 10px;">
				<small>Just copy the url to use in your codepen projects.</small>
			</div>
		</div>
	</div>
</body>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Source+Code+Pro&display=swap');
html {
	height: 100%;
}
/*****************
CODE MIRROR STYLES 
*****************/
.cm-s-berry-dark.CodeMirror {
	font-size: 14px ;
	background: #272757;
	box-shadow: 2px 2px 10px #111139 inset;
	font-family: 'Source Code Pro', monospace;
	color: #aaa;
}
.cm-s-berry-dark .CodeMirror-cursor {
	height: 17px ;
	margin-top: 4px ;
}
.cm-s-berry-dark .CodeMirror-gutters {
	background: #343470;
	border-right: 1px solid #343470;
	box-shadow: 2px 0px 10px #111139;
	margin-left: -1px;
}
.cm-s-berry-dark .CodeMirror-sizer {
	padding-top: 5px; 
	margin-left: 31px ; 
	margin-bottom: -17px ; 
	border-right-width: 13px ; 
	min-height: 29px ; 
	min-width: 7px ; 
	padding-right: 20px ; 
	padding-bottom: 0px ; 
	padding-left: 5px ;
}
.cm-s-berry-dark .CodeMirror-line {
	line-height: 1.7 ;
}
.cm-s-berry-dark .CodeMirror-linenumber {
	color: #777aaa;
	left: 0px ; 
	width: 24px ;
	margin-left: -5px ;
}
.cm-s-berry-dark .CodeMirror-linenumbers {
	width: 31px ;
}
.cm-s-berry-dark .cm-qualifier {
	color: #75BFFF ;
}
.cm-s-berry-dark .cm-property {
	color: #86DE74;
}
.cm-s-berry-dark .cm-punctuation,.cm-unit,.cm-negative {
	color: #e09142;
}
.cm-s-berry-dark .cm-string {
	color: #6B89FF;
}
.cm-s-berry-dark .cm-positive {
	color: #6a51e6;
}
.cm-s-berry-dark .cm-def {
	color: #ddd;
}
.cm-s-berry-dark .cm-variable {
	/* 	color: #ccc !important; */
	color: #ddd;
}
.cm-s-berry-dark .cm-variable-2, .cm-s-berry-dark .cm-variable-3, .cm-s-berry-dark .cm-url {
	color: #6a51e6;
}
.cm-s-berry-dark .cm-tag {
	color: #75BFFF;
}
.cm-s-berry-dark .cm-bracket { color: #75BFFF }
.cm-s-berry-dark .cm-comment {
	color: #777aaa;
}
.cm-s-berry-dark .cm-atom, .cm-s-berry-dark .cm-number {
	color: #6B89FF;
}
.cm-s-berry-dark .cm-keyword, .cm-s-berry-dark .cm-operator, .cm-s-berry-dark .cm-attribute {
	color: #FF7DE9;
}
.cm-s-berry-dark .CodeMirror-cursor {
	border-left: 1px solid #eee;
}
.cm-s-berry-dark .CodeMirror-selectedtext, .cm-s-berry-dark .CodeMirror-selected, .cm-s-berry-dark .CodeMirror-focused .CodeMirror-selectedtext, .cm-s-berry-dark .cm-s-berry-dark .CodeMirror-focused .CodeMirror-selected { background: rgba(255, 74, 174, 0.1); }
/* .CodeMirror-selected {
	background: rgba(200,200,200,0.1) !important;
} */
.cm-s-berry-dark .CodeMirror-activeline-background {
	background: transparent;
}
.cm-s-berry-dark .CodeMirror-focused .CodeMirror-activeline-background { 
	background: rgba(150, 70, 255, 0.1); 
}
.cm-s-berry-dark .CodeMirror-matchingbracket {
	color: inherit;
}
.cm-s-berry-dark .CodeMirror-focused .CodeMirror-matchingbracket, .cm-s-berry-dark .CodeMirror-focused .CodeMirror-matchingtag.cm-tag {
	background: rgba(255, 255, 255, 0.2) !important;
	border-radius: 2px;
	padding-bottom: 3px;
}
.cm-s-berry-dark .CodeMirror-focused .CodeMirror-matchingtag.cm-tag {
	padding-bottom: 1px;
}
.cm-s-berry-dark .CodeMirror-matchingtag, .cm-s-berry-dark .CodeMirror-matchingtag.cm-bracket {
	background: transparent;
}
.cm-s-berry-dark .CodeMirror-focused .CodeMirror-matchingtag.cm-bracket {
	background: transparent;
}

.cm-s-berry-dark .cm-searching {
	/* 	color: #eee !important; */
	background-color: rgba(0, 0, 0, 0.8);
	border-radius: 3px;
	padding: 0 5px;
}


/****************
EDITOR SCROLL BAR
****************/
.CodeMirror-scrollbar-filler {
	background: transparent;
}
.CodeMirror-vscrollbar-filler, .CodeMirror-hscrollbar-filler {
	position: absolute;
	bottom: 0;
	right: 0;
	background: transparent;
	border-radius: 0 0 5px 0;
	z-index: 2;
}
.CodeMirror-vscrollbar-filler {
	width: 10px;
	top: 70px;
}
.CodeMirror-hscrollbar-filler {
	left: 30px;
	height: 10px;
}
/* width */
.CodeMirror-vscrollbar::-webkit-scrollbar {
	width: 6px !important;
}
.CodeMirror-hscrollbar::-webkit-scrollbar {
	height: 6px !important;
}
/* Track */
.CodeMirror-vscrollbar::-webkit-scrollbar-track, .CodeMirror-hscrollbar::-webkit-scrollbar-track {
	background: transparent !important; 
}
/* Handle */
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb, .CodeMirror-hscrollbar::-webkit-scrollbar-thumb {
	background: #111139 !important; 
	border-radius: 3px;
}
/* Handle on hover */
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover, .CodeMirror-hscrollbar::-webkit-scrollbar-thumb:hover {
	background: #11111f !important; 
}
              
            
!

JS

              
                $(function() {
	
	var minLines = null;
	var editorOptions = {
		autoRefresh: true,
		firstLineNumber: 1,
		lineNumbers: true,
		// lineWrapping: true,
		smartIndent: true,
		indentWithTabs: true,
		styleActiveLine: { nonEmpty: true },
		refresh: true,
		// readOnly: true,
		minLines: 10,
		theme: 'berry-dark'
	};
	$('.myEditor').each(function() {
		var self = $(this);
		var editor = CodeMirror.fromTextArea(self.find(".editor")[0], editorOptions);
		self[0].editor = editor;
		editor.save();
		
		// set the code mode
		var setMode = self.attr('lang-lg');
		editor.setOption("mode", setMode );
		
		// beautify the code
		var mode = self.attr('lang-sm');
		var text = self.find('.editor').text();
		var beautify = eval( (mode + '_beautify').toString().toLowerCase() );
		editor.setValue( beautify( text, { indent_size: 2 } ) );
		
		editor.focus();
		// Set the cursor at the end of existing content
		editor.setCursor(editor.lineCount());
		
		var lineCount = editor.lineCount(); // current number of lines
		var n = editor.options.minLines - lineCount; // how many lines we need
		
		var line = editor.getCursor().line;
		var ch = editor.getCursor().ch;
		
		for(i = 0; i < n; i++) {
			editor.replaceRange("\n", { line });
			line++;
		}
	});
});
              
            
!
999px

Console