Recommended | Not Recommended |
---|---|
Prioritize Optional Content: Use accordions for secondary or optional information that supports but isn't crucial to the main content. | Avoid Hiding Critical Info: Never use accordions for essential, must-see information. |
Group Related Information: Keep content in each accordion section closely related to ensure user predictability. | Limit Nesting: Avoid multiple levels of nested accordions to prevent user confusion. |
Include Section Summaries: For complex or lengthy content, offer short previews in the collapsed state to help users decide to expand. | Don't Overuse: If your page is filled with accordions, reconsider your content strategy to avoid clutter. |
{% include '@bolt-components-accordion/accordion.twig' with {
content: 'This is a accordion component.'
} only %}
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal attributes object. Applies extra HTML attributes to the parent element. |
object
| — |
|
content
|
All of the items in the accordion. Each item should contain a header and a content. |
any
| — |
|
single
|
Allow only one section to open at a time. |
boolean
|
false
|
|
no_separator
|
Hides the separator in between items. |
boolean
|
false
|
|
box_shadow
|
Creates a box shadow around the accordion. |
boolean
|
false
|
|
spacing
|
Controls the inset spacing of each item. |
string
|
medium
|
|
icon_valign
|
Vertically align the accordion trigger content and trigger icon. |
string
|
center
|
|
scroll_offset
|
Additional offset for smooth scrolling, integer converted to pixel value. |
integer
| — |
|
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal attributes object. Applies extra HTML attributes to the parent element. |
object
| — |
|
content
|
Expandable content of an item. |
any
| — |
|
trigger
|
Trigger content of an item. |
any
|
Toggle Accordion
|
|
open
|
Automatically expand an item on page load. |
boolean
|
false
|
|
inactive
|
Display item trigger as an inactive element. Item content will be collapsed and the toggle icon hidden. |
boolean
|
false
|
|
npm install @bolt/components-accordion
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: 'Accordion Item One',
content: 'Lorem ipsum dolor sit amet..',
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
} only %}
single
prop to true
, it allows only one Accordion item to be opened at a time.
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
single: true,
} only %}
no_separator
prop to true
, it will remove the separator in between Accordion items.
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
no_separator: true,
} only %}
box_shadow
prop to true
, it will create a box shadow around the accordion.
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
box_shadow: true,
} only %}
spacing
prop to none
, xsmall
, small
, medium
, or large
, it applies the appropriate inset spacing for each accordion item. The default is medium
.
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
spacing: 'xlarge',
} only %}
icon_valign
prop to top
or center
, it will vertically align the trigger and the icon accordingly. The default is center
.
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
icon_valign: 'top',
} only %}
open
prop to true
on any accordion item to display the content of that item on page load.
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: 'Accordion Item One',
open: true,
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
} only %}
inactive
prop to true
on any accordion item to display the trigger as an inactive element. It will have the same font-styles as the other triggers but none of the interactive styles. It will not be clickable, and that item's content and toggle icon will always be hidden.
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: 'Accordion Item One',
inactive: true,
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
} only %}
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: 'Accordion Item One',
attributes: {
id: 'accordion-item-3',
}
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
} only %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
scroll_offset: 5,
} only %}
trigger
prop of the accordion-item
.
{% set trigger1 %}
{% include '@bolt-elements-type/type.twig' with {
content: 'What are the different ways we can debug an issue in Rest OR SOAP Connector?',
weight: 'bold',
tag: 'h2',
size: 'medium',
color: 'navy',
} only %}
{% endset %}
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: trigger1,
content: 'You can debug the issues in connector through: 1) Tracing the connector activity if it is invoking through activity; 2) Add log message to the activity to check for logs; 3) If it is invoking through Data page, use response data transform to check for issues using when rules and invoke standard data transform template for logging along with email notification.',
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
box_shadow: true,
} only %}
accordion-item
props.
{% set trigger %}
{% set headline_1 %}
{% include '@bolt-elements-type/type.twig' with {
content: '12:00 PM',
} only %}
{% endset %}
{% set headline_2 %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Lunch & Networking',
size: 'xlarge',
} only %}
{% endset %}
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1',
column_span: '12 3@small',
content: headline_1,
},
{
column_start: '1 4@small',
column_span: '12 9@small',
content: headline_2,
},
]
} only %}
{% endset %}
{% set content %}
{% set link_1 %}
{% include '@bolt-elements-text-link/text-link.twig' with {
content: 'Get the presentation',
icon_before: icon_presentation,
attributes: {
href: 'https://google.com',
}
} only %}
{% endset %}
{% set link_2 %}
{% include '@bolt-elements-text-link/text-link.twig' with {
content: 'Watch video',
icon_before: icon_video,
attributes: {
href: 'https://google.com',
}
} only %}
{% endset %}
{% set content_item %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Neque minima nisi optio cumque esse ullam rerum reiciendis itaque iste, quod sunt explicabo, est eum quo aliquid hic commodi laboriosam at. Lorem ipsum dolor sit, amet consectetur adipisicing elit.',
} only %}
{% include '@bolt-elements-type/type.twig' with {
content: 'Neque minima nisi optio cumque esse ullam rerum reiciendis itaque iste, quod sunt explicabo, est eum quo aliquid hic commodi laboriosam at.',
weight: 'bold',
} only %}
{% include '@bolt-components-list/list.twig' with {
display: 'inline',
spacing: 'small',
items: [
link_1,
link_2,
]
} only %}
{% endset %}
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1 4@small',
column_span: '12 9@small',
content: content_item,
},
]
} only %}
{% endset %}
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: trigger,
content: content,
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
} only %}
{% set image %}
{% include '@bolt-elements-image/image.twig' with {
attributes: {
src: '/images/placeholders/16x9.jpg',
alt: 'Alt text.',
loading: 'lazy',
width: 800,
height: 450,
}
} only %}
{% endset %}
{% set items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: 'Expand this to see an image.',
content: image,
} only %}
...
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: items,
} only %}
{% set list_items %}
{% include '@bolt-elements-list/list-item.twig' with {
content: 'Heading very long accordion first label',
} only %}
{% include '@bolt-elements-list/list-item.twig' with {
content: 'Heading second label',
} only %}
{% endset %}
{% set double_label %}
{% include '@bolt-elements-list/list.twig' with {
separator: 'solid',
content: list_items,
display: 'horizontal',
nowrap: true,
tag: 'span'
} only %}
{% endset %}
{% set accordion_items %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: double_label,
content: 'Lorem ipsum dolor sit amet..',
} only %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: double_label,
content: 'Lorem ipsum dolor sit amet..',
} only %}
{% include '@bolt-components-accordion/accordion-item.twig' with {
trigger: double_label,
content: 'Lorem ipsum dolor sit amet..',
} only %}
{% endset %}
{% include '@bolt-components-accordion/accordion.twig' with {
content: accordion_items,
} only %}