Navigated to /docs/ui/components/calendar

Calendar

Month grid with date selection and optional built-in month and year navigation.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { Calendar } from "@tavojs/ui/calendar";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/calendar.

When to use

Use it when

Use Calendar for inline date selection. Supply selected and onSelect for selection, and year, month, and onMonthChange to enable and control the built-in navigation.

Choose something else when

Use DatePicker for a native date input with a floating calendar. Calendar navigation appears when onMonthChange is supplied; the application must update year and month after the callback.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

Selectable month and year

TSXCreate: src/components/examples/CalendarExample1.tsx
tsximport { createTavo } from "@tavojs/core";
import { Calendar } from "@tavojs/ui/calendar";
import { Text } from "@tavojs/ui";

type State = { year: number; month: number; selected: string };

export const CalendarExample1 = createTavo<Record<string, never>, State>({
  model: () => ({ year: 2026, month: 8, selected: "2026-09-07" }),
  view: ({ state, model }) => (
    <>
      <Calendar
        year={state.year}
        month={state.month}
        selected={state.selected}
        yearRange={{ start: 2020, end: 2030 }}
        onMonthChange={(year, month) => model.patch({ year, month })}
        onSelect={(selected) => model.set("selected", selected)}
      />
      <Text>Selected date: {state.selected}</Text>
    </>
  )
});

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
sizeSize

md

Control scale: sm, md, or lg when supported. Applies to Calendar.
disabledboolean

false

Disables the control when supported. Applies to Calendar.
aria-*unknown

ARIA attributes are passed through for accessible labeling and state. Applies to Calendar.
yearnumber

Displayed year.
monthnumber

Displayed zero-based month.
yearRange{ start: number; end: number }

Inclusive year options shown by the year selector.
onMonthChange(year: number, month: number) => void

Makes the month and year in the top heading selectable and requests a controlled visible-month change.
onSelect(value: string) => void

Runs when an enabled date is selected.

Complete TypeScript API

Import from @tavojs/ui/calendar. Published exports: Calendar, CalendarProps.

CalendarProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by Calendar.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by Calendar.

idstring

No

Inherited id attribute accepted by Calendar.

rolestring

No

Inherited role attribute accepted by Calendar.

styleRecord<string, unknown>

No

Inherited style attribute accepted by Calendar.

titlestring

No

Inherited title attribute accepted by Calendar.

tabIndexnumber

No

Inherited tabIndex attribute accepted by Calendar.

hiddenboolean

No

Inherited hidden attribute accepted by Calendar.

disabledboolean

No

Disables the control when supported. Applies to Calendar.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by Calendar.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by Calendar.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by Calendar.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by Calendar.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by Calendar.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by Calendar.

yearnumber

No

Displayed year.

monthnumber

No

Displayed zero-based month.

yearRange{ start: number; end: number; }

No

Inclusive year options shown by the year selector.

selectedstring

No

Inherited selected attribute accepted by Calendar.

minstring

No

Inherited min attribute accepted by Calendar.

maxstring

No

Inherited max attribute accepted by Calendar.

localestring

No

Inherited locale attribute accepted by Calendar.

onSelect(value: string) => void

No

Runs when an enabled date is selected.

onMonthChange(year: number, month: number) => void

No

Makes the month and year in the top heading selectable and requests a controlled visible-month change.

State ownership and DOM target

ConcernContract
StateUpdate selected in onSelect. Supply year, month, and onMonthChange to enable and control the built-in month and year navigation.
DOM targetNative input attributes target the owned form control; wrapper-specific props stay on the documented component root.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Use DatePicker for a native date input with a floating calendar. Calendar navigation appears when onMonthChange is supplied; the application must update year and month after the callback.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Form components pass through native attributes and should be paired with visible labels or accessible names.

  • Use Field, FormLabel, FormControlLabel, or aria-label for labeling.

  • Preserve native input semantics whenever possible.

  • Expose validation with error text and aria-invalid where relevant.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/calendar
Explicit CSS import@tavojs/ui/css/calendar
PreviewInteractive preview available on this page