Collapse
A content area which can be collapsed and expanded.
When To Use
- Can be used to group or hide complex regions to keep the page clean.
- Accordion is a special kind of Collapse, which allows only one panel to be expanded at a time.
Collapse
More than one panel can be expanded at a time.
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
astro
<Accordion>
<AccordionItem title="This is panel header 1">
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
</AccordionItem>
<AccordionItem title="This is panel header 2">
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
</AccordionItem>
<AccordionItem title="This is panel header 3">
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
</AccordionItem>
</Accordion> Accordion
Accordion mode, only one panel can be expanded at a time.
This is panel header 1 content
This is panel header 2 content
This is panel header 3 content
astro
<Accordion type="single">
<AccordionItem title="This is panel header 1" isOpen>
This is panel header 1 content
</AccordionItem>
<AccordionItem title="This is panel header 2">
This is panel header 2 content
</AccordionItem>
<AccordionItem title="This is panel header 3">
This is panel header 3 content
</AccordionItem>
</Accordion> Extra Node / Icons
You can use `icon` and `expandIcon` props to customize icons.
Manage your account settings and preferences.
View and update your payment methods and billing history.
Configure how you receive alerts and updates.
astro
<Accordion>
<AccordionItem title="Account Settings" icon="User">
Manage your account settings and preferences.
</AccordionItem>
<AccordionItem title="Billing Information" icon="CreditCard">
View and update your payment methods and billing history.
</AccordionItem>
<AccordionItem title="Notifications" icon="Bell">
Configure how you receive alerts and updates.
</AccordionItem>
</Accordion> Custom Panel Header
Customize the header styles for each panel using the `title` slot.
This item uses a custom slot for the title to allow complex layouts.
astro
<Accordion>
<AccordionItem>
<div slot="title" class="flex items-center justify-between w-full pr-4 text-left">
<span class="font-semibold text-blue-600 dark:text-blue-400">Custom Styled Title</span>
<span class="text-xs px-2 py-1 bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 rounded-full">New</span>
</div>
This item uses a custom slot for the title to allow complex layouts.
</AccordionItem>
</Accordion> API
Accordion
| Property | Description | Type | Default |
|---|---|---|---|
| type | Sets the behavior to either allow "single" or "multiple" items expanded at once. | "single" | "multiple" | "multiple" |
| class | Additional CSS classes to apply to the accordion container. | string | '' |
AccordionItem
| Property | Description | Type | Default |
|---|---|---|---|
| title | The text title of the accordion item. | string | '' |
| isOpen | Whether the item is open by default. | boolean | false |
| icon | Icon to display to the left of the title. | IconName | '' |
| expandIcon | Icon to display to the right for the expand trigger. | IconName | "ChevronDown" |
| class | Additional CSS classes for the item. | string | '' |