# Date Picker

A button that opens a Calendar in a Popover and shows the picked date in words.

Section: Components / Inputs
Page: https://ui.heyramzi.com/components/date-picker
Import path: `@heyramzi/ui/shadcn/popover`

## Import

```ts
import * as Popover from "@heyramzi/ui/shadcn/popover";
import { Calendar } from "@heyramzi/ui/shadcn/calendar";
import { buttonVariants } from "@heyramzi/ui/shadcn/button";
```

## Demo

```svelte
<script lang="ts">
	import { DateFormatter, getLocalTimeZone, type DateValue } from "@internationalized/date";
	import { CalendarBlank } from "phosphor-svelte";
	import * as Popover from "@heyramzi/ui/shadcn/popover";
	import { Calendar } from "@heyramzi/ui/shadcn/calendar";
	import { buttonVariants } from "@heyramzi/ui/shadcn/button";

	const format = new DateFormatter("en-GB", { dateStyle: "long" });

	let open = $state(false);
	let value = $state<DateValue>();
</script>

<Popover.Root bind:open>
	<Popover.Trigger
		class={[
			buttonVariants({ variant: "outline" }),
			"w-60 justify-start font-normal",
			!value && "text-muted-foreground",
		]}
	>
		<CalendarBlank aria-hidden="true" />
		{value ? format.format(value.toDate(getLocalTimeZone())) : "Pick a due date"}
	</Popover.Trigger>
	<Popover.Content class="w-auto p-0" align="start">
		<Calendar
			type="single"
			bind:value
			captionLayout="dropdown"
			onValueChange={() => (open = false)}
		/>
	</Popover.Content>
</Popover.Root>
```

## API

### Popover

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `portalProps` | `WithoutChildrenOrChild<ComponentProps<typeof PopoverPortal>>` |  |  |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `sideOffset` | `number` | `4` |  |
| `align` | `string` | `"center"` |  |
| `collisionPadding` | `number` | `8` |  |

Every prop of `Popover.Content` 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`.
