Skip to content

Accordion — wd-accordion

Category: Content · Tag: wd-accordionBack to: Components overview


What it does

A stack of collapsible sections. Each section has a header; clicking a header expands its content and collapses the others (one open at a time).


Adding it & its settings

Add Component → Content → Accordion.

Basic Settings (all components): #id, Classes, Inline Style.

Component Settings: none — the accordion is built entirely from the content you put inside it.


Content & slots

  • Default slot — one child element per section. Each child provides:
    • a header attribute → the section's header text,
    • its inner HTML → the section's collapsible content.
html
<wd-accordion>
  <div header="Shipping">We ship worldwide within 3–5 days.</div>
  <div header="Returns">Free returns within 30 days.</div>
</wd-accordion>

The component reads these children on load, builds the accordion, and removes the original elements. The first click opens a section; clicking it again closes it.


Styling

CSS variables

Container & items

VariableDefault
--wd-accordion-border1px solid #ccc
--wd-accordion-border-radius4px
--wd-accordion-item-border1px solid #ccc
--wd-accordion-content-max-heightauto

Header

VariableDefault
--wd-accordion-header-background#f7f7f7
--wd-accordion-header-hover-background#e2e2e2
--wd-accordion-header-gap1rem
--wd-accordion-header-min-height4rem
--wd-accordion-header-padding1rem

Header text

VariableDefault
--wd-accordion-header-text-font-color#333
--wd-accordion-header-text-font-familysans-serif
--wd-accordion-header-text-font-size1.5rem
--wd-accordion-header-text-font-weightnormal
--wd-accordion-header-text-margin0
--wd-accordion-header-text-padding0

Header icon (the +/− toggle)

VariableDefault
--wd-accordion-header-icon-color#333
--wd-accordion-header-icon-font-size1.5rem
--wd-accordion-header-icon-size1.5rem

::part()

PartElement
accordion-<id>The accordion container.
css
wd-accordion::part(accordion-faq) { box-shadow: 0 1px 4px rgba(0,0,0,.08); }

Notes

  • One open at a time: opening a section closes the previously open one.
  • The component emits an accordionToggle event when a section opens/closes (useful for custom scripts).