# jquery.nice-number

> A tiny jQuery plugin for styling HTML number inputs

Latest version **2.1.0** (published 2020-08-27) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install jquery.nice-number
pnpm add jquery.nice-number
yarn add jquery.nice-number
bun add jquery.nice-number
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2020-08-27 |
| First published | 2017-11-19 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 55 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Joshua Smith |
| Maintainers | joshua-s |
| Keywords | jquery, jquery-plugin, html5, input, number, css |

## Links

- npm: https://www.npmjs.com/package/jquery.nice-number
- Repository: https://github.com/joshua-s/jquery.nice-number
- Homepage: https://github.com/joshua-s/jquery.nice-number#readme
- Issues: https://github.com/joshua-s/jquery.nice-number/issues
- npm.io page: https://npm.io/package/jquery.nice-number

## Dependencies (1)

- [jquery](https://npm.io/package/jquery.md) ^3.4.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2020-08-27
- 2.0.1 — 2019-07-19
- 2.0.0 — 2018-02-03
- 1.0.2 — 2017-12-29
- 1.0.1 — 2017-11-19
- 1.0.0 — 2017-11-19

## README

# jQuery Nice Number

A tiny plugin that converts HTML numeric inputs (`type="number"`) into an
easily-styled format.

## Usage

### Prerequisites

Download the project files or install it using Yarn, NPM, etc...

```sh
$ yarn add jquery.nice-number
$ npm install jquery.nice-number --save
```

Include the plugin files in your source.

> Note: the path will need to be changed if you downloaded or moved the files.

```html
<link
	rel="stylesheet"
	href="node_modules/jquery.nice-number/dist/jquery.nice-number.min.css"
/>
<script src="node_modules/jquery.nice-number/dist/jquery.nice-number.min.js"></script>
```

### Basic usage

Call the `niceNumber()` function on your jQuery element of choice.

> Pro Tip: use `$('input[type="number"]')` to select all numeric inputs in the
> current page.

```javascript
$('input[type="number"]').niceNumber();
```

### Advanced usage

You can pass an optional object to `niceNumber()` containing advanced
configuration options.

#### Currently supported options

| Name            | Permitted values                                           | Description                                                                                                             | Default value |
| --------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------- |
| autoSize        | boolean                                                    | Enables or disables automatic input sizing to fit content                                                               | `true`        |
| autoSizeBuffer  | number                                                     | The number of extra character widths that are added to the element's content size calculation when automatically sizing | `1`           |
| buttonDecrement | jQuery element, HTML element, HTML string, or plain string | The contents of the decrement button                                                                                    | `'-'`         |
| buttonIncrement | jQuery element, HTML element, HTML string, or plain string | The contents of the increment button                                                                                    | `'+'`         |
| buttonPosition  | `'around'`, `'left'`, or `'right'`                         | The positions of the control buttons                                                                                    | `'around'`    |
| onDecrement     | false or function                                          | callback function to run on decrement                                                                                   | false         |
| onIncrement     | false or function                                          | callback function to run on increment                                                                                   | false         |

**Callback Examples**

Passed arguments are `$currentInput`: the selected input in a jQuery object, the new amount, and the niceNumber settings.

```js
$('input[type="number"]').niceNumber({
	onIncrement: function ($currentInput, amount, settings) {
		if (amount >= 100) {
			$currentInput.classList.add('more-than-100');
		} else {
			$currentInput.classList.remove('more-than-100');
		}
	},
});
```

## Development

### Building

Install the project dependencies

```sh
$ yarn
```

Build the project

```sh
$ yarn gulp
```

Or individually

```sh
$ yarn gulp css

$ yarn gulp js

$ yarn gulp copy # copies the contents of the src folder to the dist folder
```

If you are developing on the project, you can use

```sh
$ yarn gulp dev # runs default, then copy, css, js on save of any src file
```

---
_Source: https://npm.io/package/jquery.nice-number · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
