Accordion
Sections one below the other that open and close: questions and answers, settings by topic.
import { Accordion, AccordionSkeleton } from '@sypnia/ui/react'
Questions and answers
One open at a time.
A place for your tables, your keys and your team. Each project has its own address and its own bill.
Code
import { Accordion } from '@sypnia/ui/react';
// One section open at a time; the first starts open. Tab moves between the titles, Enter or Space opens one.
export default function Questions() {
return (
<Accordion defaultOpen={['what']} items={[
{ id: 'what', title: 'What is a project?', content: 'A place for your tables, your keys and your team. Each project has its own address and its own bill.' },
{ id: 'invite', title: 'Can I invite people who do not program?', content: 'Yes. They see the data as tables and cards, and change only what their role allows.' },
{ id: 'delete', title: 'What happens when I delete a project?', content: 'It stops answering at once. Its data is kept for 7 days in case you change your mind; after that it is gone.' },
]} />
);
} Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
Code
import { Accordion, AccordionSkeleton } from '@sypnia/ui/react';
export default function Skeleton() {
return (
<div className="sy-stack">
<Accordion items={[{ id: 'a', title: 'Billing', content: 'Monthly, on the 1st.' }, { id: 'b', title: 'Limits', content: '5 million requests.' }]} />
<AccordionSkeleton items={2} />
</div>
);
} When to use it
Use it when
- Many sections where people read one or two.
Do not use it when
- Everything is short: show it open.
- There is only one: Disclosure.
For everyone
- Each title is a button inside a heading, and says whether it is open. Enter or Space opens it.
- With
multiplemore than one can be open.
Props
| Accordion | Type | Default |
|---|---|---|
itemsrequired | AccordionItem[] | |
defaultOpen | string[] | |
multiple | boolean |
| AccordionSkeleton | Type | Default |
|---|---|---|
items | number | 4 |