react-quantity-input
v1.0.4
Published
A simple, customizable quantity input component for React that allows users to increment/decrement numeric values.
Maintainers
Readme
React Quantity Input
A simple, customizable quantity input component for React that allows users to increment/decrement numeric values.
Features
- Supports increment/decrement actions
- Fully customizable
- Works with both numbers and strings
- Built-in TypeScript support
Installation
npm install react-quantity-input
or
yarn install react-quantity-inputRequirements
react >= 18.3.1react-dom >= 18.3.1
Usage
import React, { useState } from 'react';
import ReactQuantityInput from 'react-quantity-input';
const MyComponent = () => {
const [quantity, setQuantity] = useState(1);
const handleQuantityChange = (newQuantity) => {
setQuantity(newQuantity);
};
return (
<div>
<ReactQuantityInput
value={quantity}
onChange={handleQuantityChange}
min={1}
max={10}
step={1}
placeholder="Enter quantity"
disabled={false}
/>
</div>
);
};
export default MyComponent;
Props
value?- Valuemin?- Minimum allowed valuemax?- Maximum allowed valuestep?- Increment/decrement step valueplaceholder?- Placeholder text for the inputmaxLength?- Max number of characters in the inputdisabled?- Disable the input fieldisInvalid?- Indicates if the input is in an invalid stateonState?- Callback when input is active or clicked
