Calendar
A month calendar for selecting a date with month and year navigation, date bounds, disabled dates, and selection states.
Import Calendar
Import Calendar from Tavix:
import { Calendar, Calendar2 } from "tavix";Component API
<Calendar
value=""
onChange
minDate
maxDate
disabledDates={[]}
minYear
maxYear
weekStartsOn={0}
showOutsideDays={true}
className
/>Props
value: Selected date inYYYY-MM-DDformat.onChange: Callback called with the selected date inYYYY-MM-DDformat.minDate: Earliest selectable date inYYYY-MM-DDformat.maxDate: Latest selectable date inYYYY-MM-DDformat.disabledDates: Dates that cannot be selected, provided asYYYY-MM-DDstrings.minYear: Earliest year available in the year selector. Defaults to1900.maxYear: Latest year available in the year selector. Defaults to2100.weekStartsOn: First day of the week, where0is Sunday and1is Monday. Defaults to0.showOutsideDays: Displays days from adjacent months in the calendar grid. Defaults totrue.className: Additional classes applied to the calendar.
Behavior
- Renders the selected month as a 42-cell calendar grid.
- Uses
valueas the selected date and marks today separately. - Calls
onChangewith aYYYY-MM-DDvalue when a selectable day is chosen. - Prevents dates before
minDateor aftermaxDatefrom being selected. - Prevents dates listed in
disabledDatesfrom being selected. - Limits year navigation to
minYearandmaxYear, also constrained byminDateandmaxDate. - Supports moving between months and years.
- Supports a Today action for quickly returning to the current date.
- Shows adjacent-month dates when
showOutsideDaysistrue. - Keeps outside-month dates visible but does not treat them as part of the active month.
Examples
Basic calendar
<Calendar
value={date}
onChange={setDate}
/>;Calendar with date bounds
<Calendar
value="2026-09-15"
onChange={setDate}
minDate="2026-01-01"
maxDate="2026-12-31"
/>;Disabled dates
<Calendar
value={date}
onChange={setDate}
disabledDates={[
"2026-09-18",
"2026-09-19",
"2026-09-25",
]}
/>;Monday as the first day of the week
<Calendar
value={date}
onChange={setDate}
weekStartsOn={1}
/>;Hide outside-month days
<Calendar
value={date}
onChange={setDate}
showOutsideDays={false}
/>;Controlled calendar
const [date, setDate] = useState("2026-09-15");
<Calendar
value={date}
onChange={(nextDate) => {
setDate(nextDate);
}}
/>;Date format
Calendar values and date constraints use the YYYY-MM-DD format:
<Calendar
value="2026-09-15"
minDate="2026-01-01"
maxDate="2026-12-31"
onChange={(date) => {
console.log(date); // "2026-09-15"
}}
/>;Accessibility
- Day controls expose selected and today states.
- Use a controlled
valueso the selected date remains synchronized with application state. - Keep date bounds and disabled dates consistent with the surrounding form validation.
- Use a clear label or surrounding field label when the calendar is used as part of a form.
Notes
- Calendar is controlled through
valueandonChange. - Dates are emitted as strings rather than JavaScript
Dateobjects. - The default year range is
1900through2100. minDateandmaxDatefurther constrain the available date and year range.- Date strings should use zero-padded months and days, such as
2026-09-05.