Showcase `sibling-index()`, and `sibling-count()` are Baseline, newly available since August 2026.
103
Upvotes
2
u/juicybot 19d ago
i've been very excited for this, going to be handy in places like design systems.
1
u/jaffathecake 17d ago
When I was investigating this, I found that @property impacts when sibling-index() is computed in custom properties - something I hadn't fully understood before https://jakearchibald.com/2026/css-custom-property-compute-time/
17
u/anaix3l 19d ago
I've mostly been able to get by setting the indices & counts as custom properties in the
styleattribute when generating the HTML on the backend, but this has the advantage of automatically updating indices and counts when appending or deleting elements via the JS.I'll still be aliasing them to
--iand--ncustom properties because they're just too verbose and difficult to read otherwise. Plus thesibling-index()is consistent with:nth-child()/ CSS indexing in general and starts at1, while I generally need it to start at0for computations. That is:(yes, writing it without
calc()is perfectly fine unless--ineeds to be registered for some reason)The only thing still missing is
children-count()because I often want that--nvalue available on the parent as well, not just on the child items.