Skip to main content

Calendar

Calendar renders a full inline calendar for date selection. RangeCalendar extends this to support selecting a date range. Both support min/max date bounds and custom date services for localization.

Import​

import { Calendar, RangeCalendar } from '@ui-kitten/components';

Basic Usage​

Single Date​

import React, { useState } from 'react';
import { Layout, Calendar } from '@ui-kitten/components';

const CalendarExample = () => {
const [date, setDate] = useState(new Date());

return (
<Layout style={{ flex: 1, padding: 16 }}>
<Calendar
date={date}
onSelect={(nextDate) => setDate(nextDate)}
/>
</Layout>
);
};

Date Range​

import React, { useState } from 'react';
import { Layout, RangeCalendar } from '@ui-kitten/components';

const RangeCalendarExample = () => {
const [range, setRange] = useState({});

return (
<Layout style={{ flex: 1, padding: 16 }}>
<RangeCalendar
range={range}
onSelect={(nextRange) => setRange(nextRange)}
/>
</Layout>
);
};

Props​

Calendar​

PropertyTypeDefaultDescription
dateDateundefinedThe currently selected date.
onSelect(date: Date) => void-Called when a date is selected.
minDateundefinedMinimum selectable date. Dates before this are disabled.
maxDateundefinedMaximum selectable date. Dates after this are disabled.
dateServiceDateServiceNativeDateServiceCustom date service for localization and date formatting.
filter(date: Date) => booleanundefinedPredicate to disable specific dates. Return false to disable a date.
renderDay(info, style) => ReactElementundefinedCustom render function for day cells.
initialVisibleDateDateundefinedDate the calendar opens on. Falls back to the selected date, then today.
boundingMonthbooleantrueWhether days of the neighbouring months are rendered in the current month's grid.
startViewCalendarViewModeCalendarViewModes.DATEView the calendar opens in — DATE, MONTH or YEAR.
title(pickerDate, monthYearPickerDate, viewMode) => stringundefinedCustom header title.
renderFooter() => ReactElementundefinedRender function for content below the calendar grid.
renderMonth(info, style) => ReactElementundefinedCustom render function for month cells.
renderYear(info, style) => ReactElementundefinedCustom render function for year cells.
renderArrowLeftComponentType<{ onPress: () => void }> | nullundefinedCustom left navigation arrow. Pass null to hide it.
renderArrowRightComponentType<{ onPress: () => void }> | nullundefinedCustom right navigation arrow. Pass null to hide it.
onVisibleDateChange(date: Date, viewModeId: CalendarViewModeId) => voidundefinedCalled when the visible date or view mode changes.

Calendar also accepts all standard React Native View props.

Calendar exposes an imperative API through a ref typed as CalendarRef:

MethodSignatureDescription
scrollToToday() => voidScrolls the calendar to the current date.
scrollToDate(date: Date) => voidScrolls the calendar to a given date.
getVisibleDate() => DateReturns the currently visible date.
getViewMode() => CalendarViewModeReturns the current view mode.
getPickerDate() => DateReturns the date shown by the month/year picker.

RangeCalendar​

PropertyTypeDefaultDescription
range{ startDate?: Date, endDate?: Date }{}The currently selected date range.
onSelect(range: { startDate: Date, endDate: Date }) => void-Called when a range is selected.
minDateundefinedMinimum selectable date.
maxDateundefinedMaximum selectable date.
dateServiceDateServiceNativeDateServiceCustom date service for localization and date formatting.
filter(date: Date) => booleanundefinedPredicate to disable specific dates.

RangeCalendar accepts the same presentation properties as Calendar — initialVisibleDate, boundingMonth, startView, title, renderDay, renderFooter, renderMonth, renderYear, renderArrowLeft, renderArrowRight and onVisibleDateChange — and exposes scrollToToday(), scrollToDate() and getVisibleDate() through a ref typed as RangeCalendarRef.

Storybook​

Live examples coming soon via Storybook.