Skip to content
Likable Aurora @likable-hair/svelte 5

DatePicker

Calendar panel to choose a day or, with range, a range of days: the title of the visible month between two arrows, above a Calendar. Clicking the title shows the months of the year, clicking it again the years; choosing a year goes to its months, choosing a month to its days. visibleMonth, visibleYear and view can be bound to follow or drive the navigation. Values are Date objects at local midnight, names come from locale through Intl, min and max limit the days, the months, the years and the arrows, and isDateDisabled the days. With months={2} the day view shows two months side by side, the visible one and the next, with the arrows at the outer sides; the days of the nearby months are hidden there. footerSnippet adds content under the calendar, such as Cancel and Apply buttons. It is a role="group" named by aria-label (the field gives it role="dialog") with the surface of a popup; DatePickerTextField shows it in a menu under a field. Its state is exposed as data-view, data-months and data-disabled for app CSS.

import { DatePicker } from '@likable-hair/svelte';

src/lib/components/simple/dates/DatePicker.svelte ยท Markdown for LLMs

Choose a day

A calendar panel: the arrows change month, the title opens the months and then the years. bind:selectedDate holds the chosen day.

Sun
Mon
Tue
Wed
Thu
Fri
Sat
Sunday, August 30, 2026
Monday, August 31, 2026
Tuesday, September 1, 2026
Wednesday, September 2, 2026
Thursday, September 3, 2026
Friday, September 4, 2026
Saturday, September 5, 2026
Sunday, September 6, 2026
Monday, September 7, 2026
Tuesday, September 8, 2026
Wednesday, September 9, 2026
Thursday, September 10, 2026
Friday, September 11, 2026
Saturday, September 12, 2026
Sunday, September 13, 2026
Monday, September 14, 2026
Tuesday, September 15, 2026
Wednesday, September 16, 2026
Thursday, September 17, 2026
Friday, September 18, 2026
Saturday, September 19, 2026
Sunday, September 20, 2026
Monday, September 21, 2026
Tuesday, September 22, 2026
Wednesday, September 23, 2026
Thursday, September 24, 2026
Friday, September 25, 2026
Saturday, September 26, 2026
Sunday, September 27, 2026
Monday, September 28, 2026
Tuesday, September 29, 2026
Wednesday, September 30, 2026
Thursday, October 1, 2026
Friday, October 2, 2026
Saturday, October 3, 2026
Sunday, October 4, 2026
Monday, October 5, 2026
Tuesday, October 6, 2026
Wednesday, October 7, 2026
Thursday, October 8, 2026
Friday, October 9, 2026
Saturday, October 10, 2026

Thu Sep 24 2026

Code
<script lang="ts">
	import { DatePicker } from '@likable-hair/svelte';

	let selectedDate = $state<Date | undefined>(new Date(2026, 8, 24));
</script>

<div class="example">
	<DatePicker bind:selectedDate aria-label="Appointment day" />
	<p>{selectedDate ? selectedDate.toDateString() : 'No day chosen'}</p>
</div>

<style>
	.example {
		display: grid;
		justify-items: start;
		gap: 12px;
	}

	p {
		margin: 0;
		color: var(--global-color-text-2);
		font-size: 13px;
	}
</style>

Range

With range the first click sets the start and the second the end; hovering previews the range. min and max also disable the arrows, the months and the years outside them.

Sun
Mon
Tue
Wed
Thu
Fri
Sat
Sunday, August 30, 2026
Monday, August 31, 2026
Tuesday, September 1, 2026
Wednesday, September 2, 2026
Thursday, September 3, 2026
Friday, September 4, 2026
Saturday, September 5, 2026
Sunday, September 6, 2026
Monday, September 7, 2026
Tuesday, September 8, 2026
Wednesday, September 9, 2026
Thursday, September 10, 2026
Friday, September 11, 2026
Saturday, September 12, 2026
Sunday, September 13, 2026
Monday, September 14, 2026
Tuesday, September 15, 2026
Wednesday, September 16, 2026
Thursday, September 17, 2026
Friday, September 18, 2026
Saturday, September 19, 2026
Sunday, September 20, 2026
Monday, September 21, 2026
Tuesday, September 22, 2026
Wednesday, September 23, 2026
Thursday, September 24, 2026
Friday, September 25, 2026
Saturday, September 26, 2026
Sunday, September 27, 2026
Monday, September 28, 2026
Tuesday, September 29, 2026
Wednesday, September 30, 2026
Thursday, October 1, 2026
Friday, October 2, 2026
Saturday, October 3, 2026
Sunday, October 4, 2026
Monday, October 5, 2026
Tuesday, October 6, 2026
Wednesday, October 7, 2026
Thursday, October 8, 2026
Friday, October 9, 2026
Saturday, October 10, 2026
Code
<script lang="ts">
	import { DatePicker } from '@likable-hair/svelte';

	let selectedDate = $state<Date | undefined>(new Date(2026, 8, 11));
	let selectedDateTo = $state<Date | undefined>(new Date(2026, 8, 24));
</script>

<DatePicker
	range
	bind:selectedDate
	bind:selectedDateTo
	min={new Date(2026, 0, 1)}
	max={new Date(2027, 11, 31)}
	aria-label="Stay"
/>

Views and locale

view decides what the panel shows and can be bound: here it starts on the months. locale translates names and title and sets the first day of the week.

Gen
Feb
Mar
Apr
Mag
Giu
Lug
Ago
Set
Ott
Nov
Dic

View: month

Code
<script lang="ts">
	import { DatePicker } from '@likable-hair/svelte';

	let view = $state<'day' | 'month' | 'year'>('month');
	let selectedDate = $state<Date | undefined>(new Date(2026, 8, 24));
</script>

<div class="example">
	<DatePicker locale="it" bind:view bind:selectedDate aria-label="Data" />
	<p>View: {view}</p>
</div>

<style>
	.example {
		display: grid;
		justify-items: start;
		gap: 12px;
	}

	p {
		margin: 0;
		color: var(--global-color-text-2);
		font-size: 13px;
	}
</style>

Two months

months={2} shows the visible month and the next side by side, which makes long ranges easier to pick; the arrows move both. footerSnippet adds content under the calendar, here the length of the range.

Sun
Mon
Tue
Wed
Thu
Fri
Sat
Tuesday, September 1, 2026
Wednesday, September 2, 2026
Thursday, September 3, 2026
Friday, September 4, 2026
Saturday, September 5, 2026
Sunday, September 6, 2026
Monday, September 7, 2026
Tuesday, September 8, 2026
Wednesday, September 9, 2026
Thursday, September 10, 2026
Friday, September 11, 2026
Saturday, September 12, 2026
Sunday, September 13, 2026
Monday, September 14, 2026
Tuesday, September 15, 2026
Wednesday, September 16, 2026
Thursday, September 17, 2026
Friday, September 18, 2026
Saturday, September 19, 2026
Sunday, September 20, 2026
Monday, September 21, 2026
Tuesday, September 22, 2026
Wednesday, September 23, 2026
Thursday, September 24, 2026
Friday, September 25, 2026
Saturday, September 26, 2026
Sunday, September 27, 2026
Monday, September 28, 2026
Tuesday, September 29, 2026
Wednesday, September 30, 2026
Sun
Mon
Tue
Wed
Thu
Fri
Sat
Thursday, October 1, 2026
Friday, October 2, 2026
Saturday, October 3, 2026
Sunday, October 4, 2026
Monday, October 5, 2026
Tuesday, October 6, 2026
Wednesday, October 7, 2026
Thursday, October 8, 2026
Friday, October 9, 2026
Saturday, October 10, 2026
Sunday, October 11, 2026
Monday, October 12, 2026
Tuesday, October 13, 2026
Wednesday, October 14, 2026
Thursday, October 15, 2026
Friday, October 16, 2026
Saturday, October 17, 2026
Sunday, October 18, 2026
Monday, October 19, 2026
Tuesday, October 20, 2026
Wednesday, October 21, 2026
Thursday, October 22, 2026
Friday, October 23, 2026
Saturday, October 24, 2026
Sunday, October 25, 2026
Monday, October 26, 2026
Tuesday, October 27, 2026
Wednesday, October 28, 2026
Thursday, October 29, 2026
Friday, October 30, 2026
Saturday, October 31, 2026
Code
<script lang="ts">
	import { DatePicker } from '@likable-hair/svelte';

	let selectedDate = $state<Date | undefined>(new Date(2026, 8, 21));
	let selectedDateTo = $state<Date | undefined>(new Date(2026, 9, 4));

	let nights = $derived(
		selectedDate && selectedDateTo
			? Math.round((selectedDateTo.getTime() - selectedDate.getTime()) / 86_400_000)
			: 0
	);
</script>

<DatePicker range months={2} bind:selectedDate bind:selectedDateTo aria-label="Stay">
	{#snippet footerSnippet()}
		<p class="nights">{nights ? `${nights} nights` : 'Choose the last night'}</p>
	{/snippet}
</DatePicker>

<style>
	.nights {
		margin: 0;
		color: var(--global-color-text-2);
		font-size: 13px;
	}
</style>

Props

NameTypeDefaultDescription
view bindable 'day' | 'month' | 'year'What the panel shows: the days of the visible month, the months of the visible year or the years. Clicking the title goes from days to months to years and back; choosing a year shows its months, choosing a month its days.
months 1 | 21Months shown side by side in the day view: the visible one and, with 2, the next. Choosing a month in the month view shows it first.
class { container?: string; header?: string; title?: string; calendar?: string }{}Extra classes for each part.
datePickerElement bindable HTMLDivElementThe panel element.
locale stringBCP 47 locale of the title, of the names of months and days, of the first day of the week and of the texts of the arrows (it and en are built in, other languages fall back to English). Defaults to the one set with setDefaultLocale, else en.
previousMonthLabel stringAccessible name of the left arrow in the day view. Defaults to "Previous month", in the language of locale.
nextMonthLabel stringAccessible name of the right arrow in the day view. Defaults to "Next month", in the language of locale.
previousYearLabel stringAccessible name of the left arrow in the month view. Defaults to "Previous year", in the language of locale.
nextYearLabel stringAccessible name of the right arrow in the month view. Defaults to "Next year", in the language of locale.

From Calendar

It accepts the props, snippets and events of Calendar, listed in the tables "From Calendar". Except variant, calendarElement.

NameTypeDefaultDescription
selectedDate bindable DateThe chosen day; with range, the first day of the range. Days are local midnights.
selectedDateTo bindable DateWith range, the last day of the range.
range booleanfalseChooses a range of days: the first click sets selectedDate, the second selectedDateTo (they swap when the second day is earlier, and the same day twice is a one-day range), the third starts a new range.
visibleMonth bindable numberVisible month, 0 to 11. Defaults to the month of selectedDate, or the current one; it follows selectedDate when that changes to another month. Bind it to drive or follow the navigation.
visibleYear bindable numberVisible year.
weekStart 0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week, from 0 (Sunday) to 6 (Saturday). Defaults to the one of locale.
min DateEarliest day that can be chosen.
max DateLatest day that can be chosen.
isDateDisabled (date: Date) => booleanReturns true for the days that cannot be chosen (weekends, holidays, ...).
disabled booleanfalseShows the days without letting anyone choose them; the grid leaves the Tab order.
showOutsideDays booleantrueShows the days of the previous and next month that complete the first and last week.
showWeekdays booleantrueShows the row with the names of the days of the week.
weekdayFormat 'narrow' | 'short' | 'long''short'Length of the names of the days of the week. Screen readers always read the full name.
fillOpenRange booleanfalseWith range and only one end chosen, highlights every day after the start (or before the end).
previewDate bindable DateWith range, the day the preview reaches while the range is being chosen: the day under the pointer or with the focus. Bind the same variable on two calendars to share the preview between them.
followSelection booleantrueShows the month of selectedDate or selectedDateTo when they change to a month that is not visible. Turn it off when the parent decides the month, as with two calendars side by side.

It also accepts the native attributes and events of <div> (for example id, title, aria-label, onkeydown), which are forwarded to the element.

Snippets

NameParametersDescription
footerSnippetContent under the calendar, inside the panel, such as Cancel and Apply buttons.
titleSnippet{ title: string; month: number; year: number; view: 'day' | 'month' | 'year' }Replaces the text of the title: the month and year in the day view, the year in the others. The button around it keeps switching view. With two months it is called for each.

From Calendar

NameParametersDescription
daySnippetCalendarDayReplaces the number of a day. It receives a CalendarDay: date, outside, selected, inRange, today, disabled. The cell around it keeps click, keyboard and state, and screen readers keep reading the full date.
dayAppendSnippetCalendarDayContent after the number of a day: events in the grid variant, a mark in the top corner in the compact one.
weekdaySnippet{ label: string; name: string; day: number }Replaces the name of a day of the week. day goes from 0 (Sunday) to 6, name is the full name.

Events

From Calendar

NameTypeDescription
ondayClick(event: { date: Date; outside: boolean; nativeEvent: MouseEvent | KeyboardEvent; }) => voidCalled when a day that can be chosen is clicked or chosen with Enter or Space, after the selection changed. outside is true for the days of the nearby months.
onchange(event: { selectedDate: Date | undefined; selectedDateTo: Date | undefined }) => voidCalled when the user changes the selection.

Methods

Call them on the instance: <DatePicker bind:this={ref} />, then ref.focus().

SignatureDescription
focus()Moves the focus into the grid of the current view: a day, a month or a year.

Types

Exported by the package: import type { CalendarDay } from '@likable-hair/svelte';

CalendarDay

A day of the grid, as the day snippets receive it.

interface CalendarDay

NameTypeDescription
date requiredDateThe day, at local midnight.
outside requiredbooleanThe day belongs to the month before or after the visible one.
selected requiredbooleanThe day is the chosen one, or an end of the chosen range.
inRange requiredbooleanThe day is inside the chosen range, ends excluded.
today requiredbooleanThe day is today.
disabled requiredbooleanThe day cannot be chosen (min, max, isDateDisabled).

CSS variables

For a single instance, pass them as style props: <DatePicker --date-picker-background="tomato">. The --date-picker-default-* defaults apply to the whole app: override them in :root or in a theme.

It also takes the variables of Calendar.

Per-instance variableDefault
--date-picker-gap
--date-picker-default-gap 12px
--date-picker-width
--date-picker-default-width 280px
--date-picker-padding
--date-picker-default-padding 12px
--date-picker-border-width
--date-picker-default-border-width var(--global-border-width)
--date-picker-border-color
--date-picker-default-border-color var(--global-color-border-strong)
--date-picker-border-radius
--date-picker-default-border-radius var(--global-radius-lg)
--date-picker-background
--date-picker-default-background var(--global-color-surface-pop)
--date-picker-box-shadow
--date-picker-default-box-shadow var(--global-shadow-lg)
--date-picker-color
--date-picker-default-color var(--global-color-text)
--date-picker-month-width
--date-picker-default-month-width 254px
--date-picker-months-gap
--date-picker-default-months-gap 24px
--date-picker-title-border-radius
--date-picker-default-title-border-radius var(--global-radius-sm)
--date-picker-title-color
--date-picker-default-title-color var(--global-color-text)
--date-picker-title-font-family
--date-picker-default-title-font-family var(--global-font-family-display)
--date-picker-title-font-size
--date-picker-default-title-font-size 16px
--date-picker-title-font-weight
--date-picker-default-title-font-weight 600
--date-picker-title-letter-spacing
--date-picker-default-title-letter-spacing -0.02em
--date-picker-title-hover-background
--date-picker-default-title-hover-background var(--global-color-surface-2)
--date-picker-focus-ring-color
--date-picker-default-focus-ring-color var(--global-focus-ring-color)