site-index
Interactive site keyword index with A-Z jump nav, search filtering, entry counts, display limits, sort options, and optional JSON data loading.
Overview
The <site-index> component enhances a static keyword index with A-Z jump navigation, search filtering with scope control, entry counts, display limits with expand/collapse, and sort options.
Without JavaScript, the static markup is a fully functional keyword index with CSS multi-column layout at wider viewports.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
placeholder |
string | "Filter index…" |
Placeholder text for the search input |
letters |
string | "entries" |
Jump nav mode: "entries" (only letters with entries), "all" (full A-Z strip, empty letters disabled), or "none" (hidden). |
filter |
string | — | Search scope filter mode |
sort |
string | — | Sort order for letter sections |
limit |
number | — | Max topics per letter section before a "Show N more" toggle appears. |
src |
string | — | URL to load index data from as JSON |
Features
A-Z Jump Navigation
By default, the jump nav shows only letters that have entries. Set letters="all" to show all 26 letters with disabled states for empty ones. Scroll-spy highlights the current letter as the user scrolls.
Search Scope
The controls bar includes a scope dropdown:
- By Topic (default) — matches only the topic heading (
.index-term) - All — matches both topic headings and sub-entry link text (
.index-refs a)
For example, searching "button" in "All" mode will find topics that have a "Button element" sub-entry even if "button" isn't in the topic name.
Entry Counts
The component automatically appends reference counts: (N) after each topic term and in each letter heading. This helps users see at a glance which topics have the most content.
Display Limit
When limit is set, letter sections with more topics than the limit show a "Show N more" toggle button. Clicking expands to show all entries; clicking again collapses back.
Sort Options
The controls bar includes a sort dropdown:
- Alphabetical (default) — standard A-Z order
- Most entries — reorders letter sections by total reference count, highest first
HTML Structure
The static markup uses semantic HTML with specific classes that the component recognizes.
| Class / Element | Purpose |
|---|---|
.index-term |
Topic heading text within a <span> |
.index-refs |
Nested <ul> of page reference links |
<small> |
Optional content-type pill (e.g., "blog", "tutorial") |
id="index-X" |
Section ID for jump nav anchors (lowercase letter) |
JSON Data Loading
When src is set, the component fetches index data and renders dynamically. Static markup serves as fallback.
Accessibility
- Jump nav uses
aria-label="Jump to letter"; disabled letters havearia-disabled="true" - Scroll-spy sets
aria-current="true"on the active letter link - Search input and dropdowns have
aria-labelattributes - Expand/collapse buttons use
aria-expanded - Filtered items use
hiddento remove from the accessibility tree - Without JavaScript, the full index is visible and navigable
Related
<glossary-index>— Glossary with search and scroll-spy<time-index>— Changelog/timeline index<site-map>— Interactive HTML sitemap