A vanilla JavaScript multi-checkbox dropdown web component.

Overview

Multi-Checkbox Web Component

Published on npm Version

Multi-Checkbox is a web component that utilizes multiple checkboxes in a dropdown list to populate the value of an input. It is written in pure Javascript with no dependencies.

Installation

  • NPM npm install multi-checkbox

  • CDN <script type="module" src="https://www.unpkg.com/multi-checkbox/multi-checkbox.js"></script>

Usage

The Multi-Checkbox component utilizes the custom element tag <multi-checkbox>. Within the custom tag the component requires a slotted <ul> element with the slot attribute set to check-values. Within the slotted <ul> each <li> element represents a checkbox label and value for the component. The custom element has two attributes:

  • separator - The separator string used between the checked values.
  • value - The custom element component value.

The component will automatically update when attributes are set dynamically. So changing the separator attribute dynamically will automatically replace the value attribute with the updated separator. Changing the value attribute dynamically will automatically check the corresponding checkboxes, if they exist. Additionally, if the <li> elements are changed dynamically the element will reset with the new checkbox values.

<multi-checkbox separator="," value="">
    <ul slot="check-values">
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
    </ul>
</multi-checkbox>

CSS Style Variables

The following CSS property variables, along with their default values, are available for custom styling.

Property Variable Default Value
General Element
--mc-border 1px solid #000000
--mc-border-radius 2px
--mc-display inline-block
--mc-font 400 0.9em Arial
--mc-margin 0
--mc-vertical-align middle
Dropdown
--mc-dropdown-background #efefef
--mc-dropdown-box-shadow 3px 3px 5px 1px rgba(0,0,0,0.35)
--mc-dropdown-text-align left
--mc-dropdown-width 209px
Input
--mc-target-background #efefef
--mc-target-color #000000
--mc-target-cursor default
--mc-target-height 28px
--mc-target-margin 0
--mc-target-max-height default
--mc-target-min-height default
--mc-target-max-width default
--mc-target-min-width default
--mc-target-padding 0px 0px 0px 3px
--mc-target-outline none
--mc-vertical-align middle
--mc-target-width 175px
Dropdown Line Items
--mc-dropdown-color #000000
--mc-dropdown-line-height 2em
--mc-ul-margin 5px
--mc-ul-padding 0
--mc-checkbox-height auto
--mc-checkbox-width auto
Toggle Button
--mc-toggle-button-background #ffffff
--mc-toggle-button-color #000000
--mc-toggle-button-cursor pointer
--mc-toggle-button-height 30px
--mc-toggle-button-outline none
--mc-vertical-align middle
--mc-toggle-button-width 30px
Close Button
--mc-close-button-background #efefef
--mc-close-button-border none
--mc-close-button-border-radius default
--mc-close-button-color #000000
--mc-close-button-cursor pointer
--mc-close-button-display block
--mc-close-button-height 22px
--mc-close-button-margin 5px auto
--mc-close-button-outline none
--mc-close-button-width 22px

Changing the Tag Name

The Multi-Checkbox component uses the <multi-checkbox> tag in html. In certain cases users may want, or need, to change the tag name. This can be accomplished in Javascript by subclassing the element and registering this subclass under a new tag name.

import {MultiCheckbox} from 'multi-checkbox';

customElements.define('my-new-tag', class extends MultiCheckbox{});

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.
You might also like...

Lightweight vanilla js modal component (just 2kb) , pure javascript Modal

Lightweight vanilla js modal component (just 2kb) pure javascript Modal , This is just 2kb Lightweight vanilla js modal component with zero dependenci

Dec 12, 2022

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

Select creates a dropdown list of items with the selected item in closed view.

Select creates a dropdown list of items with the selected item in closed view.

Native Base Select 🔽 This module includes a customizable multi-select and a single select component for Native Base. The package is both Android and

Dec 25, 2022

A custom select dropdown. This is something that is not too difficult to make.

Custom-Dropdown-JS A custom select dropdown using basic JS fucntionality. This is something that is not too difficult to make. But it shows that you h

Mar 26, 2022

Converts select multiple elements into dropdown menus with checkboxes

jquery-multi-select Converts select multiple elements into dropdown menus with a checkbox for each option. The original select element is hidden

Dec 8, 2022

a jquery searchable select dropdown

Select Search A simple jquery search on select options plugin for your website How To Use Just create an html structure that contains select tag e.g.

Sep 25, 2020

Google translate dropdown customize with country flag

Google translate dropdown customize with country flag

Flag google trasnalte demo without google bar and logo Screenshot How to use this 1. Create a country checklist containing languages from which you’ll

Oct 11, 2022

Dropdown select box for bootstrap 5

dselect Dropdown select box for bootstrap 5 Demo Features Placeholder Multiple Search Creatable Clearable Sizing Validation Installation Install dsele

Dec 21, 2022

Multiple level dropdown works with Bootstrap 5, just like native support.

Bootstrap 5 Multiple Level Dropdown. For Bootstrap 4, please visit Bootstrap 4 Multiple Level Dropdown Using official HTML without adding extra CSS st

Dec 13, 2022
Owner
null
Superlight vanilla javascript plugin, for modern web dropdowns. Supporting multi-options, search and images. Designed to be seamlessly themed

Superlight vanilla javascript dropdowns by LCweb Need to jump off of jQuery (or any other) dependency? Other packages are too heavy to just tweak sele

Luca 10 Dec 26, 2022
proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ?? yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

4D/ҵ.com Dashboards 13 Dec 30, 2022
Multi-level contextmenu created in Vanilla Javascript (no css files included)

ContexMenu.js Multi-level ContextMenu Created in Vanilla Javascript (No CSS Files) Import with jsDelivr <script src="https://cdn.jsdelivr.net/gh/L1qui

null 5 Nov 22, 2022
🍦 ✨ Simple multi-select pure vanilla Javascript library.

multiSelect.js ✨ Simple multi-select pure vanilla Javascript library. ?? Live Demo v1.0.8 multiSelect.js is a simple, pure vanilla Javascript library

Jacob Kleiman 5 Mar 15, 2022
Create beautiful, functional and extensive (Multi) Select Fields with pure, vanilla JavaScript.

tail.select.js - Beautify Select Fields (formerly tail.select) Replace and Improve your HTML <select> fields with style and without jQuery! The tail.s

Ciprian Popescu 69 Dec 30, 2022
A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" ?? The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Linus Lee 20 Oct 30, 2022
Pure JavaScript (VanillaJS) dropdown menu, with multiple select and searching support

JS Select Pure JavaScript (VanillaJS) dropdown menu, with multiple select and searching support How to use To use the select plugins, two main file mu

Luigi Verolla 4 Mar 17, 2022
Simple quick javascript dropdown plugin with search, that able to work with thousands of options

fstdropdown fstdropdown - simple quick javascript dropdown plugin with bootstrap design and search, that able to work with thousands of options. Now w

Vladyslav Andrieiev 15 Nov 12, 2022
A JavaScript library that creates a small dropdown list of selectable Emojis.

Welcome to EmojiButtonList.js: This is a JavaScript library that creates a small dropdown list of selectable Emojis. To get started, download the sour

William Troup 2 Mar 27, 2021
Colr Pickr, a vanilla JavaScript color picker component built with SVGs, with features like saving colors. Similar design to the chrome-dev-tools color picker.

Colr Pickr Colr Pickr, a vanilla JavaScript color picking component built with SVGs, with features like saving colors. Similar design to the chrome-de

TEK 27 Jun 27, 2022