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

              
                
<!DOCTYPE html>
<html lang="en" class="no-js">
  <head>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.bundle.min.js" type="module"></script>
    
    <script type="module">
      import Superfile from "https://cdn.jsdelivr.net/npm/superfile@1/superfile.min.js";
      Superfile.init();
    </script>
  </head>
  <body>
       <div class="container">
      <h1>Demo</h1>
      <form class="needs-validation" novalidate method="post" enctype="multipart/form-data" action="https://vercel-dumper.vercel.app/">
        <div class="mb-3 superfile">
          <label for="formFile" class="form-label">Default file input example</label>
          <div class="input-group">
            <input class="form-control" type="file" id="formFile" accept="image/*" name="file" />
            <button class="btn btn-outline-secondary superfile-clear" type="button">Clear</button>
          </div>
          <img class="img-fluid superfile-preview" />
        </div>
        <div class="mb-3 superfile">
          <label for="formFile2" class="form-label">Default file input example (no resize)</label>
          <div class="input-group">
            <input class="form-control" type="file" id="formFile2" name="file2" data-disable-resize="1" />
            <button class="btn btn-outline-secondary superfile-clear" type="button">Clear</button>
          </div>
          <img class="img-fluid superfile-preview" />
        </div>
        <div class="mb-3 superfile">
          <label for="formFile3" class="form-label">Default file input example (custom size)</label>
          <div class="input-group">
            <input class="form-control" type="file" id="formFile3" name="file3" accept="image/*" data-max-width="100" data-max-height="100" />
            <button class="btn btn-outline-secondary superfile-clear" type="button">Clear</button>
          </div>
          <img class="img-fluid superfile-preview" />
        </div>

        <div class="mb-3">
          <p>Upload an avatar (cropped to square, retina size). Try dragging a file!</p>
          <div class="superfile avatar">
            <label for="formFile4" class="form-label">Avatar upload</label>
            <button class="superfile-clear" type="button">✖️</button>
            <div class="input-group">
              <!-- double width/height for retina display -->
              <input class="form-control" type="file" id="formFile4" name="file4" accept="image/*" data-max-width="200" data-max-height="200" data-hide-clear="1" data-ratio="1:1" />
            </div>
            <img class="img-fluid superfile-preview" />
          </div>
        </div>

        <div class="mb-3">
          <p>Upload an avatar (preset value)</p>
          <div class="superfile avatar">
            <label for="formFile5" class="form-label">Avatar upload</label>
            <button class="superfile-clear" type="button">✖️</button>
            <div class="input-group">
              <!-- double width/height for retina display -->
              <input class="form-control" type="file" id="formFile5" name="file5" accept="image/*" data-max-width="200" data-max-height="200" data-hide-clear="1" data-ratio="1:1" />
            </div>
            <img src="https://randomuser.me/api/portraits/men/36.jpg" class="img-fluid superfile-preview" />
          </div>
        </div>

        <div class="mb-3 superfile">
          <label for="formFileMultiple" class="form-label">Multiple file input example (checkout the nice gallery layout!)</label>
          <div class="input-group">
            <input class="form-control" type="file" multiple id="formFileMultiple" accept="image/*" name="formFileMultiple[]" />
            <button class="btn btn-outline-secondary superfile-clear" type="button">Clear</button>
          </div>
          <div class="gallery-preview">
            <img class="img-fluid superfile-preview" />
          </div>
        </div>

        <div class="mb-3 superfile">
          <label for="formFileDirectory" class="form-label">Directory file input example</label>
          <div class="input-group">
            <input class="form-control" type="file" multiple directory webkitdirectory id="formFileDirectory" accept="image/*" name="formFileDirectory[]" />
            <button class="btn btn-outline-secondary superfile-clear" type="button">Clear</button>
          </div>
          <img class="img-fluid superfile-preview" />
        </div>

        <button class="btn btn-primary" type="submit">Submit form</button>
      </form>
    </div>
  </body>
</html>
              
            
!

CSS

              
                  img:not([src]) {
        display: none;
      }
      .superfile:not(.superfile-ready) {
        visibility: hidden;
      }
      .superfile-drag input {
        background: palegoldenrod;
      }
      .avatar {
        width: 100px;
        height: 100px;
        background: #ccc;
        border-radius: 100px;
        position: relative;
      }
      .avatar.superfile-drag {
        background-color: palegoldenrod;
      }
      .avatar .superfile-clear {
        position: absolute;
        top: 0px;
        right: 0px;
        width: 24px;
        height: 24px;
        display: inline-flex;
        align-items: center;
        text-align: center;
        border: 0;
        background: #ddd;
        font-size: 10px;
        border-radius: 24px;
        z-index: 2;
      }
      .avatar input {
        display: none;
      }
      .avatar label {
        z-index: 1;
      }
      .avatar.superfile-preview-active label {
        text-indent: -9999px;
      }
      .avatar .superfile-preview {
        z-index: 0;
        border-radius: 500px;
      }
      .avatar.superfile-drag .superfile-preview {
        display: none;
      }
      .avatar label,
      .avatar .superfile-preview {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
      }
      .avatar label {
        display: inline-flex;
        align-items: center;
        text-align: center;
        max-width: 75%;
        left: 12.5%;
      }
      .gallery-preview {
        margin:20px auto;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        grid-gap: 20px;
        align-items: center;
      }
      .gallery-preview .superfile-preview {
        border: 1px solid #ccc;
        box-shadow: 2px 2px 6px 0px rgba(0, 0, 0, 0.3);
        max-width: 100%;
      }
              
            
!

JS

              
                
              
            
!
999px

Console