<advent-door>
One dependency-free web component. Knob turns, latch pops, door swings, Font Awesome icons fly. Locked doors rattle.
Click a door.
Use it
<script type="module" src="advent-door.js"></script>
<advent-door day="2" unlock="2026-12-02" confetti>
<details>
<summary>December 2</summary>
<h2>Build a truly original icon</h2>
<p>Behind the door. A plain disclosure without JS.</p>
</details>
<div slot="confetti">
<wa-icon name="star"></wa-icon>
<wa-icon name="snowflake"></wa-icon>
</div>
</advent-door>Confetti clones each element in the confetti slot, like Web Awesome’s <wa-icon> or any svg or img. Without icons it throws paper.
A whole calendar
<link rel="stylesheet" href="advent-window.css">
<script type="module" src="advent-door.js"></script>
<script type="module" src="advent-window.js"></script>
<advent-window src="content.json">
<advent-door day="1" unlock="2026-12-01T00:00-06:00"></advent-door>
<advent-door day="2" unlock="2026-12-02T00:00-06:00"></advent-door>
<!-- … through day 24 -->
</advent-window>{
"doors": [
{
"day": 1,
"image": "possum.svg",
"imagePosition": "right top / auto 90%",
"attributes": { "confetti-colors": "#146ebe #ffc94a" },
"html": "<h2>Let the browser pick the right image</h2>…",
"confetti": "<wa-icon name=\"star\"></wa-icon>"
}
]
}<advent-window> fills only unlocked doors from src, so future content never ships in the markup. Image paths resolve against the JSON’s URL, only today’s door throws confetti, and today’s door scrolls into view.
Sample Agent Prompt
Add an advent calendar to my site with <advent-door> and <advent-window> from https://advent-calendar.11ty.dev/.
- Copy https://advent-calendar.11ty.dev/advent-door.js, https://advent-calendar.11ty.dev/advent-window.js and https://advent-calendar.11ty.dev/advent-window.css into my site.
- Link advent-window.css in the <head> and load advent-door.js and advent-window.js as modules.
- Inside <advent-window src="https://advent-calendar.11ty.dev/service/content.json">, add 24 empty <advent-door> elements, one per day, each with a day and an unlock date-time at midnight in my time zone (e.g. 2026-12-01T00:00-06:00).
- To use my own content instead, host a content.json with a "doors" array and point src at it: each entry has a day, an html string with an h2, a short paragraph and a <div class="cta"> link, and optional image, imagePosition, attributes and confetti fields.
- Don't put door content in the HTML, so future days aren't spoiled.API
| Name | What it does |
|---|---|
day | Date on the door. Month comes from unlock. |
unlock | YYYY-MM-DD. Locked until local midnight; unlocks live. |
open | Reflects state. Set it to open without animation. |
confetti | Burst on open. Optional count, default 28. |
confetti-colors | Space-separated colors. |
persist | Key to remember open state; defaults to unlock. Use off to disable. |
toggle(force?) | Animated open or close. Resolves to a boolean. |
advent-door-toggle | Event before opening or closing. Cancelable. |
advent-door-locked | Event when a locked door is tried. |
--advent-door-* | color, ink, radius, angle, speed, thickness, knob-size, back, glow, focus. |
slot="close" | Custom close icon, e.g. a Font Awesome xmark. |
::part() | door, face, back, date, number, knob, status, contents, close. |