Accordion
Accordion
Component demo
Interactive example
<ic-accordionheading="English Breakfast"><ic-typographyvariant="body"> A blend of different black teas.</ic-typography></ic-accordion><ic-accordionheading="Earl Grey"><ic-typographyvariant="body"> A tea blend that has been flavoured with oil of bergamot.</ic-typography></ic-accordion>
<IcAccordionheading="English Breakfast"><IcTypographyvariant="body"> A blend of different black teas.</IcTypography></IcAccordion><IcAccordionheading="Earl Grey"><IcTypographyvariant="body"> A tea blend that has been flavoured with oil of bergamot.</IcTypography></IcAccordion>
Accordion details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
If |
|
|
If |
|
|
The section header outlining section content. |
|
|
The main body message of the accordion. |
|
|
The size of the accordion. |
|
|
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
|
If |
If |
The section header outlining section content. |
The main body message of the accordion. |
The size of the accordion. |
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Accordion group details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The accessible button label to provide more context to the 'See all/Hide all' button for screen reader users. |
|
|
If |
|
|
The header for the accordion group. |
|
|
If |
|
|
The size of the accordion. |
|
|
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
|
The accessible button label to provide more context to the 'See all/Hide all' button for screen reader users. |
If |
The header for the accordion group. |
If |
The size of the accordion. |
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Variants
With icon
Interactive example
<ic-accordionheading="English Breakfast"><svgslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg><ic-typographyvariant="body"> A blend of different black teas.</ic-typography></ic-accordion><ic-accordionheading="Earl Grey"><svgslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg><ic-typographyvariant="body"> A tea blend that has been flavoured with oil of bergamot.</ic-typography></ic-accordion>
<IcAccordionheading="English Breakfast"><SlottedSVGslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG><IcTypographyvariant="body"> A blend of different black teas.</IcTypography></IcAccordion><IcAccordionheading="Earl Grey"><SlottedSVGslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG><IcTypographyvariant="body"> A tea blend that has been flavoured with oil of bergamot.</IcTypography></IcAccordion>
With accordion group label and see all / hide all button
Interactive example
Coffee
<ic-accordion-grouplabel="Coffee"><ic-accordionheading="Cappuccino"><ic-typographyvariant="body"> An espresso-based drink that is traditionally prepared with steamed milk foam.</ic-typography></ic-accordion><ic-accordionheading="Americano"><ic-typographyvariant="body"> An espresso-based drink that is diluted with hot water.</ic-typography></ic-accordion></ic-accordion-group>
<IcAccordionGrouplabel="Coffee"><IcAccordionheading="Cappucino"><IcTypographyvariant="body"> An espresso-based drink that is traditionally prepared with steamed milk foam.</IcTypography></IcAccordion><IcAccordionheading="Americano"><IcTypographyvariant="body"> An espresso-based drink that is diluted with hot water.</IcTypography></IcAccordion></IcAccordionGroup>
Theme
Interactive example
Coffee
<ic-accordion-grouplabel="Coffee"theme="dark"><ic-accordionheading="English Breakfast"><svgslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg><ic-typographyvariant="body"> A blend of different black teas.</ic-typography></ic-accordion><ic-accordionheading="Earl Grey"><svgslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg><ic-typographyvariant="body"> A tea blend that has been flavoured with oil of bergamot.</ic-typography></ic-accordion></ic-accordion-group>
<IcAccordionGrouplabel="Coffee"theme="dark"><IcAccordionheading="English Breakfast"><SlottedSVGslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG><IcTypographyvariant="body"> A blend of different black teas.</IcTypography></IcAccordion><IcAccordionheading="Earl Grey"><SlottedSVGslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG><IcTypographyvariant="body"> A tea blend that has been flavoured with oil of bergamot.</IcTypography></IcAccordion></IcAccordionGroup>
With nested accordions
Interactive example
Coffee
<ic-accordion-grouplabel="Coffee"><ic-accordionheading="Cappuccino"><ic-typographyvariant="body"> An espresso-based drink that is traditionally prepared with steamed milk foam.</ic-typography></ic-accordion><ic-accordionheading="Other coffees"><ic-accordionheading="Americano"><ic-typographyvariant="body"> An espresso-based drink that is diluted with hot water.</ic-typography></ic-accordion><ic-accordionheading="Latte"><ic-typographyvariant="body"> A milkier coffee than a cappuccino.</ic-typography></ic-accordion></ic-accordion></ic-accordion-group>
<IcAccordionGrouplabel="Coffee"><IcAccordionheading="Cappucino"><IcTypographyvariant="body"> An espresso-based drink that is traditionally prepared with steamed milk foam.</IcTypography></IcAccordion><IcAccordionheading="Other coffees"><IcAccordionheading="Americano"><IcTypographyvariant="body"> An espresso-based drink that is diluted with hot water.</IcTypography></IcAccordion><IcAccordionheading="Latte"><IcTypographyvariant="body"> A milkier coffee than a cappuccino.</IcTypography></IcAccordion></IcAccordion></IcAccordionGroup>