cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

              @import url('https://fonts.googleapis.com/css?family=Droid+Sans+Mono');

$primary-color: #FF0050;
$secondary-color: #aaa;
$background-color: #440015;

html {
  background-color: $background-color;
  font-family: 'Droid Sans Mono', monospace;
  color: $secondary-color;

#container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: absolute;

svg {
  fill: none;
  stroke: $primary-color;
  stroke-width: 5px;
  background-color: white;
  border: solid 1px white;
#content {
  width: 500px;
#label {
  padding: 20px;
  width: 500px;
  box-sizing: border-box;
  text-align: center;
  user-select: none;
              class Component extends React.Component {
  constructor() {

    this.state = {      
      points: [/* "M 0 0", "L 20 20", "L 50 100" */] // The Path SVG tag recieves a series of MoveTo and LineTo coordinates

  render() {
    return (
       <div id='container'>
        <div id='content'>
          <svg ref={(canvas) => {this.canvas = canvas }} width="500" height="500" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" version="1.1">
            <path d={this.state.points}/>
          <div id='label'>
            [Click to draw, double click to reset]
  componentDidMount() {
    const mouseEventToCoordinate = event => event.offsetX+" "+event.offsetY;
    let mouseDowns = Rx.Observable.fromEvent(this.canvas, "mousedown").map(mouseEventToCoordinate);
    let mouseMoves = Rx.Observable.fromEvent(this.canvas, "mousemove");
    let mouseUps = Rx.Observable.fromEvent(this.canvas, "mouseup");
    let mouseLeaves = Rx.Observable.fromEvent(this.canvas, "mouseleave");
    let mouseDbClick = Rx.Observable.fromEvent(this.canvas, "dblclick");
    let mouseDrags = mouseDowns.concatMap(() => mouseMoves.takeUntil(mouseUps.merge(mouseLeaves)).map(mouseEventToCoordinate));
    mouseDowns.forEach(drag => {
      this.setState({points: [...this.state.points, "M "+drag]});
    mouseDrags.forEach(drag => {
      this.setState({points: [...this.state.points, "L "+drag]});
    mouseDbClick.forEach(() => {
      this.setState({points: []});

  <Component />,

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................