Skip to content
// EFFECT DAYS 2026

DatePicker unstable

A headless date input with a popup calendar, built on DateField and Calendar. Supply value, open, month and today; handle the events to update the controlled value, open state and displayed month.

Anatomy

Part Element
input <input>, the DateField's typed date
trigger <button> that opens and closes the popup
positioner <div>, a manual popover next to the input
popup <div> inside the positioner

The Calendar's parts, root, previous, next, weekday and each month's heading, grid, cell and day, go inside the popup, as Calendar describes. Each part takes the consumer's builder and returns it. input adds the DateField's wrapper and hidden form input. No other part adds markup.

The parts also carry open, side and align, and the values of DateField (value, inputValue, pattern, disabled, readOnly, required) and Calendar (weekdays and months).

The positioner uses a manual popover in the top layer unless topLayer: false. It anchors to the input with side: "bottom" and align: "start" by default. Its inline style carries left, top and the CSS variables described in Positioning.

Date values

As in Calendar and DateField, every date prop accepts any DateTime and is normalized with DateTime.removeTime, and every date the picker emits is a DateTime.Utc at midnight UTC. Take today from DateTime.nowInCurrentZone or another zoned value.

Data attributes

Each present with an empty value or absent, except the ones with a value:

  • trigger: data-popup-open, data-disabled, data-readonly
  • positioner, popup: data-open / data-closed, data-side, data-align
  • input and the calendar's parts: as DateField and Calendar list

Keyboard

Enter and Space press the trigger. Opening focuses the calendar's focused day; see Calendar for its navigation keys. Picking a day, pressing Escape or pressing or moving focus outside the picker requests a close. Escape during input-method composition does not close the popup. When open turns false with focus still in the popup, focus goes back to the trigger. Focus that already left stays where it went.

Field

Wrap the input, trigger and positioner in field.focusWithin and apply field.member to the input, as below. Moving focus between them then keeps the field focused without marking it touched. Pass disabled: field.disabled. Label the input explicitly with aria-label or an id and <label for>, and give the popup an aria-label.

Example A controlled departure date picker inside a Field

import { UiSchema } from "effect/ui"
import { Html, HtmlServer } from "effect/ui/html"
import { DatePicker, Field } from "effect/ui/kit"
import { DateTime, Effect, Schema } from "effect"
const TripMessage = UiSchema.TaggedEnum({
PickedDate: { date: Schema.NullOr(Schema.DateTimeUtc) },
RequestedOpenDatePicker: {},
RequestedCloseDatePicker: {},
RequestedMonth: { month: Schema.DateTimeUtc }
})
const Trip = Html.component({
name: "Trip",
model: Schema.Struct({
date: Schema.NullOr(Schema.DateTimeUtc),
month: Schema.DateTimeUtc,
open: Schema.Boolean
}),
message: TripMessage
}).make({
init: () => ({
date: DateTime.makeUnsafe("2026-11-15T00:00:00Z"),
month: DateTime.makeUnsafe("2026-11-01T00:00:00Z"),
open: false
}),
update: {
PickedDate: ($, { date }) => $.evolve({ date }),
RequestedOpenDatePicker: ($) => $.evolve({ open: true }),
RequestedCloseDatePicker: ($) => $.evolve({ open: false }),
RequestedMonth: ($, { month }) => $.evolve({ month })
},
view: (h, model) =>
Field(h, {
view: (field) =>
DatePicker(h, {
props: {
value: model.date,
open: model.open,
month: model.month,
today: DateTime.makeUnsafe("2026-11-26T00:00:00Z"),
locale: "en-GB",
disabled: field.disabled
},
onEmit: {
Picked: ({ date }) => TripMessage.PickedDate({ date }),
RequestedOpen: () => TripMessage.RequestedOpenDatePicker(),
RequestedClose: () => TripMessage.RequestedCloseDatePicker(),
RequestedMonth: ({ month }) => TripMessage.RequestedMonth({ month })
},
view: (datePicker) =>
field.root(field.focusWithin(h.div)).children(
datePicker.input(field.member(h.input.class("date"))).attr("aria-label", "Departure"),
datePicker.trigger(h.button).children("Choose date"),
datePicker.positioner(h.div).children(
datePicker.popup(h.div.attr("aria-label", "Departure")).children(
datePicker.root(h.div).children(
...datePicker.months.map((month) =>
h.section(
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(Trip, {}))
if (!/<input class="date"[^>]* value="15\/11\/2026"/.test(html)) throw new Error("the input doesn't show the date")
if (!/<button[^>]* aria-haspopup="dialog" aria-expanded="false"/.test(html)) throw new Error("the trigger doesn't name its popup")
7 exports Since v4.2.0 Source

Components

DatePicker

unstable
Since v4.2.0

A headless date picker. Supply h, props, onEmit and a view that renders the input, trigger and positioner, with the popup and calendar inside the positioner.

Details

Each part's attributes win over the ones the consumer set on the builder before the part, including the ones a state leaves absent:

  • input: what DateField's input writes
  • trigger: type="button", aria-haspopup="dialog", aria-expanded, aria-controls while open, disabled, aria-disabled (removed) and its data attributes, plus a fallback aria-label when the button has no accessible name
  • positioner: role="presentation", the popover and its data attributes, and its placement in its inline style
  • popup: id, role="dialog" and its data attributes
  • the calendar's parts: what Calendar writes

Internal placement state is not restored from history.

Signature

declare const DatePicker: Headless<{
readonly align?: "start" | "end" | "center";
readonly alignOffset?: number;
readonly anchor?: string | {
readonly height: number;
readonly width: number;
readonly x: number;
readonly y: number;
};
readonly arrowPadding?: number;
readonly collisionAvoidance?: {
readonly align?: "shift" | "none" | "flip";
readonly fallbackAxisSide?: "start" | "none" | "end";
readonly side?: "shift" | "none" | "flip";
};
readonly collisionBoundary?: "clipping-ancestors" | {
readonly height: number;
readonly width: number;
readonly x: number;
readonly y: number;
} | {
readonly id: string;
};
readonly collisionPadding?: number | {
readonly bottom?: number;
readonly left?: number;
readonly right?: number;
readonly top?: number;
};
readonly disableAnchorTracking?: boolean;
readonly disabled?: boolean;
readonly firstDayOfWeek?: 0 | 1 | 2 | 5 | 3 | 4 | 6;
readonly form?: string;
readonly locale?: string | readonly Array<string>;
readonly max?: Utc | Zoned;
readonly min?: Utc | Zoned;
readonly month: Utc | Zoned;
readonly months?: number;
readonly name?: string;
readonly open: boolean;
readonly positionMethod?: "fixed" | "absolute";
readonly readOnly?: boolean;
readonly required?: boolean;
readonly side?: "left" | "right" | "top" | "bottom" | "inline-start" | "inline-end";
readonly sideOffset?: number;
readonly sticky?: boolean;
readonly today: Utc | Zoned;
readonly topLayer?: boolean;
readonly value: Utc | Zoned | null;
}, {
readonly _tag: "RequestedOpen";
readonly reason: "trigger-press" | "outside-press" | "escape-key" | "focus-out" | "day-press";
} | {
readonly _tag: "RequestedClose";
readonly reason: "trigger-press" | "outside-press" | "escape-key" | "focus-out" | "day-press";
} | {
readonly _tag: "Picked";
readonly date: Utc | null;
} | {
readonly _tag: "RequestedMonth";
readonly month: Utc;
}, {
align: "start" | "end" | "center";
disabled: boolean;
input: <B extends PartTarget<"input">>(element: B) => ReturnType<B["attr"]> & Pick<Part<"input", [], never>, "~R">;
inputValue: string;
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, key: string, unavailable: boolean, gridMonth: Utc], never>, "~R">;
grid: Part<"table", [], never>;
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, key: string, unavailable: boolean, gridMonth: Utc], never>, "~R">;
grid: Part<"table", [], never>;
heading: Part<string, [], never>;
month: Utc;
title: string;
weeks: readonly Array<readonly Array<Utc>>;
}];
next: Part<"button", [], never>;
open: boolean;
pattern: string;
popup: Part<"div", [], never>;
positioner: Part<"div", [], never>;
previous: Part<"button", [], never>;
readOnly: boolean;
required: boolean;
root: Part<string, [], never>;
side: "left" | "right" | "top" | "bottom" | "inline-start" | "inline-end";
trigger: Part<"button", [], never>;
value: Utc | null;
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 placement: {
readonly align: "start" | "end" | "center";
readonly anchorHidden: boolean;
readonly arrowUncentered: boolean;
readonly side: "left" | "right" | "top" | "bottom" | "inline-start" | "inline-end";
} | null;
}, {
readonly _tag: "ClickedTrigger";
} | {
readonly _tag: "ChangedPlacement";
readonly placement: {
readonly align: "start" | "end" | "center";
readonly anchorHidden: boolean;
readonly arrowUncentered: boolean;
readonly side: "left" | "right" | "top" | "bottom" | "inline-start" | "inline-end";
};
} | {
readonly _tag: "CommittedDateField";
readonly date: Utc | null;
} | {
readonly _tag: "PickedCalendar";
readonly date: Utc;
} | {
readonly _tag: "RequestedCalendarMonth";
readonly month: Utc;
} | {
readonly _tag: "Dismissed";
readonly reason: "outside-press" | "escape-key" | "focus-out";
}, QueryEntries<{}, {}>>

Models

Since v4.2.0

Why a DatePicker asks to open or close its popup.

Signature

type DatePickerChangeReason = typeof DatePickerChangeReason.Type

DatePickerEvents

type unstable
Since v4.2.0

What a DatePicker emits.

Signature

type DatePickerEvents = typeof DatePickerEvents.Type

DatePickerProps

type unstable
Since v4.2.0

The props of a DatePicker.

Signature

type DatePickerProps = typeof DatePickerProps.Type

Schemas

Why a DatePicker asks to open or close its popup.

Details

  • "trigger-press": a press, or Enter or Space, on the trigger
  • "escape-key": Escape in the popup, the input or the trigger
  • "outside-press": a press outside the input, the trigger and the popup
  • "focus-out": focus left the input, the trigger and the popup
  • "day-press": a day was picked

Signature

declare const DatePickerChangeReason: Literals<readonly ["trigger-press", "escape-key", "outside-press", "focus-out", "day-press"]>
Since v4.2.0

What a DatePicker emits.

Details

  • Picked: requests a new value after a typed commit or day press within min and max. Carries date: null when the input is cleared.
  • RequestedOpen and RequestedClose: ask for open to change, with the reason. A day press emits Picked, then RequestedClose.
  • RequestedMonth: asks for the calendar to show month, the first of that month. Emitted from the calendar's own navigation, and after a Picked whose date is outside the shown months, so the popup opens on it as the first month.

Signature

declare const DatePickerEvents: TaggedEnum<{
Picked: TaggedStruct<"Picked", {
readonly date: NullOr<DateTimeUtc>;
}>;
RequestedClose: TaggedStruct<"RequestedClose", {
readonly reason: Literals<readonly ["trigger-press", "escape-key", "outside-press", "focus-out", "day-press"]>;
}>;
RequestedMonth: TaggedStruct<"RequestedMonth", {
readonly month: DateTimeUtc;
}>;
RequestedOpen: TaggedStruct<"RequestedOpen", {
readonly reason: Literals<readonly ["trigger-press", "escape-key", "outside-press", "focus-out", "day-press"]>;
}>;
}>
Since v4.2.0

Props for a DatePicker.

Details

  • value: the date, any DateTime, or null for none.
  • open: whether the popup shows. Required: the consumer owns it.
  • month, months, today, min, max, firstDayOfWeek: as Calendar takes them. A typed date outside min or max emits nothing, and the input reverts to value.
  • locale: the locale of both the input and the calendar.
  • name, form, required: as DateField takes them.
  • disabled: disables the input, the trigger and the calendar, and suppresses every request.
  • readOnly: the popup still opens and the calendar can be browsed, but neither typing nor a day press asks for a date.
  • side, align and the other positioning options: as Positioning describes them. side is "bottom" and align "start" by default.

Signature

declare const DatePickerProps: Struct<{
readonly align: optional<Literals<readonly ["start", "center", "end"]>>;
readonly alignOffset: optional<Number>;
readonly anchor: optional<Union<readonly [String, Struct<{
readonly height: Number;
readonly width: Number;
readonly x: Number;
readonly y: Number;
}>]>>;
readonly arrowPadding: optional<Number>;
readonly collisionAvoidance: optional<Struct<{
readonly align: optional<Literals<readonly ["flip", "shift", "none"]>>;
readonly fallbackAxisSide: optional<Literals<readonly ["start", "end", "none"]>>;
readonly side: optional<Literals<readonly ["flip", "shift", "none"]>>;
}>>;
readonly collisionBoundary: optional<Union<readonly [Literal<"clipping-ancestors">, Struct<{
readonly id: String;
}>, Struct<{
readonly height: Number;
readonly width: Number;
readonly x: Number;
readonly y: Number;
}>]>>;
readonly collisionPadding: optional<Union<readonly [Number, Struct<{
readonly bottom: optional<Number>;
readonly left: optional<Number>;
readonly right: optional<Number>;
readonly top: optional<Number>;
}>]>>;
readonly disableAnchorTracking: optional<Boolean>;
readonly disabled: optional<Boolean>;
readonly firstDayOfWeek: optional<Literals<readonly [0, 1, 2, 3, 4, 5, 6]>>;
readonly form: optional<String>;
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 name: optional<String>;
readonly open: Boolean;
readonly positionMethod: optional<Literals<readonly ["absolute", "fixed"]>>;
readonly readOnly: optional<Boolean>;
readonly required: optional<Boolean>;
readonly side: optional<Literals<readonly ["top", "bottom", "left", "right", "inline-start", "inline-end"]>>;
readonly sideOffset: optional<Number>;
readonly sticky: optional<Boolean>;
readonly today: Union<readonly [DateTimeUtc, DateTimeZoned]>;
readonly topLayer: optional<Boolean>;
readonly value: NullOr<Union<readonly [DateTimeUtc, DateTimeZoned]>>;
}>