├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── .npmrc ├── .prettierrc.mjs ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── astro.config.mjs ├── docs ├── CNAME ├── assets │ ├── client.CMMtWkl7.js │ ├── customize.ChsKtbAZ.css │ ├── hind-siliguri-latin-300-normal.BmRGVauJ.woff │ ├── hind-siliguri-latin-300-normal.CxtQ64TU.woff2 │ ├── hind-siliguri-latin-400-normal.esES0U7a.woff2 │ ├── hind-siliguri-latin-400-normal.mAXWzDdv.woff │ ├── hind-siliguri-latin-500-normal.C39pZ2Wf.woff │ ├── hind-siliguri-latin-500-normal.S8HLIV69.woff2 │ ├── hind-siliguri-latin-600-normal.DHrLfb92.woff2 │ ├── hind-siliguri-latin-600-normal.DznM-F7B.woff │ ├── hind-siliguri-latin-700-normal.Bfx7EHGG.woff │ ├── hind-siliguri-latin-700-normal.DO_14aHP.woff2 │ ├── hoisted.BHYAm2h0.js │ ├── hoisted.Bfhi6YCy.js │ ├── inter-tight-latin-100-normal.BUQHjXUO.woff2 │ ├── inter-tight-latin-100-normal.D6j6PT36.woff │ ├── inter-tight-latin-200-normal.BpBSUNUw.woff2 │ ├── inter-tight-latin-200-normal.CxHSWdVf.woff │ ├── inter-tight-latin-300-normal.B7aEqmkm.woff │ ├── inter-tight-latin-300-normal.CcE1U6m0.woff2 │ ├── inter-tight-latin-400-normal.BW_APOAv.woff │ ├── inter-tight-latin-400-normal.CjmW70MP.woff2 │ ├── inter-tight-latin-500-normal.DHfo6WYp.woff2 │ ├── inter-tight-latin-500-normal.DSK3iurg.woff │ ├── inter-tight-latin-600-normal.BhR4EMHT.woff2 │ ├── inter-tight-latin-600-normal.RFJ2ueZL.woff │ ├── inter-tight-latin-700-normal.DXx9Bw8i.woff2 │ ├── inter-tight-latin-700-normal.R7r4QQK5.woff │ ├── inter-tight-latin-800-normal.Cs5FMU-_.woff2 │ ├── inter-tight-latin-800-normal.oIdnBkMp.woff │ ├── inter-tight-latin-900-normal.CTv59UVw.woff │ ├── inter-tight-latin-900-normal.EWT6IQYC.woff2 │ ├── page.D3gCUAtq.js │ └── tab.CrkoWeCF.js ├── customize.html ├── demo.html ├── favicon.svg ├── index.html ├── install.html └── methods.html ├── eslint.config.js ├── package.json ├── public ├── CNAME └── favicon.svg ├── purgecss.config.cjs ├── scss └── use-bootstrap-tag.scss ├── src ├── components │ ├── Code.astro │ ├── DemoCard.astro │ ├── Layout.astro │ ├── Pagination.astro │ ├── customize │ │ ├── CustomizeA.scss │ │ ├── CustomizeB.scss │ │ └── CustomizeStructure.txt │ └── demo │ │ ├── AllowDuplicates.astro │ │ ├── Basic.astro │ │ ├── CustomSeparator.astro │ │ ├── Disabled.astro │ │ ├── Label.astro │ │ ├── MaxLimit.astro │ │ ├── Methods.astro │ │ ├── NoInputOnblur.astro │ │ ├── Placeholder.astro │ │ ├── Sizing.astro │ │ ├── TransformTags.astro │ │ ├── Validation.astro │ │ ├── Variants.astro │ │ └── XPosition.astro ├── env.d.ts ├── global.d.ts ├── lib │ ├── use-bootstrap-tag.scss │ ├── use-bootstrap-tag.tsx │ └── util.ts ├── pages │ ├── customize.astro │ ├── demo.astro │ ├── index.astro │ ├── install.astro │ └── methods.astro └── style.scss ├── tsconfig.json └── vite.config.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [use-bootstrap] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | dist/ 3 | # generated types 4 | .astro/ 5 | 6 | # dependencies 7 | node_modules/ 8 | 9 | # logs 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | 16 | # environment variables 17 | .env 18 | .env.production 19 | 20 | # macOS-specific files 21 | .DS_Store 22 | 23 | # jetbrains setting folder 24 | .idea/ 25 | 26 | # locks 27 | pnpm-lock.yaml 28 | bun.lockb 29 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact=true 2 | -------------------------------------------------------------------------------- /.prettierrc.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import("prettier").Config} */ 2 | const config = { 3 | semi: false, 4 | singleQuote: true, 5 | printWidth: 999999999999, 6 | htmlWhitespaceSensitivity: 'ignore', 7 | } 8 | 9 | export default config 10 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "html-css-class-completion.includeGlobPattern": "node_modules/bootstrap/dist/css/bootstrap.css", 3 | "html-css-class-completion.excludeGlobPattern": "!node_modules/bootstrap/dist/css/bootstrap.css", 4 | "html-css-class-completion.HTMLLanguages": [ 5 | "html", 6 | "astro" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | v2.2.2 2 | - Fixed placeholder color 3 | 4 | v2.2.1 5 | - Fixed types 6 | - Update docs 7 | 8 | v2.2.0 9 | - Added no-input-onblur option. 10 | 11 | v2.1.1 12 | - Updated to bootstrap v5.3.2. 13 | - Small improvements. 14 | 15 | v2.1.0 16 | - Added max option. 17 | 18 | v2.0.1 19 | - Some rendering improvements. 20 | 21 | v2.0.0 22 | - Rewrite project back to vanilla-js to improve performance and reduce size. 23 | - Pressing Enter is now the default action for adding a tag. Previously, users had to include an attribute option. 24 | - Now pressing Backspace on a focused tag deletes it and shifts focus to the previous tag, while pressing Delete deletes the tag and moves focus to the next one. 25 | - Fixed the tag with long text not breaking words. 26 | - Fixed server-side validation styles. 27 | - Fixed where adding existing values programmatically did not trigger a warning for duplicate tags. 28 | 29 | v1.0.3 30 | - Remove placeholder when input value is not empty (native input placeholder behavior). 31 | 32 | v1.0.2 33 | - Fixed lost focus after deleting the focused tag with the backspace or delete key (Firefox only). 34 | 35 | v1.0.1 36 | - Fixed docs. 37 | 38 | v1.0.0 39 | - Named export to default export. 40 | - Added transition. 41 | - Added variant option. 42 | - Added x-position option. 43 | - Added focusable tag, when it focused you can press backspace or delete key to remove it. 44 | - Fixed clicking label not focusing input. 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Use Bootstrap 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # use-bootstrap-tag 2 | 3 | Tag input for Bootstrap 5 4 | 5 | Demo and documentation: [https://use-bootstrap-tag.js.org](https://use-bootstrap-tag.js.org) 6 | 7 | ## Features 8 | 9 | - **Custom separator**: Set a specific delimiter character between tag elements. 10 | - **Enable/disable duplicates**: Toggle the allowance of duplicate tags. 11 | - **Custom transformation**: Define personalized modifications to input tag entries. 12 | - **Max limit**: Set a maximum limit of tags that can be added. 13 | - **Sizing**: Adjustable sizing to match user preferences or layouts. 14 | - **Validation**: Reflects validation states visually to align with Bootstrap's form validation feedback. 15 | ## Installation 16 | 17 | Install use-bootstrap-tag from npm: 18 | 19 | ```bash 20 | npm install use-bootstrap-tag 21 | ``` 22 | 23 | ## Usage/Examples 24 | 25 | After installation, you can import the library into your project as follows 26 | 27 | ```javascript 28 | import UseBootstrapTag from 'use-bootstrap-tag' 29 | import 'use-bootstrap-tag/dist/use-bootstrap-tag.css' 30 | ``` 31 | 32 | or, since it also comes with an IIFE bundle, you can insert it directly into your HTML 33 | 34 | ```html 35 | 36 | 37 |
38 | 39 | 40 |Assuming you’re using a package manager like npm, you’ll have a file structure that looks like this:
your-project/
16 | ├── scss/
17 | │ └── custom.scss
18 | └── node_modules/
19 | │ └── bootstrap/
20 | │ ├── js/
21 | │ └── scss/
22 | │ └── use-bootstrap-tag/
23 | │ ├── dist/
24 | │ └── scss/
25 | └── index.html
26 |
In your custom.scss
, you’ll import Bootstrap’s source Sass files. You have two options: include all of Bootstrap, or pick the parts you need.
// Custom.scss
27 | // Option A: Include all of Bootstrap
28 |
29 | // Include any default variable overrides here (though functions won't be available)
30 |
31 | @import "../node_modules/bootstrap/scss/bootstrap";
32 | @import "../node_modules/use-bootstrap-tag/scss/use-bootstrap-tag";
33 |
34 | // Then add additional custom code here
35 |
// Custom.scss
36 | // Option B: Include parts of Bootstrap
37 |
38 | // 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
39 | @import "../node_modules/bootstrap/scss/functions";
40 |
41 | // 2. Include any default variable overrides here
42 |
43 | // 3. Include remainder of required Bootstrap stylesheets (including any separate color mode stylesheets)
44 | @import "../node_modules/bootstrap/scss/variables";
45 | @import "../node_modules/bootstrap/scss/variables-dark";
46 |
47 | // 4. Include any default map overrides here
48 |
49 | // 5. Include remainder of required parts
50 | @import "../node_modules/bootstrap/scss/maps";
51 | @import "../node_modules/bootstrap/scss/mixins";
52 | @import "../node_modules/bootstrap/scss/root";
53 |
54 | // 6. Optionally include any other parts as needed
55 | @import "../node_modules/bootstrap/scss/utilities";
56 | @import "../node_modules/bootstrap/scss/reboot";
57 | @import "../node_modules/bootstrap/scss/type";
58 | @import "../node_modules/bootstrap/scss/images";
59 | @import "../node_modules/bootstrap/scss/containers";
60 | @import "../node_modules/bootstrap/scss/grid";
61 | @import "../node_modules/bootstrap/scss/helpers";
62 |
63 | // 7. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
64 | @import "../node_modules/bootstrap/scss/utilities/api";
65 |
66 | // 8. Include use-bootstrap-tag
67 | @import "../node_modules/use-bootstrap-tag/scss/use-bootstrap-tag";
68 |
69 | // 9. Add additional custom code here
70 |
By default, components inherit their styles from the default Bootstrap theme. Therefore, any changes made to Bootstrap will automatically affect the styling of these components as well.
Read more about customize bootstrap styles at https://getbootstrap.com/docs/5.3/customize/sass/.
Tag input for Bootstrap 5.
MIT
To install this library, you can use npm for package management, the CDN for direct inclusion, or manually download it from the GitHub releases page.
Install use-bootstrap-tag
in your Node.js powered apps with the npm package:
npm install use-bootstrap-tag
After installation, you can import the library into your project as follows:
import 'use-bootstrap-tag/dist/use-bootstrap-tag.css'
17 | import UseBootstrapTag from 'use-bootstrap-tag'
You can use use-bootstrap-tag
directly via CDN:
<link href="https://cdn.jsdelivr.net/npm/use-bootstrap-tag@2.2.2/dist/use-bootstrap-tag.min.css" rel="stylesheet">
18 | <script src="https://cdn.jsdelivr.net/npm/use-bootstrap-tag@2.2.2/dist/use-bootstrap-tag.min.js"></script>
Example
<!doctype html>
19 | <html lang="en">
20 | <head>
21 | <meta charset="utf-8">
22 | <meta name="viewport" content="width=device-width, initial-scale=1">
23 | <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
24 | <link href="https://cdn.jsdelivr.net/npm/use-bootstrap-tag@2.2.2/dist/use-bootstrap-tag.min.css" rel="stylesheet">
25 | <title>Example</title>
26 | </head>
27 | <body>
28 | <div class="container pt-4">
29 | <input type="text" class="form-control" value="html,css,js" id="example">
30 | </div>
31 | <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
32 | <script src="https://cdn.jsdelivr.net/npm/use-bootstrap-tag@2.2.2/dist/use-bootstrap-tag.min.js"></script>
33 | <script>
34 | UseBootstrapTag(document.getElementById('example'))
35 | </script>
36 | </body>
37 | </html>
Visit the GitHub releases page to download the latest version
Name | Params | Returns | Example |
---|---|---|---|
addValue | string | array | void |
|
removeValue | string | array | void |
|
getValue | null | string |
|
getValues | null | array |
|
35 | Assuming you’re using a package manager like npm, you’ll have a file structure that looks like this:
12 |
13 | In your custom.scss
, you’ll import Bootstrap’s source Sass files. You have two options: include all of Bootstrap, or pick the parts you need.
15 |
16 | By default, components inherit their styles from the default Bootstrap theme. Therefore, any changes made to Bootstrap will automatically affect the styling of these components as well.
17 |Read more about customize bootstrap styles at https://getbootstrap.com/docs/5.3/customize/sass/.
18 |{pkg.description}.
27 |{pkg.license}
46 |To install this library, you can use npm for package management, the CDN for direct inclusion, or manually download it from the GitHub releases page.
35 | 46 |Install {pkg.name}
in your Node.js powered apps with the npm package:
52 | After installation, you can import the library into your project as follows:
55 |
56 | You can use {pkg.name}
directly via CDN:
62 | Example
63 |
64 | Visit the GitHub releases page to download the latest version
67 |Name | 19 |Params | 20 |Returns | 21 |Example | 22 |
---|---|---|---|
addValue |
27 | string | array |
28 | void |
29 |
30 |
31 |
32 |
33 | |
34 |
removeValue |
37 | string | array |
38 | void |
39 |
40 |
41 |
42 |
43 | |
44 |
getValue |
47 | null |
48 | string |
49 |
50 |
51 | |
52 |
getValues |
55 | null |
56 | array |
57 |
58 |
59 | |
60 |