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.


                <h1>Copy to clipboard from a data source (array)</h1>
<div id="trigger">Copy to clipboard</div>

<textarea name="clipboardTextarea" id="clipboardTextarea"></textarea>



                #clipboardTextarea {
  overflow: hidden;
  max-height: 0px;
  max-width: 0px;
  resize: none;
  border: none;
  position: absolute;
  bottom: 0px;
  right: 0px;
  z-index: -10;
#clipboardTextarea:focus {
  outline: none;

/*simple demo styles*/
#trigger {
  padding: 1em;
  background-color: green;
  display: inline-block;
  border-radius: 10px;
  color: white;
  font-family: Arial, Helvetica, sans-serif;

#trigger:hover {
  cursor: pointer;
h1 {
  font-family: Arial, Helvetica, sans-serif;



                // First, dynamically produce a list as an array. In my use case I programmed an array from other application data to yield a list of grocery items
var myList = [
  "egg x10",
  "basmati rice 300g",
  "banana x7",
  "apple x1",
  "onion x2"
//Have a play around with the array values

//will need a dom element to use execCommand but will hide with css from the user
var myTarget = document.getElementById("clipboardTextarea");

function createListOutput() {
  console.log('output fired')
  var myListOutput = "";
  for (var i = 0; i < myList.length; i++) {
    //check if list is NOT the last in the array, if last don't output a line break
    if (i != myList.length - 1) {
      let lineItem = myList[i] + "\n";
      myListOutput = myListOutput + lineItem;
    } else {
      let lineItem = myList[i];
      myListOutput = myListOutput + lineItem;
  myTarget.value = myListOutput;;
  myTarget.setSelectionRange(0, 99999); //for mobile
  console.log("Copied to clipboard"); //could respond with some visual feedback to user
  alert("Copied to clipboard");

document.getElementById("trigger").addEventListener("click", createListOutput, false);