Skip to main content

Accordion

Usage

Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum
function AccordionUsage() {
return (
<View>
<Accordion
title="Hello from Accordion"
description="Hello from Blossom UI"
content={'Lorem Ipsum '.repeat(20)}
/>
</View>
)
}

Custom

You are certainly not spammed!!
function AccordionCustom() {
const ChevronView = useCallback(
(isOpen: boolean) => <Text typography="h3">{isOpen ? '🙃' : '🙂'}</Text>,
[],
)

return (
<View>
<Accordion
title={
<Text status="success" typography="h6">
Hello
</Text>
}
description={
<Text status="accent" typography="c2">
Click to know more
</Text>
}
left={<Icon name="home" />}
chevron={ChevronView}>
<Text status="info">You are certainly not spammed!!</Text>
</Accordion>
</View>
)
}

Props

PropData TypeDefault ValueDescription
Extends--Inherits properties from
isOpenboolean--Set it to true to open the accordion
titleReactNode--Title of the accordion
descriptionReactNode--description of the accordion below title
contentstring--Content of the accordion shown when expanded
childrenReactNode--Render custom view inside the accordion instead of the content string
leftReactNode--Render any icon/JSX on left of the title
rightReactNode--Render any icon/JSX on right of the title
chevron(isOpen: boolean) => ReactNode--Custom chevron icon to show
containerStyleStyleProp<ViewStyle>--Container style for the accordion
headerStyleStyleProp<ViewStyle>--Accordion header style for title & description
onPress() => void--On press callback on the title section
transitionDurationnumber300Set the animation transition duration for the accordion