Tags Collector
<msc-tags-collector /> is a web component for input tags purpose. Users could key in anything they like (include space). Besides that sorting has already build-in with <msc-tags-collector />. We can go by 「DRAG」and「DROP」or ←、→ to arrange tag orders we like.
Try to key in something in the following field and press 「GET TAGS」to see what can <msc-tags-collector /> do ?
Basic Usage
<msc-tags-collector /> is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-tags-collector />'s html structure and everything will be all set.
Required Script
Structure
Put <msc-tags-collector /> into HTML document. It will have different functions and looks with attribute mutation.
Otherwise, developers could also choose remoteconfig to fetch config for <msc-tags-collector />.
JavaScript Instantiation
<msc-tags-collector /> could also use JavaScript to create DOM element. Here comes some examples.
Storage
<msc-tags-collector /> will generate an input[type=hidden] as storage and put success inputed tags data as its value. <input /> default name is msc-tags-collector, developers can switch any name they liked.
Style Customization
Developers could apply styles to decorate <msc-tags-collector />'s looking.
Attributes
<msc-tags-collector /> supports some attributes to let it become more convenience & useful.
placeholder
Set placeholder for <msc-tags-collector />. It should be JSON string. Developers could set default tags here. Default is [] (not set).
illegalkeys
Set illegal keys for <msc-tags-collector />. It should be JSON string. Developers could set illegal keys here (some keys you don't want user input). Default is [] (not set).
l10n
Set localization for <msc-tags-collector />. It will replace some text to anything you like. It should be JSON string. Developers could set input's placeholder here.
- placeholder input field placeholder content. Default is tag.
limitation
Set limitation for <msc-tags-collector />. It should be JSON string. Developers could set maxcount and maxlength here.
- maxcount:maximum tags count. Default is 10.
- maxlength:input maxlength setting. Default is 30.
Property
| Property Name | Type | Description |
|---|---|---|
placeholder
|
Array | Getter / Setter for placeholder. Developers could set default tags here. Default is []. |
illegalkeys
|
Array | Getter / Setter for illegalkeys. Developers could set illegal keys here (some keys you don't want user input). Default is []. |
l10n
|
Object | Getter / Setter for l10n. Developers could set input's placeholder here. Default is tag. |
limitation
|
Object | Getter / Setter for limitation. Developers could set maxcount and maxlength here. |
tagsInfo
|
Array | Getter for current <msc-tags-collector />'s tags information. |
count
|
Number | Getter for current <msc-tags-collector />'s tags count. |
Method
| Method Signature | Description |
|---|---|
addTag(tag)
|
Add tag you like. |
removeTag(tag)
|
Remove tag you like. |
removeAll
|
Remove all tags. |
focus
|
Focus on input field. |
Event
| Event Signature | Description |
|---|---|
msc-tags-collector-input
|
Fired when user input something. Developers could gather input content > { tag } through event.detail. |
msc-tags-collector-mutate
|
Fired when <msc-tags-collector /> tags mutated (include add / remove / sort actions). Developers could gather current inputed tags > { tags } through event.detail. |
msc-tags-collector-error
|
Fired when <msc-tags-collector /> error occured. Develpoers could gather information through event.detail. |