Datepicker
The TkDatepicker
component is a versatile and customizable date picker that supports single
date and date range
selection. It offers various display modes, localization, and customizable date formatting.
- React
- Vue
- Angular
import { TkDatepicker } from '@takeoff-ui/react'
import { TkDatepicker } from '@takeoff-ui/vue'
import { TkDatepicker } from '@takeoff-ui/angular'
Basic​
A simple TkDatepicker
is created using default properties, allowing for single date selection.
- React
- Vue
- Angular
const [selectedDate, setSelectedDate] = useState("");
<TkDatepicker
label="Select Date"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
value={selectedDate}
onTkChange={(event) => setSelectedDate(event.detail)}
/>
const selectedDate = ref("");
<TkDatepicker
label="Select Date"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
v-model="selectedDate"
/>
Inline Mode​
Demonstrates how to use the TkDatepicker
in inline mode, where the calendar is always visible.
Selected date: 2023-05-15
- React
- Vue
- Angular
const [selectedDate, setSelectedDate] = useState("2023-05-15");
<TkDatepicker
value={selectedDate}
onTkChange={(event) => setSelectedDate(event.detail)}
inline
/>
const selectedDate = ref("2023-05-15");
<TkDatepicker v-model="selectedDate" inline />
Date Range Selection​
Shows how to enable date range selection using the mode="range"
property.
Selected range: 2024-02-10 - 2024-02-20
- React
- Vue
- Angular
const [dateRange, setDateRange] = useState({
start: "2024-02-10",
end: "2024-02-20",
});
<TkDatepicker
mode="range"
label="Select Date Range"
placeholder="Start date - End date"
value={dateRange}
onTkChange={(event) => setDateRange(event.detail)}
inline
/>
const dateRange = ref({
start: "2024-02-10",
end: "2024-02-20",
});
<TkDatepicker
mode="range"
label="Select Date Range"
placeholder="Start date - End date"
v-model="dateRange"
inline
/>
Custom Date Format​
Illustrates how to customize the date display format using the dateFormat
property.
- React
- Vue
- Angular
<TkDatepicker
label="Custom Format"
placeholder="DD.MM.YYYY"
dateFormat="dd.MM.yyyy"
value={selectedDate}
onTkChange={handleDateChange}
/>
<TkDatepicker
label="Custom Format"
placeholder="DD.MM.YYYY"
dateFormat="dd.MM.yyyy"
v-model="selectedDate"
/>
Allowed and Disabled Dates​
Demonstrates how to restrict or enable specific dates using allowedDates
and disabledDates
properties.
- React
- Vue
- Angular
const [selectedDate1, setSelectedDate1] = useState("");
const [selectedDate2, setSelectedDate2] = useState("");
<TkDatepicker
label="Only specific dates are selectable"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
allowedDates={["10/08/2025", "15/08/2025", "20/08/2025"]}
value={selectedDate1}
onTkChange={(event) => setSelectedDate1(event.detail)}
/>
<TkDatepicker
label="Specific dates are disabled"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
disabledDates={["10/08/2025", "15/08/2025", "20/08/2025"]}
value={selectedDate2}
onTkChange={(event) => setSelectedDate2(event.detail)}
/>
const selectedDate1 = ref("");
const selectedDate2 = ref("");
<TkDatepicker
label="Only specific dates are selectable"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
:allowedDates="['10/08/2025', '15/08/2025', '20/08/2025']"
v-model="selectedDate1"
/>
<TkDatepicker
label="Specific dates are disabled"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
:disabledDates="['10/08/2025', '15/08/2025', '20/08/2025']"
v-model="selectedDate2"
/>
Disabled Week Days​
Demonstrates how to disable specific days of the week using the disabledWeekDays
property.
- React
- Vue
- Angular
const [selectedDate1, setSelectedDate1] = useState('');
const [selectedDate2, setSelectedDate2] = useState('');
// Weekend days (Saturday and Sunday)
const weekendDays = [0, 6]; // 0 is Sunday, 6 is Saturday
// Weekdays (Monday to Friday)
const weekdays = [1, 2, 3, 4, 5]; // 1 is Monday, 5 is Friday
<TkDatepicker
label="Weekends Disabled"
placeholder="Select a weekday"
dateFormat="dd/MM/yyyy"
disabledWeekDays={weekendDays}
value={selectedDate1}
onTkChange={(event) => setSelectedDate1(event.detail)}
/>
<TkDatepicker
label="Only Weekends Allowed"
placeholder="Select a weekend day"
dateFormat="dd/MM/yyyy"
disabledWeekDays={weekdays}
value={selectedDate2}
onTkChange={(event) => setSelectedDate2(event.detail)}
/>
const selectedDate1 = ref('');
const selectedDate2 = ref('');
// Weekend days (Saturday and Sunday)
const weekendDays = [0, 6]; // 0 is Sunday, 6 is Saturday
// Weekdays (Monday to Friday)
const weekdays = [1, 2, 3, 4, 5]; // 1 is Monday, 5 is Friday
<TkDatepicker
label="Weekends Disabled"
placeholder="Select a weekday"
dateFormat="dd/MM/yyyy"
:disabledWeekDays="weekendDays"
v-model="selectedDate1"
/>
<TkDatepicker
label="Only Weekends Allowed"
placeholder="Select a weekend day"
dateFormat="dd/MM/yyyy"
:disabledWeekDays="weekdays"
v-model="selectedDate2"
/>
Localization​
Demonstrates how to set different locales for the TkDatepicker
using the locale
property.
- React
- Vue
- Angular
const [enDate, setEnDate] = useState("");
const [trDate, setTrDate] = useState("");
<TkDatepicker
label="English (US)"
placeholder="Select date"
locale="en-US"
dateFormat="MMM d, yyyy"
value={enDate}
onTkChange={handleEnDateChange}
/>
<TkDatepicker
label="Turkish"
placeholder="Tarih seçin"
locale="tr-TR"
value={trDate}
onTkChange={handleTrDateChange}
/>
const enDate = ref();
const trDate = ref();
<TkDatepicker
label="English (US)"
placeholder="Select date"
locale="en-US"
dateFormat="MMM d, yyyy"
v-model="enDate"
/>
<TkDatepicker
label="Turkish"
placeholder="Tarih seçin"
locale="tr-TR"
v-model="trDate"
/>
First Day Of Week​
Demonstrates how to change firstDayOfWeekIndex
property.
- React
- Vue
- Angular
const [selectedDate, setSelectedDate] = useState("");
<TkDatepicker
label="Default for First Day of Week"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
value={selectedDate}
onTkChange={(event) => setSelectedDate(event.detail)}
/>
<TkDatepicker
label="Thursday for First Day of Week"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
value={selectedDate}
onTkChange={(event) => setSelectedDate(event.detail)}
firstDayOfWeekIndex={3}
/>
<TkDatepicker
label="Default for First Day of Week"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
v-model="selectedDate"
/>
<TkDatepicker
label="Thursday for First Day of Week"
placeholder="Choose a date"
dateFormat="dd/MM/yyyy"
:firstDayOfWeekIndex.prop="3"
v-model="selectedDate"
/>
Header Types​
Illustrates different header styles available via the headerType
property.
- React
- Vue
- Angular
Footer Customization​
Demonstrates how to customize the footer using the footerType
and footerVariant
properties. When the footer is in triple
mode, a Today
button appears alongside the 'Cancel' and 'Continue' buttons.
- React
- Vue
- Angular
import { useRef } from "react";
import { TkDatepicker, TkButton } from "@takeoff-ui/react";
const dp = useRef(null);
const setToday = async () => {
await dp.current.setToday();
};
<TkDatepicker ref={dp} inline>
<div slot="footer-actions" className="flex justify-between w-full">
<TkButton label="Today" type="filled" variant="secondary" onTkClick={setToday} />
<div className="flex gap-2">
<TkButton label="Cancel" type="text" variant="neutral" />
<TkButton label="Submit" />
</div>
</div>
</TkDatepicker>
<script setup>
import { ref } from 'vue';
const dp = ref(null);
const setToday = async () => {
await dp.value.setToday()
};
</script>
<template>
<TkDatepicker ref="dp" inline>
<template #footer-actions>
<div class="flex justify-between w-full">
<TkButton label="Today" type="filled" variant="secondary" @tkClick="setToday" />
<div class="flex gap-2">
<TkButton label="Cancel" type="text" variant="neutral" />
<TkButtonlabel="Submit" />
</div>
</div>
</template>
</TkDatepicker>
</template>
Time Picker Mode​
Demonstrates how to enable date & time selection using the showTimePicker
property for single date.
- React
- Vue
- Angular
const [selectedDateTime, setSelectedDateTime] = useState("");
<TkDatepicker
label="Select Date & Time"
placeholder="YYYY-MM-DD HH:mm"
showTimePicker
value={selectedDateTime}
onTkChange={(event) => setSelectedDateTime(event.detail)}
/>
const selectedDateTime = ref("");
<TkDatepicker
label="Select Date & Time"
placeholder="YYYY-MM-DD HH:mm"
showTimePicker
v-model="selectedDateTime"
/>
Date & Time Range Selection​
Illustrates how to use mode="range"
together with showTimePicker
to select a date range with time.
- React
- Vue
- Angular
const [dateTimeRange, setDateTimeRange] = useState({
start: "2024-02-10 08:00",
end: "2024-02-10 17:30",
});
<TkDatepicker
mode="range"
label="Select Date & Time Range"
placeholder="YYYY-MM-DD HH:mm - YYYY-MM-DD HH:mm"
showTimePicker
value={dateTimeRange}
onTkChange={(event) => setDateTimeRange(event.detail)}
/>
const dateTimeRange = ref({
start: "2024-02-10 08:00",
end: "2024-02-10 17:30",
});
<TkDatepicker
mode="range"
label="Select Date & Time Range"
placeholder="YYYY-MM-DD HH:mm - YYYY-MM-DD HH:mm"
showTimePicker
v-model="dateTimeRange"
/>
API​
Props​
Name | Type | Default | Description |
---|---|---|---|
string[] | [] | Array of dates that are allowed to be selected. All other dates will be disabled. Note: Format should match dateFormat prop | |
boolean | false | Indicates whether the input of datepicker can be cleared | |
string | 'yyyy-MM-dd' | Date format pattern | |
boolean | false | Whether to disable input mask | |
boolean | false | Whether the datepicker is disabled | |
string[] | [] | Array of dates that are disabled for selection. Format should match dateFormat prop | |
number[] | [] | Disabled week days (0-6, where 0 is Sunday and 6 is Saturday) Example: [0,6] will disable Sunday and Saturday | |
string | null | Error message to display | |
number | null | Defines the first day of the week. 0 for Monday, 1 for Tuesday, ..., 6 for Sunday. If not provided, the first day of the week is determined by the locale prop. If neither firstDayOfWeekIndex nor locale provide a value, defaults to Monday (0). Providing this prop overrides the locale setting for the start of the week. | |
"basic", "divided", "light" | 'basic' | The visual variant of the footer: 'basic', 'divided', or 'light'. | |
"basic", "dark", "divided", "light", "primary" | 'basic' | Header visual variant | |
string | null | Hint text to display | |
number | 1 | Hour increment step. | |
IIconOptions, IMultiIconOptions, string | 'calendar_month' | Specifies a material icon name to be displayed. | |
"left", "right" | 'left' | Defines the position of the icon. | |
boolean | false | Whether to display inline panel | |
boolean | false | Whether the datepicker is in an invalid state | |
string | null | Defines the label for the input | |
string | 'en' | Locale for date formatting | |
string | '' | Maximum selectable date | |
string | null | Maximum selectable time (HH:mm format). | |
string | '' | Minimum selectable date | |
string | null | Minimum selectable time (HH:mm format). | |
number | 1 | Minute increment step. | |
"range", "single" | 'single' | The selection mode of the date picker: 'single' for single date selection, 'range' for date range selection. | |
string | null | The name of the control. | |
string | null | Input placeholder text | |
boolean | false | Displays a red asterisk (*) next to the label for visual emphasis. | |
boolean | false | Whether to show the timepicker panel next to the calendar. | |
"base", "large", "small" | 'base' | Defines the size for the label | |
"12", "24" | '24' | Time format: '12' or '24'. | |
IDateSelection, string | null | The value representing the selected date(s) |
Events​
Name | Description |
---|---|
tk-change | Emitted on date selection changes |
tk-input-change | Emitted on input value changes |
Methods​
Name | Description |
---|---|
closePanel | Closes the datepicker panel if it is open. |
setToday | Sets the date to today |
Slots​
Name | Description |
---|---|
footer | Custom footer template. |
footer-actions | Custom actions template to default footer. |
Interfaces​
interface IDateSelection {
start: string;
end?: string;
}