@dz8540/custom-select
v1.0.0
Published
DZ's custom select component library.
Downloads
5
Readme
DZ Custom-select
In order to use, it is enough to find the element you need, and then pass it to the class.
Installation
- Via npm
npm i @dz8540/custom-select
- Manually - all you need is in the "Dist" folder. If you need to use only multiple select, all you need is in the "Multiple-select" folder. If you need to use only select, all you need is in the "Select" folder.
<link href="/Your-path/customSelect.min.css" rel="stylesheet">
<script src="/Your-path/CustomSelect.min.js"></script>
Instruction:
- Don't remove all data attributes.
- Your value could has a data-checked attribute.
- Your values should be in the data-value attribute.
- Your values could has a data-disabled attribute.
- Component maintains data-name attribute, to you can set component name.
Example
HTML
<div class="Select" tabindex="-1" id="firstSelect" data-name="First select">
<input type="hidden" data-id="dz-input">
<div class="Select__inputBlock">
<span class="Select__input" data-id="dz-inputText"></span>
<span class="Select__icon">▼</span>
</div>
<ul class="Select__list">
<li class="Select__item">
<span class="Select__text" data-value="value1">Text 1</span>
</li>
<li class="Select__item">
<span class="Select__text" data-value="value2" data-disabled>Text 2</span>
</li>
<li class="Select__item">
<span class="Select__text" data-value="value3" data-checked>Text 3</span>
</li>
<li class="Select__item">
<span class="Select__text" data-value="value4">Text 4</span>
</li>
</ul>
</div>
<!-- If multiple -->
<div class="Select" tabindex="-1" id="firstSelect" data-multiple data-name="First select">
<input type="hidden" data-id="dz-input">
<div class="Select__inputBlock">
<span class="Select__input" data-id="dz-inputText"></span>
<span class="Select__icon">▼</span>
</div>
<ul class="Select__list">
<li class="Select__item">
<span class="Select__text" data-value="value1">Text 1</span>
</li>
<li class="Select__item">
<span class="Select__text" data-value="value2" data-disabled>Text 2</span>
</li>
<li class="Select__item">
<span class="Select__text" data-value="value3" data-checked>Text 3</span>
</li>
<li class="Select__item">
<span class="Select__text" data-value="value4">Text 4</span>
</li>
</ul>
</div>
JS
let el = document.querySelector(el);
new Select(el);
// If multiple
new MultipleSelect(el);
End
That's all! Enjoy this (☞゚ヮ゚)☞ ☜(゚ヮ゚☜)