1.3.0 • Published 5 years ago

material-ui-time-picker v1.3.0

Weekly downloads
1,876
License
MIT
Repository
github
Last release
5 years ago

material-ui-time-picker

npm Package Build Status Coverage Status

This project provides a time picker for Material-UI.

Demo

Installation

npm i --save material-ui-time-picker

Usage

There are multiple ways to use this component to allow greater flexibility. This is the most basic usage that behaves similar to the Material-UI 0.x time picker:

import TimeInput from 'material-ui-time-picker'

// uncontrolled input
<TimeInput
  mode='12h'
  onChange={(time) => this.handleChange(time)}
/>

// controlled input
<TimeInput
  mode='12h'
  value={this.state.time}
  onChange={(time) => this.handleChange(time)}
/>

For detailed documentation, take a look into the styleguide. The source code, especially the tests, might also be helpful.

TimeInput Properties

NameTypeDefaultDescription
autoOkboolfalseIf true, automatically accept and close the picker on set minutes.
cancelLabelstring'Cancel'Override the label of the cancel button.
ClockPropsobjectProperties to pass down to the Clock component.
defaultValueDateThis default value overrides initialTime and placeholder.
initialTimeDateThe default value for the time picker.
inputComponentelementTypeInputThe component used for the input. Either a string to use a DOM element or a component.
placeholderstringThe placeholder value for the time picker before a time has been selected.
modeenum: '12h' '24h''12h'Sets the clock mode, 12-hour or 24-hour clocks are supported.
okLabelstring'Ok'Override the label of the ok button.
onChangefuncCallback that is called with the new date (as Date instance) when the value is changed.
openOnMountboolIf true, automatically opens the dialog when the component is mounted.
TimePickerPropsobjectProperties to pass down to the TimePicker component.
valueDateThe value of the time picker, for use in controlled mode.

Note: TimeInput behaves like Material-UI's Input component and can be used inside FormControls.

License

The files included in this repository are licensed under the MIT license.