Skip to main content
5.0.0Next5.1.05.0.35.0.25.0.15.0.04.0.94.0.84.0.73.2.03.1.03.0.13.0.02.1.12.0.101.0.0
Version: 5.0.0

Accordion

The Triton Accordion is a user interface element that allows for the display of expandable and collapsible content sections. It provides a compact and organized way to present information, where only one section is visible at a time while the others are hidden. Users can toggle the visibility of the sections by clicking on their respective headers, providing a seamless way to access additional content without overwhelming the interface.

Basic Usage

<triton-accordion>
<triton-accordion-item header="Open me">some content</triton-accordion-item>
<triton-accordion-item header="Open me">Item One</triton-accordion-item>
<triton-accordion-item header="Open me">Item Two</triton-accordion-item>
<triton-accordion-item header="Open me">some content</triton-accordion-item>
</triton-accordion>
<TritonAccordion>
<TritonAccordionItem header="Accordion">
Some content
</TritonAccordionItem>
</TritonAccordion>
<html> 
<head>
<script type="module">
import { defineCustomElements } from '~node_modules/@kognifai/triton-cl-core/loader/index.es2017.js';
defineCustomElements();
</script>
</head>
<body>
<triton-accordion>
<triton-accordion-item header="Open me">some content</triton-accordion-item>
<triton-accordion-item header="Open me">Item One</triton-accordion-item>
<triton-accordion-item header="Open me">Item Two</triton-accordion-item>
<triton-accordion-item header="Open me">some content</triton-accordion-item>
</triton-accordion>
</body>
</html>
Some content

Some content

Some more content

Hello

Variants

Accordion

To render an accordion, wrap accordion-items with <triton-accordion>. This wrapper will apply style and prevent unwanted events from child conmponents to propagate outside the accordion.

  <triton-accordion>
...
</triton-accordion>

Items

A TritonAccordion consists of TritonAccordionItem elements. These are the items which will be rendered in the accordion.

accordion Item 1accordion Item 2accordion Item 3
<triton-accordion>
<triton-accordion-item header="Open me">accordion Item 1</triton-accordion-item>
<triton-accordion-item header="Open me">accordion Item 2</triton-accordion-item>
<triton-accordion-item header="Open me">accordion Item 3</triton-accordion-item>
</triton-accordion>

Set the header property to edit the text to be displayed at the top of the accordion. This is the part that is visible before it expands.

Header!accordion Item 1some content
<triton-accordion>
<triton-accordion-item header="Open me">Header!</triton-accordion-item>
<triton-accordion-item header="Open me">accordion Item 1</triton-accordion-item>
<triton-accordion-item header="Open me">some content</triton-accordion-item>
</triton-accordion>

Appearance

Skin

The accordion can be styled using the skin property.

Flat accordion ItemFlat accordion ItemFlat accordion ItemSemi-border accordion ItemSemi-border accordion ItemSemi-border accordion Item
<triton-accordion skin="flat">
<triton-accordion-item header="Open me">Flat accordion Item</triton-accordion-item>
<triton-accordion-item header="Open me">Flat accordion Item</triton-accordion-item>
<triton-accordion-item header="Open me">Flat accordion Item</triton-accordion-item>
</triton-accordion>

<triton-accordion skin="semi-border">
<triton-accordion-item header="Open me">Semi-border accordion Item</triton-accordion-item>
<triton-accordion-item header="Open me">Semi-border accordion Item</triton-accordion-item>
<triton-accordion-item header="Open me">Semi-border accordion Item</triton-accordion-item>
</triton-accordion>

Behavior

Multiple-Open

Set the multiple-open property to true, to enable multiple accordion items to be open simultneously.

1 accordion Item2 accordion Item3 accordion Item
<triton-accordion multiple-open>
<triton-accordion-item header="Open me">1 accordion Item</triton-accordion-item>
<triton-accordion-item header="Open me">2 accordion Item</triton-accordion-item>
<triton-accordion-item header="Open me">3 accordion Item</triton-accordion-item>
</triton-accordion>

API

Properties

TritonAccordion

PropertyDescriptionTypeDefault
backgroundskin to apply to the accordiongrey transparent'grey'
multiple-openbooleanfalse
skinskin to apply to the accordionborder flat gap semi-border'border'

TritonAccordionItem

PropertyDescriptionTypeDefault
activethe openclose state of the accordionboolean-
animationIf true an animation will fire when the accordion opens and closesbooleantrue
headertitle to display in the header of the accordionstring-
icon-closedIcon to display in the header when state is not activeIcon'chevron-down'
icon-openIcon to display in the header when state is activeIcon'chevron-up'