Accordion
Accordion is a vertical stack of interactive headings used to toggle the display of further information; each item can be collapsed with just a short label visible or expanded to show the full content.
Usage
Code EditorCopyimport { Accordion } from '@erudilabs/alma' import type { AccordionItemsProps } from '@erudilabs/alma'
Types
Code EditorCopyimport type { AccordionItemsProps } from '@erudilabs/alma'
AccordionItemsProps = { title: ReactNode; content: ReactNode }[]
To make Accordion
content you must have an array of object and use AccordionItemsProps
types like example below
Code EditorCopyconst items: AccordionItemsProps = [ { title: 'Do you have a guardian', content: 'Account verification and important application updates will be sent to your mobile, therefore you must have a working mobile number', }, { title: 'Do you have a valid and active mobile number', content: 'We will require you to provide a guardian who is at least 21 years old and currently residing in the Philippines. Your guardian must also have a contactable mobile number and an active email address.', }, ]
Component
Here preview and detail explain of Accordion
component
Default
Code EditorCopy<Accordion items={items} />
Expanded Item
In an accordion component, the default expanded item refers to the section that is initially expanded when the accordion is rendered. By default, all other sections are collapsed. but you can set with defaultExpandedItem
prop set with an number or all
.
Single Item
Code EditorCopy<Accordion items={items} defaultExpandedItem={1} />
All Item
if you pass with all
accordion items will expanded all items and allow multipleExpand
without passing the props
Code EditorCopy<Accordion items={items} defaultExpandedItem="all" />
Multiple Expand
Allows multiple items to be expanded simultaneously, you can use props multipleExpand
as a boolean
.
Code EditorCopy<Accordion items={items} multipleExpand />
Props Reference
Prop
Type
Default
testId?
string
-
className?
string
-
items
AccordionItemsProps
-
defaultExpandedItem?
number | all
-
multipleExpand?
boolean
false