Calendar
A month of days in a grid, for picking one date.
<arc-calendar>Overview
Calendar shows one month as a grid of days, with previous and next month buttons in the header. Use it on its own or inside a date picker or scheduling screen.
The selected date is an ISO string (YYYY-MM-DD) in value. The visible month is set separately by month (0-based) and year, so you can change the month from code without changing the selection. It doesn't follow value: it shows the current month until you set month and year.
Month and weekday names come from locale (by default the document's lang, then the browser's language). The week starts on the locale's usual first day unless you set first-day-of-week (1 = Monday to 7 = Sunday).
Arrow keys move a focus ring through the grid and cross into the next or previous month at the edges. Enter or Space selects the focused day. arc-change fires with the selected date, and arc-month-change fires when the visible month changes, so you can load events or availability for the new month.
Guidelines
Do
- Set min and max when only some dates are valid
- Load events or availability on arc-month-change
- Pair it with a text input, or use DatePicker, when people should be able to type a date too
- Set month and year to the month of the initial value so the selection is visible on load
- Give it at least 280px of width so the days are easy to tap
Don't
- Don't use it to pick a time. It handles dates only
- Don't set min later than max. Every day ends up disabled
- Don't use it to pick a range. It selects one date, so use DateRangePicker
Features
- Days from the neighboring months fill out a 6-row grid at 30% opacity
- Today gets an inset `--border-bright` ring. The selected date gets a solid accent-primary background and bold weight
- `min` and `max` (ISO strings) disable and dim the days outside the range
- Day numbers are monospace so the columns line up
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-calendar></arc-calendar>import { Calendar } from '@arclux/arc-ui-react';
export default function Example() {
return (
<Calendar />
);
}<script setup>
import { Calendar } from '@arclux/arc-ui-vue';
</script>
<template>
<Calendar />
</template><script>
import { Calendar } from '@arclux/arc-ui-svelte';
</script>
<Calendar />import { Component } from '@angular/core';
import { Calendar } from '@arclux/arc-ui-angular';
@Component({
imports: [Calendar],
template: `
<arc-calendar></arc-calendar>
`,
})
export class MyComponent {}import { Calendar } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Calendar />
);
}import { Calendar } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Calendar />
);
}API
localestring''- BCP 47 tag used for month and weekday names. Defaults to the document's
lang, then the browser's language. valuestring''- The selected date as an ISO string (YYYY-MM-DD). Empty string means no date is selected.
minstring''- Minimum selectable date as an ISO string. Days before this date are disabled.
maxstring''- Maximum selectable date as an ISO string. Days after this date are disabled.
monthnumber- The currently displayed month (0-based, 0=January). Defaults to the current month. Clamped to 0-11: an out-of-range month reached
new Date(year, month), which silently rolls into another year. yearnumber- The currently displayed year. Defaults to the current year.
firstDayOfWeek0|1|2|3|4|5|6|70- Which day the week starts on, 1 = Monday … 7 = Sunday. 0 (the default) follows the locale's own convention. An unrecognised value falls back to 0 rather than reaching weekdayOffset() and reordering the week arbitrarily.
Events
arc-month-changedetail:{ month: number, year: number }- Fired when the visible month or year changes via the navigation buttons.
arc-change- Fired when a date is selected.
event.detail.valuecontains the ISO date string (YYYY-MM-DD).