You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

@wertarbyte/material-ui-currency-textfield

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wertarbyte/material-ui-currency-textfield

Currency textField for React Material UI

1.0.4
latest
Version published
Weekly downloads
3
-80%
Maintainers
0
Weekly downloads
 
Created

CurrencyTextField - React Material UI Component

Overview

CurrencyTextField is a React component built using Material UI's TextField and react-number-format. It provides a text field for currency input, supporting custom formatting options.

Example of currency field

Installation

# npm
npm install @wertarbyte/material-ui-currency-textfield

# yarn
yarn add @wertarbyte/material-ui-currency-textfield

Usage

import * as React from 'react';
import Dinero from 'dinero.js';
import { CurrencyTextField } from '@wertarbyte/material-ui-currency-textfield';

export const MyComponent: React.FC = () => {

  const [value, setValue] = React.useState<Dinero.Dinero>();

  return (
    <CurrencyTextField
        label={'Amount'}
        name={'amount'}
        value={value}
        variant={'outlined'}
        currencySymbol="€"
        currency="EUR"
        precision={2}
        minimumValue={0}
        decimalCharacter=","
        digitGroupSeparator="."
        onChange={(value) => {
            setValue(value);
        }}
    />
  );
};

Documentation

Props

NameTypeDefaultDescription
decimalCharacterstring'.'The character used as the decimal separator.
digitGroupSeparatorstring','The character used as the thousand separator.
currencyDinero.Currency'USD'ISO 4217 CURRENCY CODES as specified in the documentation. Sorted and parsed
currencySymbolstring'$'The symbol used as the currency prefix.
minimumValuestring number'-10000000000000'The minimum allowable value as a string.
maximumValuestring number'10000000000000'The maximum allowable value as a string.
precisionnumber2The number of decimal places to display.
valueDinero.DineroThe current value of the text field. Can be a number or a string.
defaultValueDinero.DineroThe default value of the text field.
onChangefuncCallback function that is called when the value changes. Receives the new value and formatted value as arguments.
onBlurfuncCallback function that is called when the input loses focus. Receives the event and value as arguments.

Development

Testing

The library can be easily testet in dev mode via the provided 'dev' script and App.tsx.

# npm
npm run dev

# yarn
yarn dev

FAQs

Package last updated on 04 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts