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

DateTimePickerTextField

Date and time field: type them or choose them in a panel with a calendar and the columns of hours and minutes. The value is value, a Date with the local date and time (seconds at 0). The text is one mask, the date and then the time: the date format comes from locale (en is MM/dd/yyyy, it dd/MM/yyyy) or from format, the clock from locale (en is 12-hour with AM/PM, it 24-hour) or from hour12, and the whole format is shown as a chip after the text, which hides itself when the field is too narrow for both. Typing accepts digits only and adds the separators, the space and the colon; on a 12-hour clock A and P set AM and PM. A date and time that does not exist, is before min or after max or falls on a day disabled by isDateDisabled (and an unfinished one when the field loses focus) turns the field to the error state with invalidText, and the form refuses to submit it. On desktop, focusing or clicking the field opens a DatePicker and a TimePicker side by side in a menu; Arrow Down moves the focus into the calendar, choosing a day with the keyboard moves it to the hours, Escape closes the panel and Tab leaves it. Choosing a day keeps the time already chosen, or uses 00:00 (moved inside min and max); choosing the minutes (or AM/PM on a 12-hour clock) once there is a day closes the panel (closeOnSelect). On screens up to 1024px wide the calendar button opens the panel in a bottom drawer instead, and the field stays typable (mobileDrawer); in the drawer, and in the menu on screens up to 600px wide, the time is below the calendar. With name the value is submitted as the local yyyy-MM-ddTHH:mm. Its state is exposed as data-state, data-disabled, data-readonly, data-open and data-hour-cycle for app CSS.

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

src/lib/components/composed/forms/DateTimePickerTextField.svelte ยท Markdown for LLMs

Type or choose

Type the digits (the separators, the space and the colon come by themselves) or open the panel: focus the field, then Arrow Down moves into the calendar, choosing a day with Enter moves to the hours and Escape closes it. A day keeps the time already chosen; choosing the minutes closes the panel. On a phone the calendar button opens a bottom drawer instead.

Value: 2026-09-24T09:30

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

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

<div class="example">
	<DateTimePickerTextField label="Appointment" locale="en-GB" bind:value />
	<p>Value: {value ? toISODateTime(value) : 'none'}</p>
</div>

<style>
	.example {
		display: grid;
		gap: 12px;
		width: min(100%, 360px);
	}

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

Locale and clock

With the default en locale the date is MM/dd/yyyy and the clock is 12-hour: type 092420260230p (A and P set AM and PM) or a 24-hour time like 14:30, which becomes 02:30 PM. locale="it" gives dd/MM/yyyy, the 24-hour clock and the Italian texts (the chip reads gg/mm/aaaa hh:mm); format and hour12 force either part, and text props such as openLabel win over the texts of locale.

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

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

<div class="example">
	<DateTimePickerTextField label="Pickup" bind:value />
	<DateTimePickerTextField
		label="Ritiro"
		locale="it"
		openLabel="Scegli quando ritirare"
		bind:value
	/>
	<DateTimePickerTextField label="ISO date, 24-hour clock" format="yyyy-MM-dd" hour12={false} bind:value />
</div>

<style>
	.example {
		display: grid;
		gap: 14px;
		width: min(100%, 360px);
	}
</style>

Limits and step

min and max are instants: they limit the days of the calendar and, on their own day, the hours and minutes, and a typed date and time outside them shows invalidText. Choosing a day moves the time inside the limits. isDateDisabled turns days off and minuteStep sets the minutes of the panel; any minute can still be typed.

From 22/09 08:30 to 09/10 18:00, closed on Sundays
Code
<script lang="ts">
	import { DateTimePickerTextField } from '@likable-hair/svelte';

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

<div class="example">
	<DateTimePickerTextField
		label="Delivery"
		locale="en-GB"
		min={new Date(2026, 8, 22, 8, 30)}
		max={new Date(2026, 9, 9, 18, 0)}
		isDateDisabled={(date) => date.getDay() === 0}
		minuteStep={15}
		hint="From 22/09 08:30 to 09/10 18:00, closed on Sundays"
		bind:value
	/>
</div>

<style>
	.example {
		display: grid;
		gap: 14px;
		width: min(100%, 360px);
	}
</style>

States and forms

With name the value is submitted as the local yyyy-MM-ddTHH:mm (empty without a value), required reaches the input and clearable adds a button that empties it. state and hint show a validation message; disabled and readonly lock the field.

The end must be after the start
Saved

Nothing submitted yet

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

	let submitted = $state('');

	function submit(event: SubmitEvent & { currentTarget: HTMLFormElement }) {
		event.preventDefault();
		submitted = new URLSearchParams(new FormData(event.currentTarget) as never).toString();
	}
</script>

<form onsubmit={submit}>
	<DateTimePickerTextField
		label="Starts"
		name="starts"
		locale="en-GB"
		value={new Date(2026, 8, 24, 9, 0)}
		required
		clearable
	/>
	<DateTimePickerTextField label="Ends" name="ends" locale="en-GB" state="error" hint="The end must be after the start" />
	<DateTimePickerTextField label="Published" locale="en-GB" value={new Date(2026, 8, 1, 8, 0)} state="success" hint="Saved" />
	<DateTimePickerTextField label="Created" locale="en-GB" value={new Date(2026, 7, 31, 17, 45)} disabled />
	<DateTimePickerTextField label="Updated" locale="en-GB" value={new Date(2026, 8, 23, 11, 5)} readonly />
	<Button type="submit">Save event</Button>
	<p>{submitted ? `Submitted: ${submitted}` : 'Nothing submitted yet'}</p>
</form>

<style>
	form {
		display: grid;
		justify-items: start;
		gap: 14px;
		width: min(100%, 360px);
	}

	form > :global(.aurora-date-time-picker-text-field) {
		justify-self: stretch;
	}

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

Mobile drawer

On screens up to 1024px wide (try it in a narrow window) focusing the field does not open anything: the field stays typable, and the calendar button opens the panel in a bottom drawer titled drawerTitle, with the time below the calendar. mobileDrawer={false} keeps the menu, closeOnSelect={false} keeps the panel open after a choice.

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

	let value = $state<Date | undefined>(new Date(2026, 8, 25, 19, 0));
</script>

<div class="example">
	<DateTimePickerTextField label="Dinner" locale="en-GB" drawerTitle="Dinner date and time" bind:value />
	<DateTimePickerTextField
		label="Reminder"
		locale="en-GB"
		closeOnSelect={false}
		mobileDrawer={false}
		value={new Date(2026, 8, 25, 7, 45)}
	/>
</div>

<style>
	.example {
		display: grid;
		gap: 14px;
		width: min(100%, 360px);
	}
</style>

Props

NameTypeDefaultDescription
value bindable DateThe date and time, as a Date in local time with seconds at 0. undefined while the field is empty or its text is not a valid date and time.
open bindable booleanWhether the panel is open. undefined counts as closed.
locale stringBCP 47 locale: the date format, the names in the calendar, the first day of the week, the 12-hour (en) or 24-hour (it) clock, the names of AM and PM and the language of the texts (it and en are built in, other languages fall back to English). Defaults to the one set with setDefaultLocale, else en.
format stringFormat of the date part of the text, with the tokens dd, MM and yyyy and any separator (dd/MM/yyyy, yyyy-MM-dd). Defaults to the one of locale.
hour12 booleanForces the 12-hour clock (true) or the 24-hour clock (false) instead of the one of locale.
minuteStep number5Minutes between two options of the minutes column. Typed minutes can be any.
min DateEarliest date and time that can be chosen or typed, compared as an instant: it limits the days of the calendar and, on its day, the hours and minutes.
max DateLatest date and time that can be chosen or typed, compared as an instant.
isDateDisabled (date: Date) => booleanReturns true for the days that cannot be chosen or typed (weekends, holidays, ...). It receives the day at local midnight.
weekStart 0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week in the calendar, from 0 (Sunday) to 6 (Saturday). Defaults to the one of locale.
weekdayFormat 'narrow' | 'short' | 'long''short'Length of the names of the days of the week in the calendar.
showOutsideDays booleantrueShows in the calendar the days of the previous and next month that complete the first and last week.
label stringVisible label above the field, linked to the input. In the mobile drawer it is the title.
hint stringText below the field. With state it becomes the error or success message.
state 'error' | 'success'Validation state: colors the border and the hint and shows an icon. error also sets aria-invalid. Without it the field still shows the error state for an invalid date and time.
invalidText stringMessage shown below the field, and given to the form, when the typed date and time is not valid. Defaults to "Enter a valid date and time", in the language of locale.
placeholder stringPlaceholder of the input. Without it the format chip tells what to type.
disabled booleanfalseNative disabled: the field and the panel cannot be used.
readonly booleanfalseNative readonly: the date and time are shown and can be selected, but not changed.
required booleanfalseNative required on the input.
id stringid of the input. Generated when missing, so the label always points to it.
name stringName of a hidden input that submits the value as the local yyyy-MM-ddTHH:mm (empty when there is no value).
clearable booleanfalseShows a button that empties the field.
clearLabel stringAccessible name of the clear button. Defaults to "Clear", in the language of locale.
closeOnSelect booleantrueCloses the panel when the minutes (on a 12-hour clock, the minutes or AM/PM) are chosen and there is a day, or when the day is chosen after the time.
placement 'bottom-start' | 'bottom' | 'bottom-end' | 'top-start' | 'top' | 'top-end' | 'left-start' | 'left' | 'left-end' | 'right-start' | 'right' | 'right-end''bottom-start'Side of the field where the panel opens. It flips when there is not enough space.
mobileDrawer booleantrueOn screens up to 1024px wide, opens the panel in a bottom drawer from the calendar button instead of a menu, and focusing the field does not open it.
drawerTitle stringTitle of the mobile drawer. Defaults to label.
closeLabel stringAccessible name of the close button of the mobile drawer. Defaults to "Close", in the language of locale.
openLabel stringAccessible name of the calendar button, and of the panel when there is no label. Defaults to "Choose date and time", in the language of locale.
showFormat booleantrueShows the format as a chip after the text, also read by screen readers. The chip hides itself while the field is too narrow for the whole text and the chip.
formatLabel stringText of the format chip. Defaults to the date format in lowercase, with the letters of the language of locale, and hh:mm (dd/mm/yyyy hh:mm, in Italian gg/mm/aaaa hh:mm), with am on a 12-hour clock (mm/dd/yyyy hh:mm am).
previousMonthLabel stringAccessible name of the calendar's left arrow in the day view (DatePicker). Defaults to "Previous month", in the language of locale.
nextMonthLabel stringAccessible name of the calendar's right arrow in the day view. Defaults to "Next month", in the language of locale.
previousYearLabel stringAccessible name of the calendar's left arrow in the month view. Defaults to "Previous year", in the language of locale.
nextYearLabel stringAccessible name of the calendar's right arrow in the month view. Defaults to "Next year", in the language of locale.
hoursLabel stringAccessible name of the hours column of the panel (TimePicker). Defaults to "Hours", in the language of locale.
minutesLabel stringAccessible name of the minutes column of the panel. Defaults to "Minutes", in the language of locale.
periodLabel stringAccessible name of the AM/PM column of the panel. Defaults to "AM/PM", in the language of locale.
input bindable HTMLInputElementThe input element.
class { container?: string; label?: string; row?: string; field?: string; input?: string; hint?: string; panel?: string; datePicker?: string; timePicker?: string; }{}Extra classes for each part. panel goes on the box around the calendar and the time, datePicker on the DatePicker, timePicker on the TimePicker.

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

Snippets

NameParametersDescription
labelSnippet{ label: string | undefined }Replaces the label content. It stays linked to the input.
hintSnippet{ hint: string | undefined }Replaces the hint below the field.
stateIconSnippet{ state: 'error' | 'success' }Replaces the icon shown for the validation state. Render nothing to hide it.
iconSnippetReplaces the calendar icon. The button around it keeps opening the panel.
prependSnippetContent outside the field, on the left.
appendInnerSnippetContent inside the field, after the format chip and before the clear button.
appendSnippetContent outside the field, on the right.
clearSnippetReplaces the icon of the clear button.
formatSnippet{ format: string }Replaces the content of the format chip. format is the date format and the clock (dd/MM/yyyy hh:mm).
daySnippetCalendarDayReplaces the number of a day in the calendar (see Calendar).
dayAppendSnippetCalendarDayContent after the number of a day in the calendar (see Calendar).
optionSnippet{ value: number | 'am' | 'pm'; label: string; column: 'hours' | 'minutes' | 'period'; selected: boolean; disabled: boolean; }Replaces the text of an option of the time columns (see TimePicker).

Events

NameTypeDescription
onchange(event: { value: Date | undefined }) => voidCalled when the user changes the date and time: in the panel, by typing a whole valid date and time (or making it invalid again) and with the clear button.

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: <DateTimePickerTextField --date-time-picker-text-field-background="tomato">. The --date-time-picker-text-field-default-* defaults apply to the whole app: override them in :root or in a theme.

Per-instance variableDefault
--date-time-picker-text-field-border-color
--date-time-picker-text-field-default-border-color var(--global-input-border-color)
--date-time-picker-text-field-hover-border-color
--date-time-picker-text-field-default-hover-border-color var(--global-input-hover-border-color)
--date-time-picker-text-field-focus-border-color
--date-time-picker-text-field-default-focus-border-color var(--global-input-focus-border-color)
--date-time-picker-text-field-focus-ring-color
--date-time-picker-text-field-default-focus-ring-color var(--global-input-focus-ring-color)
--date-time-picker-text-field-hint-color
--date-time-picker-text-field-default-hint-color var(--global-input-hint-color)
--date-time-picker-text-field-icon-size
--date-time-picker-text-field-default-icon-size 18px
--date-time-picker-text-field-gap
--date-time-picker-text-field-default-gap 6px
--date-time-picker-text-field-width
--date-time-picker-text-field-default-width 100%
--date-time-picker-text-field-max-width
--date-time-picker-text-field-default-max-width none
--date-time-picker-text-field-error-color
--date-time-picker-text-field-default-error-color var(--global-input-error-color)
--date-time-picker-text-field-success-color
--date-time-picker-text-field-default-success-color var(--global-input-success-color)
--date-time-picker-text-field-label-color
--date-time-picker-text-field-default-label-color var(--global-input-label-color)
--date-time-picker-text-field-label-font-size
--date-time-picker-text-field-default-label-font-size var(--global-input-label-font-size)
--date-time-picker-text-field-label-font-weight
--date-time-picker-text-field-default-label-font-weight var(--global-input-label-font-weight)
--date-time-picker-text-field-outer-gap
--date-time-picker-text-field-default-outer-gap 8px
--date-time-picker-text-field-icon-color
--date-time-picker-text-field-default-icon-color var(--global-input-icon-color)
--date-time-picker-text-field-inner-gap
--date-time-picker-text-field-default-inner-gap var(--global-input-gap)
--date-time-picker-text-field-height
--date-time-picker-text-field-default-height var(--global-input-height)
--date-time-picker-text-field-padding
--date-time-picker-text-field-default-padding 0 var(--global-input-padding-x)
--date-time-picker-text-field-background
--date-time-picker-text-field-default-background var(--global-input-background)
--date-time-picker-text-field-border-width
--date-time-picker-text-field-default-border-width var(--global-input-border-width)
--date-time-picker-text-field-border-radius
--date-time-picker-text-field-default-border-radius var(--global-input-radius)
--date-time-picker-text-field-box-shadow
--date-time-picker-text-field-default-box-shadow var(--global-input-shadow)
--date-time-picker-text-field-focus-ring-width
--date-time-picker-text-field-default-focus-ring-width var(--global-focus-ring-width)
--date-time-picker-text-field-color
--date-time-picker-text-field-default-color var(--global-input-color)
--date-time-picker-text-field-font-family
--date-time-picker-text-field-default-font-family var(--global-font-family-mono)
--date-time-picker-text-field-font-size
--date-time-picker-text-field-default-font-size var(--global-input-font-size)
--date-time-picker-text-field-font-weight
--date-time-picker-text-field-default-font-weight 400
--date-time-picker-text-field-placeholder-color
--date-time-picker-text-field-default-placeholder-color var(--global-input-placeholder-color)
--date-time-picker-text-field-format-padding
--date-time-picker-text-field-default-format-padding 2px 6px
--date-time-picker-text-field-format-border-color
--date-time-picker-text-field-default-format-border-color var(--global-color-border)
--date-time-picker-text-field-format-border-radius
--date-time-picker-text-field-default-format-border-radius var(--global-radius-xs)
--date-time-picker-text-field-format-background
--date-time-picker-text-field-default-format-background var(--global-color-surface-2)
--date-time-picker-text-field-format-color
--date-time-picker-text-field-default-format-color var(--global-color-text-3)
--date-time-picker-text-field-format-font-size
--date-time-picker-text-field-default-format-font-size 11px
--date-time-picker-text-field-hint-font-size
--date-time-picker-text-field-default-hint-font-size var(--global-input-hint-font-size)
--date-time-picker-text-field-disabled-background
--date-time-picker-text-field-default-disabled-background var(--global-input-disabled-background)
--date-time-picker-text-field-disabled-opacity
--date-time-picker-text-field-default-disabled-opacity var(--global-input-disabled-opacity)
--date-time-picker-text-field-panel-gap
--date-time-picker-text-field-default-panel-gap 8px
--date-time-picker-text-field-panel-padding
--date-time-picker-text-field-default-panel-padding 4px
--date-time-picker-text-field-divider-color
--date-time-picker-text-field-default-divider-color var(--global-color-border)