Accordions allow users to expand and collapse sections of content, facilitating efficient information organization.
Open in new window
Open in new window
Open in new window
Open in new window
View RTL
<template><BaseAccordionheader="I am an accordion"><pclass="n-padding-b-s"> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nulla provident aliquid corporis tempora eius quam, quae vel molestias esse maxime aperiam totam suscipit. Nobis consectetur optio reprehenderit animi? Suscipit, quibusdam?</p></BaseAccordion></template>
<scriptsetuplang="ts">const isCollapsed =ref(false)const isDisabled =ref(false)</script><template><div><divslot="header-end"class="n-stack-horizontal n-margin-bs-s n-margin-be-l"><provet-buttontype="button"size="s":disabled="isDisabled"@click="isCollapsed = !isCollapsed"> {{ isCollapsed ? 'Expand' : 'Collapse' }}</provet-button><provet-buttontype="button"size="s"@click="isDisabled = !isDisabled"> {{ isDisabled ? 'Enabled' : 'Disable' }}</provet-button></div><BaseAccordionv-model:collapsed="isCollapsed"header-gap="l":disabled="isDisabled"><template#header><spanclass="n-font-weight-heading">Some title</span></template><template#header-description><spanclass="n-color-text-weaker n-font-weight"> Some description</span></template><divclass="n-padding-b-s"> It is also possible to add header actions. There will be plenty of cases where we'll use a<provet-tagsize="s">BaseAccordion</provet-tag> to wrap forms, in such scenarios both the <b>Submit/Save</b> and <b>Cancel</b> buttons can be placed under the card's <i>header-end</i> slot.<dl><dt> Additionally, the component expose useful methods to collapse, expand and/or toggle the card's state. The methods names are:</dt><dd><ul><li><pre>collapse</pre></li><li><pre>expand</pre></li><li><pre>toggleAccordion</pre></li></ul></dd></dl></div></BaseAccordion></div></template>
<template><BaseAccordionheader="With disabled"disabled><pclass="n-padding-b-s"> The toggle to expand/collapse the card can also be disabled by using the<i>disabled</i> prop. This becomes handy in cases you want to ensure the content of the card is visible, such as an <b>inline edit</b> form is loaded and while the form is not submitted, you need the card to remain expanded so the content is visible.</p></BaseAccordion></template>
<template><BaseAccordionheader="With collapsed initial state"collapsed><divclass="n-padding-b-s"> The <provet-tagsize="s">BaseAccordion</provet-tag> component has two main states:<dl><dtclass="n-font-weight-heading">Expanded</dt><dd><ul><li>This is the default state of the component.</li><li> The card content is fully visible and accessible to the user.</li></ul></dd><dtclass="n-font-weight-heading">Collapsed</dt><dd><ul><li> To render the card in a collapsed state, you can use the<i>collapsed</i> prop.</li><li> When collapsed, the card content is hidden, and only the header or title is visible.</li><li> This can be useful for conserving space or creating an accordion-style layout.</li></ul></dd></dl></div></BaseAccordion></template>
Use accordions to manage lengthy content: Implement accordions to organize extensive information, such as FAQs or detailed guides, allowing users to access specific sections without being overwhelmed by the full content.
Employ accordions for step-by-step processes: Utilize accordions to guide users through sequential tasks, presenting each step individually to maintain focus and reduce cognitive load.
Apply accordions when space is limited: In scenarios with constrained space, such as mobile interfaces, use accordions to present content compactly, enabling users to navigate information efficiently.
Avoid overcomplicating content areas: Refrain from adding non-essential links, buttons, or additional subsections inside the accordion content, as this can make the interface complicated and challenging to navigate.
Don't neglect hover states: Ensure that interactive elements within the accordion have clear hover states to communicate interactivity effectively.
Avoid inconsistent behavior: Ensure that the accordion's expand/collapse behavior is predictable and consistent to prevent user confusion.
Integration
This product pattern is currently only available to use in the New Frontend for Provet Cloud (using Vue & Nuxt).
Troubleshooting
If you experience any issues while using this pattern, please ask for support in the #vet-frontend Slack channel.