1.1.0 • Published 2 years ago

gedditlocal-react-date-inputs v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

React Date Inputs

Simple and lightweight date inputs for your React app.

View demo

Installation

Install with npm

npm i --save react-date-inputs

or with yarn

yarn add react-date-inputs

Usage

import React, { useState } from 'react';
import ReactDateInputs from 'react-date-inputs';

const MyComponent = () => {
  const [value, setValue] = useState(new Date());

  return <ReactDateInputs value={value} onChange={setValue} />;
};

Props

proptyperequireddefaultdescription
valueDate--
onChange(value: Date): undefined--
onBlur(): undefined--
dayPlaceholderstring-'DD'
monthPlaceholderstring-'MM'
yearPlaceholderstring-'YYYY'
classNamestring--
labelstring--
disabledboolean-false
inputComponentReact.ReactType--Component used for inputs. Must use React.forwardRef for functional components
labelComponentReact.ReactType--Component used for label
inputComponentPropsRecord<string, unknown>-{}Any additional prop to be passed down to custom input component
labelComponentPropsRecord<string, unknown>-{}Any additional prop to be passed down to custom label component
showstring[]-['day', 'month', 'year']Determines which inputs to show
autoTabboolean-falseEnable automatic tab between inputs. If set to true, inputComponent must be wrapped in React.forwardRef()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Main Project

This is a fork of https://github.com/massierc/react-date-inputs with input order allowed to accommodate for US date formats