Class Accordion
java.lang.Object
org.patternfly.component.BaseComponent<HTMLElement, Accordion>
org.patternfly.component.accordion.Accordion
- All Implemented Interfaces:
Iterable<AccordionItem>, Attachable, ElementAttributeMethods<HTMLElement, Accordion>, ElementClassListMethods<HTMLElement, Accordion>, ElementConsumerMethods<HTMLElement, Accordion>, ElementContainerMethods<HTMLElement, Accordion>, ElementEventMethods<HTMLElement, Accordion>, ElementIdMethods<HTMLElement, Accordion>, ElementQueryMethods<HTMLElement>, HTMLElementAttributeMethods<HTMLElement, Accordion>, HTMLElementDataMethods<HTMLElement, Accordion>, HTMLElementStyleMethods<HTMLElement, Accordion>, HTMLElementVisibilityMethods<HTMLElement, Accordion>, IsElement<HTMLElement>, TypedBuilder<HTMLElement, Accordion>, Component, HasItems<HTMLElement, Accordion, AccordionItem>, Modifiers.Bordered<HTMLElement, Accordion>
public class Accordion
extends BaseComponent<HTMLElement, Accordion>
implements Attachable, Modifiers.Bordered<HTMLElement, Accordion>, HasItems<HTMLElement, Accordion, AccordionItem>
An accordion is an interactive container that expands and collapses to hide or reveal nested content. It takes advantage of
progressive disclosure to help reduce page scrolling by allowing users to choose whether they want to show or hide more
detailed information as needed.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic AccordionCreates a new Accordion instance backed by a<dl/>.static Accordionaccordion(AccordionType type) add(AccordionItem item) Adds an item to the component.voidattach(MutationRecord mutationRecord) voidclear()Clears all items from the component.voidvoidbooleanChecks whether the component contains an item associated with the given identifier.voidvoidfixed()Same as fixed(true)fixed(boolean fixed) Flag to indicate Accordion content is fixedheadingLevel(int headingLevel) iconPosition(IconPosition iconPosition) booleanisEmpty()Checks whether the collection of items in the component is empty.Retrieves the item associated with the specified identifier from the component.iterator()large()Same as large(true)large(boolean large) Adds/removes modifier(large, lg)onAdd(AddItemHandler<Accordion, AccordionItem> onAdd) Registers a callback to be invoked whenever a new item is added to the component.onRemove(RemoveItemHandler<Accordion, AccordionItem> onRemove) Registers a callback to be invoked whenever an item is removed from the component.onToggle(ToggleHandler<AccordionItem> toggleHandler) onUpdate(UpdateItemHandler<Accordion, AccordionItem> onUpdate) Registers a callback to be invoked whenever an item is updated in the component.voidremoveItem(String identifier) Removes an item from the component based on the provided identifier.Same as singleExpand(true)singleExpand(boolean singleExpand) Whether only oneAccordionItemcan be expandedintsize()Retrieves the total number of items currently contained in the component.that()voidupdateItem(AccordionItem item) Updates an existing item in the component.Methods inherited from class BaseComponent
componentType, element, registerComponentMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Attachable
detachMethods inherited from interface ElementAttributeMethods
aria, aria, aria, attr, attr, attr, role, roleMethods inherited from interface ElementClassListMethods
classList, classList, css, toggle, toggle, toggleMethods inherited from interface ElementConsumerMethods
apply, runMethods inherited from interface ElementContainerMethods
add, add, add, add, addAll, addAll, addAll, addAll, addAll, addAllMethods inherited from interface ElementEventMethods
on, on, onMethods inherited from interface ElementIdMethods
id, uniqueIdMethods inherited from interface ElementQueryMethods
closest, querySelector, querySelectorAllMethods inherited from interface HasItems
addItem, addItems, items, replaceItemElement, updateItem, updateItemMethods inherited from interface HTMLElementAttributeMethods
titleMethods inherited from interface HTMLElementDataMethods
data, dataMethods inherited from interface HTMLElementVisibilityMethods
hiddenMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Modifiers.Bordered
bordered, bordered
-
Method Details
-
accordion
Creates a new Accordion instance backed by a<dl/>. -
accordion
-
attach
- Specified by:
attachin interfaceAttachable
-
add
Description copied from interface:HasItemsAdds an item to the component.- Specified by:
addin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
item- the item to be added to the component- Returns:
- the builder instance after the item has been added
-
fixed
Same as fixed(true) -
fixed
Flag to indicate Accordion content is fixed -
large
Same as large(true) -
large
Adds/removes modifier(large, lg) -
singleExpand
Same as singleExpand(true) -
singleExpand
Whether only oneAccordionItemcan be expanded -
headingLevel
-
iconPosition
-
that
- Specified by:
thatin interfaceTypedBuilder<HTMLElement, Accordion>
-
onAdd
Description copied from interface:HasItemsRegisters a callback to be invoked whenever a new item is added to the component.- Specified by:
onAddin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
onAdd- aAddItemHandlerthat takes the builder instance and the item being added as arguments- Returns:
- the builder instance after adding the callback
-
onUpdate
Description copied from interface:HasItemsRegisters a callback to be invoked whenever an item is updated in the component.- Specified by:
onUpdatein interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
onUpdate- aUpdateItemHandlerthat takes the component, the previous state of the item, and the updated state of the item as arguments- Returns:
- the builder instance after adding the callback
-
onRemove
Description copied from interface:HasItemsRegisters a callback to be invoked whenever an item is removed from the component.- Specified by:
onRemovein interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
onRemove- aRemoveItemHandlerthat takes the component and the item being removed as arguments- Returns:
- the builder instance after adding the callback
-
onToggle
-
collapse
-
collapse
-
expand
-
expand
-
iterator
- Specified by:
iteratorin interfaceIterable<AccordionItem>
-
size
public int size()Description copied from interface:HasItemsRetrieves the total number of items currently contained in the component.- Specified by:
sizein interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Returns:
- the number of items contained in the component
-
isEmpty
public boolean isEmpty()Description copied from interface:HasItemsChecks whether the collection of items in the component is empty.- Specified by:
isEmptyin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Returns:
trueif the component contains no items;falseotherwise
-
contains
Description copied from interface:HasItemsChecks whether the component contains an item associated with the given identifier.- Specified by:
containsin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
identifier- the identifier of the item to be checked- Returns:
- true if the component contains an item associated with the provided identifier, false otherwise
-
item
Description copied from interface:HasItemsRetrieves the item associated with the specified identifier from the component.- Specified by:
itemin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
identifier- the identifier of the item to be retrieved- Returns:
- the item associated with the given identifier, or
nullif no item is found
-
updateItem
Description copied from interface:HasItemsUpdates an existing item in the component.- Specified by:
updateItemin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
item- the item to be updated
-
removeItem
Description copied from interface:HasItemsRemoves an item from the component based on the provided identifier.- Specified by:
removeItemin interfaceHasItems<HTMLElement, Accordion, AccordionItem>- Parameters:
identifier- the identifier of the item to be removed
-
clear
public void clear()Description copied from interface:HasItemsClears all items from the component. This method removes any existing items within the component, leaving it empty. Any associated or registered callbacks related to the removal of items may be invoked as part of this operation.- Specified by:
clearin interfaceHasItems<HTMLElement, Accordion, AccordionItem>
-