# Calendar

One calendar with day, month and year views, without nested popups.

Connect Flood once using [the installation guide](https://flood.md/docs/installation). Then import the components you use; no per-component add command is needed.

## Example

```tsx
"use client";

import { FloodRoot, Calendar } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <Calendar label="Choose a date" defaultValue="2026-10-26" today="2026-10-26" weekStartsOn={1} />
    </FloodRoot>
  );
}
```

## Design notes

- Calendar is a standalone visual collection. DateField handles text entry and DatePicker composes the field and calendar layer.
- Values use canonical YYYY-MM-DD and visibleMonth uses YYYY-MM. Locale formats Gregorian month/day names; weekStartsOn is explicit.
- Arrows move dates; Home/End move within a week and PageUp/PageDown navigate months. Controlled month refusal preserves a real focused day. Disabled dates remain discoverable but cannot select.
- The host owns selected values, availability and side effects. Provide today for a deterministic clock in tests or rendering. Min/max bound navigation; readonly prevents selection while allowing browsing. Introduced in 0.2.7.
- Month and year controls replace the content of this calendar. Selecting a navigation period returns to days without changing the selected date.
- granularity="day" | "month" | "year" chooses YYYY-MM-DD, YYYY-MM or YYYY.

## API reference

| Prop | Values | Default |
| --- | --- | --- |
| `label` | `string` | `Required` |
| `granularity` | `"day" \| "month" \| "year"` | `—` |
| `showViewControls` | `boolean` | `—` |
| `viewLabels` | `{month?:string;year?:string;previous?:string;next?:string}` | `—` |
| `value` | `string` | `—` |
| `defaultValue` | `string` | `—` |
| `onValueChange` | `(date: string) => void` | `—` |
| `onDateSelect` | `(date: string) => void` | `—` |
| `visibleMonth` | `string` | `—` |
| `defaultVisibleMonth` | `string` | `—` |
| `onVisibleMonthChange` | `(month: string) => void` | `—` |
| `min` | `string` | `—` |
| `max` | `string` | `—` |
| `disabled` | `boolean` | `—` |
| `readOnly` | `boolean` | `—` |
| `isDateDisabled` | `(date: string) => boolean` | `—` |
| `weekStartsOn` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6` | `0` |
| `locale` | `string` | `"en-US"` |
| `autoFocus` | `boolean` | `false` |
| `today` | `string` | `—` |
| `previousMonthLabel` | `string` | `—` |
| `nextMonthLabel` | `string` | `—` |
| `Native HTML props` | `Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" \| "onChange" \| "children">` | `Forwarded` |
