Skip to content

ComponentsForms & data

SourceSource

Calendar

A month grid for picking one day, with keyboard navigation and optional first and last selectable dates.

Use it to pick a single day when seeing the month helps: scheduling an event, choosing when a timeout ends. For a date the reader already knows, such as a birthday, a text field is faster.

Dates go in and out as YYYY-MM-DD strings. They sort as text, survive JSON, and carry no time zone, so the day the reader picked is the day you store.

Root class newt-calendar
"use client"

import * as React from "react"

import { Calendar } from "@/registry/bases/newt/ui/calendar"

export default function CalendarDemo() {
  const [date, setDate] = React.useState("2026-11-14")

  return (
    <div className="flex flex-col items-center gap-3">
      <Calendar
        aria-label="Event date"
        value={date}
        onValueChange={setDate}
        min="2026-11-03"
      />
      <p className="m-0 text-xs text-newt-text-muted" aria-live="polite">
        Event on <span className="font-mono">{date}</span>
      </p>
    </div>
  )
}
<script setup lang="ts">
import { ref } from "vue"
import { Calendar } from "~~/registry/bases/newt/ui/calendar"

const date = ref("2026-11-14")
</script>

<template>
  <div class="flex flex-col items-center gap-3">
    <Calendar v-model="date" aria-label="Event date" min="2026-11-03" />
    <p class="m-0 text-xs text-newt-text-muted" aria-live="polite">
      Event on <span class="font-mono">{{ date }}</span>
    </p>
  </div>
</template>

Installation

npx newtui@latest add calendarnpx shadcn@latest add @newtui/calendarnpx shadcn-vue@latest add @newtui/calendarpnpm dlx newtui@latest add calendarpnpm dlx shadcn@latest add @newtui/calendarpnpm dlx shadcn-vue@latest add @newtui/calendaryarn dlx newtui@latest add calendaryarn dlx shadcn@latest add @newtui/calendaryarn dlx shadcn-vue@latest add @newtui/calendarbunx newtui@latest add calendarbunx shadcn@latest add @newtui/calendarbunx shadcn-vue@latest add @newtui/calendardeno run -A npm:newtui@latest add calendardeno run -A npm:shadcn@latest add @newtui/calendardeno run -A npm:shadcn-vue@latest add @newtui/calendarvlx newtui@latest add calendarvlx shadcn@latest add @newtui/calendarvlx shadcn-vue@latest add @newtui/calendarvp dlx newtui@latest add calendarvp dlx shadcn@latest add @newtui/calendarvp dlx shadcn-vue@latest add @newtui/calendarnubx newtui@latest add calendarnubx shadcn@latest add @newtui/calendarnubx shadcn-vue@latest add @newtui/calendarnlx newtui@latest add calendarnlx shadcn@latest add @newtui/calendarnlx shadcn-vue@latest add @newtui/calendarupx newtui@latest add calendarupx shadcn@latest add @newtui/calendarupx shadcn-vue@latest add @newtui/calendar

The shadcn CLI needs the @newtui registry in your components.json. Set it up.

Copy the source into your project

"use client"

import * as React from "react"

import { cn } from "@/lib/utils"

export interface CalendarProps extends Omit<
  React.ComponentProps<"div">,
  "onChange" | "defaultValue"
> {
  /** The chosen day as `YYYY-MM-DD`. Leave undefined to let the calendar own it. */
  value?: string
  defaultValue?: string
  onValueChange?: (value: string) => void
  /** The first and last day that can be chosen, as `YYYY-MM-DD`. */
  min?: string
  max?: string
  /** A BCP 47 tag for the month and weekday names. */
  locale?: string
  /** `0` starts the week on Sunday, `1` on Monday. */
  weekStartsOn?: 0 | 1
  /** Accessible names of the two month buttons. */
  previousLabel?: string
  nextLabel?: string
}

/*
 * Dates are `YYYY-MM-DD` strings and all arithmetic is in UTC, so a day never
 * shifts with the reader's time zone and two dates compare as text.
 */
const DAY = 86_400_000
const pad = (value: number) => String(value).padStart(2, "0")
const toIso = (date: Date) =>
  `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`
const fromIso = (iso: string) => new Date(`${iso}T00:00:00Z`)

/** The same day of the month `amount` months away, or that month's last day. */
function shiftMonth(iso: string, amount: number): string {
  const from = fromIso(iso)
  const target = new Date(
    Date.UTC(from.getUTCFullYear(), from.getUTCMonth() + amount, 1)
  )
  const last = new Date(
    Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)
  ).getUTCDate()
  target.setUTCDate(Math.min(from.getUTCDate(), last))
  return toIso(target)
}

function localToday(): string {
  const now = new Date()
  return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
}

/* 4 January 1970 was a Sunday, which makes it day zero of a week of names. */
const SUNDAY = Date.UTC(1970, 0, 4)

const navClassName =
  "inline-flex h-7 w-7 items-center justify-center rounded-[var(--newt-radius-sm)] text-newt-text-muted hover:bg-newt-bg-hover hover:text-newt-text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-newt-text-link"

/*
 * One month as a grid of days. The days are real buttons inside a table with
 * `role="grid"`, so a screen reader announces the weekday column as it moves,
 * and only one day at a time is a tab stop: the arrow keys do the rest, and
 * moving off the edge of the month turns the page. Today is marked by an
 * outline and the chosen day by a fill.
 */
const Calendar = React.forwardRef<HTMLDivElement | null, CalendarProps>(
  (
    {
      className,
      value,
      defaultValue,
      onValueChange,
      min,
      max,
      locale = "en-US",
      weekStartsOn = 0,
      previousLabel = "Previous month",
      nextLabel = "Next month",
      ...props
    },
    ref
  ) => {
    const root = React.useRef<HTMLDivElement | null>(null)
    React.useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(
      ref,
      () => root.current
    )
    const [internal, setInternal] = React.useState(defaultValue)
    const selected = value ?? internal
    /*
     * "Today" is the reader's, so it is only known in the browser. Until
     * then a calendar with no value has no month to show and draws none.
     */
    const [today, setToday] = React.useState<string | undefined>(undefined)
    const [cursor, setCursor] = React.useState(selected)
    const moveFocus = React.useRef(false)

    /* A controlled value changed from outside turns the page to it. */
    const [seenValue, setSeenValue] = React.useState(value)
    if (value !== seenValue) {
      setSeenValue(value)
      if (value !== undefined) setCursor(value)
    }

    /* The nearest day that can be chosen; a month jump lands on it too. */
    const clamp = (iso: string) =>
      min !== undefined && iso < min
        ? min
        : max !== undefined && iso > max
          ? max
          : iso

    /*
     * The one tab stop. It is clamped because a disabled day cannot take
     * focus: with today or the value outside the range, the grid would
     * otherwise have no way in from the keyboard.
     */
    /* An empty string is how a form says "no date yet"; it is not a day. */
    const anchorDay = cursor === "" ? today : (cursor ?? today)
    const focused = anchorDay === undefined ? undefined : clamp(anchorDay)

    React.useEffect(() => setToday(localToday()), [])

    React.useEffect(() => {
      if (!moveFocus.current || focused === undefined) return
      moveFocus.current = false
      root.current
        ?.querySelector<HTMLElement>(`[data-date="${focused}"]`)
        ?.focus()
    }, [focused])

    const allowed = (iso: string) =>
      (min === undefined || iso >= min) && (max === undefined || iso <= max)

    const goTo = (iso: string, withFocus: boolean) => {
      moveFocus.current = withFocus
      setCursor(iso)
    }

    const weekdays = Array.from({ length: 7 }, (_, index) => {
      const date = new Date(SUNDAY + (index + weekStartsOn) * DAY)
      const name = (weekday: "long" | "short") =>
        new Intl.DateTimeFormat(locale, { weekday, timeZone: "UTC" }).format(
          date
        )
      return { long: name("long"), short: name("short").slice(0, 2) }
    })

    const anchor = focused === undefined ? undefined : fromIso(focused)
    const title =
      anchor === undefined
        ? ""
        : new Intl.DateTimeFormat(locale, {
            month: "long",
            year: "numeric",
            timeZone: "UTC",
          }).format(anchor)

    const weeks: (string | undefined)[][] = []
    if (anchor !== undefined) {
      const year = anchor.getUTCFullYear()
      const month = anchor.getUTCMonth()
      const lead =
        (new Date(Date.UTC(year, month, 1)).getUTCDay() - weekStartsOn + 7) % 7
      const days = new Date(Date.UTC(year, month + 1, 0)).getUTCDate()
      for (let slot = 0; slot < lead + days; slot += 1) {
        if (slot % 7 === 0) weeks.push([])
        weeks
          .at(-1)
          ?.push(
            slot < lead
              ? undefined
              : toIso(new Date(Date.UTC(year, month, slot - lead + 1)))
          )
      }
    }

    const onKeyDown = (
      event: React.KeyboardEvent<HTMLButtonElement>,
      iso: string
    ) => {
      const forward =
        getComputedStyle(event.currentTarget).direction === "rtl" ? -1 : 1
      const at = fromIso(iso)
      const column = (at.getUTCDay() - weekStartsOn + 7) % 7
      let next: string
      switch (event.key) {
        case "ArrowLeft":
          next = toIso(new Date(at.getTime() - forward * DAY))
          break
        case "ArrowRight":
          next = toIso(new Date(at.getTime() + forward * DAY))
          break
        case "ArrowUp":
          next = toIso(new Date(at.getTime() - 7 * DAY))
          break
        case "ArrowDown":
          next = toIso(new Date(at.getTime() + 7 * DAY))
          break
        case "Home":
          next = toIso(new Date(at.getTime() - column * DAY))
          break
        case "End":
          next = toIso(new Date(at.getTime() + (6 - column) * DAY))
          break
        case "PageUp":
          next = clamp(shiftMonth(iso, -1))
          break
        case "PageDown":
          next = clamp(shiftMonth(iso, 1))
          break
        default:
          return
      }
      event.preventDefault()
      if (allowed(next)) goTo(next, true)
    }

    return (
      <div
        ref={root}
        className={cn(
          "inline-flex flex-col gap-2 rounded-[var(--newt-radius-md)] border border-newt-border bg-newt-bg-surface p-3 text-newt-text-primary",
          className
        )}
        {...props}
      >
        <div className="flex items-center justify-between gap-2">
          <button
            type="button"
            aria-label={previousLabel}
            disabled={focused === undefined}
            onClick={() => {
              if (focused !== undefined) goTo(shiftMonth(focused, -1), false)
            }}
            className={navClassName}
          >
            <svg
              viewBox="0 0 16 16"
              aria-hidden="true"
              className="h-3.5 w-3.5 -scale-x-100 rtl:scale-x-100"
            >
              <path
                fill="currentColor"
                d="M5.3 3.3a1 1 0 0 1 1.4 0l4 4a1 1 0 0 1 0 1.4l-4 4a1 1 0 0 1-1.4-1.4L8.6 8 5.3 4.7a1 1 0 0 1 0-1.4Z"
              />
            </svg>
          </button>
          <div aria-live="polite" className="text-sm font-semibold leading-5">
            {title}
          </div>
          <button
            type="button"
            aria-label={nextLabel}
            disabled={focused === undefined}
            onClick={() => {
              if (focused !== undefined) goTo(shiftMonth(focused, 1), false)
            }}
            className={navClassName}
          >
            <svg
              viewBox="0 0 16 16"
              aria-hidden="true"
              className="h-3.5 w-3.5 rtl:-scale-x-100"
            >
              <path
                fill="currentColor"
                d="M5.3 3.3a1 1 0 0 1 1.4 0l4 4a1 1 0 0 1 0 1.4l-4 4a1 1 0 0 1-1.4-1.4L8.6 8 5.3 4.7a1 1 0 0 1 0-1.4Z"
              />
            </svg>
          </button>
        </div>
        <table role="grid" aria-label={title} className="border-collapse">
          <thead>
            <tr>
              {weekdays.map((weekday) => (
                <th
                  key={weekday.long}
                  scope="col"
                  abbr={weekday.long}
                  className="h-7 w-9 p-0 text-center text-[11px] font-bold uppercase text-newt-text-muted"
                >
                  {weekday.short}
                </th>
              ))}
            </tr>
          </thead>
          <tbody>
            {weeks.map((week) => (
              <tr key={week.find((iso) => iso !== undefined)}>
                {week.map((iso, column) =>
                  iso === undefined ? (
                    <td key={`blank-${column}`} className="p-px" />
                  ) : (
                    <td
                      key={iso}
                      role="gridcell"
                      aria-selected={iso === selected}
                      className="p-px"
                    >
                      <button
                        type="button"
                        data-date={iso}
                        tabIndex={iso === focused ? 0 : -1}
                        disabled={!allowed(iso)}
                        aria-current={iso === today ? "date" : undefined}
                        onClick={() => {
                          if (value === undefined) setInternal(iso)
                          onValueChange?.(iso)
                          goTo(iso, true)
                        }}
                        onKeyDown={(event) => onKeyDown(event, iso)}
                        className={cn(
                          "flex h-[34px] w-[34px] items-center justify-center rounded-[var(--newt-radius-sm)] p-0 font-[family-name:var(--newt-font-sans)] text-[13px] tabular-nums focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-newt-text-link disabled:cursor-not-allowed disabled:opacity-35",
                          iso === selected
                            ? "bg-newt-brand font-bold text-newt-on-accent"
                            : "text-newt-text-secondary enabled:hover:bg-newt-bg-hover enabled:hover:text-newt-text-primary",
                          iso === today &&
                            iso !== selected &&
                            "text-newt-text-primary shadow-[inset_0_0_0_1px_var(--newt-text-muted)]"
                        )}
                      >
                        {Number(iso.slice(8))}
                      </button>
                    </td>
                  )
                )}
              </tr>
            ))}
          </tbody>
        </table>
      </div>
    )
  }
)
Calendar.displayName = "Calendar"

export { Calendar }
<script setup lang="ts">
import {
  computed,
  nextTick,
  onMounted,
  ref,
  watch,
  type HTMLAttributes,
} from "vue"

import { cn } from "@/lib/utils"

/*
 * One month as a grid of days. The days are real buttons inside a table with
 * `role="grid"`, so a screen reader announces the weekday column as it moves,
 * and only one day at a time is a tab stop: the arrow keys do the rest, and
 * moving off the edge of the month turns the page. Today is marked by an
 * outline and the chosen day by a fill.
 */
const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /** The first and last day that can be chosen, as `YYYY-MM-DD`. */
    min?: string
    max?: string
    /** A BCP 47 tag for the month and weekday names. */
    locale?: string
    /** `0` starts the week on Sunday, `1` on Monday. */
    weekStartsOn?: 0 | 1
    /** Accessible names of the two month buttons. */
    previousLabel?: string
    nextLabel?: string
  }>(),
  {
    locale: "en-US",
    weekStartsOn: 0,
    previousLabel: "Previous month",
    nextLabel: "Next month",
  }
)

/** The chosen day as `YYYY-MM-DD`. */
const selected = defineModel<string>()

/*
 * Dates are `YYYY-MM-DD` strings and all arithmetic is in UTC, so a day never
 * shifts with the reader's time zone and two dates compare as text.
 */
const DAY = 86_400_000
const pad = (value: number) => String(value).padStart(2, "0")
const toIso = (date: Date) =>
  `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`
const fromIso = (iso: string) => new Date(`${iso}T00:00:00Z`)

/** The same day of the month `amount` months away, or that month's last day. */
function shiftMonth(iso: string, amount: number): string {
  const from = fromIso(iso)
  const target = new Date(
    Date.UTC(from.getUTCFullYear(), from.getUTCMonth() + amount, 1)
  )
  const last = new Date(
    Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)
  ).getUTCDate()
  target.setUTCDate(Math.min(from.getUTCDate(), last))
  return toIso(target)
}

/* 4 January 1970 was a Sunday, which makes it day zero of a week of names. */
const SUNDAY = Date.UTC(1970, 0, 4)

const root = ref<HTMLDivElement | null>(null)
/*
 * "Today" is the reader's, so it is only known in the browser. Until then a
 * calendar with no value has no month to show and draws none.
 */
const today = ref<string | undefined>(undefined)
const cursor = ref(selected.value)

/* A value changed from outside turns the page to it. */
watch(selected, (next) => {
  if (next !== undefined) cursor.value = next
})

/* The nearest day that can be chosen; a month jump lands on it too. */
function clamp(iso: string): string {
  if (props.min !== undefined && iso < props.min) return props.min
  if (props.max !== undefined && iso > props.max) return props.max
  return iso
}

/*
 * The one tab stop. It is clamped because a disabled day cannot take focus:
 * with today or the value outside the range, the grid would otherwise have no
 * way in from the keyboard.
 */
const focused = computed(() => {
  /* An empty string is how a form says "no date yet"; it is not a day. */
  const anchorDay =
    cursor.value === "" ? today.value : (cursor.value ?? today.value)
  return anchorDay === undefined ? undefined : clamp(anchorDay)
})

onMounted(() => {
  const now = new Date()
  today.value = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
})

function allowed(iso: string): boolean {
  return (
    (props.min === undefined || iso >= props.min) &&
    (props.max === undefined || iso <= props.max)
  )
}

async function goTo(iso: string, withFocus: boolean) {
  cursor.value = iso
  if (!withFocus) return
  await nextTick()
  root.value?.querySelector<HTMLElement>(`[data-date="${iso}"]`)?.focus()
}

function shift(amount: number) {
  if (focused.value !== undefined) {
    void goTo(shiftMonth(focused.value, amount), false)
  }
}

function choose(iso: string) {
  selected.value = iso
  void goTo(iso, true)
}

const weekdays = computed(() =>
  Array.from({ length: 7 }, (_, index) => {
    const date = new Date(SUNDAY + (index + props.weekStartsOn) * DAY)
    const name = (weekday: "long" | "short") =>
      new Intl.DateTimeFormat(props.locale, {
        weekday,
        timeZone: "UTC",
      }).format(date)
    return { long: name("long"), short: name("short").slice(0, 2) }
  })
)

const title = computed(() =>
  focused.value === undefined
    ? ""
    : new Intl.DateTimeFormat(props.locale, {
        month: "long",
        year: "numeric",
        timeZone: "UTC",
      }).format(fromIso(focused.value))
)

const weeks = computed(() => {
  const result: (string | undefined)[][] = []
  if (focused.value === undefined) return result
  const anchor = fromIso(focused.value)
  const year = anchor.getUTCFullYear()
  const month = anchor.getUTCMonth()
  const lead =
    (new Date(Date.UTC(year, month, 1)).getUTCDay() - props.weekStartsOn + 7) %
    7
  const days = new Date(Date.UTC(year, month + 1, 0)).getUTCDate()
  for (let slot = 0; slot < lead + days; slot += 1) {
    if (slot % 7 === 0) result.push([])
    result
      .at(-1)
      ?.push(
        slot < lead
          ? undefined
          : toIso(new Date(Date.UTC(year, month, slot - lead + 1)))
      )
  }
  return result
})

function onKeydown(event: KeyboardEvent, iso: string) {
  if (!(event.currentTarget instanceof HTMLElement)) return
  const forward =
    getComputedStyle(event.currentTarget).direction === "rtl" ? -1 : 1
  const at = fromIso(iso)
  const column = (at.getUTCDay() - props.weekStartsOn + 7) % 7
  let next: string
  switch (event.key) {
    case "ArrowLeft":
      next = toIso(new Date(at.getTime() - forward * DAY))
      break
    case "ArrowRight":
      next = toIso(new Date(at.getTime() + forward * DAY))
      break
    case "ArrowUp":
      next = toIso(new Date(at.getTime() - 7 * DAY))
      break
    case "ArrowDown":
      next = toIso(new Date(at.getTime() + 7 * DAY))
      break
    case "Home":
      next = toIso(new Date(at.getTime() - column * DAY))
      break
    case "End":
      next = toIso(new Date(at.getTime() + (6 - column) * DAY))
      break
    case "PageUp":
      next = clamp(shiftMonth(iso, -1))
      break
    case "PageDown":
      next = clamp(shiftMonth(iso, 1))
      break
    default:
      return
  }
  event.preventDefault()
  if (allowed(next)) void goTo(next, true)
}

const navClassName =
  "inline-flex h-7 w-7 items-center justify-center rounded-[var(--newt-radius-sm)] text-newt-text-muted hover:bg-newt-bg-hover hover:text-newt-text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-newt-text-link"
</script>

<template>
  <div
    ref="root"
    :class="
      cn(
        'inline-flex flex-col gap-2 rounded-[var(--newt-radius-md)] border border-newt-border bg-newt-bg-surface p-3 text-newt-text-primary',
        props.class
      )
    "
  >
    <div class="flex items-center justify-between gap-2">
      <button
        type="button"
        :aria-label="props.previousLabel"
        :disabled="focused === undefined"
        :class="navClassName"
        @click="shift(-1)"
      >
        <svg
          viewBox="0 0 16 16"
          aria-hidden="true"
          class="h-3.5 w-3.5 -scale-x-100 rtl:scale-x-100"
        >
          <path
            fill="currentColor"
            d="M5.3 3.3a1 1 0 0 1 1.4 0l4 4a1 1 0 0 1 0 1.4l-4 4a1 1 0 0 1-1.4-1.4L8.6 8 5.3 4.7a1 1 0 0 1 0-1.4Z"
          />
        </svg>
      </button>
      <div aria-live="polite" class="text-sm font-semibold leading-5">
        {{ title }}
      </div>
      <button
        type="button"
        :aria-label="props.nextLabel"
        :disabled="focused === undefined"
        :class="navClassName"
        @click="shift(1)"
      >
        <svg
          viewBox="0 0 16 16"
          aria-hidden="true"
          class="h-3.5 w-3.5 rtl:-scale-x-100"
        >
          <path
            fill="currentColor"
            d="M5.3 3.3a1 1 0 0 1 1.4 0l4 4a1 1 0 0 1 0 1.4l-4 4a1 1 0 0 1-1.4-1.4L8.6 8 5.3 4.7a1 1 0 0 1 0-1.4Z"
          />
        </svg>
      </button>
    </div>
    <table role="grid" :aria-label="title" class="border-collapse">
      <thead>
        <tr>
          <th
            v-for="weekday in weekdays"
            :key="weekday.long"
            scope="col"
            :abbr="weekday.long"
            class="h-7 w-9 p-0 text-center text-[11px] font-bold uppercase text-newt-text-muted"
          >
            {{ weekday.short }}
          </th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(week, row) in weeks" :key="row">
          <template
            v-for="(iso, column) in week"
            :key="iso ?? `blank-${column}`"
          >
            <td v-if="iso === undefined" class="p-px" />
            <td
              v-else
              role="gridcell"
              :aria-selected="iso === selected"
              class="p-px"
            >
              <button
                type="button"
                :data-date="iso"
                :tabindex="iso === focused ? 0 : -1"
                :disabled="!allowed(iso)"
                :aria-current="iso === today ? 'date' : undefined"
                :class="
                  cn(
                    'flex h-[34px] w-[34px] items-center justify-center rounded-[var(--newt-radius-sm)] p-0 font-[family-name:var(--newt-font-sans)] text-[13px] tabular-nums focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-newt-text-link disabled:cursor-not-allowed disabled:opacity-35',
                    iso === selected
                      ? 'bg-newt-brand font-bold text-newt-on-accent'
                      : 'text-newt-text-secondary enabled:hover:bg-newt-bg-hover enabled:hover:text-newt-text-primary',
                    iso === today &&
                      iso !== selected &&
                      'text-newt-text-primary shadow-[inset_0_0_0_1px_var(--newt-text-muted)]'
                  )
                "
                @click="choose(iso)"
                @keydown="onKeydown($event, iso)"
              >
                {{ Number(iso.slice(8)) }}
              </button>
            </td>
          </template>
        </tr>
      </tbody>
    </table>
  </div>
</template>
export { default as Calendar } from "./Calendar.vue"

Update the import paths

The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Calendar to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Calendar to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

Usage

import { Calendar } from "@/components/ui/calendar"

export function Example() {
  return <Calendar />
}
<script setup lang="ts">
import { Calendar } from "@/components/ui/calendar"
</script>

<template>
  <Calendar />
</template>

Examples

Date range

Set both min and max to limit the choice to a window. Days outside it are disabled, and the keyboard never lands on them.

Root class newt-calendar
"use client"

import * as React from "react"

import { Calendar } from "@/registry/bases/newt/ui/calendar"

/* `min` and `max` together: only the two weeks of sign-up can be chosen. */
export default function CalendarRangeDemo() {
  const [date, setDate] = React.useState("2026-11-12")

  return (
    <Calendar
      aria-label="Sign-up date"
      value={date}
      onValueChange={setDate}
      min="2026-11-09"
      max="2026-11-22"
    />
  )
}
<script setup lang="ts">
import { ref } from "vue"
import { Calendar } from "~~/registry/bases/newt/ui/calendar"

/* `min` and `max` together: only the two weeks of sign-up can be chosen. */
const date = ref("2026-11-12")
</script>

<template>
  <Calendar
    v-model="date"
    aria-label="Sign-up date"
    min="2026-11-09"
    max="2026-11-22"
  />
</template>

Locale and week start

locale translates the month and weekday names. The first day of the week and the labels of the two month buttons are separate props: set weekStartsOn, previousLabel and nextLabel to match.

Root class newt-calendar
"use client"

import * as React from "react"

import { Calendar } from "@/registry/bases/newt/ui/calendar"

/*
 * `locale` names the month and the weekdays; the week's first day and the
 * two button labels are separate props, because a locale does not settle them.
 */
export default function CalendarLocaleDemo() {
  const [date, setDate] = React.useState("2026-11-14")

  return (
    <Calendar
      aria-label="Date de l'événement"
      lang="fr"
      value={date}
      onValueChange={setDate}
      locale="fr-FR"
      weekStartsOn={1}
      previousLabel="Mois précédent"
      nextLabel="Mois suivant"
    />
  )
}
<script setup lang="ts">
import { ref } from "vue"
import { Calendar } from "~~/registry/bases/newt/ui/calendar"

/*
 * `locale` names the month and the weekdays; the week's first day and the
 * two button labels are separate props, because a locale does not settle them.
 */
const date = ref("2026-11-14")
</script>

<template>
  <Calendar
    v-model="date"
    aria-label="Date de l'événement"
    lang="fr"
    locale="fr-FR"
    :week-starts-on="1"
    previous-label="Mois précédent"
    next-label="Mois suivant"
  />
</template>

API reference

Calendar

PropType
value / v-model?string

The chosen day as `YYYY-MM-DD`. In React, leave it undefined and pass `defaultValue` to let the calendar own it.

Typestring
onValueChange?(value: string) => void

React only. Called with the chosen day; Vue emits `update:modelValue`.

Type(value: string) => void
min?string

The first day that can be chosen. Earlier days are disabled.

Typestring
max?string

The last day that can be chosen. Later days are disabled.

Typestring
locale?string

A BCP 47 tag for the month and weekday names.

Typestring
Default"en-US"
weekStartsOn?0 | 1

`0` starts the week on Sunday, `1` on Monday.

Type0 | 1
Default0
previousLabel?string

Accessible name of the previous-month button.

Typestring
Default"Previous month"
nextLabel?string

Accessible name of the next-month button.

Typestring
Default"Next month"

With no value, the calendar opens on the current month once it is running in the browser; today is the reader’s own date, so it is not known during server rendering.

Accessibility

The month is a table with role="grid", named by the month and year, with the full weekday name on each column heading. One day at a time is a tab stop. The arrow keys move by a day or a week, Home and End go to the ends of the week, Page Up and Page Down change month, and moving past the edge of the month turns the page. Enter or Space chooses the focused day. Today is marked with aria-current="date" and an outline, the chosen day with aria-selected and a fill, so the two differ in shape as well as colour. Say the chosen date in text near the calendar, as the example does.

Pass locale for the month and day names, and previousLabel and nextLabel for the two buttons. Translating labels lists every English default.

Tokens

Calendar reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-calendar.

  • --newt-border
  • --newt-radius-md
  • --newt-bg-surface
  • --newt-text-primary
  • --newt-radius-sm
  • --newt-text-muted
  • --newt-dir
  • --newt-bg-hover
  • --newt-text-secondary
  • --newt-font-sans
  • --newt-brand
  • --newt-on-accent
  • --newt-text-link