Skip to content

Mini Calendar

Compact month calendar generated with vanilla JS and styled with pure CSS: selectable days, today marker, month navigation and full arrow-key support.

Also known as: small calendar widget, month calendar, date picker calendar, compact calendar

Mini Calendar live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A compact month calendar generated with vanilla JavaScript and styled with pure CSS. It shows one month at a time, marks today with a dot, lets users pick a day with mouse or keyboard and reports the choice in a footer. Use it in sidebars, booking widgets, dashboards or as the base of a custom date picker.

How it works

The root .mc-cal carries data-mc-calendar plus three options: data-week-start, data-locale and data-selected. The markup only contains the shell: the .mc-head row with .mc-prev, the .mc-month heading and .mc-next, an empty table.mc-grid, and the .mc-foot row with the .mc-picked text and the .mc-today button.

On DOMContentLoaded the script fills the header row with weekday names from Intl.DateTimeFormat, so they follow the chosen locale, and renders the month into .mc-body. It always draws six weeks so the calendar never changes height. Days of the current month become button.mc-day elements with a data-date value in YYYY-MM-DD format; days of the previous and next month are muted .mc-day--outside spans. The selected day gets aria-pressed="true" and a filled circle, and today gets aria-current="date", shown as an accent number with a small dot.

Clicking a day, or pressing the Today button, selects it, updates data-selected on the root and fires a bubbling mc:select event whose detail.date holds the ISO date. The arrow buttons move one month back or forward.

Customization

  • data-week-start="1" on .mc-cal: use 0 to start weeks on Sunday.
  • data-locale="en-US": any BCP 47 tag such as de-DE or fr-FR translates the month name, the weekday headers and the formatted dates.
  • data-selected: set an ISO date like 2026-03-14 to preselect a day; leave it empty to select today.
  • --mc-accent and --mc-accent-soft: the selected day, today marker, hover circle and navigation buttons.
  • --mc-size: the maximum diameter of each day circle.
  • --mc-radius and max-width: 21rem in .mc-cal: the card corner radius and width.
  • Listen for mc:select on the root to fill a hidden input or load events for the chosen date.

Use cases

  • Sidebars: a compact month view with a today marker takes little space
  • Booking widgets: visitors pick a day and the choice is reported in the footer
  • Dashboards: arrow keys and Home, End, PageUp and PageDown move through dates quickly
  • Custom date pickers: the select event returns an ISO date to fill a hidden input

Accessibility

The calendar is a real data table labelled by the month heading through aria-labelledby, with weekday column headers whose abbr titles give the full names. Each day button has a full date aria-label such as "Thursday, October 15, 2026" and uses aria-pressed for the selection. A roving tabindex keeps only one day in the Tab order: arrow keys move by day and week, Home and End jump to the start and end of the week, PageUp and PageDown change the month (with Shift, the year). The month heading and the selection text are aria-live regions. Every control has a visible :focus-visible outline, and prefers-reduced-motion turns off the transitions.

Usage notes

The calendar needs JavaScript to render its days. Several calendars can share a page; each gets its own heading ID.

Mini Calendar at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
None
Layout
Responsive, works on mobile
Category
Calendars
License
Free for personal and commercial use

Questions about this template

Can I use the Mini Calendar code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Mini Calendar – Pure CSS calendars component screenshot
Mini Calendar · Pure CSS Calendars

More Calendars

Month Calendar with Events – Tailwind CSS calendars preview

Month Calendar with Events

Tailwind CSS month calendar with colored event pills, today highlight, prev/next navigation, keyboard support and a day agenda.