November 2026
SunMonTueWedThuFriSat

Nov 17 – 21, 2026

Installation

  1. Set up the project

    Once per project: the packages, Tailwind CSS, the theme tokens and the cn helper. Follow Installation.

  2. Copy the component into your project

    The kit owns behaviour, ARIA and data attributes. This file is the look, written with Tailwind classes, and it is yours to change.

    src/ui/range-calendar.ts
    import type { Component } from "@effect/ui"
    import type { Html } from "@effect/ui/html"
    import type { RangeCalendar } from "@effect/ui-kit"
    import type { DateTime } from "effect"
    import { CalendarGrid, CalendarHeader, CalendarRoot } from "#ui/calendar"
    
    /** What the kit's `RangeCalendar` passes to its `view` closure. */
    export type RangeCalendarParts = Component.Headless.Parts<typeof RangeCalendar>
    
    // The cell paints the band of the range, so it has no gaps between days and
    // rounds off at each end of a week. The day keeps its own corners.
    const cellClass = "p-0 text-center has-data-[in-range]:bg-brand-wash first:rounded-s-sm last:rounded-e-sm " +
      "has-data-[range-start]:rounded-s-sm has-data-[range-end]:rounded-e-sm"
    
    const dayClass = "inline-grid size-8 place-items-center rounded-sm p-0 text-[13px] text-foreground tabular-nums " +
      "transition-colors duration-150 hover:bg-accent focus-visible:relative focus-visible:outline-offset-1 " +
      "not-data-[in-range]:data-[today]:bg-accent data-[today]:font-semibold " +
      "not-data-[in-range]:data-[outside-month]:text-muted-foreground not-data-[in-range]:data-[outside-month]:opacity-55 " +
      "data-[range-start]:bg-brand data-[range-start]:text-brand-foreground data-[range-start]:hover:bg-brand " +
      "data-[range-end]:bg-brand data-[range-end]:text-brand-foreground data-[range-end]:hover:bg-brand " +
      "data-[unavailable]:cursor-not-allowed data-[unavailable]:text-muted-foreground data-[unavailable]:line-through " +
      "data-[unavailable]:hover:bg-transparent " +
      "data-[disabled]:cursor-not-allowed data-[disabled]:text-muted-foreground data-[disabled]:opacity-35! " +
      "data-[disabled]:hover:bg-transparent"
    
    /** The element around the header and the grid. `variant: "ghost"` drops the card. */
    export const RangeCalendarRoot = <Msg>(
      h: Html.H<Msg>,
      rangeCalendar: RangeCalendarParts,
      options: { readonly variant?: "card" | "ghost" | undefined; readonly class?: string | undefined } = {}
    ) => CalendarRoot(h, rangeCalendar, options)
    
    /** Previous, the month and year, next. */
    export const RangeCalendarHeader = <Msg>(
      h: Html.H<Msg>,
      rangeCalendar: RangeCalendarParts,
      options: { readonly class?: string | undefined } = {}
    ) => CalendarHeader(h, rangeCalendar, options)
    
    /**
     * The whole table. The ends of the range are filled with the brand colour and
     * the days between them washed, for the preview as for the committed range.
     */
    export const RangeCalendarGrid = <Msg>(
      h: Html.H<Msg>,
      rangeCalendar: RangeCalendarParts,
      options: {
        readonly unavailable?: ((date: DateTime.Utc) => boolean) | undefined
        readonly class?: string | undefined
      } = {}
    ) => CalendarGrid(h, rangeCalendar, { ...options, cellClass, dayClass })
    
  3. Import it

    import { RangeCalendarRoot, RangeCalendarHeader, RangeCalendarGrid } from "#ui/range-calendar"
    

Usage

Basic.ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { RangeCalendar } from "@effect/ui-kit"
import { DateTime, Schema } from "effect"
import { RangeCalendarGrid, RangeCalendarHeader, RangeCalendarRoot } from "#ui/range-calendar"

const DateRange = Schema.Struct({ start: Schema.DateTimeUtc, end: Schema.DateTimeUtc })

const RangeCalendarBasicMessage = UiSchema.TaggedEnum({
  PickedCalendarRange: { range: DateRange },
  RequestedCalendarMonth: { month: Schema.DateTimeUtc }
})

const today = DateTime.makeUnsafe("2026-11-26T00:00:00Z")

// The calendar's dates are midnight UTC, so format them in UTC.
const shortDate = new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeZone: "UTC" })

export const RangeCalendarBasic = Html.component({
  name: "RangeCalendarBasic",
  model: Schema.Struct({
    range: Schema.NullOr(DateRange),
    month: Schema.DateTimeUtc
  }),
  message: RangeCalendarBasicMessage
}).make({
  init: () => ({
    range: { start: DateTime.subtract(today, { days: 9 }), end: DateTime.subtract(today, { days: 5 }) },
    month: today
  }),
  update: {
    PickedCalendarRange: ($, { range }) => $.evolve({ range }),
    RequestedCalendarMonth: ($, { month }) => $.evolve({ month })
  },
  view: (h, model) =>
    RangeCalendar(h, {
      props: { value: model.range, month: model.month, today, locale: "en-US" },
      onEmit: {
        Picked: ({ end, start }) => RangeCalendarBasicMessage.PickedCalendarRange({ range: { start, end } }),
        RequestedMonth: ({ month }) => RangeCalendarBasicMessage.RequestedCalendarMonth({ month })
      },
      view: (rangeCalendar) =>
        h.div.class("flex flex-col items-center gap-3.5").children(
          RangeCalendarRoot(h, rangeCalendar).children(
            RangeCalendarHeader(h, rangeCalendar),
            RangeCalendarGrid(h, rangeCalendar)
          ),
          // `anchor` is set between the first press and the second.
          h.p.class("m-0 text-[13px] tabular-nums").children(
            rangeCalendar.anchor !== null
              ? `${DateTime.formatIntl(rangeCalendar.anchor, shortDate)} – pick an end date`
              : model.range === null
              ? "No range picked"
              : shortDate.formatRange(DateTime.toDateUtc(model.range.start), DateTime.toDateUtc(model.range.end))
          )
        )
    })
})

Examples

With presets

Preset buttons write the range and the shown month straight into the Model.

November 2026
SunMonTueWedThuFriSat

Bounded

min and max limit both ends of the range.

November 2026
SunMonTueWedThuFriSat

Check in from today, up to 60 days ahead.

Unavailable days

A range may span unavailable days, so the consumer validates it in update.

December 2026
SunMonTueWedThuFriSat

Struck-through nights are booked.

Read-only

Shows a fixed range that can be browsed but not changed.

November 2026
SunMonTueWedThuFriSat

Sprint 48 is locked.

Anatomy

The parts the view closure receives. Apply each one to an element of your own.

PartDescription
rootAny element around the header and the grid.
headingAny element showing rangeCalendar.title.
previous / nextThe <button>s that ask for the neighbouring month.
gridThe <table>, with aria-multiselectable.
weekdayA <th> of the header row: weekday({ element, index }).
cellA <td> of the body: cell({ element, date }).
dayThe <button> in each cell: day({ element, date, unavailable? }).
anchorValue: the first day of a range in progress, or null.
weeks, weekdays, month, titleValues, as Calendar exposes them.

API reference

Props

PropTypeDescription
value{ start: DateTime, end: DateTime } | nullThe committed range.
monthDateTimeAny date in the month to show. Controlled.
todayDateTimeThe current day.
min / maxDateTimeInclusive bounds for both ends.
firstDayOfWeek0 | 1 | ... | 6Defaults to the locale's first day.
localestring | string[]BCP 47 tag for titles and names.
disabledbooleanDisables every button; no anchor, no preview.
readOnlybooleanBrowsable, but sets no anchor and shows no preview.

Events

EventDescription
Picked{ start, end }: the second press of a range, with the two days in order.
RequestedMonth{ month }: an arrow or the keyboard asked for another month.

Data attributes

AttributeDescription
data-selectedOn day: the day is in value, the committed range.
data-in-rangeOn day: the day is in the range shown, preview or value.
data-range-startOn day: the first day of the range shown.
data-range-endOn day: the last day of the range shown.
data-todayOn day: the day is today.
data-outside-monthOn day: the day belongs to a neighbouring month.
data-unavailableOn day: drawn with unavailable: true.
data-disabledOn day, previous, next, root, heading and grid.
data-readonlyOn root, heading and grid.

The components this page's file and examples import.

  • Button: A native button that can stay focusable while disabled.
  • Calendar: A controlled month grid for picking one date, with full keyboard navigation.

effectcn is built with Effect UI and @effect/ui-kit. Not affiliated with Effectful Technologies.