<Accordionm="$5"width="90%"size="md"variant="filled"type="single"isCollapsible={true}isDisabled={false}><AccordionItem value="a"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>How do I place an order?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={ChevronUpIcon} ml="$3" />) : (<AccordionIcon as={ChevronDownIcon} ml="$3" />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>To place an order, simply select the products you want, proceed tocheckout, provide shipping and payment information, and finalize yourpurchase.</AccordionContentText></AccordionContent></AccordionItem><AccordionItem value="b"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>What payment methods do you accept?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={ChevronUpIcon} ml="$3" />) : (<AccordionIcon as={ChevronDownIcon} ml="$3" />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>We accept all major credit cards, including Visa, Mastercard, andAmerican Express. We also support payments through PayPal.</AccordionContentText></AccordionContent></AccordionItem></Accordion>
import { Accordion } from '@gluestack-ui/themed';
export default () => (<Accordion><AccordionItem><AccordionHeader><AccordionTrigger><AccordionTitleText /><AccordionIcon /></AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText /></AccordionContent></AccordionItem></Accordion>)
Prop | Type | Default | Description |
---|---|---|---|
type | "single" | "multiple" | "single" | Determines whether one or multiple items can be opened at the same time. |
isCollapsible | boolean | true | When type is "single" or "multiple", allows closing content when clicking trigger for an open item. |
defaultValue | string[] | [] | The value of the item to expand when initially rendered when type is "single" or "multiple". |
value | string[] | [] | The controlled value of the item to expand when type is "single" or "multiple". |
onValueChange | function | - | Event handler called when the expanded state of an item changes and type is "single" or "multiple". |
isDisabled | boolean | false | When true, prevents the user from interacting with the accordion and all its items. |
Sx Prop | Description |
---|---|
_item | Prop to style the AccordionItem Component |
_titleText | Prop to style the AccordionTitleText Component |
_contentText | Prop to style the AccordionContentText Component |
_icon | Prop to style the AccordionIcon Component |
Prop | Type | Default | Description |
---|---|---|---|
value | string | - | The controlled value of the item to expand when type is "single" or "multiple". Must be used in conjunction with onValueChange.This is a mandatory prop. |
isDisabled | boolean | false | When true, prevents the user from interacting with the accordion and all its items. |
function App() {return (<Accordionwidth="90%"type="multiple"m="$5"borderWidth={1}shadowColor="transparent"borderColor="$borderLight300"$dark-borderColor="$borderDark700"><AccordionItemvalue="a"borderBottomWidth={1}sx={{borderBottomColor: "$borderLight300",_dark: {borderBottomColor: "$borderDark700",},}}><AccordionHeadersx={{backgroundColor: "$backgroundLight0",_dark: {backgroundColor: "$backgroundDark950",},}}><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>What does the "type" prop of the Accordion component do?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={ChevronUpIcon} />) : (<AccordionIcon as={ChevronDownIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContentmt="$0"pt="$2"sx={{backgroundColor: "$backgroundLight50",_dark: {backgroundColor: "$backgroundDark900",},}}><AccordionContentText>The type prop determines whether one or multiple items can be openedat the same time. The default value is "single" which means only oneitem can be opened at a time.</AccordionContentText></AccordionContent></AccordionItem><AccordionItemvalue="b"borderBottomWidth={1}borderBottomColor="$borderLight300"$dark-borderBottomColor="$borderDark700"><AccordionHeadersx={{backgroundColor: "$backgroundLight0",_dark: {backgroundColor: "$backgroundDark950",},}}><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>Can I disable the whole accordion?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={ChevronUpIcon} />) : (<AccordionIcon as={ChevronDownIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContentmt="$0"pt="$2"sx={{backgroundColor: "$backgroundLight50",_dark: {backgroundColor: "$backgroundDark900",},}}><AccordionContentText>Yes, you can disable the whole accordion by setting the isDisabledprop to true on the Accordion component.</AccordionContentText></AccordionContent></AccordionItem><AccordionItem value="c"><AccordionHeadersx={{backgroundColor: "$backgroundLight0",_dark: {backgroundColor: "$backgroundDark950",},}}><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>What is a controlled accordion? How can I make itcontrolled?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={ChevronUpIcon} />) : (<AccordionIcon as={ChevronDownIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContentmt="$0"pt="$2"sx={{backgroundColor: "$backgroundLight50",_dark: {backgroundColor: "$backgroundDark900",},}}><AccordionContentText>Controlled components refer to the components where the state andbehaviors are controlled by the Parent component. You can make theaccordion a controlled component by passing the value prop to theAccordion component and setting the onValueChange prop to update thevalue prop. Refer to the controlled accordion example in the docs.</AccordionContentText></AccordionContent></AccordionItem></Accordion>)}
function App() {return (<Accordion m="$5" width="80%" maxWidth={640} shadowColor="transparent"><AccordionItem value="item-1" borderRadius="$lg"><AccordionHeader><AccordionTriggersx={{":focusVisible": {borderRadius: "$lg",},}}>{({ isExpanded }) => {return (<>{isExpanded ? (<AccordionIcon as={MinusIcon} mr="$3" />) : (<AccordionIcon as={PlusIcon} mr="$3" />)}<AccordionTitleText>How do I place an order?</AccordionTitleText></>)}}</AccordionTrigger></AccordionHeader><AccordionContent ml="$9"><AccordionContentText>To place an order, simply select the products you want, proceed tocheckout, provide shipping and payment information, and finalizeyour purchase.</AccordionContentText></AccordionContent></AccordionItem><AccordionItem value="item-2" mt="$5" borderRadius="$lg"><AccordionHeader><AccordionTriggersx={{":focusVisible": {borderRadius: "$lg",},}}>{({ isExpanded }) => {return (<>{isExpanded ? (<AccordionIcon as={MinusIcon} mr="$3" />) : (<AccordionIcon as={PlusIcon} mr="$3" />)}<AccordionTitleText>What payment methods do you accept?</AccordionTitleText></>)}}</AccordionTrigger></AccordionHeader><AccordionContent ml="$9"><AccordionContentText>We accept all major credit cards, including Visa, Mastercard, andAmerican Express. We also support payments through PayPal.</AccordionContentText></AccordionContent></AccordionItem></Accordion>)}
function App() {return (<Accordion m="$5" variant="unfilled" width="90%"><AccordionItemvalue="item-1"isDisabled={true}borderBottomWidth={1}borderColor="$borderLight300"$dark-borderColor="$borderDark700"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>Disabled Item</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>This is a Disabled Item.</AccordionContentText></AccordionContent></AccordionItem><AccordionItem value="item-2"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>Is this accordion accessible?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Yes, the accordion is accessible. It adheres to the WAI-ARIA designpattern. You can read more about it in the accessibility section ofthe docs.</AccordionContentText></AccordionContent></AccordionItem></Accordion>)}
function App() {return (<Accordionm="$5"variant="unfilled"type="single"defaultValue="item-3"width="90%"><AccordionItem value="item-1" borderRadius="$lg"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>What is the defaultValue prop of the Accordion component?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>The defaultValue prop of the Accordion component is used to definethe open item by default. It is used when the Accordion component isuncontrolled.</AccordionContentText></AccordionContent></AccordionItem><Divider /><AccordionItem value="item-2" borderRadius="$lg"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>How many size variants does the Accordion component have?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>The Accordion component has three size variants - sm, md and lg.</AccordionContentText></AccordionContent></AccordionItem><Divider /><AccordionItem value="item-3" borderRadius="$lg"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>Can I nest my accordions?</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Yes, you can nest your accordions. Refer to the nested accordionexample in the docs.</AccordionContentText></AccordionContent></AccordionItem></Accordion>)}
function App() {return (<Accordionvariant="unfilled"size="sm"m="$5"borderWidth={1}borderColor="$borderLight300"$dark-borderColor="$borderDark700"width="80%"maxWidth={640}><AccordionItem value="a"><AccordionHeadersx={{backgroundColor: "$backgroundLight0",_dark: {backgroundColor: "$backgroundDark950",},}}><AccordionTrigger>{({ isExpanded }) => (<>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}<AccordionTitleText ml="$3">USA</AccordionTitleText></>)}</AccordionTrigger></AccordionHeader><AccordionContent pb="$0"><Accordionwidth="100%"shadowColor="transparent"borderWidth={1}sx={{borderColor: "$borderLight300",backgroundColor: "$backgroundLight0",_dark: {borderColor: "$borderDark700",backgroundColor: "$backgroundDark950",},}}><AccordionItem value="b"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => (<>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}<AccordionTitleText ml="$3">California</AccordionTitleText></>)}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Capital city of California is Sacramento. California has a GDPof 2.89 trillion dollars and follows Pacific Standard Timezone.</AccordionContentText></AccordionContent></AccordionItem></Accordion><Accordionwidth="100%"shadowColor="transparent"mt="$5"sx={{backgroundColor: "$backgroundLight0",_dark: {backgroundColor: "$backgroundDark950",},}}><AccordionItem value="c"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => (<>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}<AccordionTitleText ml="$3">Nevada</AccordionTitleText></>)}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Nevada is located in a mountainous region that includes vastsemiarid grasslands and sandy alkali deserts. It is the mostarid state of the country.</AccordionContentText></AccordionContent></AccordionItem></Accordion></AccordionContent></AccordionItem></Accordion>)}
function App() {const [selectedValues, setSelectedValues] = React.useState(["item-1","item-2",])return (<Accordionm="$5"variant="unfilled"width="95%"type="multiple"value={selectedValues}onValueChange={(item) => setSelectedValues(item)}><AccordionItemvalue="item-1"borderTopWidth={1}borderBottomWidth={1}sx={{borderColor: "$borderLight300",_dark: {borderColor: "$borderDark700",},}}><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>Exploring Nature's Wonders</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Embark on a journey through the breathtaking landscapes and diverseecosystems of our planet. From majestic mountains to serene oceans,discover the beauty that nature has to offer.</AccordionContentText></AccordionContent></AccordionItem><AccordionItem value="item-2"><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>The Art of Culinary Delights</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Indulge your senses in a culinary adventure. Uncover the secretsbehind delectable dishes, learn about unique flavor profiles, andignite your passion for cooking.</AccordionContentText></AccordionContent></AccordionItem><AccordionItemvalue="item-3"borderTopWidth={1}borderBottomWidth={1}sx={{borderColor: "$borderLight300",_dark: {borderColor: "$borderDark700",},}}><AccordionHeader><AccordionTrigger>{({ isExpanded }) => {return (<><AccordionTitleText>Mastering the Creative Process</AccordionTitleText>{isExpanded ? (<AccordionIcon as={MinusIcon} />) : (<AccordionIcon as={PlusIcon} />)}</>)}}</AccordionTrigger></AccordionHeader><AccordionContent><AccordionContentText>Immerse yourself in the world of creativity. Unleash your artisticpotential, whether it's through writing, painting, or any other formof expression.</AccordionContentText></AccordionContent></AccordionItem></Accordion>)}