Installations
npm install @nasfald/tagify
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
7.10.0
NPM Version
4.2.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
HTML (55.14%)
JavaScript (35.28%)
CSS (9.58%)
Developer
Download Statistics
Total Downloads
572
Last Day
2
Last Week
2
Last Month
7
Last Year
46
GitHub Statistics
69 Commits
2 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
1.2.2
Package Id
@nasfald/tagify@1.2.2
Size
61.98 kB
NPM Version
4.2.0
Node Version
7.10.0
Total Downloads
Cumulative downloads
Total Downloads
572
Last day
0%
2
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
250%
7
Compared to previous month
Last year
-44.6%
46
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Tagify - lightweight input "tags" script
Want to simply convert an input field into a tags element, in a easy customizable way, with good performance and smallest code footprint? You are in the right place my friend.
Demo page
Selling points
- supports whitelist (with native suggestions dropdown as-you-type)
- supports blacklists
- JS file is under 150 very readiable lines of code
- JS weights less than ~5kb
- SCSS file is ~2kb of highly readable and flexible code
- No other inputs are used beside the original, and its value is kept in sync
- Can paste in multiple values ("tag 1, tag 2, tag 3")
- Automatically disallow duplicate tags (vis "settings" object)
- Tags can be created by commas or by pressing the "Enter" key
- Tags can be trimmed via
hellip
by givingmax-width
to thetag
element in yourCSS
- Easily customized
- Exposed custom events
building the project
Simply run gulp
in your terminal, from the project's path (Gulp should be installed first)
Basic usage
Lets say this is your markup, and you already have a value set on the input (which was pre-filled by data from the server):
1<input name='tags' placeholder='write some tags' value='foo, bar,buzz'> 2<textarea name='tags' placeholder='write some tags'>foo, bar,buzz</textarea>
what you need to do to convert that nice input into "tags" is simply select your input/textarea and run tagify()
:
1// vanilla component 2var input = document.querySelector('input[name=tags]'), 3 tagify = new Tagify( input ); 4 5// with settings passed 6tagify = new Tagify( input, { 7 duplicates: true, 8 whitelist: ['foo', 'bar'], 9 callbacks: { 10 add : onAddTag // calls an imaginary "onAddTag" function when a tag is added 11 } 12}); 13 14// listen to custom tags' events such as 'add' or 'remove' 15tagify1.on('remove', ()=>{ 16 console.log(e, e.detail); 17});
jQuery plugin version (jQuery.tagify.js)
1$('[name=tags]') 2 .tagify() 3 .on('add', function(e, tagName){ 4 console.log('added', tagName) 5 });
Now markup be like:
1<tags> 2 <tag> 3 <x></x> 4 <div><span title="css">css</span></div> 5 </tag> 6 <tag> 7 <x></x> 8 <div><span title="html">html</span></div> 9 </tag> 10 <tag> 11 <x></x> 12 <div><span title="javascript">javascript</span></div> 13 </tag> 14 <div> 15 <input list="tagsSuggestions3l9nbieyr" class="input placeholder"> 16 <datalist id="tagsSuggestions3l9nbieyr"> 17 <label> select from the list: 18 <select> 19 <option value=""></option> 20 <option>foo</option> 21 <option>bar</option> 22 </select> 23 </label> 24 </datalist><span>write some tags</span> 25 </div> 26 <input name="tags" placeholder="write some tags" value="foo, bar,buzz"> 27</tags>
Methods
Name | Info |
---|---|
destroy | if called, will revert the input back as it was before Tagify was applied |
removeAllTags | removes all tags and rests the original input tag's value property |
Exposed events
Name | Info |
---|---|
add | A tag has been added |
remove | A tag has been removed |
duplicate | A tag has been added and found to be a duplicate of existing one |
maxTagsExceed | Number of tags exceeds the allowed quantity and the exceed tags were denied (removed) |
blacklisted | A tag which is in the blacklist has been added and denied (removed) |
notWhitelisted | A tag which is not in the whitelist has been added and denied (removed) |
Settings
Name | Type | Default | Info |
---|---|---|---|
delimiters | String | "," | [regex] split tags by any of these delimiters. Example: Space or Coma - ", " |
pattern | String | "" | Validate the input by REGEX pattern (can also be applied on the input itself as an attribute) |
duplicates | Boolean | false | (flag) should duplicate tags be allowed or not |
enforeWhitelist | Boolean | false | should ONLY use tags allowed in whitelist |
autocomplete | Boolean | true | show native suggeestions list, as you type |
whitelist | Array | [] | an array of tags which only they are allowed |
blacklist | Array | [] | an array of tags which aren't allowed |
callbacks | Object | {} | exposed callbacks object to be triggered on events: 'add' / 'remove' tags |
maxTags | Number | Infinity | max number of tags |
suggestionsMinChars | Number | 2 | minimum characters to input which shows the sugegstions list |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More