Static sites
@lit-material/site-kit holds the pieces of a prerendered site that have to work before any script runs: plain HTML templates, one stylesheet, and small scripts that add behaviour. This site and rws8.tech are built with it.
Install
npm install @lit-material/site-kit
Render the templates with Lit SSR (or any Lit render), load @lit-material/site-kit/css/site-kit.css, and call the init functions from your client entry. The styles sit in one cascade layer, so your own CSS overrides them without specificity fights.
FAQ
Questions on native <details>: they open without JavaScript, find-in-page reaches closed answers, and exclusive keeps one open at a time.
Does it need JavaScript?
Can more than one be open?
Is it searchable?
faq([{ question: "Does it need JavaScript?", answer: "No." }], { exclusive: "faq" })>Numbered steps
- Install the kit
npm install @lit-material/site-kit - Render the templatesOn the server, in your prerender step.
- Call the scriptsIn the client entry, once.
An <ol> numbered by CSS counters, so screen readers count the steps.
Terminal
The prerendered block shows the finished session; initTerminal() replays it while it's on screen, unless the visitor prefers reduced motion. It is one image to assistive technology, described by label.
Keys and shortcuts
Press / or CtrlK to search this site.
- Search
- />orCtrlK>
- Close search
- Esc>
Scripts
import { initThemeToggle } from "@lit-material/site-kit/client/theme.js";
import { initMenu } from "@lit-material/site-kit/client/menu.js";
import { initSearch } from "@lit-material/site-kit/client/search.js";
import { initTerminal } from "@lit-material/site-kit/client/terminal.js";
import { initReveal } from "@lit-material/site-kit/client/reveal.js";
initThemeToggle({ key: "my-theme" });
initMenu();
initSearch({ emptyHint: "Try a component name." });
initTerminal();
initReveal();
- Theme:
themeBootScript(key)goes inline in<head>. It applies the stored choice before first paint and addsjsto<html>. ThethemeToggleicon follows the theme in CSS, so it is right before scripts run. - Menu:
menuToggle()opens the panel it controls. Escape closes it and returns focus; widening past the breakpoint closes it too. - Search:
searchDialog()plussearchButton(). The Pagefind index loads on first use; passloadfor another index. - Reveal:
.revealelements get.inon entering the viewport. Hide them only underhtml.js.