A tiny script (less than 1KB gzipped) to build accessible content toggles. You can try the live demo which also acts as a documentation.
a11y-toggle targets modern browsers and is not intended for Internet Explorer.
npm install a11y-toggleImport it from your JavaScript entry point:
import 'a11y-toggle';You can also import the initializer directly when you need to initialize dynamically rendered markup:
import { initA11yToggle } from 'a11y-toggle';
initA11yToggle(document.querySelector('#new-content'));For direct browser usage, use the generated IIFE build:
<script src="dist/a11y-toggle.iife.js" defer></script>Vitest and jsdom are used to run DOM tests.
npm testnpm run build