Bootstrap

API accordion

AccordionApi

interface
Methods
collapse

collapse(itemId): void

Given the itemId, will collapse the corresponding accordion-item.

If the itemId is not valid, nothing will happen.

Parameters

itemId: string

Returns

void


collapseAll

collapseAll(): void

It will collapse all the accordion-items in the accordion.

Returns

void


expand

expand(itemId): void

Given the itemId, will expand the corresponding accordion-item.

If the itemId is not valid, nothing will happen.

Parameters

itemId: string

Returns

void


expandAll

expandAll(): void

It will expand all the items in the accordion.

If closeOthers is true it will expand only the last accordion-item.

Returns

void


registerItem

registerItem(itemConfig?): AccordionItemWidget

Creates a new accordionItem.

Parameters

itemConfig?: PropsConfig<AccordionItemProps>

Returns

AccordionItemWidget


toggle

toggle(itemId): void

Given the itemId, will toggle the corresponding accordion-item.

If the itemId is not valid, nothing will happen.

Parameters

itemId: string

Returns

void


AccordionDirectives

interface
Properties
accordionDirective

accordionDirective: Directive

Directive to put on the accordion DOM element


AccordionItemActions

interface
Methods
click

click(): void

Action to be called when the user clicks on the accordion-item button. If the accordion-item is disabled nothing will happen.

Returns

void


AccordionItemApi

interface
Methods
collapse

collapse(): void

It will collapse the accordion-item.

Returns

void


expand

expand(): void

It will expand the accordion-item.

Returns

void


initDone

initDone(): void

Method to be called after the initialization to allow animations.

Returns

void


toggle

toggle(): void

It will toggle the accordion-item.

Returns

void


AccordionItemContext

type alias

AccordionItemContext: WidgetSlotContext<AccordionItemWidget>


AccordionItemDirectives

interface
Properties
bodyContainerAttrsDirective

bodyContainerAttrsDirective: Directive

Directive to apply aria attributes to the expanded body panel


bodyContainerDirective

bodyContainerDirective: Directive

Directive to be put on the accordion-item body container. It will handle the animation.


bodyDirective

bodyDirective: Directive

Directive to put on the accordion-item body.


buttonDirective

buttonDirective: Directive

Directive to put on the button element that will control the collapsing of the accordion-item.


headerDirective

headerDirective: Directive

Directive to put on the accordion-item header that will contain the button element.


itemDirective

itemDirective: Directive

Directive to be put on the accordion-item. It will handle adding the accordion-item to the accordion.


toggleDirective

toggleDirective: Directive

Directive to use in special cases, if the accordion header does not use a button element to control the collapsing.


transitionDirective

transitionDirective: Directive

Directive to apply the itemTransition


AccordionItemProps

interface
Properties
animated

animated: boolean

If true, accordion-item will be animated.


bodyClassName

bodyClassName: string

CSS classes to add on the accordion-item body DOM element.


bodyContainerClassName

bodyContainerClassName: string

CSS classes to add on the accordion-item body container DOM element. The accordion-item body container is the DOM element on what the itemTransition is applied.


buttonClassName

buttonClassName: string

CSS classes to add on the accordion-item collapse DOM element.


children

children: SlotContent<AccordionItemContext>

Content present in the accordion body.

It is a prop of the accordion-item.


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


destroyOnHide

destroyOnHide: boolean

If true, the accordion-item body container will be removed from the DOM when the accordion-item is collapsed. It will be just hidden otherwise.


disabled

disabled: boolean

If true, the accordion-item will be disabled. It will not react to user's clicks, but still will be possible to toggle programmatically.


header

header: SlotContent<AccordionItemContext>

Content present in the accordion button inside the accordion header.

It is a prop of the accordion-item.


headerClassName

headerClassName: string

CSS classes to add on the accordion-item header DOM element.


headingTag

headingTag: string

The html tag to use for the accordion-item-header.


id

id: string

The id of the accordion-item. It can be used for controlling the accordion-item via the accordion api.


onHidden

onHidden: () => void

An event fired when an item is hidden.

Returns

void


onShown

onShown: () => void

An event fired when an item is shown.

Returns

void


onVisibleChange

onVisibleChange: (visible) => void

An event fired when the visible value changes.

Event payload is the new value of visible.

Parameters

visible: boolean

Returns

void


structure

structure: SlotContent<AccordionItemContext>

Structure of the accordion-item. The default item structure is: accordion-item contains accordion header and accordion-item body container; the accordion header contains the accordion button (that contains header), while the accordion-item body container contains the accordion body (that contains children). The itemTransition is applied on this element.

It is a prop of the accordion-item.


transition

transition: TransitionFn

The transition to use for the accordion-item body-container when the accordion-item is toggled.


visible

visible: boolean

If true, the accordion-item will be visible (expanded). Otherwise, it will be hidden (collapsed).


AccordionItemSlots

interface
Properties
default

default: AccordionItemContext


header

header: AccordionItemContext


structure

structure: AccordionItemContext


AccordionItemState

interface
Properties
bodyClassName

bodyClassName: string

CSS classes to add on the accordion-item body DOM element.


bodyContainerClassName

bodyContainerClassName: string

CSS classes to add on the accordion-item body container DOM element. The accordion-item body container is the DOM element on what the itemTransition is applied.


buttonClassName

buttonClassName: string

CSS classes to add on the accordion-item collapse DOM element.


children

children: SlotContent<AccordionItemContext>

Content present in the accordion body.

It is a prop of the accordion-item.


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


disabled

disabled: boolean

If true, the accordion-item will be disabled. It will not react to user's clicks, but still will be possible to toggle programmatically.


header

header: SlotContent<AccordionItemContext>

Content present in the accordion button inside the accordion header.

It is a prop of the accordion-item.


headerClassName

headerClassName: string

CSS classes to add on the accordion-item header DOM element.


headingTag

headingTag: string

The html tag to use for the accordion-item-header.


id

id: string

The id of the accordion-item. It can be used for controlling the accordion-item via the accordion api.


shouldBeInDOM

shouldBeInDOM: boolean

If true the content of the accordion-item collapse should be in DOM. Its value depends on the value of the visible and destroyOnHide.


structure

structure: SlotContent<AccordionItemContext>

Structure of the accordion-item. The default item structure is: accordion-item contains accordion header and accordion-item body container; the accordion header contains the accordion button (that contains header), while the accordion-item body container contains the accordion body (that contains children). The itemTransition is applied on this element.

It is a prop of the accordion-item.


visible

visible: boolean

If true, the accordion-item will be visible (expanded). Otherwise, it will be hidden (collapsed).


AccordionItemWidget

type alias

AccordionItemWidget: Widget<AccordionItemProps, AccordionItemState, AccordionItemApi, AccordionItemActions, AccordionItemDirectives>


AccordionProps

interface
Properties
className

className: string

CSS classes to be applied on the widget main container

Default Value

''


closeOthers

closeOthers: boolean

If true, only one accordion-item at the time can stay open.

Default Value

false


itemAnimated

itemAnimated: boolean

If true, accordion-item will be animated.

Default Value

true


itemBodyClassName

itemBodyClassName: string

CSS classes to add on the accordion-item body DOM element.

Default Value

''


itemBodyContainerClassName

itemBodyContainerClassName: string

CSS classes to add on the accordion-item body container DOM element. The accordion-item body container is the DOM element on what the itemTransition is applied.

Default Value

''


itemButtonClassName

itemButtonClassName: string

CSS classes to add on the accordion-item toggle button DOM element.

Default Value

''


itemClassName

itemClassName: string

CSS classes to add on the accordion-item DOM element.

Default Value

''


itemDestroyOnHide

itemDestroyOnHide: boolean

If true, the accordion-item body container will be removed from the DOM when the accordion-item is collapsed. It will be just hidden otherwise.

Default Value

true


itemHeaderClassName

itemHeaderClassName: string

CSS classes to add on the accordion-item header DOM element.

Default Value

''


itemHeadingTag

itemHeadingTag: string

The html tag to use for the accordion-item-header.

Default Value

''


itemStructure

itemStructure: SlotContent<AccordionItemContext>

Structure of the accordion-item. The default item structure is: accordion-item contains accordion header and accordion-item body container; the accordion header contains the accordion button (that contains header), while the accordion-item body container contains the accordion body (that contains children). The itemTransition is applied on this element.

It is a prop of the accordion-item.


itemTransition

itemTransition: TransitionFn

The transition to use for the accordion-item body-container when the accordion-item is toggled.

Default Value
collapseVerticalTransition

onItemHidden

onItemHidden: (itemId) => void

An event fired when an item is hidden.

Event payload is the id of the item.

Parameters

itemId: string

Returns

void

Default Value
() => {}

onItemShown

onItemShown: (itemId) => void

An event fired when an item is shown.

Event payload is the id of the item.

Parameters

itemId: string

Returns

void

Default Value
() => {}

AccordionSlots

interface
Properties
itemStructure

itemStructure: AccordionItemContext


AccordionState

interface
Properties
className

className: string

CSS classes to be applied on the widget main container

Default Value

''


itemStructure

itemStructure: SlotContent<AccordionItemContext>

Structure of the accordion-item. The default item structure is: accordion-item contains accordion header and accordion-item body container; the accordion header contains the accordion button (that contains header), while the accordion-item body container contains the accordion body (that contains children). The itemTransition is applied on this element.

It is a prop of the accordion-item.


itemWidgets

itemWidgets: AccordionItemWidget[]

Array containing all the accordion-items contained in the accordion.


AccordionWidget

type alias

AccordionWidget: Widget<AccordionProps, AccordionState, AccordionApi, object, AccordionDirectives>


createAccordion

function

createAccordion(props?): AccordionWidget

Create an AccordionWidget with given config props

Parameters

props?: PropsConfig<AccordionProps>

Returns

AccordionWidget

an AccordionWidget


createAccordionItem

function

createAccordionItem(props?): AccordionItemWidget

Create an AccordionItemWidget with given config props

Parameters

props?: PropsConfig<AccordionItemProps>

Returns

AccordionItemWidget

an AccordionItemWidget


factoryCreateAccordion

function

factoryCreateAccordion(itemFactory?, accordionItemProps?, accordionConfig?, accordionValidator?): WidgetFactory<AccordionWidget>

Create an accordion WidgetFactory based on a item factory and the list of item props that should inherit from the parent accordion

Parameters

itemFactory?: WidgetFactory<AccordionItemWidget>

the item factory

accordionItemProps?: string[]

the list of item props

accordionConfig?: AccordionProps

the default accordion config

accordionValidator?: ConfigValidator<AccordionProps>

the validator of props

Returns

WidgetFactory<AccordionWidget>

the accordion widget factory


getAccordionApi

function

getAccordionApi(): AccordionApi

Returns

AccordionApi


getAccordionDefaultConfig

function

getAccordionDefaultConfig(): AccordionProps

Retrieve a shallow copy of the default accordion config

Returns

AccordionProps

the default accordion config


setAccordionApi

function

setAccordionApi(accordionApi): void

Parameters

accordionApi: AccordionApi

Returns

void