Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

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


Auto Save

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.


                <script src="[email protected]/dist/cdn.min.js" defer></script>

<div x-data="app" x-cloak>
	<!-- on top, render a list of files in a table -->
	<h2>Available Files <span x-text="loading"></span></h2>
	<table id="fileList">
			<template x-for="file in files">
					<td><span x-text=""></span></td>
					<td><span x-text="humanType(file.mimeType)"></span></td>
					<td><span x-text="humanFileSize(file.size,true)"></span></td>
					<td><a :href="file.webViewLink" target="_new">view</a>/<a :href="file.webContentLink">download</a></td>



                [x-cloak] { display: none !important; }

table {
	border-collapse: collapse;
	border: 1px solid black;
	width: 100%;
	max-width: 750px;

th, td {
	border: 1px solid black;
	padding: 5px;	


                const FILES_API = '';

document.addEventListener('alpine:init', () => {'app', () => ({
		async init() {
		files: [],
		async getFiles() {
			let resp = await fetch(FILES_API);
			this.loading = '';
			this.files = await resp.json();

 * Format bytes as human-readable text.
 * @param bytes Number of bytes.
 * @param si True to use metric (SI) units, aka powers of 1000. False to use 
 *           binary (IEC), aka powers of 1024.
 * @param dp Number of decimal places to display.
 * @return Formatted string.
function humanFileSize(bytes, si=false, dp=1) {
  const thresh = si ? 1000 : 1024;

  if (Math.abs(bytes) < thresh) {
    return bytes + ' B';

  const units = si 
    ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] 
    : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
  let u = -1;
  const r = 10**dp;

  do {
    bytes /= thresh;
  } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);

  return bytes.toFixed(dp) + ' ' + units[u];

function humanType(mime) {
	if(mime === 'application/pdf') return 'PDF';
	if(mine.startsWith('image/')) return 'Image';
	if(mime === 'text/html') return 'HTML';
	if(mime === 'application/word' || mime === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') return 'Word';
	if(mime === 'application/' || mime === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') return 'Excel';
	if(mime === 'application/' || mime === 'application/vnd.openxmlformats-officedocument.presentationml.presentation') return 'PowerPoint';
	return 'File';