# Calendar

A calendar component that allows users to select a date or a range of dates.

Section: Components / Inputs
Page: https://ui.heyramzi.com/components/calendar
Import path: `@heyramzi/ui/shadcn/calendar`

## Import

```ts
import { Calendar } from "@heyramzi/ui/shadcn/calendar";
```

## Usage

```svelte
<Calendar type="single" bind:value captionLayout="dropdown" />
```

## Demo

```svelte
<script lang="ts">
	import { getLocalTimeZone, today } from "@internationalized/date";
	import { Calendar } from "@heyramzi/ui/shadcn/calendar";

	let value = today(getLocalTimeZone());
</script>

<Calendar type="single" bind:value class="rounded-md border shadow-sm" captionLayout="dropdown" />
```

## API

### Day

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.Day` from `bits-ui`.

### Calendar

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `buttonVariant` | `"default"` \| `"outline"` \| `"ghost"` \| `"destructive"` \| `"text"` \| `"dashed"` | `"ghost"` |  |
| `captionLayout` | `"dropdown" \| "dropdown-months" \| "dropdown-years" \| "label"` | `"label"` |  |
| `months` | `CalendarPrimitive.MonthSelectProps["months"]` |  |  |
| `years` | `CalendarPrimitive.YearSelectProps["years"]` |  |  |
| `monthFormat` | `CalendarPrimitive.MonthSelectProps["monthFormat"]` |  |  |
| `yearFormat` | `CalendarPrimitive.YearSelectProps["yearFormat"]` | `"numeric"` |  |
| `day` | `Snippet<[{ day: DateValue; outsideMonth: boolean }]>` |  |  |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `value` |  |  | bindable |
| `placeholder` |  |  | bindable |
| `class` | `string` |  |  |
| `weekdayFormat` | `string` | `"short"` |  |
| `locale` | `string` | `"en-US"` |  |
| `disableDaysOutsideMonth` | `boolean` | `false` |  |
| `weekStartsOn` | `number` | `1` |  |
| `fixedWeeks` | `boolean` | `true` |  |

Every prop of `Calendar.Root` from `bits-ui`, except `child, children`.

### Cell

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.Cell` from `bits-ui`.

### Grid

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.Grid` from `bits-ui`.

### Header

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.Header` from `bits-ui`.

### Months

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLDivElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLDivElement>` from `svelte/elements`.

### GridRow

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.GridRow` from `bits-ui`.

### Heading

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.Heading` from `bits-ui`.

### GridBody

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.GridBody` from `bits-ui`.

### GridHead

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.GridHead` from `bits-ui`.

### HeadCell

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Calendar.HeadCell` from `bits-ui`.

### NextButton

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `variant` | `"default"` \| `"outline"` \| `"ghost"` \| `"destructive"` \| `"text"` \| `"dashed"` | `"ghost"` |  |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Calendar.NextButton` from `bits-ui`.

### PrevButton

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `variant` | `"default"` \| `"outline"` \| `"ghost"` \| `"destructive"` \| `"text"` \| `"dashed"` | `"ghost"` |  |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Calendar.PrevButton` from `bits-ui`.

### Nav

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLElement>` from `svelte/elements`.

### Month

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLElement>` from `svelte/elements`.

### YearSelect

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `value` |  |  |  |

Every prop of `Calendar.YearSelect` from `bits-ui`, except `child, children`.

### MonthSelect

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `value` |  |  |  |
| `onchange` |  |  |  |

Every prop of `Calendar.MonthSelect` from `bits-ui`, except `child, children`.

### Caption

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `captionLayout` | `ComponentProps<typeof Calendar>["captionLayout"]` |  | required |
| `months` | `ComponentProps<typeof CalendarMonthSelect>["months"]` |  | required |
| `monthFormat` | `ComponentProps<typeof CalendarMonthSelect>["monthFormat"]` |  | required |
| `years` | `ComponentProps<typeof CalendarYearSelect>["years"]` |  | required |
| `yearFormat` | `ComponentProps<typeof CalendarYearSelect>["yearFormat"]` |  | required |
| `month` | `DateValue` |  | required |
| `placeholder` | `DateValue \| undefined` |  | required. bindable |
| `locale` | `string` |  | required |
| `monthIndex` | `number` | `0` |  |
