2.2.2 • Published 9 years ago
yet-another-react-time-picker v2.2.2
yet-another-react-time-picker
Install
npm install --save yet-another-react-time-picker
Basic usage
At a minimum a TimePicker
needs an hour
, minute
, second
and onChange
property.
export default function MyComponent({hour, minute, second, handleChange}) {
return (
<TimePicker
name="myTimePicker"
hour={hour}
minute={minute}
second={second}
onChange={(h, m, s) => handleChange(h, m, s)}
/>
);
}
Hide time fields
You can hide time fields if they are not important to you. This example hides the second
field.
export default function MyComponent(props) {
const showSecond = false;
return <TimePicker {...props} showSecond/>;
}
You can do the same with showHour
and showMinute
.
Set a maximum time
You can specify that the TimePicker
not be allowed to go beyond a given max time using the maxHour
, maxMinute
and maxSecond
properties.
export default function MyComponent(props) {
return (
<div>
<TimePicker {...props} maxHour={22} maxMinute={18} maxSecond={25}/>
</div>
);
}
Props
className
- Optional classes to pass to the underlyinginput
field.name
- Required property that will be used for the underlyinginput
fields. The maininput
field will inherit this name, while the individual time fields will be prepended, ie:mytime-hour
.hour
- Required property for the initial hours.showHour
- Optional boolean that can be set tofalse
if you want to hide the hours field.maxHour
- Optional numeric value for max hours.minute
- Required property for the initial minutes.showMinute
- Optional boolean that can be set tofalse
if you want to hide the minutes field.maxMinute
- Optional numeric value for max minutes.second
- Required property for initial seconds.showSecond
- Optional boolean that can be set tofalse
if you want to hide the seconds field.maxSecond
- Optional numeric value for the max seconds.onChange
- Required function that will accept 3 parameters forhours
,minutes
andseconds
when the time is changed.
Styling
@import "node_modules/yet-another-react-time-picker/dist/styles/timepicker.min.css"
2.2.2
9 years ago
2.0.5
9 years ago
2.2.1
9 years ago
2.2.0
9 years ago
2.1.0
9 years ago
2.0.4
9 years ago
2.0.3
9 years ago
2.0.2
9 years ago
2.0.1
9 years ago
2.0.0
9 years ago
1.1.0
9 years ago
1.0.2
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago
0.0.6
9 years ago
0.0.5
9 years ago
0.0.3
9 years ago
0.0.2
9 years ago
0.0.1
9 years ago