Features Installation Usage/Examples Options Methods

@erwinstone/bs-tag

v1.0.1

Bootstrap tags input

Github

Features

Installation

Install with npm:

npm install @erwinstone/bs-tag

Install from cdn:



			

Usage/Examples

Place css between <head></head> tags:

<head>
	...
	<link href="https://unpkg.com/@erwinstone/bs-tag@1.0.1/dist/bs-tag.min.css" rel="stylesheet">
</head>

Place js before </body> tag:

<body>
	...
	<script src="https://unpkg.com/@erwinstone/bs-tag@1.0.1/dist/bs-tag.min.js"></script>
</body>

* You can also use bs-tag as javascript module:

<script src="yourscript.js" type="module"></script>

In yourscript.js file, import BsTag (Change location according to your path):

import BsTag from './path/to/bs-tag.module.js'

Or you can use it directly in the html script as a module:

<script type="module">
	import BsTag from './path/to/bs-tag.module.js'
</script>
			

Examples:

1. Basic
2. Placeholder
3. Custom separator

Example tags with "space" separator.

4. Allow duplicates
5. Transform tags

Sometimes we need to transform tags. Example tags with toUpperCase().

6. Force add on enter
7. Disabled
8. Sizing
9. Validation
This field is required.
Ok.
10. Methods

Options

Name Type Default Description
separator string , Separator between tags
duplicate boolean false Allow duplicates
transform string input => input Function to change value. The function must be an arrow function
enter boolean false Force adding tag when enter key is pressed

Methods

Name Params Returns Example
addValue string | array void
input.addValue('cyan')
input.addValue(['light', 'dark'])
removeValue string | array void
input.removeValue('cyan')
input.removeValue(['light', 'dark'])
getValue null string
input.getValue() // red,green,blue
getValues null array
input.getValues() // ["red","green","blue"]