- Plugins
- Input Number
Plugins
Tailwind CSS Input Number
Input Number - input idea for Shop systems or so.
Installation
To get started, install Input Number plugin via npm, else you can skip this step if you are already using Preline UI as a package.
npm i @preline/input-number
Example
Wrap the input-number's toggle data-hs-input-number-input
and buttons data-hs-input-number-decrement
with data-hs-input-number-increment
within data-hs-input-number
.
Select quantity
Basic usage
Prefer to create your own style? Here is a completely unstylized example.
<div data-hs-input-number>
<input type="text" aria-roledescription="Number field" value="1" data-hs-input-number-input>
<button type="button" class="" tabindex="-1" aria-label="Decrease" data-hs-input-number-decrement>
Minus
</button>
<button type="button" class="" tabindex="-1" aria-label="Increase" data-hs-input-number-increment>
Add
</button>
</div>
Methods
The HSInputNumber
object is contained within the global window
object
Destroy instance.
const { element } = HSInputNumber.getInstance('#input-number', true);
const destroyBtn = document.querySelector('#destroy-btn');
destroyBtn.addEventListener('click', () => {
element.destroy();
});
Events
Open any item event example.
const el = HSInputNumber.getInstance('#input-number');
el.on('change', ({inputValue}) => {...});
Demo examples
Looking for prebuilt UI components based on the Tailwind CSS? Preline UI packs hundreds of component examples for all your website needs.
Check out Preline UI Components