react-keyboard-time-input

2.1.1 • Public • Published

react-keyboard-time-input

Build Status codecov

PeerDependencies Dependencies DevDependencies

Forked from alanclarke/time-input.

A keyboard friendly react component for capturing time.

Only es6 modules (import/export default) import is available. commonjs (require()/module.export) build is published but is not tested.

DEMO HERE

Features

  • small UI surface area (just a form input)
  • keyboard friendly (can type times, use up and down keys to go forwards and backwards in time, can tab between time groups)
  • simple api (infers most options from value, e.g. 24hr time or 12hr, whether to display seconds and milliseconds)
  • easy going UX: ignores invalid input and simply skips over separator if omitted
  • no dependencies
  • 95% test coverage

Installation

yarn add react-keyboard-time-input

or

npm install react-keyboard-time-input

Usage

import ReactDom from 'ReactDom';
import TimeInput from 'react-keyboard-time-input';
 
function render (value) {
  ReactDom.render((
    <TimeInput value={value} onChange={render}/>
  ), document.body)
}
 
render()

Valid formats

/*
 * '12:00'
 * '12:00 AM'
 * '12:00:00'
 * '12:00:00:000 AM'
*/

Run tests

npm test

Package Sidebar

Install

npm i react-keyboard-time-input

Weekly Downloads

1,360

Version

2.1.1

License

MIT

Last publish

Collaborators

  • bamse