coss.com Svelte

Calendar

A date picker component with range and multi-select support.

Loading p-calendar-1 preview…

Installation

pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/calendar.json

Usage

<script lang="ts">
  import { Calendar } from "$lib/components/ui/calendar/index.js";
</script>

<Calendar />

API Reference

Calendar is the Svelte calendar implementation used by COSS for Svelte. It preserves the COSS calendar grid, styling, keyboard navigation, locale handling, and single, multiple, and range selection contracts.

Calendar

A calendar component for date selection.

PropTypeDefaultDescription
mode"single" \| "multiple" \| "range""single"Selection mode for the calendar.
captionLayout"label" \| "dropdown" \| "dropdown-months" \| "dropdown-years""label"Caption presentation.
selectedDate \| Date[] \| DateRangeCurrent selection. Supports bind:selected.
onSelect(selected, triggerDate, modifiers, event) => voidRuns after a date selection.
showOutsideDaysbooleantrueShows dates from adjacent months.
startMonthDateFirst navigable month.
endMonthDateLast navigable month.
classNamesCalendarClassNamesAdds classes to calendar parts.
componentsCalendarComponentsSvelte snippets that replace calendar parts.

For the full contract, use the exported CalendarProps type from $lib/components/ui/calendar/index.js.

Customizing Cell Size

The calendar uses CSS custom properties for cell sizing. It uses --spacing(10) on mobile and --spacing(9) on larger screens by default.

<Calendar class="[--cell-size:--spacing(11)] sm:[--cell-size:--spacing(10)]" />

Examples

Single Date Selection

Loading p-calendar-2 preview…

Date Range Selection

Loading p-calendar-3 preview…

Use captionLayout="dropdown" with startMonth and endMonth to enable month and year navigation.

Loading p-calendar-4 preview…

Select Dropdown for Month/Year

Calendar with the COSS Select component for month and year navigation.

Loading p-calendar-5 preview…

Combobox Dropdown for Month/Year

Calendar with a searchable COSS Combobox for month and year navigation.

Loading p-calendar-6 preview…

Changelog

  • July 26, 2026 — The pinned COSS reference upgraded to React DayPicker 10 and moved from react-day-picker to @daypicker/react. This Svelte port preserves the resulting COSS behavior and styling without shipping React.