use-date-input - Build Your Own Date Picker
Getting StartedStateThemingCompositionDate FrameworksLocalization
Components
Hooks
AnimatedGroupAnimatedMonthGroupCalendarCalendarProviderClickOutsideExamplePropsDayDayOfWeekHeaderHomeMonthMonthGroupPopperRootWeekWeekHeaderuseCalendarDispatchuseCalendarPropsuseCalendarStateuseDateAPIuseDateInputuseDateRangeInput

ClickOutside

The ClickOutside component is used to detect when the mouse is clicked outside the calendar.

In the default implementation ClickOutside is used to determine when to close the Calendar when rendered inside a Popper. Clicks within the Calender or on the associated inputs should not close the Calendar but everywhere else should.

Example

In this example when you click the buttons they log whether or not it considers it a click outside the rendered tree. In addition an ignored list of refs can be provided which, when clicked, will not invoke onClickOutside.

Props

Prop NameTypeIs RequiredDefault ValueDescription
childrennodeoptionalchildren to monitor for click outside events
ignoreClickOutsideRefsarrayoptionalAdditional array of refs, will ignore click outside from
onClickOutsidefuncoptionalCallback called when the mouse is clicked outside