import * as React from 'react'; import { DefaultButton } from 'office-ui-fabric-react/lib/Button'; import { DatePicker, DayOfWeek, defaultDayPickerStrings, IDatePicker } from '@uifabric/date-time'; import './DatePicker.Examples.scss'; export interface IDatePickerInputExampleState { firstDayOfWeek?: DayOfWeek; value?: Date | null; } export class DatePickerInputExample extends React.Component<{}, IDatePickerInputExampleState> { private datePicker = React.createRef(); constructor(props: {}) { super(props); this.state = { firstDayOfWeek: DayOfWeek.Sunday, value: null, }; } public render(): JSX.Element { const { firstDayOfWeek, value } = this.state; const desc = 'This field is required. One of the support input formats is year dash month dash day.'; return (

Text input allowed by default when use keyboard navigation. Mouse click the TextField will popup DatePicker, click the TextField again will dismiss the DatePicker and allow text input.

); } private _onSelectDate = (date: Date | null | undefined): void => { this.setState({ value: date }); }; private _onClick = (): void => { this.datePicker.current?.reset(); this.setState({ value: null }); }; }