Calendar
A month calendar for picking a date. Under each date you can add a line of lunar text, or a moon phase.
Demo
十一月
一二三四五六日
今天 丙午年十月初十
十一月
一二三四五六日
今天 丙午年十月初十7 日立冬22 日小雪
November
MTWTFSS
Today: lunar month 10, day 10Nov 7, Start of WinterNov 22, Minor Snow
<div class="hao-row" style="gap:var(--hao-space-6);align-items:flex-start">
<div class="hao-cal" data-hao-calendar data-mode="lunar" data-today="2026-11-18" data-value="2026-11-20">
<div class="hao-cal__head">
<h2 class="hao-cal__title">十一月</h2>
<span>
<button class="hao-cal__nav" aria-label="上个月"><i class="hao-icon hao-icon--chevron-left" aria-hidden="true"></i></button>
<button class="hao-cal__nav" aria-label="下个月"><i class="hao-icon hao-icon--chevron-right" aria-hidden="true"></i></button>
</span>
</div>
<div class="hao-cal__grid">
<span class="hao-cal__dow">一</span>
<span class="hao-cal__dow">二</span>
<span class="hao-cal__dow">三</span>
<span class="hao-cal__dow">四</span>
<span class="hao-cal__dow">五</span>
<span class="hao-cal__dow">六</span>
<span class="hao-cal__dow">日</span>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">26<small class="hao-cal__lunar">十七</small></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">27<small class="hao-cal__lunar">十八</small></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">28<small class="hao-cal__lunar">十九</small></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">29<small class="hao-cal__lunar">二十</small></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">30<small class="hao-cal__lunar">廿一</small></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">31<small class="hao-cal__lunar">廿二</small></button>
<button class="hao-cal__day">1<small class="hao-cal__lunar">廿三</small></button>
<button class="hao-cal__day">2<small class="hao-cal__lunar">廿四</small></button>
<button class="hao-cal__day">3<small class="hao-cal__lunar">廿五</small></button>
<button class="hao-cal__day">4<small class="hao-cal__lunar">廿六</small></button>
<button class="hao-cal__day">5<small class="hao-cal__lunar">廿七</small></button>
<button class="hao-cal__day">6<small class="hao-cal__lunar">廿八</small></button>
<button class="hao-cal__day">7<small>立冬</small></button>
<button class="hao-cal__day">8<small class="hao-cal__lunar">三十</small></button>
<button class="hao-cal__day">9<small class="hao-cal__lunar hao-cal__lunar--first">十月</small></button>
<button class="hao-cal__day">10<small class="hao-cal__lunar">初二</small></button>
<button class="hao-cal__day">11<small class="hao-cal__lunar">初三</small></button>
<button class="hao-cal__day">12<small class="hao-cal__lunar">初四</small></button>
<button class="hao-cal__day">13<small class="hao-cal__lunar">初五</small></button>
<button class="hao-cal__day">14<small class="hao-cal__lunar">初六</small></button>
<button class="hao-cal__day">15<small class="hao-cal__lunar">初七</small></button>
<button class="hao-cal__day">16<small class="hao-cal__lunar">初八</small></button>
<button class="hao-cal__day">17<small class="hao-cal__lunar">初九</small></button>
<button class="hao-cal__day" aria-current="date">18<small class="hao-cal__lunar">初十</small></button>
<button class="hao-cal__day">19<small class="hao-cal__lunar">十一</small></button>
<button class="hao-cal__day" aria-pressed="true">20<small class="hao-cal__lunar">十二</small></button>
<button class="hao-cal__day">21<small class="hao-cal__lunar">十三</small></button>
<button class="hao-cal__day">22<small>小雪</small></button>
<button class="hao-cal__day">23<small class="hao-cal__lunar">十五</small></button>
<button class="hao-cal__day">24<small class="hao-cal__lunar">十六</small></button>
<button class="hao-cal__day">25<small class="hao-cal__lunar">十七</small></button>
<button class="hao-cal__day">26<small class="hao-cal__lunar">十八</small></button>
<button class="hao-cal__day">27<small class="hao-cal__lunar">十九</small></button>
<button class="hao-cal__day">28<small class="hao-cal__lunar">二十</small></button>
<button class="hao-cal__day">29<small class="hao-cal__lunar">廿一</small></button>
<button class="hao-cal__day">30<small class="hao-cal__lunar">廿二</small></button>
</div>
<p class="hao-cal__foot"><span>今天 丙午年十月初十</span></p>
</div>
<div class="hao-cal" data-hao-calendar data-mode="moon" data-today="2026-11-18" data-value="2026-11-20">
<div class="hao-cal__head">
<h2 class="hao-cal__title">十一月</h2>
<span>
<button class="hao-cal__nav" aria-label="上个月"><i class="hao-icon hao-icon--chevron-left" aria-hidden="true"></i></button>
<button class="hao-cal__nav" aria-label="下个月"><i class="hao-icon hao-icon--chevron-right" aria-hidden="true"></i></button>
</span>
</div>
<div class="hao-cal__grid">
<span class="hao-cal__dow">一</span>
<span class="hao-cal__dow">二</span>
<span class="hao-cal__dow">三</span>
<span class="hao-cal__dow">四</span>
<span class="hao-cal__dow">五</span>
<span class="hao-cal__dow">六</span>
<span class="hao-cal__dow">日</span>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">26<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.98"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">27<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.94"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">28<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.89"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">29<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.81"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">30<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.72"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">31<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.62"></i></button>
<button class="hao-cal__day">1<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.52"></i></button>
<button class="hao-cal__day">2<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.41"></i></button>
<button class="hao-cal__day">3<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.31"></i></button>
<button class="hao-cal__day">4<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.21"></i></button>
<button class="hao-cal__day">5<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.13"></i></button>
<button class="hao-cal__day">6<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.07"></i></button>
<button class="hao-cal__day">7<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.03"></i></button>
<button class="hao-cal__day">8<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.00"></i></button>
<button class="hao-cal__day">9<i class="hao-moon hao-moon--xs" style="--p:0.00"></i></button>
<button class="hao-cal__day">10<i class="hao-moon hao-moon--xs" style="--p:0.01"></i></button>
<button class="hao-cal__day">11<i class="hao-moon hao-moon--xs" style="--p:0.04"></i></button>
<button class="hao-cal__day">12<i class="hao-moon hao-moon--xs" style="--p:0.10"></i></button>
<button class="hao-cal__day">13<i class="hao-moon hao-moon--xs" style="--p:0.17"></i></button>
<button class="hao-cal__day">14<i class="hao-moon hao-moon--xs" style="--p:0.26"></i></button>
<button class="hao-cal__day">15<i class="hao-moon hao-moon--xs" style="--p:0.36"></i></button>
<button class="hao-cal__day">16<i class="hao-moon hao-moon--xs" style="--p:0.46"></i></button>
<button class="hao-cal__day">17<i class="hao-moon hao-moon--xs" style="--p:0.57"></i></button>
<button class="hao-cal__day" aria-current="date">18<i class="hao-moon hao-moon--xs" style="--p:0.67"></i></button>
<button class="hao-cal__day">19<i class="hao-moon hao-moon--xs" style="--p:0.76"></i></button>
<button class="hao-cal__day" aria-pressed="true">20<i class="hao-moon hao-moon--xs" style="--p:0.85"></i></button>
<button class="hao-cal__day">21<i class="hao-moon hao-moon--xs" style="--p:0.92"></i></button>
<button class="hao-cal__day">22<i class="hao-moon hao-moon--xs" style="--p:0.97"></i></button>
<button class="hao-cal__day">23<i class="hao-moon hao-moon--xs" style="--p:0.99"></i></button>
<button class="hao-cal__day">24<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:1.00"></i></button>
<button class="hao-cal__day">25<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.98"></i></button>
<button class="hao-cal__day">26<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.94"></i></button>
<button class="hao-cal__day">27<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.89"></i></button>
<button class="hao-cal__day">28<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.81"></i></button>
<button class="hao-cal__day">29<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.72"></i></button>
<button class="hao-cal__day">30<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.62"></i></button>
</div>
<p class="hao-cal__foot"><span>今天 丙午年十月初十</span><span><i></i>7 日立冬</span><span><i></i>22 日小雪</span></p>
</div>
</div><div class="hao-row" style="gap:var(--hao-space-6);align-items:flex-start">
<div class="hao-cal" data-hao-calendar data-mode="moon" data-today="2026-11-18" data-value="2026-11-20">
<div class="hao-cal__head">
<h2 class="hao-cal__title">November</h2>
<span>
<button class="hao-cal__nav" aria-label="Previous month"><i class="hao-icon hao-icon--chevron-left" aria-hidden="true"></i></button>
<button class="hao-cal__nav" aria-label="Next month"><i class="hao-icon hao-icon--chevron-right" aria-hidden="true"></i></button>
</span>
</div>
<div class="hao-cal__grid">
<span class="hao-cal__dow">M</span>
<span class="hao-cal__dow">T</span>
<span class="hao-cal__dow">W</span>
<span class="hao-cal__dow">T</span>
<span class="hao-cal__dow">F</span>
<span class="hao-cal__dow">S</span>
<span class="hao-cal__dow">S</span>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">26<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.98"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">27<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.94"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">28<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.89"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">29<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.81"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">30<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.72"></i></button>
<button class="hao-cal__day hao-cal__day--out" tabindex="-1">31<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.62"></i></button>
<button class="hao-cal__day">1<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.52"></i></button>
<button class="hao-cal__day">2<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.41"></i></button>
<button class="hao-cal__day">3<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.31"></i></button>
<button class="hao-cal__day">4<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.21"></i></button>
<button class="hao-cal__day">5<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.13"></i></button>
<button class="hao-cal__day">6<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.07"></i></button>
<button class="hao-cal__day">7<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.03"></i></button>
<button class="hao-cal__day">8<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.00"></i></button>
<button class="hao-cal__day">9<i class="hao-moon hao-moon--xs" style="--p:0.00"></i></button>
<button class="hao-cal__day">10<i class="hao-moon hao-moon--xs" style="--p:0.01"></i></button>
<button class="hao-cal__day">11<i class="hao-moon hao-moon--xs" style="--p:0.04"></i></button>
<button class="hao-cal__day">12<i class="hao-moon hao-moon--xs" style="--p:0.10"></i></button>
<button class="hao-cal__day">13<i class="hao-moon hao-moon--xs" style="--p:0.17"></i></button>
<button class="hao-cal__day">14<i class="hao-moon hao-moon--xs" style="--p:0.26"></i></button>
<button class="hao-cal__day">15<i class="hao-moon hao-moon--xs" style="--p:0.36"></i></button>
<button class="hao-cal__day">16<i class="hao-moon hao-moon--xs" style="--p:0.46"></i></button>
<button class="hao-cal__day">17<i class="hao-moon hao-moon--xs" style="--p:0.57"></i></button>
<button class="hao-cal__day" aria-current="date">18<i class="hao-moon hao-moon--xs" style="--p:0.67"></i></button>
<button class="hao-cal__day">19<i class="hao-moon hao-moon--xs" style="--p:0.76"></i></button>
<button class="hao-cal__day" aria-pressed="true">20<i class="hao-moon hao-moon--xs" style="--p:0.85"></i></button>
<button class="hao-cal__day">21<i class="hao-moon hao-moon--xs" style="--p:0.92"></i></button>
<button class="hao-cal__day">22<i class="hao-moon hao-moon--xs" style="--p:0.97"></i></button>
<button class="hao-cal__day">23<i class="hao-moon hao-moon--xs" style="--p:0.99"></i></button>
<button class="hao-cal__day">24<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:1.00"></i></button>
<button class="hao-cal__day">25<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.98"></i></button>
<button class="hao-cal__day">26<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.94"></i></button>
<button class="hao-cal__day">27<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.89"></i></button>
<button class="hao-cal__day">28<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.81"></i></button>
<button class="hao-cal__day">29<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.72"></i></button>
<button class="hao-cal__day">30<i class="hao-moon hao-moon--xs hao-moon--wane" style="--p:0.62"></i></button>
</div>
<p class="hao-cal__foot">
<span>Today: lunar month 10, day 10</span>
<span><i></i>Nov 7, Start of Winter</span>
<span><i></i>Nov 22, Minor Snow</span>
</p>
</div>
</div>Usage
Inside .hao-cal are .hao-cal__head (the month title in the Song typeface and the month-paging buttons), .hao-cal__grid (seven columns: a row of weekday names, then the date buttons .hao-cal__day), and an optional .hao-cal__foot. Today gets aria-current="date", the chosen date gets aria-pressed="true", and dates filling in from the neighboring months get hao-cal__day--out.
What goes under a date: pick one of three
| Way | Markup | Look |
|---|---|---|
| Lunar text | <small class="hao-cal__lunar">初十</small> | A lunar day under every date; on the first of the lunar month, the month’s name (十月) with hao-cal__lunar--first; on a solar term, the term’s name instead, in a plain <small> with no class, in gold ink |
| Moon phase | <i class="hao-moon hao-moon--xs" style="--p:.6"> | A small moon under every date; in the second half of the month add hao-moon--wane, and the lit side moves to the left |
| Nothing | The cleanest, for when a date is all you’re choosing |
- Use only one of the three in a calendar; lunar text and a moon phase together won’t fit in the cells.
- For the moon phase,
--pis the share of the face that is lit: 0 is the new moon (the first of the lunar month), 1 the full moon (around the fifteenth). The lit side sits right in the first half of the month and left in the second—the view from the Northern Hemisphere. - The footer (
.hao-cal__foot) gives today’s sexagenary year and lunar day; with a moon phase, or in English, list the month’s solar terms there too. - English interfaces show no lunar text; use the moon phase, and list the solar terms by English name in the footer.
- The week starts on Monday. An English interface may follow local custom and start on Sunday.
- Today is
tintin bold; the chosen date is filledtint; when the two fall on the same day, it shows as chosen. - Arrow keys move between dates, Enter selects, and the paging keys change the month.
Where the data comes from
- Never hand-write lunar dates, and never work them out yourself; use calendar data. The internationalization interface built into browsers and systems provides it (set the calendar to
chinese) and gives the month, the day, and the sexagenary year. - The moon phase converts straight from the lunar day: the first of the month is the new moon, around the fifteenth the full moon. To pin down the exact phase of a given day, use an astronomical ephemeris library.
- Solar terms call for an ephemeris library or an officially published table. The Start of Winter (立冬) and Minor Snow (小雪) dates and the lunar dates in the preview come from system calendar data for November 2026.
Behavior (when the behavior script is loaded)
- Add
data-hao-calendarto the<div class="hao-cal">and the script takes over what’s inside and draws a real month calendar. Attributes:data-mode(lunar,moon, orplain),data-value(the chosen date, written like2026-11-20),data-today(pins “today” to a given date, for demos; left out, it’s the real today), anddata-terms="off"(no solar term marks). - The month-paging buttons work. Tap a day and it’s selected; the calendar fires a
hao-changeevent carrying the date and the lunar date. - Keyboard: the arrow keys move by day or by week, and leaving the month pages to the next on its own; Home and End go to the start and end of the week; Page Up and Page Down change the month; Enter or Space selects. The whole calendar is a single Tab stop.
- The script-drawn calendar is three layers deep—table, row, cell (
.hao-cal__row, one week per row;.hao-cal__cell, wrapping the date button)—so a screen reader can announce the weekday and the week number. - Every date has a full spoken form (year, month, and day; weekday; lunar date; solar term) for screen readers.
- Lunar dates and moon phases are computed live, on the browser’s built-in Chinese calendar data. Where the browser doesn’t support it, the calendar falls back to the look without lunar text.
- The browser’s lunar data is off by a day on a handful of dates. When a new moon falls right at midnight, it can land the first of the lunar month on the neighboring day; in testing, for February 6, 2027 it gives the 30th of the twelfth lunar month, a day that should be the first of the first lunar month. It’s good enough for everyday display. For anything that can’t be wrong—fixing holidays, working out birthdays—swap
Hairline.calendar.sourcefor a function that takes a date and returns the lunar date, backed by authoritative calendar data. - Solar terms run on an approximate formula that can be off by a day in some years, covering only 2001 through 2100. For exactness, swap
Hairline.calendar.termsfor a function returning ephemeris data. - With no script loaded, the static month written inside the container shows as it is.