replace-datetime API - v5.0.1
    Preparing search index...

    Interface DatetimeHandle

    Imperative handle exposed by the Datetime component when used with a ref.

    Attach a React ref to the component to access these methods programmatically:

    const ref = useRef<DatetimeHandle>(null);

    // Navigate the calendar to a specific date
    ref.current?.setViewDate(dayjs('2025-06-01'));

    // Switch the active view
    ref.current?.navigate('years');

    // Read internal state
    console.log(ref.current?.state.selectedDate);

    return <Datetime ref={ref} />;
    interface DatetimeHandle {
        navigate: (mode: ViewMode) => void;
        setViewDate: (date: string | Dayjs | Date) => void;
        state: {
            currentView: ViewMode;
            inputValue: string;
            open: boolean;
            selectedDate: Dayjs | undefined;
            viewDate: Dayjs;
        };
    }
    Index

    Properties

    navigate: (mode: ViewMode) => void

    Programmatically switch the active calendar view.

    Type Declaration

    setViewDate: (date: string | Dayjs | Date) => void

    Navigate the calendar to the given date without changing the selected value.

    Type Declaration

      • (date: string | Dayjs | Date): void
      • Parameters

        • date: string | Dayjs | Date

          A dayjs object, native Date, or date string.

        Returns void

    state: {
        currentView: ViewMode;
        inputValue: string;
        open: boolean;
        selectedDate: Dayjs | undefined;
        viewDate: Dayjs;
    }

    Read-only snapshot of the component's current internal state.

    Type Declaration

    • currentView: ViewMode

      The view currently rendered inside the calendar.

    • inputValue: string

      The current raw string value of the text input.

    • open: boolean

      Whether the calendar overlay is currently open.

    • selectedDate: Dayjs | undefined

      The selected date, or undefined if nothing is selected.

    • viewDate: Dayjs

      The date the calendar is currently navigated to.