Interactive
Menus, dialogs and tabs built on what browsers already do: popover, command and <dialog>. Kerf checks that each button points at something that exists and does what it says. Tabs need one small script, kerf.js, which Kerf writes for you.
Dialogs
A <dialog> is a raised panel on your surface colour with a dimmed page behind it, no wider than the screen. The browser handles focus and Escape. A button with command="show-modal" opens it without JavaScript, and a <form method="dialog"> inside closes it (so does a button with command="close" and the same commandfor).
<button command="show-modal" commandfor="confirm" s="button">Delete</button>
<dialog id="confirm" aria-labelledby="confirm-title" s="stack 16">
<h2 id="confirm-title" s="lg bold">Delete this post?</h2>
<p s="text-muted">It can't be undone.</p>
<form method="dialog" s="row 12 justify end">
<button s="button">Cancel</button>
<button value="delete" s="button primary">Delete</button>
</form>
</dialog>
A dialog with no name is an error, and one with no close button a warning; its content is checked for contrast on the dialog's own background. A command with a typo, one without commandfor, or show-modal pointed at something that isn't a <dialog> is an error too: the button would do nothing. See Checks.
Tabs
tabs shows one panel at a time, picked by a row of buttons. Write the buttons first, with a name for the row, then a panel for each, in the same order.
<div s="tabs">
<div aria-label="Billing">
<button>Monthly</button>
<button>Yearly</button>
</div>
<section>…</section>
<section id="yearly">…</section>
</div>
£12 a month
Cancel any time.
£120 a year
Two months free.
£300 once
Yours for good.
HTML has no tabs of its own, so this is the one word that needs a script. kerf build writes kerf.js next to kerf.css when a page uses tabs; load it in the <head> with <script src="/kerf.js" defer></script>. With Vite or another bundler, import "@kerfcss/kerf/tabs" instead. It's about 2.5 kB.
The script adds what screen readers expect: the roles, ids that tie each button to its panel, aria-selected, and one tab in the Tab order. The arrow keys move between tabs (mirrored in right-to-left pages), Home and End go to the first and last, and Tab moves into the open panel. A link to a panel's id (#yearly) opens its tab. Without JavaScript, the buttons stay hidden and every panel shows, one after another.
The selected tab is underlined in the text's own colour, so tabs read on any background. A row of buttons that isn't first, a panel too few or too many, and a page with tabs that doesn't load kerf.js are errors; a row with no name is a warning. See Checks.