Guides
Interactive content in MDX
Tabs, a data table and a form in an Astro article, with no client JavaScript.
On this page
The same MDX map that styles headings and code blocks also carries the parts an article needs most: tabs, a table of figures and a form. None of them ships a framework. This page loads no JavaScript of its own beyond the two kilobytes every page of this site carries.
Tabs
Tabs are platform markup: an ARIA tab list, panels in the page, and the arrow keys, Home and End wired by the one inline script. Without the script every panel shows under its name.
bun add basalt-uinpm install basalt-uipnpm add basalt-uiName each tab once in tabs and once as the label of its panel, in the same order. The panels stay in the document, so find-in-page and a printout still reach them.
A table of figures
DataTable takes plain columns and rows, so the same tag can run as an island. With no interactive prop it is the static table: formatted numbers and dates, rows as given, 0 bytes of JavaScript.
| Part | Directive | React on the page |
|---|---|---|
| Tabs | none | no |
| Table, static | none | no |
| Table, sortable | client:visible | yes |
| Chart | client:only | yes |
A form
A form in an article is a native form: it posts to its action, the browser validates required and type, and a field turns red after the reader leaves it, never on the first key.
This demo sends its fields back to this page as a query string; a real form posts to a URL on your site or to a form service. For live error summaries, async checks or steps, build the form in an app with basalt-ui/form.
A code block
A fenced block is highlighted when the page is built and carries the site’s copy button, so it adds no module script either:
bun add basalt-ui