November 2026
SunMonTueWedThuFriSat

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/calendar.ts
    import type { Component } from "@effect/ui"
    import type { Html } from "@effect/ui/html"
    import type { Calendar } from "@effect/ui-kit"
    import { DateTime } from "effect"
    import { cn } from "#lib/cn"
    
    /** What the kit's `Calendar` passes to its `view` closure. A `DatePicker`'s parts fit too. */
    export type CalendarParts = Pick<
      Component.Headless.Parts<typeof Calendar>,
      "root" | "heading" | "previous" | "next" | "grid" | "weekday" | "cell" | "day" | "weeks" | "weekdays" | "title"
    >
    
    const rootVariants = {
      card: "rounded-lg border bg-card p-3 shadow-sm",
      ghost: ""
    } as const
    
    const navClass = "inline-grid size-7 shrink-0 place-items-center rounded-sm border border-input bg-background " +
      "text-foreground transition-colors duration-150 hover:bg-accent data-[disabled]:cursor-not-allowed " +
      "data-[disabled]:opacity-40 data-[disabled]:hover:bg-background [&_svg]:size-3.5 rtl:[&_svg]:rotate-180"
    
    const cellClass = "p-0 text-center"
    
    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-[selected]:data-[today]:bg-accent data-[today]:font-semibold " +
      "not-data-[selected]:data-[outside-month]:text-muted-foreground not-data-[selected]:data-[outside-month]:opacity-55 " +
      "data-[selected]:bg-brand data-[selected]:text-brand-foreground data-[selected]: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"
    
    const Chevron = <Msg>(h: Html.H<Msg>, d: string) =>
      h.el("svg")
        .attrs({ viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" })
        .children(h.el("path").attr("d", d))
    
    /** The element around the header and the grid. `variant: "ghost"` drops the card, for a calendar inside one. */
    export const CalendarRoot = <Msg>(
      h: Html.H<Msg>,
      calendar: CalendarParts,
      options: { readonly variant?: keyof typeof rootVariants | undefined; readonly class?: string | undefined } = {}
    ) =>
      calendar.root(
        h.div.class(
          cn(
            "inline-flex w-fit flex-col gap-2.5 text-[13px] outline-none data-[disabled]:opacity-60",
            rootVariants[options.variant ?? "card"],
            options.class
          )
        )
      )
    
    /** The month and year. It labels the grid, so keep it in the tree: hide it with `class: "sr-only"`. */
    export const CalendarHeading = <Msg>(
      h: Html.H<Msg>,
      calendar: CalendarParts,
      options: { readonly class?: string | undefined } = {}
    ) =>
      calendar.heading(h.div.class(cn("flex-1 text-center text-[13px] font-medium", options.class))).children(
        calendar.title
      )
    
    export const CalendarPrevious = <Msg>(
      h: Html.H<Msg>,
      calendar: CalendarParts,
      options: { readonly class?: string | undefined } = {}
    ) => calendar.previous(h.button.class(cn(navClass, options.class))).children(Chevron(h, "M15 6l-6 6 6 6"))
    
    export const CalendarNext = <Msg>(
      h: Html.H<Msg>,
      calendar: CalendarParts,
      options: { readonly class?: string | undefined } = {}
    ) => calendar.next(h.button.class(cn(navClass, options.class))).children(Chevron(h, "M9 6l6 6-6 6"))
    
    /** The usual header: previous, the title, next. Compose the three parts yourself for another layout. */
    export const CalendarHeader = <Msg>(
      h: Html.H<Msg>,
      calendar: CalendarParts,
      options: { readonly class?: string | undefined } = {}
    ) =>
      h.div.class(cn("flex min-h-7 items-center gap-1", options.class)).children(
        CalendarPrevious(h, calendar),
        CalendarHeading(h, calendar),
        CalendarNext(h, calendar)
      )
    
    /**
     * The whole table: the weekday row and a button for every day.
     * `unavailable` strikes a day through: it stays focusable but can't be picked.
     */
    export const CalendarGrid = <Msg>(
      h: Html.H<Msg>,
      calendar: CalendarParts,
      options: {
        readonly unavailable?: ((date: DateTime.Utc) => boolean) | undefined
        readonly class?: string | undefined
        /** Replace the look of every cell or day, as `#ui/range-calendar` does. */
        readonly cellClass?: string | undefined
        readonly dayClass?: string | undefined
      } = {}
    ) =>
      calendar.grid(h.table.class(cn("border-separate border-spacing-x-0 border-spacing-y-0.5", options.class))).children(
        h.thead(
          h.tr(
            ...calendar.weekdays.map((weekday, index) =>
              calendar.weekday({
                element: h.th.class("h-6 w-8 p-0 text-xs font-normal text-muted-foreground"),
                index
              }).children(weekday.short)
            )
          )
        ),
        h.tbody(
          ...calendar.weeks.map((week) =>
            h.tr(
              ...week.map((date) =>
                calendar.cell({ element: h.td.class(options.cellClass ?? cellClass), date }).children(
                  calendar.day({
                    element: h.button.class(options.dayClass ?? dayClass),
                    date,
                    unavailable: options.unavailable?.(date)
                  }).children(String(DateTime.getPartUtc(date, "day")))
                )
              )
            )
          )
        )
      )
    
  3. Import it

    import { CalendarRoot, CalendarHeading, CalendarPrevious, CalendarNext, CalendarHeader, CalendarGrid } from "#ui/calendar"
    

Usage

Basic.ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { Calendar } from "@effect/ui-kit"
import { DateTime, Schema } from "effect"
import { CalendarGrid, CalendarHeader, CalendarRoot } from "#ui/calendar"

const CalendarBasicMessage = UiSchema.TaggedEnum({
  PickedCalendarDate: { date: Schema.DateTimeUtc },
  RequestedCalendarMonth: { month: Schema.DateTimeUtc }
})

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

export const CalendarBasic = Html.component({
  name: "CalendarBasic",
  model: Schema.Struct({
    date: Schema.NullOr(Schema.DateTimeUtc),
    month: Schema.DateTimeUtc
  }),
  message: CalendarBasicMessage
}).make({
  init: () => ({ date: today, month: today }),
  update: {
    PickedCalendarDate: ($, { date }) => $.evolve({ date }),
    RequestedCalendarMonth: ($, { month }) => $.evolve({ month })
  },
  view: (h, model) =>
    Calendar(h, {
      props: { value: model.date, month: model.month, today, locale: "en-US" },
      onEmit: {
        Picked: ({ date }) => CalendarBasicMessage.PickedCalendarDate({ date }),
        RequestedMonth: ({ month }) => CalendarBasicMessage.RequestedCalendarMonth({ month })
      },
      view: (calendar) =>
        CalendarRoot(h, calendar).children(
          CalendarHeader(h, calendar),
          CalendarGrid(h, calendar)
        )
    })
})

Examples

Min and max

Days outside the bounds are disabled, and keyboard focus stops at them.

November 2026
SunMonTueWedThuFriSat

Bookable from today and 30 days ahead.

Unavailable days

Mark single days as unavailable from the view, here every weekend.

November 2026
SunMonTueWedThuFriSat

Weekends keep their place in the arrow-key order but can't be picked.

Month and year controls

The month is a prop, so selects and a Today button can jump anywhere.

November 2026
SunMonTueWedThuFriSat
2026-11-26

In a card

A borderless calendar inside a card that prints the picked date.

Schedule delivery

Pick the day the courier should arrive.

November 2026
SunMonTueWedThuFriSat
Monday, November 30, 2026

Locale and week start

Titles, weekday names and the first day of the week follow the locale.

November 2026
MoDiMiDoFrSaSo
Week starts on

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. Keep it mounted across month changes.
headingAny element showing calendar.title; it labels the grid.
previousThe <button> that asks for the previous month.
nextThe <button> that asks for the next month.
gridThe <table> with role="grid".
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? }).
weeks, weekdays, month, titleValues: the grid's dates in whole weeks, the weekday names, the first of the month and its title.

API reference

Props

PropTypeDescription
valueDateTime | nullThe selected date, normalized to midnight UTC.
monthDateTimeAny date in the month to show. Controlled.
todayDateTimeThe current day, passed in so rendering stays pure.
min / maxDateTimeInclusive bounds. Days outside are natively disabled.
firstDayOfWeek0 | 1 | ... | 6Sunday is 0. Defaults to the locale's first day.
localestring | string[]BCP 47 tag for titles, weekday names and day labels.
disabledbooleanDisables every button and all interaction.
readOnlybooleanKeeps focus and navigation but suppresses Picked.

Events

EventDescription
Picked{ date }: the user pressed an enabled, available day.
RequestedMonth{ month }: an arrow or the keyboard asked for another month.

Data attributes

AttributeDescription
data-selectedOn day: the day is value.
data-todayOn day: the day is today.
data-outside-monthOn day: the day belongs to the previous or next month.
data-unavailableOn day: drawn with unavailable: true.
data-focusedOn day: the day has keyboard focus.
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.

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