svelte-calendar Svelte Themes

Svelte Calendar

A minimal, clean calendar component built with Svelte 5 and Tailwind CSS 4 — designed as a starting point for your own DatePicker.

šŸ“… Svelte Calendar

A minimal, clean calendar component built with Svelte 5 and Tailwind CSS 4 — designed as a starting point for your own DatePicker.

✨ Features

  • šŸš€ Svelte 5 Runes — reactive state with $state and $derived
  • šŸŽØ Tailwind CSS 4 — modern utility-first styling with @import "tailwindcss"
  • šŸ“¦ Zero runtime deps — only dayjs for date manipulation
  • 🧩 Composable logic — clean separation of calendar math in calendar.ts
  • šŸ”„ Month navigation — slide through months with prev/next controls

šŸš€ Quick Start

# Install dependencies
bun i

# Start dev server
bun run dev

šŸ“ Structure

src/
ā”œā”€ā”€ routes/
│   ā”œā”€ā”€ +page.svelte    # Calendar UI component
│   └── calendar.ts     # Date generation logic
└── app.css             # Global styles

🧠 How It Works

The core logic lives in calendar.ts:

  • genMonths(date, count) — generates surrounding months for the navigation bar
  • genCells(date) — builds a 2D array of days for the calendar grid, handling overflow from adjacent months
const rows = calendar.genCells(currentDate);
// → [[day1, day2, ...], [day8, day9, ...], ...]

Top categories

Loading Svelte Themes