A material ui next datepicker, demo on
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo Bugfix May 24, 2018
image Feature May 8, 2018
src Passing through fullWidth to FormControl (#21) Nov 8, 2018
.gitignore Hello World Feb 2, 2018
.npmignore Bugfix Feb 28, 2018
README.md Feature Sep 3, 2018
index.html Feature May 2, 2018
package-lock.json Feature Sep 3, 2018
package.json Feature Sep 3, 2018
tsconfig.json Add source maps inline (#23) Nov 8, 2018
webpack.config.js Feature May 15, 2018

README.md

Material UI Next Pickers

Description

This repository act as a sample of creating a datepicker or timepicker in Material UI Next or it can be imported as a datepicker or timepicker component.

Prerequisite

npm install material-ui-next-pickers --save

Screenshot

Image of Material UI DatePicker Image of Material UI TimePicker

Options

Datepicker

name: string
label?: string
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement>) => void
anchorOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
transformOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
disabled?: boolean
error?: string
dateDisabled?: (date:Date) => boolean
min?: Date
max?: Date
dateFormat?: string | ((date:Date) => string)
fullWidth?: boolean
dialog?: boolean
okToConfirm?: boolean
endIcon?: Node
className?: string
InputLabelProps?: InputLabelProps
InputProps?: InputProps
FormHelperTextProps?: FormHelperTextProps
CalendarProps?: CalendarProps

Calendar

action: (actions:any) => void // only resize event
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement>) => void
closeCalendar: () => void
dateDisabled?: (date:Date) => boolean
min?: Date
max?: Date
okToConfirm?: boolean
classes?: {
  root?: string
  selectedDay?: string
  selectedDayText?: string
  selectedYear?: string
  selectedYearText?: string
}

Timepicker

name: string
label?: string
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>) => void
selectableMinutesInterval?: number
anchorOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
transformOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
disabled?: boolean
error?: string
fullWidth?: boolean
dialog?: boolean
okToConfirm?: boolean
endIcon?: Node
className?: string
InputLabelProps?: InputLabelProps
InputProps?: InputProps
FormHelperTextProps?: FormHelperTextProps
ClockProps?: ClockProps

Clock

action: (actions:any) => void // only resize event
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>) => void
closeClock: () => void
selectableMinutesInterval?: number
okToConfirm?: boolean
classes?: {
  root?: string
  digitalContainer?: string
  clockBackground?: string
  hand?: string
  textSelected?: string
  minuteDotSelected?: string
}

Basic setup

  1. Make sure you installed Material UI Next.
  2. Install this package via npm.
  3. Import this package and use like the following:
import {DateFormatInput, TimeFormatInput} from 'material-ui-next-pickers'

class YourComponent extends React.Component<{}, YourComponentState> {
  onChangeDate = (date:Date) => {
    console.log('Date: ', date)
    this.setState({date})
  } 
  onChangeTime = (time:Date) => {
    console.log('Time: ', time)
    this.setState({time})
  } 
  render() {
    const {date, time} = this.state
    return (
      <div>
        <DateFormatInput name='date-input' value={date} onChange={this.onChangeDate}/>
        <TimeFormatInput name='time-input' value={time} onChange={this.onChangeTime}/>
      </div>
    )
  } 
}
interface YourComponentState {
  date: Date
  time: Date
}