Forms & Inputs
Calendar
A month to pick one day from — a move-in date, a due date, the day a reading was taken. It sits in the page; for a field that opens one on demand, use nana-date-picker.
Days before min or after max cannot be reached at all. Days refused by
isDateDisabled — weekends, public holidays — can still be reached by
keyboard, so a person moving through the month always knows where they are,
but cannot be chosen.
Arrow keys move by day and week, Home and End to the ends of the week, Page Up and Page Down by month (by year with Shift); Enter or Space picks.
Preview
Section titled “Preview”<nana-calendar label="Rent due date" value="2026-03-05"></nana-calendar> Weekdays only.
<script lang="ts">
import { NanaCalendar } from '$lib/components/ui/calendar';
let day = $state('');
const weekend = (iso: string) => [0, 6].includes(new Date(iso).getDay());
</script>
<div class="flex flex-col items-start gap-3">
<NanaCalendar label="Viewing date" bind:value={day} isDateUnavailable={weekend} />
<p class="text-sm text-foreground-muted">{day ? `Viewing on ${day}` : 'Weekdays only.'}</p>
</div> For a form field that opens a calendar on demand, use date picker. For a span of days, use date range.
Installation
Section titled “Installation”npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add calendar --framework web-componentsnpx @nana-tec/ui add calendar --framework svelteLands in src/lib/components/ui/calendar/ as NanaCalendar.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and
each component downloads only the first time a page uses it:
import "@nana-tec/ui-components/autoloader";import "@nana-tec/ui-components/theme";The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.
Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:
import "@nana-tec/ui-components/calendar";
Copied in with npx @nana-tec/ui add calendar? Import your project's own
@/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.
<nana-calendar value="2026-03-15" min="2026-03-01" label="Move-in date"></nana-calendar>const el = document.querySelector("nana-calendar");el.addEventListener("nana-change", (e) => console.log(e.detail));<script lang="ts"> import { NanaCalendar } from '$lib/components/ui/calendar';
let day = $state(''); let start = $state(''); let end = $state('');</script>
<NanaCalendar bind:value={day} min="2026-01-01" /><NanaCalendar mode="range" months={2} bind:start bind:end />Values are ISO dates (2026-03-10). Arrow keys move by day and week, Home and End to
the week’s ends, Page Up and Page Down by month (with Shift, by year). In range mode the
first pick sets one end and the second the other, in either order.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
firstDayOfWeek | first-day-of-week | number | 1 | Which weekday starts the week; 0 is Sunday |
isDateDisabled | — | CalendarDateDisabled | undefined | — | Refuses days by rule, such as weekends; receives yyyy-mm-dd |
label | label | string | '' | Accessible name for the calendar |
locale | locale | — | — | BCP 47 tag for month and weekday names |
max | max | string | '' | Latest day that can be picked, yyyy-mm-dd |
min | min | string | '' | Earliest day that can be picked, yyyy-mm-dd |
size | size | 'sm' | 'md' | 'lg' | 'md' | Cell size |
value | value | string | '' | The picked day, yyyy-mm-dd |
Methods
| Method | Description |
|---|---|
focus(options?: FocusOptions): void | Move focus to the day the keyboard is on |
Events
| Event | Description |
|---|---|
nana-change | A day was picked (detail.value, yyyy-mm-dd) |
CSS parts
| Part | Description |
|---|---|
::part(base) | The calendar |
::part(header) | The month and the arrows |
::part(month-select) | The list to jump to a month |
::part(year-select) | The list to jump to a year |
::part(grid) | The month grid |
::part(day) | A day cell; carries outside, selected, today |
::part(nav-btn) | The nav button |
::part(month-label) | The month label |
::part(weekdays) | The weekdays |
::part(weekday) | The weekday |
::part(week) | The week |
::part(day-num) | The day num |
::part(nav-icon) | The arrow inside a month button |
CSS custom properties
| Property | Description |
|---|---|
--nana-calendar-accent | The selected day's colour |
NanaCalendar
| Prop | Type | Default |
|---|---|---|
mode | CalendarMode | 'single' |
valuebind: | string | '' |
startbind: | string | '' |
endbind: | string | '' |
min | string | |
max | string | |
locale | string | 'en' |
firstDayOfWeek | number | 0 |
months | number | 1 |
label | string | |
isDateUnavailable | (iso: string) => boolean | |
onValueChange | (value: string) => void | |
onRangeChange | (range: CalendarRange) => void |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.