# Use cases

> Calendar and date-range pickers with presets like today, last 7 days, this month. Copy these shadcn/ui patterns for filters and booking flows.

A shadcn/ui block from the [@shadcnuikit](https://shadcnuikit.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/shadcnuikit/date-picker-example2).

- Page, with a live preview: https://shadcn.exchange/r/shadcnuikit/date-picker-example2
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/shadcnuikit/date-picker-example2-light-4e8651201ceacbae.png
- Registry item: https://shadcnuikit.com/r/date-picker-example2.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://shadcnuikit.com/r/date-picker-example2.json
```

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

## Dependencies

- npm packages: `date-fns`, `react-day-picker`
- Registry items: `calendar`

## Files

### `contents/examples/date-picker/use-cases/2/index.tsx`

```tsx
"use client";

import * as React from "react";
import { startOfDay, subDays, endOfDay } from "date-fns";
import { DateRange } from "react-day-picker";

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

export default function DatePickerWithRange() {
  const today = new Date();
  const sevenDaysAgo = subDays(today, 6);

  const [date, setDate] = React.useState<DateRange | undefined>({
    from: startOfDay(sevenDaysAgo),
    to: endOfDay(today)
  });

  return (
    <div className="border rounded-lg">
      <Calendar
        mode="range"
        defaultMonth={date?.from}
        selected={date}
        onSelect={setDate}
        numberOfMonths={2}
      />
    </div>
  );
}
```
