import * as React from 'react'; import { DefaultButton } from '@fluentui/react/lib/Button'; import { DatePicker, IDatePicker, mergeStyleSets } from '@fluentui/react'; const styles = mergeStyleSets({ root: { selectors: { '> *': { marginBottom: 15 } } }, control: { maxWidth: 300, marginBottom: 15 }, }); export const DatePickerInputExample: React.FunctionComponent = () => { const [value, setValue] = React.useState(); const datePickerRef = React.useRef(null); const onClick = React.useCallback((): void => { setValue(undefined); datePickerRef.current?.focus(); }, []); return (
Clicking the input field will open the DatePicker, and clicking the field again will dismiss the DatePicker and allow text input. When using keyboard navigation (tabbing into the field), text input is allowed by default, and pressing Enter will open the DatePicker.
void} className={styles.control} />
); };