Accordion
variant advanced/basic/border-bottom/bordered/canvas/divided/primary · color (6)
Seções recolhíveis para FAQs e configurações longas.
Abrindo e fechando
<.accordion id="acc-anim" variant="divided" color="primary"><.accordion_item id="acc-anim-1" title="Como emitir uma NF-e?" open class="[&>[data-part=accordion-body]]:animate-[mo-expand_6s_ease-in-out_infinite] [&>[data-part=accordion-body]]:overflow-hidden [&>[data-part=accordion-body]]:[--lu-mh:80px] [&_[data-part=accordion-chevron]]:animate-[mo-rot2_6s_ease-in-out_infinite]">Abra o pedido e toque em Emitir NF-e; a nota vai para a SEFAZ.</.accordion_item><.accordion_item id="acc-anim-2" title="Posso cancelar uma nota?" /><.accordion_item id="acc-anim-3" title="E se a SEFAZ estiver fora?" /></.accordion>
variant (7)
<div class="grid grid-cols-2 gap-4"> <div :for={v <- ~w(advanced basic border-bottom bordered canvas divided primary)} class="flex flex-col gap-1.5"> <span class="font-mono text-xs text-muted">{v}</span> <.accordion id={"acc-#{v}"} variant={v} color="primary"><.accordion_item id={"acc-#{v}-1"} title="Como emitir uma NF-e?" open>Abra o pedido e toque em Emitir NF-e; a nota vai para a SEFAZ.</.accordion_item><.accordion_item id={"acc-#{v}-2"} title="Posso cancelar uma nota?" /><.accordion_item id={"acc-#{v}-3"} title="E se a SEFAZ estiver fora?" /></.accordion> </div> </div>
color (primary)
<div class="flex flex-wrap items-center gap-2.5"><.badge :for={c <- ~w(primary secondary info success warning error)} color={c} variant="soft">{c}</.badge></div>
Uso
<.accordion id="faq"><:item title="…">…</:item></.accordion>
Regras
- Use
<details>nativo: teclado e leitor de tela de graça. - Variante
sepcom cada item em seu painel.
Referência da API
Todos os function components, atributos, valores e slots que este componente cobre.
A list of sections that open under their titles (<.accordion> with <.accordion_item>).
<.accordion id="faq" variant="bordered">
<.accordion_item id="faq-1" title="Accordion Item 1" open>
<p>Lorem ipsum dolor sit amet.</p>
</.accordion_item>
<.accordion_item id="faq-2" title="Accordion Item 2">...</.accordion_item>
</.accordion>
<.accordion id="help" variant="primary" color="warning">...</.accordion>
Variants: canvas (default), basic, border-bottom, bordered, divided, primary and
advanced (a :header of your own per item, with the chevron at its end). color tints the
primary style. One section is open at a time; multiple lets them open independently.
The browser owns which sections are open (the LedgerUI.Collapse hook,
priv/static/ledger_ui/hooks/collapse.js); the server's open wins when it changes,
LedgerUI.open/close/toggle("faq-1") work and on_open / on_close push %{"id" => item_id}
when they are event names. The ARIA is rendered by the server: the header is a role="button"
with tabindex="0", aria-expanded and aria-controls, the body a role="region" labelled by
the header; the hook only updates aria-expanded.
<.accordion>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
id (required) |
:string |
||
variant |
:string |
"canvas" |
advanced, basic, border-bottom, bordered, canvas, divided, primary |
color |
:string |
"primary" |
primary, secondary, info, success, warning, error |
multiple |
:boolean |
false |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>-accordion_item/1s, after the<:item>s.<:item>- attrs:title,open,id,class- A section, its content the body: oneaccordion_item/1, with the id<id>-<position>.
<.accordion_item>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
id (required) |
:string |
||
title |
:string |
nil |
|
open |
:boolean |
false |
|
on_open |
:any |
nil |
|
on_close |
:any |
nil |
|
target |
:any |
nil |
|
toggle_label |
:string |
"Toggle" |
|
class |
:any |
nil |
|
trigger_class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:header><:inner_block>