# Calendar

A month grid with today marked and the chosen day lit.

[View Calendar on CyberSpec](https://www.cyberspec.dev/components/sidebar/calendar)

## Component

Calendar belongs to the Pickers group in the CyberSpec catalog. It uses @ui-sdk/react/calendar.

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/calendar.json
```

## Example

```tsx
"use client"

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

// An ISO date some days from today, so the example always opens on a month
// that shows today and a chosen day.
function fromToday(days: number) {
  const date = new Date()
  date.setDate(date.getDate() + days)
  return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`
}

export default function CalendarDemo() {
  return (
    <>
      <Calendar
        defaultValue={fromToday(3)}
        defaultMonth={fromToday(0).slice(0, 7)}
        unavailable={[{ weekday: [0] }, fromToday(5)]}
        code="LOWTIDE // WINDOW"
      />
    </>
  )
}
```

## Install this example

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/calendar-demo.json
```

## Resources

- [Interactive Calendar preview](https://www.cyberspec.dev/preview/calendar)
- [Component catalog](https://www.cyberspec.dev/components.md)
- [Calendar source code](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/ui/calendar.tsx)
- [Shadcn registry item](https://www.cyberspec.dev/r/calendar.json)
