Accordion
Component
Let users show and hide sections of related content on a page.
Related components: Details, TabsComponent
<GoAAccordion heading="Heading" headingSize="medium">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
</GoAAccordion>Properties
headingstringSets the heading text.
secondaryTextstringSets secondary text.
openbooleanSets the state of the accordion container open or closed. Defaults to
false.headingSizesmall | mediumSets the heading size of the accordion container heading. Defaults to
small.headingContentReactNodeAdd components to the accordion container heading such as badges.
maxWidthstringSets the maximum width of the accordion.
testIdstringSets the data-testid attribute. Used with ByTestId queries in tests.
mt,mr,mb,mlnone | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xlApply margin to the top, right, bottom, and/or left of the component.
Examples
Expand or collapse part of a form
Review your application
- Date of referral
- January 27, 2021
- Work safety concerns
- None
- Type of referral
- Word of mouth, internet search
- Intake received from another site
- Yes
- Name
- Joan Smith
- Contact preference
- Text message
dl.accordion-example {
margin: 0 0;
}
.accordion-example dt {
color: var(--goa-color-text-default);
font: var(--goa-typography-heading-s);
margin-bottom: var(--goa-space-xs);
}
.accordion-example dd {
margin: 0 0 var(--goa-space-l);
font: var(--goa-typography-body-m);
}
.accordion-example dd:last-of-type {
margin-bottom: 0;
}const headingContent = <GoABadge type="important" content="Updated" />;<h3>Review your application</h3>
<GoAAccordion heading="Referral details" headingContent={headingContent}>
<dl className="accordion-example">
<dt>Date of referral</dt>
<dd>January 27, 2021</dd>
<dt>Work safety concerns</dt>
<dd>None</dd>
<dt>Type of referral</dt>
<dd>Word of mouth, internet search</dd>
<dt>Intake received from another site</dt>
<dd>Yes</dd>
</dl>
</GoAAccordion>
<GoAAccordion heading="Contact information">
<dl className="accordion-example">
<dt>Name</dt>
<dd>Joan Smith</dd>
<dt>Contact preference</dt>
<dd>Text message</dd>
</dl>
</GoAAccordion>Hide and show many sections of information (FAQ)
const [open, setOpen] = useState<boolean>(false);
const [accordionStatus, setAccordionStatus] = useState<string>("Show all sections");
const onClick = () => {
setOpen(!open);
const status = !open ? "Hide all sections" : "Show all sections";
setAccordionStatus(status);
}<GoAButton type="tertiary" mb="m" onClick={() => onClick()}>
{ accordionStatus }
</GoAButton>
<GoAAccordion open={open} heading="How do I create an account?" headingSize="medium">
To create an account you will need to contact your office admin.
</GoAAccordion>
<GoAAccordion open={open} heading="What verification is needed to sign documents digitally?" headingSize="medium">
You will need to verify your identity through our two factor authentication in addition to the digital signature.
</GoAAccordion>
<GoAAccordion open={open} heading="Can I track the status of my service requests online?" headingSize="medium">
Yes, you can see the status of your application on the main service dashboard when you login. You will receive updates and notifications in your email as your request progresses.
</GoAAccordion>
<GoAAccordion open={open} heading="Are there accessibility features for people with disabilities?" headingSize="medium">
Yes, our digital service is designed with accessibility in mind. <a href="">More information on accessibility.</a>
</GoAAccordion>Book time in drop in hours