Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <article>
  <input class='customLook' value='some.name@website.com'><button type="button">+</button>
</article>
              
            
!

CSS

              
                article{    
  width: 100%;
  max-width: 700px;
}

.customLook{
  --tag-bg                  : #0052BF;
  --tag-hover               : #CE0078;
  --tag-text-color          : #FFF;
  --tags-border-color       : silver;
  --tag-text-color--edit    : #111;
  --tag-remove-bg           : var(--tag-hover);
  --tag-pad                 : .6em 1em;
  --tag-inset-shadow-size   : 1.4em; /* compensate for the larger --tag-pad value */
  --tag-remove-btn-color    : white;
  --tag-remove-btn-bg--hover: black;

  display: inline-block;
  min-width: 0;
  border: none;
}

.customLook .tagify__tag{
  margin-top: 0;
}

.customLook .tagify__tag > div{
  border-radius: 25px;
}

.customLook .tagify__tag:not(:only-of-type):not(.tagify__tag--editable):hover .tagify__tag-text{
  margin-inline-end: -1px;
}

/* Do not show the "remove tag" (x) button when only a single tag remains */
.customLook .tagify__tag:only-of-type .tagify__tag__removeBtn{
  display: none;
}

.customLook .tagify__tag__removeBtn{
  opacity: 0;
  transform: translateX(-100%) scale(.5);
  margin-inline: -20px 6px; /* very specific on purpose  */
  text-align: right;
  transition: .12s;
}

.customLook .tagify__tag:not(.tagify__tag--editable):hover .tagify__tag__removeBtn{
  transform: none;
  opacity: 1;
}

.customLook + button{
  color: #0052BF;
  font: bold 1.4em/1.65 Arial;
  border: 0;
  background: none;
  box-shadow: 0 0 0 2px inset currentColor;
  border-radius: 50%;
  width: 1.65em;
  height: 1.65em;
  cursor: pointer;
  outline: none;
  transition: .1s ease-out;
  margin: 0 0 0 5px;
  vertical-align: top;
}

.customLook + button:hover{
  box-shadow: 0 0 0 5px inset currentColor;
}

.customLook .tagify__input{
  display: none;
}
              
            
!

JS

              
                // generate random whilist items (for the demo)
var randomStringsArr = Array.apply(null, Array(100)).map(function() {
  return Array.apply(null, Array(~~(Math.random() * 10  + 3))).map(function() {
    return String.fromCharCode(Math.random() * (123 - 97) + 97)
  }).join('') + '@gmail.com'
})

var input = document.querySelector('.customLook'),
    button = input.nextElementSibling,  // "add new tag" action-button
    tagify = new Tagify(input, {
      editTags: {
        keepInvalid: false, // better to auto-remove invalid tags which are in edit-mode (on blur)
      },
      // email address validation (https://stackoverflow.com/a/46181/104380)
      pattern: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
      whitelist: randomStringsArr,
      callbacks: {
        "invalid": onInvalidTag
      },
      dropdown : {
        position: 'text',
        enabled: 1 // show suggestions dropdown after 1 typed character
      }
    });

button.addEventListener("click", onAddButtonClick)

function onAddButtonClick(){
    tagify.addEmptyTag()
}

function onInvalidTag(e){
  console.log("invalid", e.detail)
}

              
            
!
999px

Console