Ember tag input
npm install ember-tag-input
ember-tag-input is a simple Ember addon that converts a user's typing into tags. New tags are created when the user types a comma, space, or hits the enter key. Tags can be removed using the backspace key or by clicking the x button on each tag.

In the simplest case, just pass a list of tags to render and actions for adding and removing tags. The component will never change the tags list for you, it will instead call actions when changes need to be made. The component will yield each tag in the list, allowing you to render it as you wish.
``handlebars`
@addTag={{this.addTag}}
@removeTagAtIndex={{this.removeTagAtIndex}}
as |tag|
>
{{tag}}
`js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@tracked tags = [];
@action addTag(tag) {
this.tags.pushObject(tag);
}
@action removeTagAtIndex(index) {
this.tags.removeAt(index);
}
}
`
The above example works if your tags array is just an simple array of strings. If your tags are more complex objects, you can render them however you want, as demonstrated by the following example:
`handlebars`
@addTag={{this.addTag}}
@removeTagAtIndex={{this.removeTagAtIndex}}
as |tag|
>
{{tag.name}}
{{tag.date}}
modifiers
If you pass tags objects, you can use the property to pass extra classes to individual tags:``
tags = A([
{ name: 'first', modifiers: 'primaryTag' },
{ name: 'second', modifiers: 'secondaryTag' },
]);Options
to the element that is about to be removed.
- default: true$3
- If tags are allowed to contain comma.
- default: false$3
- If tags are allowed to contain spaces.
- default: false$3
- If duplicates tags are allowed in the list.
- default: false$3
- If 'x' removal links should be displayed at the right side of each tag.
- default: true$3
- The placeholder text to display when the user hasn't typed anything. Isn't displayed if readOnly=true.
- default: ''$3
- The aria-label for the input field.
- default: ''$3
- If a read only view of the tags should be displayed. If enabled, existing tags can't be removed and new tags can't be added.
- default: false$3
- If maxlength value is passed in, each ` field(tag) will have maximum number of characters allowed.