A Simple time picker roll for React or Next app.
npm install react-time-picker-roll
import React, { useState } from 'react';
import { TimePickerComponent } from 'my-time-picker';
export default const MyApp = () => {
// initialTime
const [value, setValue] = useState({ hours: 6, minutes: 0, period: 'AM' });
// onChange
const handleTimeChange = (time: {
hours: number;
minutes: number;
period: string;
}) => {
console.log(time);
setValue(time)
};
return (
<div>
<TimePickerComponent
initialTime={value}
onChange={handleTimeChange} />
<p>Selected Time: {value} </p>
</div>
);
}
Name | Type | Default | Description |
---|---|---|---|
value | String | n/a | Current value. |
name | String | n/a | Input time picker name |
onChange | (value) => alert('New time is:', value) |
n/a | Called when select a different value |
The MIT License.