# V calendar 9

> Two-Month Range Picker

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/v-calendar-9).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/v-calendar-9
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/v-calendar-9-light-666e3681b24527c5.png
- Registry item: https://ui.cnippet.dev/r/v-calendar-9.json
- Categories: calendar
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/v-calendar-9.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/calendar`

## Files

### `registry/default/variants/v-calendar-9.tsx`

```tsx
"use client";

import * as React from "react";
import type { DateRange } from "react-day-picker";
import { Calendar } from "@/registry/default/ui/calendar";

function formatShort(d: Date) {
  return d.toLocaleDateString("en-US", {
    day: "numeric",
    month: "short",
    year: "numeric",
  });
}

function nightsBetween(a: Date, b: Date) {
  return Math.round(Math.abs(b.getTime() - a.getTime()) / 86_400_000);
}

export default function Particle() {
  const [range, setRange] = React.useState<DateRange | undefined>();

  const nights =
    range?.from && range?.to ? nightsBetween(range.from, range.to) : 0;

  return (
    <div className="flex flex-col gap-3">
      <Calendar
        mode="range"
        numberOfMonths={2}
        onSelect={setRange}
        selected={range}
      />
      <div className="rounded-lg border px-4 py-3 text-sm">
        {range?.from ? (
          <p className="flex flex-wrap items-center gap-1.5">
            <span>{formatShort(range.from)}</span>
            <span className="text-muted-foreground">→</span>
            {range.to ? (
              <>
                <span>{formatShort(range.to)}</span>
                {nights > 0 && (
                  <span className="rounded-full bg-secondary px-2 py-0.5 font-medium text-xs">
                    {nights} night{nights !== 1 ? "s" : ""}
                  </span>
                )}
              </>
            ) : (
              <span className="text-muted-foreground">pick end date</span>
            )}
          </p>
        ) : (
          <p className="text-muted-foreground">Select a check-in date.</p>
        )}
      </div>
    </div>
  );
}
```
