Accordion
The <Accordion/>
component render breadcrumbs that show the user where they are in the site's hierarchy.
- Usage
- Props
Import
import { Accordion, AccordionItem, AccordionButton } from "matro-ui";
Accordion
: The wrapper that provides context and logic to the componentsAccordionItem
: Individual accordion element containing a button.AccordionButton
: The button that toggles show/hide state of the accordion item
Usage
Loading...
Live Editor
<Accordion> <AccordionItem> <AccordionButton>Accordion Item 1</AccordionButton> <i>Content 1</i> </AccordionItem> <AccordionItem> <AccordionButton>Accordion Item 2</AccordionButton> <div>Content 2</div> </AccordionItem> </Accordion>
Custom Icon
You can pass the setIcon
prop callback to change the default icon and render it conditionaly based on the props.isOpened
argument.
Loading...
Live Editor
<Accordion setIcon={(props) => props.isOpened ? "🚀" : <>😴</>}> <AccordionItem> <AccordionButton>Item #1</AccordionButton> <i>content 1</i> </AccordionItem> <AccordionItem> <AccordionButton>Item #2</AccordionButton> <div>content 2</div> </AccordionItem> </Accordion>
Opened by default
To make the <AccordionItem/>
opened by default, pass the isOpened
prop to it:
Loading...
Live Editor
<Accordion> <AccordionItem isOpened> <AccordionButton>Item #1</AccordionButton> <b>Hi! I'm opened by default! 👋🏿</b> </AccordionItem> </Accordion>
Props of <Accordion/>
:
<Accordion/>
:children
Description
Any possible React Children. At least one
<AccordionItem/>
is required.TypeReact.FC | React.FC[] | string | number
setIcon
DescriptionCallback function that sets custom Icon to each child (
<AccordionItem/>
) and recieves props.isOpened
to render it conditionally.Typefunction
Props of <AccordionItem/>
:
<AccordionItem/>
:children
Description
Any possible React Children. At least one
<AccordionButton/>
is required.TypeReact.FC | React.FC[] | string | number
setIcon
DescriptionCallback function that sets custom Icon and recieves
props.isOpened
to render it conditionally.Typefunction
isOpened
DescriptionOpened by default if set to true.
Typeboolean
Defaultfalse
Props of <AccordionButton/>
:
<AccordionButton/>
:children
Description
Any possible React Children.
TypeReact.FC | React.FC[] | string | number