A minimal, clean calendar component built with Svelte 5 and Tailwind CSS 4 ā designed as a starting point for your own DatePicker.
$state and $derived@import "tailwindcss"dayjs for date manipulationcalendar.ts# Install dependencies
bun i
# Start dev server
bun run dev
src/
āāā routes/
ā āāā +page.svelte # Calendar UI component
ā āāā calendar.ts # Date generation logic
āāā app.css # Global styles
The core logic lives in calendar.ts:
genMonths(date, count) ā generates surrounding months for the navigation bargenCells(date) ā builds a 2D array of days for the calendar grid, handling overflow from adjacent monthsconst rows = calendar.genCells(currentDate);
// ā [[day1, day2, ...], [day8, day9, ...], ...]