Calendar
A calendar component that allows users to select a date or a range of dates.
| Mo | Tu | We | Th | Fr | Sa | Su |
|---|---|---|---|---|---|---|
Installation
pnpm add @heyramzi/ui bits-uiUsage
import { Calendar } from "@heyramzi/ui/shadcn/calendar";<Calendar type="single" bind:value captionLayout="dropdown" />Keyboard and accessibility
| Key | Does |
|---|---|
| Arrow Left | Moves to the previous day. |
| Arrow Right | Moves to the next day. |
| Arrow Up | Moves to the same day a week earlier. |
| Arrow Down | Moves to the same day a week later. |
| Space Enter | Picks the focused day. |
- Moving past the first or last day turns the month.
- Weeks start on Monday unless you pass weekStartsOn.
- The previous and next month buttons are their own Tab stops.
API reference
Day
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.Dayfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.Day from bits-ui | |
Calendar
buttonVariant"default" | "outline" | "ghost" | "destructive" | "text" | "dashed"- Default
"ghost" captionLayout"dropdown" | "dropdown-months" | "dropdown-years" | "label"- Default
"label" monthsCalendarPrimitive.MonthSelectProps["months"]yearsCalendarPrimitive.YearSelectProps["years"]monthFormatCalendarPrimitive.MonthSelectProps["monthFormat"]yearFormatCalendarPrimitive.YearSelectProps["yearFormat"]- Default
"numeric" daySnippet<[{ day: DateValue; outsideMonth: boolean }]>refbindableHTMLElement | null- Default
null valuebindableCalendar.RootplaceholderbindableCalendar.RootclassstringweekdayFormatstring- Default
"short" localestring- Default
"en-US" disableDaysOutsideMonthboolean- Default
false weekStartsOnnumber- Default
1 fixedWeeksboolean- Default
true ...rest- Every prop of
Calendar.Rootfrombits-uiexceptchild, children
| Prop | Type | Default |
|---|---|---|
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 bindable | HTMLElement | null | null |
value bindable | Calendar.Root | |
placeholder bindable | Calendar.Root | |
class | string | |
weekdayFormat | string | "short" |
locale | string | "en-US" |
disableDaysOutsideMonth | boolean | false |
weekStartsOn | number | 1 |
fixedWeeks | boolean | true |
...rest | Every prop of Calendar.Root from bits-ui except child, children | |
Cell
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.Cellfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.Cell from bits-ui | |
Grid
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.Gridfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.Grid from bits-ui | |
Header
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.Headerfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.Header from bits-ui | |
Months
refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
GridRow
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.GridRowfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.GridRow from bits-ui | |
Heading
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.Headingfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.Heading from bits-ui | |
GridBody
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.GridBodyfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.GridBody from bits-ui | |
GridHead
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.GridHeadfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.GridHead from bits-ui | |
HeadCell
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Calendar.HeadCellfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Calendar.HeadCell from bits-ui | |
NextButton
variant"default" | "outline" | "ghost" | "destructive" | "text" | "dashed"- Default
"ghost" refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
Calendar.NextButtonfrombits-ui
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "ghost" | "destructive" | "text" | "dashed" | "ghost" |
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of Calendar.NextButton from bits-ui | |
PrevButton
variant"default" | "outline" | "ghost" | "destructive" | "text" | "dashed"- Default
"ghost" refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
Calendar.PrevButtonfrombits-ui
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "ghost" | "destructive" | "text" | "dashed" | "ghost" |
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of Calendar.PrevButton from bits-ui | |
Nav
refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLElement> from svelte/elements | |
Month
refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLElement> from svelte/elements | |
YearSelect
refbindableHTMLElement | null- Default
null classstringvalueCalendar.YearSelect...rest- Every prop of
Calendar.YearSelectfrombits-uiexceptchild, children
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
value | Calendar.YearSelect | |
...rest | Every prop of Calendar.YearSelect from bits-ui except child, children | |
MonthSelect
refbindableHTMLElement | null- Default
null classstringvalueCalendar.MonthSelectonchangeCalendar.MonthSelect...rest- Every prop of
Calendar.MonthSelectfrombits-uiexceptchild, children
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
value | Calendar.MonthSelect | |
onchange | Calendar.MonthSelect | |
...rest | Every prop of Calendar.MonthSelect from bits-ui except child, children | |
Caption
captionLayoutrequiredComponentProps<typeof Calendar>["captionLayout"]monthsrequiredComponentProps<typeof CalendarMonthSelect>["months"]monthFormatrequiredComponentProps<typeof CalendarMonthSelect>["monthFormat"]yearsrequiredComponentProps<typeof CalendarYearSelect>["years"]yearFormatrequiredComponentProps<typeof CalendarYearSelect>["yearFormat"]monthrequiredDateValueplaceholderrequired bindableDateValue | undefinedlocalerequiredstringmonthIndexnumber- Default
0
| Prop | Type | Default |
|---|---|---|
captionLayout required | ComponentProps<typeof Calendar>["captionLayout"] | |
months required | ComponentProps<typeof CalendarMonthSelect>["months"] | |
monthFormat required | ComponentProps<typeof CalendarMonthSelect>["monthFormat"] | |
years required | ComponentProps<typeof CalendarYearSelect>["years"] | |
yearFormat required | ComponentProps<typeof CalendarYearSelect>["yearFormat"] | |
month required | DateValue | |
placeholder required bindable | DateValue | undefined | |
locale required | string | |
monthIndex | number | 0 |