Accordion
Secciones una debajo de otra que se abren y se cierran: preguntas y respuestas, ajustes por tema.
import { Accordion, AccordionSkeleton } from '@sypnia/ui/react'
Preguntas y respuestas
Una abierta a la vez.
A place for your tables, your keys and your team. Each project has its own address and its own bill.
Código
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
La pieza real y su skeleton: la misma caja, así nada se mueve cuando llegan los datos.
Código
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>
);
} Cuándo usarlo
Úsalo cuando
- Muchas secciones de las que la gente lee una o dos.
No lo uses cuando
- Todo es corto: muéstralo abierto.
- Hay una sola: Disclosure.
Para todos
- Cada título es un botón dentro de un encabezado y dice si está abierto. Enter o Espacio lo abren.
- Con
multiplepuede haber más de una abierta.
Props
| Accordion | Tipo | Por defecto |
|---|---|---|
itemsobligatorio | AccordionItem[] | |
defaultOpen | string[] | |
multiple | boolean |
| AccordionSkeleton | Tipo | Por defecto |
|---|---|---|
items | number | 4 |