All Projects → lekoala → bootstrap5-tags

lekoala / bootstrap5-tags

Licence: MIT license
Replace select[multiple] with nices badges for Bootstrap 5

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to bootstrap5-tags

Formbase
Better default styles for common input elements.
Stars: ✭ 560 (+865.52%)
Mutual labels:  select, input, checkbox
Vxe Table
🐬 vxe-table vue 表格解决方案
Stars: ✭ 4,242 (+7213.79%)
Mutual labels:  select, input, checkbox
Jhform
JhForm - 自定义表单工具,更加简单,快捷的创建表单、设置页面
Stars: ✭ 108 (+86.21%)
Mutual labels:  select, input, checkbox
Nb Choices
Angular wrapper for choices.js, vanilla, lightweight, configurable select box/text input plugin
Stars: ✭ 32 (-44.83%)
Mutual labels:  select, tags, checkbox
Vue Cool Select
Select with autocomplete, slots, bootstrap and material design themes.
Stars: ✭ 195 (+236.21%)
Mutual labels:  select, input
Selectize.js
Selectize is the hybrid of a textbox and <select> box. It's jQuery based, and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.
Stars: ✭ 12,744 (+21872.41%)
Mutual labels:  select, input
Teaset
A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.
Stars: ✭ 2,845 (+4805.17%)
Mutual labels:  select, checkbox
vue-tags-component
Vue.js 2+ tags component
Stars: ✭ 27 (-53.45%)
Mutual labels:  select, tags
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (+5.17%)
Mutual labels:  select, input
loopple
Drag & drop dashboard builder
Stars: ✭ 180 (+210.34%)
Mutual labels:  bootstrap4, bootstrap5
tagselector
Dependency-free JS library that turns select fields in customizable tag clouds
Stars: ✭ 19 (-67.24%)
Mutual labels:  select, tags
Flutter smart select
SmartSelect allows you to easily convert your usual form select or dropdown into dynamic page, popup dialog, or sliding bottom sheet with various choices input such as radio, checkbox, switch, chips, or even custom input. Supports single and multiple choice.
Stars: ✭ 179 (+208.62%)
Mutual labels:  select, checkbox
startbootstrap-business-frontpage
A Bootstrap HTML business homepage template created by Start Bootstrap
Stars: ✭ 177 (+205.17%)
Mutual labels:  bootstrap4, bootstrap5
Ant Plus
🔺 Ant Design 表单简化版
Stars: ✭ 212 (+265.52%)
Mutual labels:  select, input
Customalertviewdialogue
Custom AlertView Dialogue is the world's most advanced alert view library. Custom AlertView Dialogue includes simple message popups, confirmation alerts, selector popups, action sheet bottom menus, and input/feedback contact forms.
Stars: ✭ 100 (+72.41%)
Mutual labels:  select, input
startbootstrap-small-business
A Bootstrap HTML template for creating marketing websites for small businesses - created by Start Bootstrap
Stars: ✭ 186 (+220.69%)
Mutual labels:  bootstrap4, bootstrap5
react-inputs-validation
A react component for form inputs validation. Online demo examples
Stars: ✭ 48 (-17.24%)
Mutual labels:  select, checkbox
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (-43.1%)
Mutual labels:  select, input
Prompt Checkbox
This repository has been archived, use Enquirer instead.
Stars: ✭ 21 (-63.79%)
Mutual labels:  select, checkbox
tag-picker
Better tags input interaction with JavaScript.
Stars: ✭ 27 (-53.45%)
Mutual labels:  tags, input

Tags for Bootstrap 4/5

NPM Downloads

How to use

An ES6 native replacement for select using standards Bootstrap 5 (and 4) styles.

No additional CSS needed! Supports creation of new tags.

import Tags from "./tags.js";
Tags.init();
// Tags.init(selector, opts);
// You can pass global settings in opts that will apply
// to all Tags instances

By default, only provided options are available. Validation error will be displayed in case of invalid tag.

<label for="tags-input" class="form-label">Tags</label>
<select class="form-select" id="tags-input" name="tags[]" multiple>
  <option disabled hidden value="">Choose a tag...</option>
  <option value="1" selected="selected">Apple</option>
  <option value="2">Banana</option>
  <option value="3">Orange</option>
</select>
<div class="invalid-feedback">Please select a valid tag.</div>

Creation of new tags

Use attribute data-allow-new to allow creation of new tags. Their default value will be equal to the text. Since you can enter arbitrary text, no validation will occur.

<select class="form-select" id="tags-input" name="tags[]" multiple data-allow-new="true"></select>

You can force these new tags to respect a given regex.

NOTE: don't forget the [] if you need multiple values!

Server side support

You can also use options provided by the server. This script expects a json response that is an array or an object with the data key containing an array.

Simply set data-server where your endpoint is located. It should provide an array of value/label objects. The suggestions will be populated upon init except if data-live-server is set, in which case, it will be populated on type. A ?query= parameter is passed along with the current value of the searchInput.

You can preselect values either by using data-selected or by marking the suggestion as selected in the json result.

<label for="validationTagsJson" class="form-label">Tags (server side)</label>
<select
  class="form-select"
  id="validationTagsJson"
  name="tags_json[]"
  multiple
  data-allow-new="true"
  data-server="demo.json"
  data-live-server="1"
>
  <option disabled hidden value="">Choose a tag...</option>
</select>

Options

Options can be either passed to the constructor (eg: optionName) or in data-option-name format.

Name Default Description
allowNew false Allow typing arbitrary new tags
showAllSuggestions false Show all suggestions even if they don't match. Disables validation.
badgeStyle primary Color of the badge (color can be configured per option as well)
allowClear false Show a clear icon
clearEnd false Place clear icon at the end
server '' Point to a given endpoint that should provide the list of suggestions
liveServer false Should the endpoint be called dynamically when typing
serverParams {} Additionnal params to pass alongside the query parameter
selected '' A comma separated list of selected values
suggestionsThreshold 1 How many chars are needed before showing suggestions (0 to open immediately)
validationRegex false Regex for new tags
separator '' A list (pipe separated) of characters that should act as separator (default is using enter key)
max false Limit to a maximum of tags
placeholder '' Provides a placeholder if none are provided as the first empty option
clearLabel 'Clear' Text as clear tooltip
searchLabel 'Type a value' Default placeholder
valueField 'value' Value field
labelField 'label' Label field
keepOpen false Keep suggestions open after selection, clear on focus out
fullWidth false Use full input width from the dropdown menu
debounceTime 300 Debounce live server calls
baseClass '' Customize the class applied to badges

Tips

  • You can also use it on single selects! :-)
  • Use arrow down to show dropdown (and arrow up to hide it)
  • If you have a really long list of options, a scrollbar will be used
  • Access Tags instance on a given element with Tags.getInstance(mySelect)

Without Bootstrap 5

Bootstrap 4 support

Even if it was not the initial idea to support Bootstrap 4, this component is now compatible with Bootstrap 4 because it only requires minimal changes.

Check out demo-bs4.html

Standalone usage

Obviously, this package works great with the full bootstrap library, but you can also use it without Bootstrap or with a trimmed down version of it

Actually, this library doesn't even use the js library to position the dropdown menu, so its only dependencies is on css classes. You can check out the .scss file to see how to reduce bootstrap 5 css to a smaller size.

Check out demo-standalone.html

Demo

https://codepen.io/lekoalabe/pen/ExWYEqx

How does it look ?

screenshot

Do you need to init this automagically ?

You can use Modular Behaviour

https://codepen.io/lekoalabe/pen/wvmBLoB

Browser supports

Modern browsers (edge, chrome, firefox, safari... not IE11). Add a warning if necessary.

Used in

  • Admini: the minimalistic bootstrap 5 admin panel
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].