Moey Icons
No results. Try “dialog”, “dark” or “grid”.
Moey extras

Tag input

Type a word, press Enter or comma, and it becomes a chip. The form still sends one plain comma list, so it works the same without JavaScript.

<label class="form-label" for="tags">Tags</label>
<input class="form-control" id="tags" name="tags" value="summer, sale" placeholder="Add a tag…" data-moey-tags>
  • Enter or , adds a tag. Pasting “red, green, blue” adds three.
  • Backspace in the empty field selects the last tag; press it again to remove it. Or click its ✕.
  • Duplicates are skipped — the existing tag gives a little shake. Clicking away adds what you typed.
  • The original input stays in the form, hidden, and holds summer, sale, new arrivals.

Suggestions

Point it at a <datalist> with list — Moey suggests as you type (a combobox list), and picking a suggestion adds the tag.

<div class="field max-w-md"><label class="form-label" for="ti-skills">Skills</label>
  <input class="form-control" id="ti-skills" name="skills" list="ti-skill-list" placeholder="Type a skill" data-moey-tags>
  <datalist id="ti-skill-list">
    <option value="Design">
      <option value="Copywriting">
        <option value="Photography">
          <option value="Customer support">
            <option value="Shipping">
              <option value="Bookkeeping"></option>
            </option>
          </option>
        </option>
      </option>
    </option>
  </datalist>
</div>

Limits, required and other separators

Once there are three, the field stops taking more.
<input class="form-control" data-moey-max="3" data-moey-tags>
<input class="form-control" name="emails" data-moey-delimiter=";" required data-moey-tags>

Check each tag

moey:tag-add is cancelable — refuse a value and it stays in the field to fix. This one only takes email addresses:

Try “jane” and then “jane@moey.test”.
input.addEventListener('moey:tag-add', (e) => {
  if (!/^\S+@\S+\.\S+$/.test(e.detail.value)) {
    e.preventDefault();                       // keeps the text in the field
    showError('That isn’t an email address');
  }
});

Sizes and colors

<div class="grid grid-cols-1 gap-3 max-w-md">
  <input class="form-control form-control-sm" value="small, tags" aria-label="Small" data-moey-tags>
  <input class="form-control theme-blue" value="blue, colored, chips" aria-label="Blue" data-moey-tags>
  <input class="form-control form-control-lg" value="large" aria-label="Large" data-moey-tags>
  <input class="form-control" value="disabled, field" aria-label="Disabled" disabled data-moey-tags>
</div>

The chips themselves — colors, removing, filters — have their own page: Chips.

From code & events

Moey.tags(input);                     // ['summer', 'sale']
Moey.tags(input, ['mugs', 'totes']);  // replace them

input.addEventListener('moey:tag-add', (e) => e.detail.value);      // cancelable
input.addEventListener('moey:tag-remove', (e) => e.detail.value);   // cancelable
input.addEventListener('change', () => input.value);                // "mugs, totes"
Class / attributeWhat it does
data-moey-tagsOn an <input>: turns it into a tag input
list="…"Suggestions from a <datalist>
data-moey-maxThe most tags allowed
data-moey-delimiterThe separator (default ,); Enter and new lines always work
data-moey-duplicates="true"Allow the same tag twice
data-moey-add-on-blur="false"Leaving the field doesn’t add what’s typed
required · disabledAt least one tag · read-only and not sent