Skip to content
// EFFECT DAYS 2026

RangeCalendar unstable

A controlled calendar for picking a range of dates, built on Calendar, showing one month or several consecutive months. Pass the committed range as value, the first visible month as month, the number of months as months and the current day as today. Handle Picked to update value and RequestedMonth to update month.

Anatomy

Part Element
root any element, around the header and the grids
heading any element, showing the month's title
previous <button>
next <button>
grid <table>
weekday <th> inside the grid header
cell <td> inside the grid body
day <button> inside each cell

Use each entry of months for its own heading, grid, cell and day, as in Calendar. The parts take the same arguments and add no markup. The parts object also exposes weekdays and anchor: the first day of a range in progress, or null.

Inside a Field, apply field.group to root, field.member to each day, and pass disabled: field.disabled.

Selection

The first press sets the anchor. Until the second press, the range from the anchor to the day last hovered or focused is the preview, across all shown months; value stays committed. Hovering a disabled day leaves the preview unchanged. The second press emits Picked with the two days in order. Pressing the anchor again picks that one day. An unavailable day can't be an anchor or an end, but a range may span unavailable days: validate that in the consumer.

Data attributes

Those of Calendar, plus these on day, each present with an empty value or absent:

  • data-selected: the day is in value, the committed range
  • data-range-start, data-range-end, data-in-range: the day is the first day, the last day, or any day of the range shown: the preview while an anchor is set, and value otherwise

Keyboard

As Calendar, plus Escape on a day, which clears the anchor when one is set.

Usage

A range field is two DateFields and a RangeCalendar in a Popover: a typed commit updates one end of the range, and Picked updates both.

Example A controlled range calendar whose range and month live in the consumer's Model

import { UiSchema } from "effect/ui"
import { Html, HtmlServer } from "effect/ui/html"
import { RangeCalendar } from "effect/ui/kit"
import { DateTime, Effect, Schema } from "effect"
const StayMessage = UiSchema.TaggedEnum({
PickedStay: { start: Schema.DateTimeUtc, end: Schema.DateTimeUtc },
RequestedMonth: { month: Schema.DateTimeUtc }
})
const Stay = Html.component({
name: "Stay",
model: Schema.Struct({
stay: Schema.NullOr(
Schema.Struct({ start: Schema.DateTimeUtc, end: Schema.DateTimeUtc })
),
month: Schema.DateTimeUtc
}),
message: StayMessage
}).make({
init: () => ({
stay: {
start: DateTime.makeUnsafe("2026-11-12T00:00:00Z"),
end: DateTime.makeUnsafe("2026-11-15T00:00:00Z")
},
month: DateTime.makeUnsafe("2026-11-01T00:00:00Z")
}),
update: {
PickedStay: ($, stay) => $.evolve({ stay: { start: stay.start, end: stay.end } }),
RequestedMonth: ($, { month }) => $.evolve({ month })
},
view: (h, model) =>
RangeCalendar(h, {
props: {
value: model.stay,
month: model.month,
today: DateTime.makeUnsafe("2026-11-26T00:00:00Z"),
locale: "en-US"
},
onEmit: {
Picked: ({ end, start }) => StayMessage.PickedStay({ start, end }),
RequestedMonth: ({ month }) => StayMessage.RequestedMonth({ month })
},
view: (rangeCalendar) => {
const [month] = rangeCalendar.months
return rangeCalendar.root(h.div).children(
month.heading(h.h2).children(month.title),
month.grid(h.table).children(
h.tbody(
...month.weeks.map((week) =>
h.tr(
...week.map((date) =>
month.cell({ element: h.td, date }).children(
month.day({ element: h.button, date }).children(
String(DateTime.getPartUtc(date, "day"))
)
)
)
)
)
)
)
)
}
})
})
const { html } = await Effect.runPromise(HtmlServer.renderToHtml(Stay, {}))
const selected = html.match(/aria-selected="true"/g) ?? []
if (selected.length !== 4) throw new Error("the stay isn't four selected days")
if (!/November 12, 2026"[^>]* data-range-start/.test(html)) throw new Error("the stay doesn't start on the 12th")
5 exports Since v4.2.0 Source

Components

Since v4.2.0

A headless range calendar grid. Call it with the consumer's h, the props, onEmit, and a view closure that draws Calendar's parts.

Details

The parts write what Calendar's do, and these over any values the consumer set:

  • grid: aria-multiselectable="true"
  • cell: aria-selected="true" on every day of value, even during a preview
  • day: the data attributes above

History restore drops the range in progress.

Signature

declare const RangeCalendar: Headless<{
readonly disabled?: boolean;
readonly firstDayOfWeek?: 0 | 1 | 2 | 5 | 3 | 4 | 6;
readonly locale?: string | readonly Array<string>;
readonly max?: Utc | Zoned;
readonly min?: Utc | Zoned;
readonly month: Utc | Zoned;
readonly months?: number;
readonly readOnly?: boolean;
readonly today: Utc | Zoned;
readonly value: {
readonly end: Utc | Zoned;
readonly start: Utc | Zoned;
} | null;
}, {
readonly _tag: "Picked";
readonly end: Utc;
readonly start: Utc;
} | {
readonly _tag: "RequestedMonth";
readonly month: Utc;
}, {
anchor: Utc | null;
months: readonly [{
cell: <B extends Keyed<"td">>(__namedParameters: {
readonly date: DateTime;
readonly element: B;
}) => ReturnType<B["attr"]> & Pick<Part<"td", [date: Utc], never>, "~R">;
day: <B extends Keyed<"button">>(__namedParameters: {
readonly date: DateTime;
readonly element: B;
readonly unavailable?: boolean;
}) => ReturnType<B["attr"]> & Pick<Part<"button", [date: Utc, inert: boolean], never>, "~R">;
grid: <B extends PartTarget<"table">>(element: B) => ReturnType<B["attr"]> & Pick<Part<"table", [], never>, "~R">;
heading: Part<string, [], never>;
month: Utc;
title: string;
weeks: readonly Array<readonly Array<Utc>>;
}, {
cell: <B extends Keyed<"td">>(__namedParameters: {
readonly date: DateTime;
readonly element: B;
}) => ReturnType<B["attr"]> & Pick<Part<"td", [date: Utc], never>, "~R">;
day: <B extends Keyed<"button">>(__namedParameters: {
readonly date: DateTime;
readonly element: B;
readonly unavailable?: boolean;
}) => ReturnType<B["attr"]> & Pick<Part<"button", [date: Utc, inert: boolean], never>, "~R">;
grid: <B extends PartTarget<"table">>(element: B) => ReturnType<B["attr"]> & Pick<Part<"table", [], never>, "~R">;
heading: Part<string, [], never>;
month: Utc;
title: string;
weeks: readonly Array<readonly Array<Utc>>;
}];
next: Part<"button", [], never>;
previous: Part<"button", [], never>;
root: Part<string, [], never>;
weekday: <B extends Keyed<"th">>(__namedParameters: {
readonly element: B;
readonly index: number;
}) => ReturnType<B["attr"]> & Pick<Part<"th", [index: number], never>, "~R">;
weekdays: readonly Array<CalendarWeekdayName>;
}, never, never, never, never, never, never, {
readonly draft: {
readonly anchor: Utc;
readonly target: Utc;
} | null;
}, {
readonly _tag: "PressedEscape";
} | {
readonly _tag: "RequestedMonth";
readonly month: Utc;
} | {
readonly _tag: "PickedDay";
readonly date: Utc;
} | {
readonly _tag: "PreviewedDay";
readonly date: Utc;
}, QueryEntries<{}, {}>>

Models

RangeCalendarEvents

type unstable
Since v4.2.0

What a RangeCalendar emits.

Signature

type RangeCalendarEvents = typeof RangeCalendarEvents.Type

RangeCalendarProps

type unstable
Since v4.2.0

The props of a RangeCalendar.

Signature

type RangeCalendarProps = typeof RangeCalendarProps.Type

Schemas

Since v4.2.0

Events emitted by RangeCalendar.

Details

  • Picked: the second press of a range, with its midnight-UTC start and end in order.
  • RequestedMonth: as Calendar's.

Signature

declare const RangeCalendarEvents: TaggedEnum<{
Picked: TaggedStruct<"Picked", {
readonly end: DateTimeUtc;
readonly start: DateTimeUtc;
}>;
RequestedMonth: TaggedStruct<"RequestedMonth", {
readonly month: DateTimeUtc;
}>;
}>
Since v4.2.0

Props for a RangeCalendar.

Details

  • value: the committed range, or null. Both ends are normalized with DateTime.removeTime, and a start after end is read in order.
  • The rest are Calendar's: month, months, today, min, max, firstDayOfWeek, locale, disabled and readOnly. A disabled or read-only range calendar sets no anchor and shows no preview.

Signature

declare const RangeCalendarProps: Struct<{
readonly disabled: optional<Boolean>;
readonly firstDayOfWeek: optional<Literals<readonly [0, 1, 2, 3, 4, 5, 6]>>;
readonly locale: optional<Union<readonly [String, $Array<String>]>>;
readonly max: optional<Union<readonly [DateTimeUtc, DateTimeZoned]>>;
readonly min: optional<Union<readonly [DateTimeUtc, DateTimeZoned]>>;
readonly month: Union<readonly [DateTimeUtc, DateTimeZoned]>;
readonly months: optional<Number>;
readonly readOnly: optional<Boolean>;
readonly today: Union<readonly [DateTimeUtc, DateTimeZoned]>;
readonly value: NullOr<Struct<{
readonly end: Union<readonly [DateTimeUtc, DateTimeZoned]>;
readonly start: Union<readonly [DateTimeUtc, DateTimeZoned]>;
}>>;
}>