Skip to main content

Calendar

Month-view calendar. Reuses the DatePicker core month-grid algorithm (leading / trailing padding and today detection), with single / range / multiple selection, an optional date-range constraint, and arrow-key grid navigation.

Basic usage​

Basic usage
Dec 2026
SunMonTueWedThuFriSat
Current value: 2026-12-01
Dec 2026
SunMonTueWedThuFriSat
Jan 2027
SunMonTueWedThuFriSat
Current value: 2026-12-05, 2026-12-20
Dec 2026
SunMonTueWedThuFriSat
Current value: 2026-12-10
Dec 2026
SunMonTueWedThuFriSat

The first group is single selection (default, controlled); the second uses selection="range" — two clicks set the span — with panels={2} showing two month panels side by side; the third uses selection="multiple" where clicks toggle dates (sorted by time); the fourth constrains selectable dates to the 10th–20th of the current month via range, with out-of-range days natively disabled; the fifth uses mode="input" to fold the always-visible panel into an input that expands on click and collapses after selecting (closeOnSelect={false} keeps it open).

import { useState } from 'react'
import { LhCalendar } from '@lh-ui/react'

export default function Demo() {
const [date, setDate] = useState(new Date())

return <LhCalendar value={date} onChange={setDate} />
}

Calendar Props​

PropDescriptionTypeOptionsDefault
valueCurrent selection (controlled; a Date for single mode, a Date[] for range / multiple)Date | Date[]——
defaultValueDefault selection (uncontrolled)Date | Date[]——
selectionSelection modestringsingle / range / multiplesingle
rangeOptional date-range constraint[Date, Date]——
modeDisplay mode: always-visible panel / input with an expanding panelstringpanel / inputpanel
panelsNumber of month panels shown at once (flex-wrapped)number—1
placeholderPlaceholder text in input modestring——
closeOnSelectWhether the panel collapses after selecting in input modeboolean—true
sxShorthand layout propsSxProps——

Calendar events​

EventDescriptionCallback signatureVue equivalent
onChangeSelection changed (fires on both clicks and keyboard navigation)(value: Date | Date[]) => void@update:modelValue / @change
onSelectA date was selected(date: Date) => void@select
Controlled / uncontrolled

Passing value makes the component controlled (the selection is fully driven externally); omitting it (or passing defaultValue) uses the internal uncontrolled state. onChange fires in both modes, and the callback shape follows selection: a Date for single mode, a Date[] for range / multiple.

Slots → render props

plus's #header / #cell scoped slots map to the renderHeader({ year, month }) and renderCell(date) render functions here; without them the default title and day number are rendered.

Keyboard interaction​

Once the grid has focus: arrow keys move the date focus (left / right ±1 day, up / down ±7 days), Home / End jump to the row start / end, and PageUp / PageDown switch months; the focused date is selected immediately (out-of-range targets are clamped back into the selectable range, and stay unselected if still disabled).

Accessibility​

  • Grid semantics role="grid" (rows row, cells gridcell); today emits aria-current="date", selected cells emit aria-selected, and aria-label is yyyy-MM-dd
  • Roving tabindex: the focused date has tabindex=0, all other dates -1
  • Out-of-range dates are natively disabled and removed from interaction
  • The input in input mode is role="combobox" with aria-expanded and aria-haspopup="grid"

ref​

forwardRef<HTMLDivElement> — the root element (the panel container in panel mode; the input plus expanded panel in input mode).

Styles​

import '@lh-ui/react/theme.css'
import '@lh-ui/react/style/calendar'