1.2.3 ā€¢ Published 1 year ago

react-time-picker-typescript v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm downloads

React ios time picker Typescript

React-ios-time-picker demo

This is a fork of react-ios-time-picker adding typescript support and fixing nextjs implementation!

A modern time picker for your next React app.

  • No moment.js needed
  • Zero dependencies and lightweight
  • Nextjs Friendly
  • Both esm and cjs support

install

npm install react-time-picker-typescript

Usage

24 hours format

24 hours format

import React, { useState } from 'react';
import { TimePicker } from "react-time-picker-typescript";
import "react-time-picker-typescript/dist/style.css";

export default const  MyApp = () => {
   const [value, setValue] = useState('10:00');

   const onChange = (timeValue) => {
      setValue(timeValue);
   }

   return (
      <div>
         <TimePicker onChange={onChange} value={value} />
      </div>
   );
}

12 hours format

12 hours format

import React, { useState } from 'react';
import { TimePicker } from "react-time-picker-typescript";
import "react-time-picker-typescript/dist/style.css";

export default const  MyApp = () => {
   const [value, setValue] = useState('10:00 AM');

   const onChange = (timeValue) => {
      setValue(timeValue);
   }

   return (
      <div>
         <TimePicker onChange={onChange} value={value} use12Hours/>
      </div>
   );
}

API

NameTypeDefaultDescription
valueStringn/aCurrent value.
cellHeightNumber35The height of the cell number.
placeHolderString"Selet_time"Time input's placeholder.
pickerDefaultValueString"00:00"The initial value that the picker begin with in the first time.
disabledBooleanfalseWhether picker is disabled.
isOpenBooleanfalseWhether the time picker should be opened.
requiredBooleanfalseWhether time input should be required.
cancelButtonTextString"Cancel"Cancel button text content
saveButtonTextString"Save"Save button text content
controllersBooleantrueWhether the buttons should be displayed
seperatorBooleantruewhether show the colon seperator
idStringn/aInput time picker id
nameStringn/aInput time picker name
use12HoursBooleanfalse12 hours display mode
inputClassNameStringn/aInput time picker className
popupClassNameStringn/atime picker popup className
onChange(value) => alert ('New time is: ', value)n/aCalled when select a different value
onSave(value) => alert ('Time saved is: ', value)n/aWhen the user clicks on save button
onClose() => alert('Clock closed')n/aWhen the user clicks on cancel button
onAmPmChange(value) => alert('Am/Pm changed : value')n/acalled when select an am/pm value
onOpen() => alert('time picker opened')n/acalled when time picker is opened

Stay in touch

License

The MIT License.