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>Click to copy string interaction</h1>
  <p>This is <a href="" class="copy-click" data-tooltip-text="Click to copy" data-tooltip-text-copied="✔ Copied to clipboard">a string you can copy</a>. Hover over it to see the interaction. Click on the string to copy it to your clipboard.</p>

  <p>And here is <a href="" class="copy-click" data-tooltip-text="Click to copy" data-tooltip-text-copied="✔ Copied to clipboard">another string you can copy</a>. Very nice.</p>

  <p>Click this one to copy <a href="" class="copy-click" data-copy-string="#ITN12345" data-tooltip-text="Click to copy" data-tooltip-text-copied="✔ Copied to clipboard">a data-attribute itinerary string</a> added to the HTML tag.</p>

  <input placeholder="Paste copied text here"></input>

  <p>Here's an example of the HTML being used:</p>
    &lt;a href="" class="<span>copy-click</span>" 
    <br />&nbsp;&nbsp;<span>data-copy-string</span>="#ITN12345"
    <br />&nbsp;&nbsp;<span>data-tooltip-text</span>="Click to copy"
    <br />&nbsp;&nbsp;<span>data-tooltip-text-copied</span>="✔ Copied to clipboard"&gt;
    <br />&nbsp;&nbsp;Text to display
    <br />&lt/a&gt;
  <small>Original design concept by <a href="" target="_blank">@JustinDanks</a>.</small>


                :root {
  --duration: 400ms;
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
  --bounce: cubic-bezier(0.6, -0.28, 0.735, 0.045);

* {
  box-sizing: border-box;

h1 {
  line-height: 1.15;

p {
  line-height: 1.5;

code {
  display: block;
  margin-bottom: 1rem;
  padding: 1rem;
  width: 100%;
  font-family: 'Menlo', monospace;
  font-size: 14px;
  line-height: 1.4;
  color: #484848;
  background-color: #f3f3f3;
  border-radius: 2px;
  span {
    font-weight: bold;

main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  max-width: 550px;

input {
  margin: 1rem 0;
  padding: 0.5rem;
  width: 100%;
  font-size: 1rem;

.copy-click {
  position: relative;
  padding-bottom: 2px;
  text-decoration: none;
  cursor: copy;
  color: #484848;
  border-bottom: 1px dashed #767676;
  transition: background-color calc(var(--duration) * 2) var(--ease);
  &:after {
    content: attr(data-tooltip-text);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    padding: 8px 16px;
    white-space: nowrap;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 0 0 -12px rgba(0,0,0,0);
    pointer-events: none;
    backface-visibility: hidden;
    opacity: 0;
    transform: translate(-50%, 12px);
      box-shadow calc(var(--duration) / 1.5) var(--bounce),
      opacity calc(var(--duration) / 1.5) var(--bounce),
      transform calc(var(--duration) / 1.5) var(--bounce);
  &.is-hovered {    
    &:after {
      box-shadow: 0 4px 8px rgba(0,0,0,0.10);
      opacity: 1;
      transform: translate(-50%, 0);
      transition-timing-function: var(--ease);
  &.is-copied {
    background-color: yellow;
    &:after { 
      content: attr(data-tooltip-text-copied); 


                const links = document.querySelectorAll('.copy-click');
const cls = {
  copied: 'is-copied',
  hover: 'is-hovered'

const copyToClipboard = str => {
  const el = document.createElement('input');
  str.dataset.copyString ? el.value = str.dataset.copyString : el.value = str.text;
  el.setAttribute('readonly', ''); = 'absolute'; = 0;

const clickInteraction = (e) => {
  setTimeout(() =>, 1000);
  setTimeout(() =>, 700);  

Array.from(links).forEach(link => {
  link.addEventListener('click', e => clickInteraction(e));
  link.addEventListener('keypress', e => {
    if (e.keyCode === 13) clickInteraction(e);
  link.addEventListener('mouseover', e =>;
  link.addEventListener('mouseleave', e => {
    if (! {;