Usage
The accordion component is comprised of two components:
- AccordionGroup: a wrapper for grouping related panel components.
- AccordionPanel: a panel component which contains header (trigger element) and content (content to display).
The AccordionGroup provides a single default
slot to display all child AccordionPanel elements and controls the overall width of the rendered component.
::accordion-group
::accordion-panel
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Customization Options
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Components
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::
By default, the group only allows a single panel to be expanded at a time. By setting the group's multiple
prop to true
, the AccordionGroup will allow multiple items to be expanded simultaneously.
The AccordionPanel component is a group of vertically collapsing header and content slots that can be used to show and hide information.
Accordion Group
Props
multiple
A boolean
to determine if multiple items can be expanded at once.
- Type:
boolean
- Default:
false
::accordion-group
---
multiple: true
---
::accordion-panel
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Customization Options
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Components
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::
panelProps
You can configure common properties for all child AccordionPanel components from the parent AccordionGroup by passing the desired settings via the group's panelProps
.
Each panelProps
property will be bound to all panels in the current group.
Should you desire to customize an individual AccordionPanel, you can provide these same options directly to the individual panel component as top-level props.
- Type:
Object
- Default:
{ border: '1px solid #e0e4ea', margin: '0', headerColor: '#52596e', headerBackgroundColor: 'transparent', headerBorderRadius: null, headerPadding: '8px 12px', headerMargin: '0', contentColor: '#52596e', contentBackgroundColor: 'transparent', contentBorderRadius: null, contentMargin: '0', contentPadding: '0 12px 12px', }
::accordion-group
---
multiple: false
panel-props:
border: "1px solid darkcyan"
margin: "0px"
header-color: "darkcyan"
header-border-radius: "2px"
header-margin: "2px"
header-padding: "4px"
content-color: "black"
content-border-radius: "2px"
content-margin: "4px"
content-padding: "6px"
---
::accordion-panel
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Customization Options
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Components
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::
Shared Props
The AccordionGroup component also includes the shared props listed below:
margin
- default is0
maxWidth
- default is100%
.styles
- default is''
.
More information on shared props can be found here.
Slots
default
Use the #default
slot to add AccordionPanel components to display content inside AccordionGroup.
Accordion Panel
Expandable container to display a header and content, used as a direct child of the AccordionGroup component.
Props
Passing props directly to the AccordionPanel will override options passed to the AccordionGroup via panelProps
.
expanded
Determines if the accordion panel should be expanded initially.
- Type:
boolean
- Default:
false
::accordion-group
::accordion-panel
---
expanded: true
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Customization Options
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::accordion-panel
#header
Components
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
::
header
Text to display in the header of the accordion panel. If the header
slot is provided, the slot content takes precedence.
- Type:
string
- Default:
''
content
Text to display in the content section of the accordion panel. If the content
slot is provided, the slot content takes precedence.
- Type:
string
- Default:
''
::accordion-group
::accordion-panel
---
header: "Getting Started"
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate."
---
::
::
PanelProps
headerColor
The color of the header text.
- Type:
string
- Default:
#52596e
::accordion-panel
---
headerColor: "darkcyan"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
headerBackgroundColor
The background-color of the header.
- Type:
string
- Default:
transparent
::accordion-panel
---
headerBackgroundColor: "lightgray"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
headerBorderRadius
The border radius of the header.
- Type:
string | null
- Default:
null
::accordion-panel
---
headerBorderRadius: "4px"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
headerMargin
The margin of the header.
- Type:
string
- Default:
0
::accordion-panel
---
headerMargin: "12px"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
headerPadding
The padding of the header.
- Type:
string
- Default:
8px 12px
::accordion-panel
---
headerPadding: "20px"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
contentColor
The text color of the content area.
- Type:
string
- Default:
#52596e
::accordion-panel
---
contentColor: "darkcyan"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
contentBackgroundColor
The background-color of the content area.
- Type:
string
- Default:
transparent
::accordion-panel
---
contentBackgroundColor: "lightgray"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
contentBorderRadius
The border radius of the content area.
- Type:
string
- Default:
null
::accordion-panel
---
contentBackgroundColor: "lightgray"
contentBorderRadius: "4px"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
contentMargin
The margin around the content area.
- Type:
string
- Default:
0
::accordion-panel
---
contentBackgroundColor: "lightgray"
contentMargin: "12px"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
contentPadding
The padding of the content area.
- Type:
string
- Default:
0 12px 12px
::accordion-panel
---
contentBackgroundColor: "lightgray"
contentPadding: "20px"
---
#header
Getting Started
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
Shared Props
The AccordionPanel component also includes the shared props listed below:
border
- default is1px solid #e0e4ea
.margin
- default is0
.styles
- default is''
.
More information on shared props can be found here.
Slots
header
Use the #header
slot to customize the trigger button.
::accordion-panel
---
expanded: true
---
#header
[Getting Started](/){ style="color: darkcyan; font-weight: 600"}
#content
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.
::
content
Use the #content
slot to customize the panel's content.
::accordion-panel
---
expanded: true
---
#header
Getting Started
#content
[Custom link goes here](/)
::