Accordion

Accordion component

Import

import Accordion from '../components/ui/Accordion.astro'
import AccordionItem from '../components/ui/AccordionItem.astro'

Usage

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

<Accordion id='accordion-example'>
  <AccordionItem>
    <h2 slot="title">Accordion title 1</h2>
    <p slot="content">...</p>
  </AccordionItem>
  <AccordionItem>
    <h2 slot="title">Accordion title 2</h2>
    <p slot="content">...</p>
  </AccordionItem>
  <AccordionItem>
    <h2 slot="title">Accordion title 3</h2>
    <p slot="content">...</p>
  </AccordionItem>
</Accordion>

Always open

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

<Accordion id='accordion-example' alwaysOpen>
  <AccordionItem>
    <h2 slot="title">Accordion title 1</h2>
    <p slot="content">...</p>
  </AccordionItem>
  <AccordionItem>
    <h2 slot="title">Accordion title 2</h2>
    <p slot="content">...</p>
  </AccordionItem>
  <AccordionItem>
    <h2 slot="title">Accordion title 3</h2>
    <p slot="content">...</p>
  </AccordionItem>
</Accordion>

Expand

Si se quiere abrir un item del accordion por defecto, se debe agregar el atributo isOpen al componente AccordionItem. Con esta opción estamos indicando de manera manual que el item debe estar abierto.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Border

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl eget ultricies aliquam, nunc sapien aliquet nunc, vitae a

<Accordion id='accordion-example' border>
  <AccordionItem>
    <h2 slot="title">Accordion title 1</h2>
    <p slot="content">...</p>
  </AccordionItem>
  <AccordionItem>
    <h2 slot="title">Accordion title 2</h2>
    <p slot="content">...</p>
  </AccordionItem>
  <AccordionItem>
    <h2 slot="title">Accordion title 3</h2>
    <p slot="content">...</p>
  </AccordionItem>
</Accordion>

Props

PropTypedefaultDescription
idStringnullEsta prop es obligatoria y debe ser única para cada accordion en la página. Se utiliza para identificar el accordion y sus items.
alwaysOpenBooleanfalseEsta prop permite que todos los items permanezcan abiertos mientras se abre uno nuevo.
isOpenBooleanfalseEsta prop permite que un item se abra por defecto.
borderBooleanfalseAgrega un borde a cada item del accordion.
Astro ui

© 2024 Astro UI. All rights reserved.