DateField

DateField components allow users to select a date using an interactive calendar picker with full keyboard navigation support.

Preview

Dec 2025
Sun
Mon
Tue
Wed
Thu
Fri
Sat

Builder

Variant
Size
Date Constraints
Labels & Messages

The component accepts the following props:

Prop
Type
Default
Title

Description Error

No data

There are no records to display

Keyboard Navigation

The DateField component provides comprehensive keyboard navigation for improved accessibility and user experience:

KeyDescription
Arrow KeysNavigate between days (←/→) and weeks (↑/↓)
EnterSelect the focused day
EscapeClose the calendar picker
PageUpGo to previous month
PageDownGo to next month
HomeGo to first day of the month
EndGo to last day of the month

Features

  • Visual Indicators: Today's date is highlighted with a dot indicator
  • Date Constraints: Set minimum and maximum dates to restrict available selections
  • Keyboard Focus: Visual feedback for keyboard-focused days
  • Clear Function: Easy way to clear the selected date
  • Smart Positioning: Calendar automatically positions itself to stay within viewport
  • Responsive Design: Works seamlessly on desktop and mobile devices

Usage Examples

Basic Usage

<script>
	import { DateField } from 'ui-svelte';
	let date = $state(null);
</script>

<DateField name="birthdate" bind:value={date} />

With Date Constraints

<script>
	import { DateField } from 'ui-svelte';

	let date = $state(null);
	const today = new Date();
	const minDate = new Date(today.getFullYear(), today.getMonth(), 1);
	const maxDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);
</script>

<DateField
	name="appointment"
	label="Fecha de cita"
	minDate={minDate}
	maxDate={maxDate}
	bind:value={date}
/>

With Callback

<script>
	import { DateField } from 'ui-svelte';

	let date = $state(null);

	const handleDateChange = (newDate) => {
		console.log('Selected date:', newDate);
		// Perform additional actions
	};
</script>

<DateField
	name="date"
	label="Selecciona una fecha"
	onchange={handleDateChange}
	bind:value={date}
/>