joswide / react-use-locale-number-input

react-use-locale-number-input is a React hook that formats and parses number inputs based on the provided locale.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node.js CI npm version

react-use-locale-number-input

Description

react-use-locale-number-input is a React hook that formats and parses number inputs based on the provided locale.

Example

import React from "react";
import { useLocaleNumberInput } from "react-use-locale-number-input";

function ControlledInput() {
  const [value, onChange] = React.useState("10000");

  const {
    value: displayValue,
    handleBlur,
    handleChange,
  } = useLocaleNumberInput(value, "de-DE", onChange);

  return (
    <input onBlur={handleBlur} value={displayValue} onChange={handleChange} />
  );
}

Tests

npm run test

Docs

See https://joswide.com for more details

About

react-use-locale-number-input is a React hook that formats and parses number inputs based on the provided locale.

License:GNU General Public License v3.0


Languages

Language:TypeScript 73.4%Language:JavaScript 26.6%