Cards & Layout
Accordion
Native details/summary stack — exclusive or multi-open.
- Element
<details>- Module
@basenative/components- Function
renderAccordion
Quick start
Import the render function and call it from your server template.
import { renderAccordion } from '@basenative/components';
renderAccordion({ items: [{ title: '...', content: '...' }] });
Examples
Each block is a real server render — no mockups, no virtual DOM.
Native disclosure
Built on native <details>/<summary>.
renderAccordion({
items: [
{ title: 'What is BaseNative?', content: 'A signal-based runtime over native HTML.' },
{ title: 'How does SSR work?', content: 'Directives are evaluated at request time.' },
],
})
Expand / collapse all
A button toggles the open attribute on every <details>.
// multiple: true — without it the group is exclusive (shared name=), so
// opening each <details> in turn closes the one before it.
renderAccordion({
multiple: true,
items: [
{ title: 'Section one', content: 'Body for section one.' },
{ title: 'Section two', content: 'Body for section two.' },
],
});
const open = signal(false);
effect(() => {
for (const d of slot.querySelectorAll('details')) d.open = open();
});
expandBtn.onclick = () => open.set(true);
collapseBtn.onclick = () => open.set(false);
Options
Arguments accepted by renderAccordion().
| Option | Type | Default | Description |
|---|---|---|---|
items |
{ title, content }[] |
— |
Accordion sections. |