A date field with a calendar: keyboard navigation, month and year jumps, typed words like “next fri”, and a sheet on phones.
ENG-142
Export fails on workspaces over 10 GB
Due in 9 days
Due date
December 2026
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
Fri, Dec 11, 2026
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { DatePicker } from "./ui/uicontext/components/DatePicker.ts"import { epochDay } from "./ui/uicontext/components/dates/DateMath.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"// An issue's due date. Type it, pick it, or write "next fri" in the calendar's box. The hint under// the field says how far away it is, from the app's today.const today = "2026-12-02"const styles = stylex.create({ card: { display: "grid", gap: space.lg, inlineSize: "min(100%, 22rem)" }, key: { margin: 0, fontSize: font.xs, color: color.muted, fontVariantNumeric: "tabular-nums" }, title: { margin: 0, fontSize: font.lg, fontWeight: 600, letterSpacing: "-0.01em" },})const Message = UiSchema.TaggedEnum({ PickedDue: { value: Schema.NullOr(Schema.String) } })const hintOf = (due: string | null) => { if (due === null) return "No due date" const days = epochDay(due) - epochDay(today) if (days === 0) return "Due today" const words = new Intl.RelativeTimeFormat("en-US", { numeric: "auto" }).format(days, "day") return days < 0 ? `Overdue: due ${words}` : `Due ${words}`}export const IssueDueDate = Html.component({ name: "IssueDueDate", model: Schema.Struct({ due: Schema.NullOr(Schema.String) }), message: Message,}).make({ init: () => ({ due: "2026-12-11" }), update: { PickedDue: ($, { value }) => $.evolve({ due: value }) }, view: (h, { due }) => h.div.attrs(sx(styles.card)).children( h.div.children( h.p.attrs(sx(styles.key)).children("ENG-142"), h.h3.attrs(sx(styles.title)).children("Export fails on workspaces over 10 GB"), ), DatePicker(h, { props: { label: "Due date", value: due, today, locale: "en-US", description: hintOf(due), name: "due" }, onEmit: { Picked: ({ value }) => Message.PickedDue({ value }) }, }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/date-pickerUsage
import { DatePicker } from "./ui/uicontext/components/DatePicker.ts"const Message = UiSchema.TaggedEnum({ PickedDue: { value: Schema.NullOr(Schema.String) } })// `today` comes from the app, in the reader's time zone: the picker never reads the clockexport const DueDate = (h: Html.H<typeof Message.Type>, due: string | null, today: string) => DatePicker(h, { props: { label: "Due date", value: due, today }, onEmit: { Picked: ({ value }) => Message.PickedDue({ value }) }, })Examples
Weekends off
Weekends and holidays are struck through and can't be picked; typing one says why. The UK week starts on Monday.
Weekdays, from tomorrow. Not on bank holidays.
Delivery date
December 2026
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
No date
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { DatePicker } from "./ui/uicontext/components/DatePicker.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { space } from "./ui/uicontext/components/tokens.stylex.ts"// A delivery date: weekdays only, no holidays, from tomorrow to eight weeks out. Weekends and// holidays are struck through and can't be picked; typing one says why. The week starts on Monday// in the UK.const today = "2026-12-02"const styles = stylex.create({ form: { display: "grid", gap: space.md, inlineSize: "min(100%, 20rem)" },})const Message = UiSchema.TaggedEnum({ PickedDelivery: { value: Schema.NullOr(Schema.String) } })export const DeliveryDate = Html.component({ name: "DeliveryDate", model: Schema.Struct({ delivery: Schema.NullOr(Schema.String) }), message: Message,}).make({ init: () => ({ delivery: null }), update: { PickedDelivery: ($, { value }) => $.evolve({ delivery: value }) }, view: (h, { delivery }) => h.div.attrs(sx(styles.form)).children( DatePicker(h, { props: { label: "Delivery date", value: delivery, today, locale: "en-GB", min: "2026-12-03", max: "2027-01-27", unavailable: { weekdays: [0, 6], dates: ["2026-12-25", "2026-12-28", "2027-01-01"] }, description: "Weekdays, from tomorrow. Not on bank holidays.", required: true, }, onEmit: { Picked: ({ value }) => Message.PickedDelivery({ value }) }, }), ),})API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
valuerequired | IsoDate | null | — | The day, as YYYY-MM-DD, or null for none |
todayrequired | IsoDate | — | Today in the reader's time zone, from the app: the calendar marks it and starts there |
locale | string | — | The reader's locale, for the field's order, month names and the week's first day |
labelrequired | string | — | The visible label, which names the field and the calendar |
hideLabel | boolean | — | Keep the label for screen readers only |
description | string | — | A hint under the field |
error | string | null | — | The app's message about the value; it wins over the field's own |
min | IsoDate | — | The first day allowed |
max | IsoDate | — | The last day allowed |
unavailable | UnavailableDates | — | Days that can't be picked: listed days and weekdays |
firstDayOfWeek | Int | — | The weekday weeks start on, 0 for Sunday; the locale's when left out |
id | string | — | The field's id, unique on the page |
name | string | — | Submits the value under this name in a form |
required | boolean | — | — |
disabled | boolean | — | — |
readOnly | boolean | — | — |
clearable | boolean | on | Show a clear button while there's a value; on by default |
typing | boolean | on | Show the box that takes typed words such as "next fri"; on by default |
Events
| Event | Payload | Description |
|---|---|---|
Picked | { value: IsoDate | null } | A day was picked, typed or cleared (null): store it and pass it back as value |
Agent actions
| Action | Description |
|---|---|
TypedDate | Set the date: an ISO day (2026-12-04), words such as "next fri", or "" to clear |