Accordion Item
The wje-accordion-item is the actual interactive item inside wje-accordion. This is where the header click, state switching, ARIA links between headline and content, fallback toggle icon and open and close events are addressed.
Basic use in the context of the group
The sample below uses a single entry inside wje-accordion to make it clear where the headline, description and content slots belong. The headline may contain additional auxiliary or action components in addition to the text.
What's worth thinking about
- The
headlineslot forms a clickable header. After rendering, the component sets it torole="button",tabindex="0",aria-controlsandaria-expanded. - The
descriptionslot is the additional text in the header, andcontentholds the drop-down panel. - The
toggleslot is optional. If you don't fill it in, the component displays a fallbackwje-iconwith a chevron. - The events
wje-accordion-item:openandwje-accordion-item:closebubble to the parentwje-accordion. - Program opening and closing are handled by the public methods
expand()andcollapse(). - Colour variants are set via the
colorattribute; detailed visuals are tuned via shadow parts and CSS custom properties.
Accessibility
- The headline is controlled by the
EnterandSpacekeys. - The panel content has
role="region"and is linked to the headline viaaria-labelledby. - If you're inserting multiple interactive elements into the headline, test to make sure they don't "fight" with clicking on the entire headline.
Recommended practices
- Use the
headlineslot for a clear section title, not for an overly long paragraph of text. - Keep the
descriptionslot brief; move detailed explanations tocontentrather thancontent. - If you need a custom toggle appearance, fill the
toggleslot, but keep the affordance that it is a dropdown element clear to the user. - When programmatically opening and closing, think of consistency with the state of the parent
wje-accordion.
Attributes and properties
color
| Popis | Určuje významový farebný variant obalu accordion položky. |
| Atribút | color |
| Typ | string |
| Predvolené | - |
Events
| Názov | Popis |
|---|---|
wje-accordion-item:open | Vyvolá sa pri rozbalení accordion položky. |
wje-accordion-item:close | Vyvolá sa pri zbalen í accordion položky. |
Methods
collapse
| Popis | Zbalí aktuálnu accordion položku a aktualizuje jej ARIA expanded stav. |
| Signatúra | () => void |
expand
| Popis | Rozbalí aktuálnu accordion položku a aktualizuje jej ARIA expanded stav. |
| Signatúra | () => void |
CSS shadow parts
| Názov | Popis |
|---|---|
native | Štýluje koreňovú shadow časť komponentu. |
headline | Štýluje klikateľnú oblasť hlavičky. |
description | Štýluje oblasť doplnkového popisu. |
toggle | Štýluje toggle slot a oblasť markera. |
content | Štýluje rozbaľovaný obsahový panel. |
CSS custom variables
| Názov | Popis |
|---|---|
--wje-accordion-background | Vlastná CSS premenná, ktorá riadi farbu pozadia zbalenej accordion položky. |
--wje-accordion-border | Vlastná CSS premenná, ktorá riadi farbu okraja zbalenej accordion položky. |
--wje-accordion-border-radius | Vlastná CSS premenná, ktorá riadi zaoblenie rohov accordion položky. |
--wje-accordion-background-hover | Vlastná CSS premenná, ktorá riadi farbu pozadia položky pri hover stave. |
--wje-accordion-border-hover | Vlastná CSS premenná, ktorá riadi farbu okraja položky pri hover stave. |
--wje-accordion-background-expanded | Vlastná CSS premenná, ktorá riadi farbu pozadia rozbalenej accordion položky. |
--wje-accordion-border-expanded | Vlastná CSS premenná, ktorá riadi farbu okraja rozbalenej accordion položky. |
--wje-accordion-headline-color | Vlastná CSS premenná, ktorá riadi farbu textu hlavičky. |
--wje-accordion-content-color | Vlastná CSS premenná, ktorá riadi farbu textu rozbaľovaného obsahu. |
--wje-accordion-marker-rotate | Vlastná CSS premenná, ktorá riadi rotáciu toggle markera. |
Slots
| Názov | Popis |
|---|---|
headline | Slot pre hlavný klikateľný obsah hlavičky. |
description | Slot pre doplnkový popisný text. |
toggle | Slot pre obsah prepínača. |
content | Slot pre hlavný alebo rozbaľovaný obsah tela komponentu. |