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. 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


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.


      <button onclick="do_image_upload()">
        Upload Picture
      <div class="imgcropper"></div>
      <button onclick="save_cropped_image()">Save Avatar</button>
      <img class="avatar">
      <button  onclick="clear_avatar()">Clear Avatar</button>



                table {
  width: 100%;
table, th, td {
  border: 1px solid #999;
  border-collapse: collapse;
th, td {
  padding: 5px;
  width: 50%;
th {
  background-color: #eee;
button {
  display: block;
  margin: 20px auto;
  padding: 10px 20px;
  min-width: 200px;
img.avatar {
  display: block;
  margin: 15px auto;

.imgcropper {
  width: 200px;
  margin: 10px auto;


                window.onload = () => {

function initialize_crop_interface() {
  if (!window.myCropper) {
    // initialize CropInterface
    window.myCropper = new CropInterface(document.querySelector('.imgcropper'), 200, 200, 1);

function do_image_upload() {
  get_file((content) => {
    // in case window isn't fully loaded yet

function save_cropped_image() {
  // retrieve all the data from CropInterface
  let content = window.myCropper.getImageUrl();
  let dimensions = window.myCropper.getDimensions();
  let focus = window.myCropper.getFocus();
  let zoom = window.myCropper.getZoom();
  let imageScaler = new ImageScaler();
  imageScaler.loadFromDataURL(content).then(() => {
    imageScaler.setFocalPoint(focus.x, focus.y);
    let crop = imageScaler.crop(dimensions.w, dimensions.h);
    let imageUrl = crop.toDataURL();

function save_avatar(imageUrl) {
  // In a real implementation, imageURL
  // could be sent to the server to be
  // converted to a saved file
  let avatar = document.querySelector('.avatar');
  avatar.src = imageUrl;

function clear_avatar() {
  let avatar = document.querySelector('.avatar');
  avatar.src = '';

// -=Helper Functions=-
function get_file(cb) {
  let input = document.createElement('input');
  input.type = 'file';
  input.accept = 'image/x-png,image/gif,image/jpeg';
  input.onchange = e => { 
     let file =[0]; 
     let reader = new FileReader();
     reader.onload = (e) => {