The AccordionFive component offers a unique full-height accordion layout, where active sections expand significantly. This guide will help you:
Edit or add accordion items (questions, answers, and styling).
Customize the layout and appearance (colors, typography, and animations).
Ensure responsive design and accessibility.
Project Resources
Tutorial
Step 1: Editing Accordion Items
Locate the accordionFiveItems
Array
The accordion content is stored in the accordionFiveItems
array. Each item includes fields for question text, answer text, and styling properties.
Edit Existing Items
question
: The text displayed on the accordion button.answer
: The text displayed when the section is expanded.backgroundColor
,fontColor
, andiconColor
: Control the visual styles for each item.
Example Update:
Add New Items
Add a new object to the accordionFiveItems
array with a unique id
.
Example Update:
Remove Items
Delete any objects you don’t need from the array.
Step 2: Customizing Layout and Appearance
Outer Section
The container for the accordion is styled as follows:
Add Padding or Background Color:
Accordion Items
Each accordion item’s styling is determined by dynamic classes:
Change Background Color: Modify
backgroundColor
in theaccordionFiveItems
array.Adjust Border Styling:
Text Styling
The question text uses the
Display
component:
The answer text uses the
Heading
component:
Update Typography Styles:
Icons
The plus and cross icons dynamically change based on the active state:
Change Icon Size or Color:
Step 3: Adjusting Animations
Expand/Collapse Animation
The accordion’s height and opacity animations are controlled here:
Change Animation Duration:
Icon Rotation
Icons rotate to indicate the open/close state:
Slow Down Rotation:
Step 4: Accessibility Enhancements
Keyboard Navigation
Add
aria-expanded
andaria-controls
attributes for better screen reader support:
Screen Reader Support
Assign a unique
id
to the answer containers:
Step 5: Testing the Component
Run Locally: Use
npm run dev
to preview changes.Responsive Testing: Check the accordion on mobile, tablet, and desktop.
Accessibility Testing: Ensure smooth navigation via keyboard and screen reader.
Best Practices
Content Clarity:
Use concise and clear text for
question
andanswer
.
Styling Consistency:
Ensure colors and fonts match your project’s design system.
Responsive Design:
Verify that the accordion works well across all screen sizes.