Default — single open
import { html, atom, renderApp } from 'mates';
import { Accordion } from 'mates-ui';
const ITEMS = [
{ id: "q1", title: "What is mates-design?", content: "A headless-inspired UI library built on lit-html and the mates reactive framework." },
{ id: "q2", title: "How do I install it?", content: 'npm install mates-design mates lit-html' },
{ id: "q3", title: "How does theming work?", content: "Entirely via CSS custom properties in tokens.css. Toggle dark mode with data-theme=\"dark\"." },
{ id: "q4", title: "Is it accessible?", content: "Yes — WAI-ARIA patterns, keyboard navigation, and proper ARIA attributes throughout." },
];
const App = () => {
const open = atom([]);
return () => html`
<div style="max-width:36rem;width:100%;">
${Accordion({ items: ITEMS, openIds: open(), multiple: false, onToggle: (id, isOpen) => open.set(isOpen ? [id] : []) })}
</div>
`;
};
renderApp(App, document.getElementById('app'));
Multiple open
import { html, atom, renderApp } from 'mates';
import { Accordion } from 'mates-ui';
const ITEMS = [
{ id: "q1", title: "What is mates-design?", content: "A headless-inspired UI library built on lit-html and the mates reactive framework." },
{ id: "q2", title: "How do I install it?", content: 'npm install mates-design mates lit-html' },
{ id: "q3", title: "How does theming work?", content: "Entirely via CSS custom properties in tokens.css. Toggle dark mode with data-theme=\"dark\"." },
{ id: "q4", title: "Is it accessible?", content: "Yes — WAI-ARIA patterns, keyboard navigation, and proper ARIA attributes throughout." },
];
const App = () => {
const open = atom(["q1", "q3"]);
return () => html`
<div style="max-width:36rem;width:100%;">
${Accordion({
items: ITEMS, openIds: open(), multiple: true,
onToggle: (id, isOpen) => open.set(isOpen ? [...open(), id] : open().filter((x) => x !== id)),
})}
</div>
`;
};
renderApp(App, document.getElementById('app'));
Bordered variant
import { html, atom, renderApp } from 'mates';
import { Accordion } from 'mates-ui';
const ITEMS = [
{ id: "q1", title: "What is mates-design?", content: "A headless-inspired UI library built on lit-html and the mates reactive framework." },
{ id: "q2", title: "How do I install it?", content: "npm install mates-design mates lit-html" },
{ id: "q3", title: "How does theming work?", content: "Entirely via CSS custom properties. Toggle dark with data-theme=\"dark\"." },
];
const App = () => {
const open = atom([]);
return () => html`
<div style="max-width:36rem;width:100%;">
${Accordion({ items: ITEMS, openIds: open(), variant: "bordered", onToggle: (id, isOpen) => open.set(isOpen ? [id] : []) })}
</div>
`;
};
renderApp(App, document.getElementById('app'));
Filled variant
import { html, atom, renderApp } from 'mates';
import { Accordion } from 'mates-ui';
const ITEMS = [
{ id: "q1", title: "What is mates-design?", content: "A headless-inspired UI library built on lit-html and the mates reactive framework." },
{ id: "q2", title: "How do I install it?", content: "npm install mates-design mates lit-html" },
{ id: "q3", title: "How does theming work?", content: "Entirely via CSS custom properties. Toggle dark with data-theme=\"dark\"." },
];
const App = () => {
const open = atom(["q2"]);
return () => html`
<div style="max-width:36rem;width:100%;">
${Accordion({
items: ITEMS, openIds: open(), variant: "filled", multiple: true,
onToggle: (id, isOpen) => open.set(isOpen ? [...open(), id] : open().filter((x) => x !== id)),
})}
</div>
`;
};
renderApp(App, document.getElementById('app'));