Range Calendar

PohonGitHub
Presents a calendar view tailored for selecting date ranges.
Event Date, December 2025
December 2025
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
<script setup lang="ts">
import type { DateValue } from 'akar';
import { ARangeCalendarCell, ARangeCalendarCellTrigger, ARangeCalendarGrid, ARangeCalendarGridBody, ARangeCalendarGridHead, ARangeCalendarGridRow, ARangeCalendarHeadCell, ARangeCalendarHeader, ARangeCalendarHeading, ARangeCalendarNext, ARangeCalendarPrev, ARangeCalendarRoot } from 'akar';

function isDateUnavailable(date: DateValue) {
  return date.day === 17 || date.day === 18;
}
</script>

<template>
  <ARangeCalendarRoot
    v-slot="{ weekDays, grid }"
    :is-date-unavailable="isDateUnavailable"
    fixed-weeks
  >
    <ARangeCalendarHeader class="flex items-center justify-between">
      <ARangeCalendarPrev
        class="text-sm color-text font-medium p-1.5 rounded-md inline-flex gap-1.5 items-center focus-visible:bg-background-elevated hover:bg-background-elevated"
      >
        <i
          class="i-lucide:chevron-left h-4 w-4"
        />
      </ARangeCalendarPrev>
      <ARangeCalendarHeading class="text-sm font-medium mx-auto text-center truncate" />

      <ARangeCalendarNext
        class="text-sm color-text font-medium p-1.5 rounded-md inline-flex gap-1.5 items-center focus-visible:bg-background-elevated hover:bg-background-elevated"
      >
        <i
          class="i-lucide:chevron-right h-4 w-4"
        />
      </ARangeCalendarNext>
    </ARangeCalendarHeader>
    <div
      class="pt-4 flex flex-col space-y-4 sm:(flex-row space-x-4 space-y-0)"
    >
      <ARangeCalendarGrid
        v-for="month in grid"
        :key="month.value.toString()"
        class="w-full select-none border-collapse space-y-1 focus:outline-none"
      >
        <ARangeCalendarGridHead>
          <ARangeCalendarGridRow class="mb-1 grid grid-cols-7 w-full">
            <ARangeCalendarHeadCell
              v-for="day in weekDays"
              :key="day"
              class="text-xs color-primary rounded-md"
            >
              {{ day }}
            </ARangeCalendarHeadCell>
          </ARangeCalendarGridRow>
        </ARangeCalendarGridHead>
        <ARangeCalendarGridBody class="grid">
          <ARangeCalendarGridRow
            v-for="(weekDates, index) in month.rows"
            :key="`weekDate-${index}`"
            class="grid grid-cols-7 place-items-center"
          >
            <ARangeCalendarCell
              v-for="weekDate in weekDates"
              :key="weekDate.toString()"
              :date="weekDate"
              class="text-sm text-center relative"
            >
              <ARangeCalendarCellTrigger
                :day="weekDate"
                :month="month.value"
                class="m-0.5 rounded-full flex size-8 whitespace-nowrap transition-colors-280 items-center justify-center relative data-[disabled]:(color-text-dimmed cursor-not-allowed) data-[outside-view]:color-text-muted data-[unavailable]:(color-text-muted line-through pointer-events-none) data-[today]:font-semibold focus:outline-none data-[highlighted]:bg-primary/20 focus-visible:ring-2 focus-visible:ring-primary data-[today]:not-[[data-selected]]:color-primary hover:not-[[data-selected]]:bg-primary/20 akar:data-[selected]:color-text-inverted akar:data-[selected]:bg-primary"
              />
            </ARangeCalendarCell>
          </ARangeCalendarGridRow>
        </ARangeCalendarGridBody>
      </ARangeCalendarGrid>
    </div>
  </ARangeCalendarRoot>
</template>

Features

  • Full keyboard navigation
  • Can be controlled or uncontrolled
  • Focus is fully managed
  • Localization support
  • Highly composable

Preface

The component depends on the @internationalized/date package, which solves a lot of the problems that come with working with dates and times in JavaScript.

We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components.

Anatomy

Import all parts and piece them together.

<script setup>
import {
  ARangeCalendarCell,
  ARangeCalendarCellTrigger,
  ARangeCalendarGrid,
  ARangeCalendarGridBody,
  ARangeCalendarGridHead,
  ARangeCalendarGridRow,
  ARangeCalendarHeadCell,
  ARangeCalendarHeader,
  ARangeCalendarHeading,
  ARangeCalendarNext,
  ARangeCalendarPrev,
  ARangeCalendarRoot,
} from 'akar';
</script>

<template>
  <ARangeCalendarRoot>
    <ARangeCalendarHeader>
      <ARangeCalendarPrev />
      <ARangeCalendarHeading />
      <ARangeCalendarNext />
    </ARangeCalendarHeader>
    <ARangeCalendarGrid>
      <ARangeCalendarGridHead>
        <ARangeCalendarGridRow>
          <ARangeCalendarHeadCell />
        </ARangeCalendarGridRow>
      </ARangeCalendarGridHead>
      <ARangeCalendarGridBody>
        <ARangeCalendarGridRow>
          <ARangeCalendarCell>
            <ARangeCalendarCellTrigger />
          </ARangeCalendarCell>
        </ARangeCalendarGridRow>
      </ARangeCalendarGridBody>
    </ARangeCalendarGrid>
  </ARangeCalendarRoot>
</template>

Pohon

One benefit of using Akar is its flexibility and low-level control over the components. However, this also means that you may need to manually construct more complex UI elements by combining multiple Akar components together.

If you feel there's a lot of elements that needs to be constructed manually using Akar, consider using Pohon UI instead. It provides a higher-level abstraction over Akar components with pre-defined styles and behaviors that can help you build UIs faster.

API Reference

Root

Contains all the parts of a calendar

Props

Prop Default Type
as'div'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

allowNonContiguousRangesfalseboolean

When combined with isDateUnavailable, determines whether non-contiguous ranges, i.e. ranges containing unavailable dates, may be selected.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

calendarLabelstring

The accessible label for the calendar

defaultPlaceholderDateValue

The default placeholder date

defaultValue{ start: undefined, end: undefined }DateRange

The default value for the calendar

dir'ltr' | 'rtl'

The reading direction of the calendar when applicable.
If omitted, inherits globally from AConfigProvider or assumes LTR (left-to-right) reading mode.

disabledfalseboolean

Whether or not the calendar is disabled

disableDaysOutsideCurrentViewfalseboolean

Whether or not to disable days outside the current view.

fixedDate'start' | 'end'

Which part of the range should be fixed

fixedWeeksfalseboolean
initialFocusfalseboolean

If true, the calendar will focus the selected day, today, or the first day of the month depending on what is visible when the calendar is mounted

isDateDisabledDateMatcher

A function that returns whether or not a date is disabled

isDateHighlightableDateMatcher

A function that returns whether or not a date is hightable

isDateUnavailableDateMatcher

A function that returns whether or not a date is unavailable

localestring
maximumDaysnumber

The maximum number of days that can be selected in a range

maxValueDateValue

The maximum date that can be selected

minValueDateValue

The minimum date that can be selected

modelValueDateRange | null
nextPage((placeholder: DateValue) => DateValue)

A function that returns the next page of the calendar. It receives the current placeholder as an argument inside the component.

numberOfMonths1number

The number of months to display at once

pagedNavigationfalseboolean

This property causes the previous and next buttons to navigate by the number of months displayed at once, rather than one month

placeholderDateValue

The placeholder date, which is used to determine what month to display when no date is selected. This updates as the user navigates the calendar and can be used to programmatically control the calendar view

preventDeselectfalseboolean

Whether or not to prevent the user from deselecting a date without selecting another date first

prevPage((placeholder: DateValue) => DateValue)

A function that returns the previous page of the calendar. It receives the current placeholder as an argument inside the component.

readonlyfalseboolean

Whether or not the calendar is readonly

weekdayFormat'narrow''narrow' | 'long' | 'short'

The format to use for the weekday strings provided via the weekdays slot prop

weekStartsOn00 | 1 | 2 | 3 | 4 | 5 | 6

Emits

Event Type
update:modelValue[date: DateRange]

Event handler called whenever the model value changes

update:placeholder[date: DateValue]

Event handler called whenever the placeholder value changes

update:startValue[date: DateValue]

Event handler called whenever the start value changes

update:validModelValue[date: DateRange]

Event handler called whenever there is a new validModel

Slots

Slot Type
dateDateValue

The current date of the placeholder

gridDateGrid<DateValue>

The grid of dates

weekDaysstring[]

The days of the week

weekStartsOn0 | 1 | 2 | 3 | 4 | 5 | 6

The day of the week to start the calendar on

localestring

The locale to use for formatting dates

fixedWeeksboolean

Whether or not to always display 6 weeks in the calendar

modelValueDateRange

The controlled checked state of the calendar. Can be bound as v-model.

Data Attributes

Attribute Value
[data-readonly]Present when readonly
[data-disabled]Present when disabled
[data-invalid]Present when invalid

Contains the navigation buttons and the heading segments.

Props

Prop Default Type
as'div'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Prev Button

Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view.

Data Attributes

Attribute Value
[data-disabled]Present when disabled

Props

Prop Default Type
as'button'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

prevPage((placeholder: DateValue) => DateValue)

A function that returns the previous page of the calendar. It receives the current placeholder as an argument inside the component.

Slots

Slot Type
disabledboolean

Whether or not the calendar is disabled

Next Button

Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view.

Props

Prop Default Type
as'button'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

nextPage((placeholder: DateValue) => DateValue)

A function that returns the next page of the calendar. It receives the current placeholder as an argument inside the component.

Slots

Slot Type
disabledboolean

Whether or not the calendar is disabled

Data Attributes

Attribute Value
[data-disabled]Present when disabled

Heading

Heading for displaying the current month and year.

Props

Prop Default Type
as'div'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Slots

Slot Type
headingValuestring

Current month and year

Data Attributes

Attribute Value
[data-disabled]Present when disabled

Grid

Container for wrapping the calendar grid.

Props

Prop Default Type
as'table'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Data Attributes

Attribute Value
[data-readonly]Present when readonly
[data-disabled]Present when disabled

Grid Head

Container for wrapping the grid head.

Props

Prop Default Type
as'thead'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Grid Body

Container for wrapping the grid body.

Props

Prop Default Type
as'tbody'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Grid Row

Container for wrapping the grid row.

Props

Prop Default Type
as'tr'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Head Cell

Container for wrapping the head cell. Used for displaying the week days.

Props

Prop Default Type
as'th'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

Cell

Container for wrapping the calendar cells.

Props

Prop Default Type
as'td'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

date*DateValue

Data Attributes

Attribute Value
[data-disabled]Present when disabled

Cell Trigger

Interactable container for displaying the cell dates. Clicking it selects the date.

Props

Prop Default Type
as'div'APrimitiveAsTag | Component

The element or component this component should render as. Can be overwritten by asChild.

asChildboolean

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

day*DateValue
month*DateValue

Slots

Slot Type
dayValuestring

Current day

disabledboolean

Whether or not the calendar is disabled

selectedboolean

Current selected state

todayboolean

Current today state

outsideViewboolean

Current outside view state

outsideVisibleViewboolean

Current outside visible view state

unavailableboolean

Current unavailable state

highlightedboolean

Current highlighted state

highlightedStartboolean

Current highlighted start state

highlightedEndboolean

Current highlighted end state

selectionStartboolean

Current selection start state

selectionEndboolean

Current selection end state

Data Attributes

Attribute Value
[data-selected]Present when selected
[data-value]The ISO string value of the date.
[data-disabled]Present when disabled
[data-unavailable]Present when unavailable
[data-today]Present when today
[data-outside-view]Present when the date is outside the current month it is displayed in.
[data-outside-visible-view]Present when the date is outside the months that are visible on the calendar.
[data-focused]Present when focused
[data-selection-start]Present when the date is the start of the selection.
[data-selection-end]Present when the date is the end of the selection.
[data-highlighted]Present when the date is highlighted by the user as they select a range.
[data-highlighted-start]Present when the date is the start of the range that is highlighted by the user.
[data-highlighted-end]Present when the date is the end of the range that is highlighted by the user.
[data-focused]Present when focused

Accessibility

Keyboard Interactions

Key Description
Tab

When focus moves onto the calendar, focuses the first navigation button.

Space

When the focus is on either CalendarNext or CalendarPrev, it navigates the calendar. Otherwise, it selects the date.

Enter

When the focus is on either CalendarNext or CalendarPrev, it navigates the calendar. Otherwise, it selects the date.

ArrowLeftArrowRightArrowUpArrowDown

When the focus is on CalendarCellTrigger, it navigates the dates, changing the month/year/decade if necessary.