react-time-picker-roll
v0.1.5
Published
A simple time picker component for React
Downloads
27
Maintainers
Keywords
Readme
React time picker roll
A Simple time picker roll for React or Next app.
install
npm install react-time-picker-roll
Usage
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>
);
}
API
| 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 |
License
The MIT License.