# GENERAL: [Books](https://ux-patterns-for-developers-nqu072an6.vercel.app/en/patterns/general/books)
A curated list of essential UX books to help developers improve their design and implementation skills.
# UX Books for Developers
A curated list of books to help developers understand and implement better user experiences.
## Essential Reads
| Cover | Title | Author | Why Developers Should Read It |
| ------------------------------------------------------------------------------------ | ------------------------------------------------ | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|  | Don't Make Me Think, Revisited | Steve Krug | • Practical usability principles • Developer-friendly approach • Real-world examples |
|  | UX Fundamentals for Non-UX Professionals | Edward Stull | • Perfect for developers new to UX • Clear, structured approach • Focuses on core concepts |
|  | The Design of Everyday Things | Don Norman | • Fundamental design principles • Understanding user psychology • Error prevention |
|  | [Practical UI](https://www.practical-ui.com/) | Adham Dannaway | • Logic-driven approach • Quick, actionable guidelines • Includes Figma design system • Updated in 2024 |
|  | [Refactoring UI](https://www.refactoringui.com/) | Adam Wathan & Steve Schoger | • Design tactics for developers • Practical, visual examples • Component-based approach • Color & typography guidelines |
## Form Design
| Cover | Title | Author | Why Developers Should Read It |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|  | Designing UX: Forms | Jessica Enders | • Deep dive into form design psychology • Best practices for validation • Accessibility considerations • Mobile-first approach |
|  | Form Design Patterns | Adam Silver | • Step-by-step implementation guide • Progressive enhancement techniques • Accessibility best practices • Real-world examples |
|  | [Dos and Don'ts for Form Input and Selection](https://uxmovement.gumroad.com/l/dodontform) | UX Movement | • Comprehensive form patterns • Visual examples • Practical dos and don'ts • Regular updates included |
## Tools & References
| Cover | Title | Author | Why Developers Should Read It |
| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|  | [Smart Interface Design Patterns Checklist Cards](https://www.smashingmagazine.com/2020/08/checklist-cards-release/) | Vitaly Friedman | • 100 ready-to-use checklists • Covers all common UI components • Based on usability research • Perfect for design-implementation discussions |
## Inclusive Design
| Cover | Title | Author | Why Developers Should Read It |
| ------------------------------------------------------------------ | ------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|  | Inclusive Design Patterns | Heydon Pickering | • Practical accessibility techniques • ARIA implementation patterns • Progressive enhancement strategies • Cross-browser solutions |
## Advanced UX
| Cover | Title | Author | Why Developers Should Read It |
| --------------------------------------------------------------------- | ---------------------------------------------------- | ---------------- | ----------------------------------------------------------------------------------- |
|  | About Face: The Essentials of Interaction Design | Alan Cooper | • Interaction design patterns • User behavior models • Interface guidelines |
|  | 100 Things Every Designer Needs to Know About People | Susan Weinschenk | • Psychology insights • Research-based decisions • Practical applications |
# GENERAL: [Getting Started](https://ux-patterns-for-developers-nqu072an6.vercel.app/en/patterns/general/getting-started)
UX Patterns for Devs is a comprehensive resource that helps developers implement effective, accessible, and usable UI components
# Getting Started
## About UX Patterns for Devs
UX Patterns for Devs is a comprehensive resource that helps developers implement effective, accessible, and usable UI components. Each pattern in our documentation is carefully crafted to provide practical guidance while following best practices for user experience and accessibility.
## How to Use This Documentation
Each pattern in our documentation follows a consistent structure to help you quickly find the information you need:
1. **Overview** - Introduction and use cases for the pattern
2. **Use Cases** - Real-world examples and scenarios where the pattern should be implemented
3. **Benefits** - Key advantages and value propositions of using this pattern
4. **Anatomy** - Detailed breakdown of the component's structure
5. **Best Practices** - Guidelines for implementation, including do's and don'ts
6. **Micro-Interactions & Animations** - Detailed guidance on animations, transitions, and interactive feedback
7. **Tracking & Analytics** - Event tracking implementation and metrics analysis
8. **Localization** - Guidelines for translating and adapting the pattern
9. **Code Examples** - Code examples and technical considerations
10. **Accessibility** - Guidelines for accessibility considerations
11. **SEO** - Search engine optimization considerations and best practices
12. **Browser Support** - Information on browser support for the pattern
13. **Testing** - Guidelines for unit, integration, and accessibility testing
14. **Design Tokens** - Design system variables and customization options
15. **Related Patterns** - Links to similar or complementary patterns
16. **FAQs** - Common questions and detailed answers
17. **Resources** - Additional documentation, articles, libraries...
## Getting Started
To get the most out of this documentation:
1. **Browse Patterns** - Use the sidebar navigation to explore available patterns
2. **Search** - Use the search bar to find specific patterns or concepts
3. **Implementation** - Follow the code examples and guidelines for each pattern
4. **Accessibility** - Pay attention to accessibility requirements for each component
5. **Best Practices** - Review the do's and don'ts before implementing
## How Would We Define "Build Effort"?
Each pattern has a complexity indicator using this simple scale:
| Level | Description |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| 🟢 Low | Simple implementation, minimal dependencies, little to no JavaScript required (e.g., Tooltip, Expandable Text). |
| 🟡 Medium | Requires state management, user interactions, and accessibility considerations (e.g., Load More, Modal). |
| 🔴 High | Complex UI behavior, animations, accessibility, performance optimizations, and multiple edge cases (e.g., Carousel, Infinite Scroll). |
## Contributing
We welcome contributions from the community! Whether you want to:
* Add new patterns
* Improve existing documentation
* Fix bugs
* Suggest improvements
Visit our [GitHub repository](https://github.com/thedaviddias/ux-patterns-for-developers/blob/main/.github/CONTRIBUTING.md) to learn how to contribute.
## Need Help?
If you need assistance or want to report an issue:
* Open a [GitHub issue](https://github.com/thedaviddias/ux-patterns-for-developers/issues/new/choose)
* Join our [Discord community](https://ddias.link/discord)
* Check the pattern's documentation for specific implementation details
# GENERAL: [When To Use What](https://ux-patterns-for-developers-nqu072an6.vercel.app/en/patterns/general/when-to-use-what)
Guide for choosing the right UI pattern for your needs
# When to Use What?
This guide helps you choose the most appropriate UI pattern for your needs.
Each pattern includes:
* ✅ Best use cases
* ❌ When to avoid
* 🎯 Key features
* 🔄 Related patterns
## Selection Patterns (Less than 5 options)
| Pattern | Best For | Avoid When | Key Features | Related |
| ------------------------------------ | -------------------------------------------- | ------------------------------------ | --------------- | -------------------------------------------------- |
| [Radio](/patterns/forms/radio) | ✅ Single choice ✅ Visible options | ❌ Many options ❌ Multiple needed | ✅ Clear choices | [Dropdown](/patterns/forms/selection-input) |
| [Checkbox](/patterns/forms/checkbox) | ✅ Multiple choices ✅ Independent options | ❌ Single choice ❌ Many options | ✅ Toggle states | [Multi-select](/patterns/forms/multi-select-input) |
| [Toggle](/patterns/forms/toggle) | ✅ Binary settings ✅ Immediate effect | ❌ Multiple states | ✅ Quick switch | [Checkbox](/patterns/forms/checkbox) |
## Selection Patterns (5 or more options)
| Pattern | Best For | Avoid When | Key Features | Related |
| -------------------------------------------------- | ---------------------------------- | -------------------- | ----------------- | -------------------------------------------- |
| [Dropdown](/patterns/forms/selection-input) | ✅ Limited space ✅ 5-15 options | ❌ Multiple selection | ✅ Compact | [Radio](/patterns/forms/radio) |
| [Autocomplete](/patterns/forms/autocomplete) | ✅ Many options ✅ Search needed | ❌ Few options | ✅ Search & filter | [Search Field](/patterns/forms/search-field) |
| [Multi-select](/patterns/forms/multi-select-input) | ✅ Multiple items ✅ Tags needed | ❌ Single choice | ✅ Bulk selection | [Checkbox](/patterns/forms/checkbox) |
## Text Input Patterns
| Pattern | Best For | Avoid When | Key Features | Related |
| --------------------------------------------- | ----------------------------------- | -------------- | -------------- | ----------------------------------------------- |
| [Text Field](/patterns/forms/text-field) | ✅ Short text ✅ Single line | ❌ Long content | ✅ Simple input | [Rich Text](/patterns/forms/rich-text-editor) |
| [Rich Text](/patterns/forms/rich-text-editor) | ✅ Formatted text ✅ Long content | ❌ Simple text | ✅ Formatting | [Text Field](/patterns/forms/text-field) |
| [Password](/patterns/forms/password) | ✅ Secure entry ✅ Credentials | ❌ Public data | ✅ Masked input | [Code Input](/patterns/forms/code-confirmation) |
| [Search Field](/patterns/forms/search-field) | ✅ Content search ✅ Filtering | ❌ Exact match | ✅ Quick search | [Autocomplete](/patterns/forms/autocomplete) |
## Specialized Input Patterns
| Pattern | Best For | Avoid When | Key Features | Related |
| ----------------------------------------------- | ------------------------------------ | ----------------- | --------------- | ----------------------------------------------------------- |
| [Currency](/patterns/forms/currency-input) | ✅ Money values ✅ Formatting | ❌ Plain numbers | ✅ Auto-format | [Text Field](/patterns/forms/text-field) |
| [Phone](/patterns/forms/phone-number) | ✅ Phone numbers ✅ Formatting | ❌ Plain text | ✅ Validation | [Text Field](/patterns/forms/text-field) |
| [Color Picker](/patterns/forms/color-picker) | ✅ Color selection ✅ Visual input | ❌ Text input | ✅ Visual picker | [Dropdown](/patterns/forms/selection-input) |
| [Rating](/patterns/forms/rating-input) | ✅ User ratings ✅ Quick input | ❌ Precise numbers | ✅ Star scale | [Radio](/patterns/forms/radio) |
| [Code Input](/patterns/forms/code-confirmation) | ✅ 2FA/OTP ✅ Verification | ❌ Regular input | ✅ Auto-advance | [Password](/patterns/forms/password) |
| [File Input](/patterns/forms/file-input) | ✅ File uploads ✅ Multiple files | ❌ Text input | ✅ File select | [Drag and Drop](/patterns/content-management/drag-and-drop) |
## Date & Time Patterns
| Pattern | Best For | Avoid When | Key Features | Related |
| ------------------------------------------ | ---------------------------------------- | --------------- | -------------- | ------------------------------------------ |
| [Date Input](/patterns/forms/date-input) | ✅ Basic date entry ✅ Known format | ❌ Visual needed | ✅ Direct entry | [Date Picker](/patterns/forms/date-picker) |
| [Date Picker](/patterns/forms/date-picker) | ✅ Visual dates ✅ Calendar needed | ❌ Quick entry | ✅ Calendar UI | [Date Range](/patterns/forms/date-range) |
| [Date Range](/patterns/forms/date-range) | ✅ Period selection ✅ Start/end dates | ❌ Single date | ✅ Range select | [Date Picker](/patterns/forms/date-picker) |
## Content Management Patterns
| Pattern | Best For | Avoid When | Key Features | Related |
| ----------------------------------------------------------- | ----------------------------------------- | ------------------- | ------------------------ | ------------------------------------------------------- |
| [Accordion](/patterns/content-management/accordion) | ✅ Collapsible sections ✅ Space saving | ❌ Always visible | ✅ Progressive disclosure | [Modal](/patterns/content-management/modal) |
| [Modal](/patterns/content-management/modal) | ✅ Focused tasks ✅ Important actions | ❌ Frequent access | ✅ Focus trap | [Tooltip](/patterns/content-management/tooltip) |
| [Carousel](/patterns/content-management/carousel) | ✅ Multiple items ✅ Limited space | ❌ Comparison needed | ✅ Progressive reveal | [Infinite Scroll](/patterns/navigation/infinite-scroll) |
| [Tooltip](/patterns/content-management/tooltip) | ✅ Extra info ✅ Quick help | ❌ Critical info | ✅ Context help | [Modal](/patterns/content-management/modal) |
| [Drag and Drop](/patterns/content-management/drag-and-drop) | ✅ Reordering ✅ Visual sorting | ❌ Simple selection | ✅ Direct manipulation | [Selection Input](/patterns/forms/selection-input) |
## Navigation Patterns
| Pattern | Best For | Avoid When | Key Features | Related |
| ------------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [Back to Top](/patterns/navigation/back-to-top) | ✅ Long pages ✅ Quick return | ❌ Short content ❌ Mobile-first designs | ✅ Quick navigation ✅ One-click access | [Infinite Scroll](/patterns/navigation/infinite-scroll) |
| [Breadcrumb](/patterns/navigation/breadcrumb) | ✅ Deep hierarchies ✅ Complex sites ✅ E-commerce | ❌ Flat structures ❌ Single-level sites | ✅ Location awareness ✅ Easy backtracking | [Navigation Menu](/patterns/navigation/navigation-menu) |
| [Infinite Scroll](/patterns/navigation/infinite-scroll) | ✅ Content feeds ✅ Continuous flow ✅ Social media | ❌ Structured content ❌ Goal-oriented tasks | ✅ Auto-loading ✅ Seamless browsing | [Pagination](/patterns/navigation/pagination) [Load More](/patterns/navigation/load-more) |
| [Load More](/patterns/navigation/load-more) | ✅ Content exploration ✅ User control | ❌ Large datasets ❌ Sequential content | ✅ Manual loading ✅ Performance friendly | [Infinite Scroll](/patterns/navigation/infinite-scroll) [Pagination](/patterns/navigation/pagination) |
| [Pagination](/patterns/navigation/pagination) | ✅ Large datasets ✅ Structured content | ❌ Short lists ❌ Continuous reading | ✅ Clear boundaries ✅ Better orientation | [Load More](/patterns/navigation/load-more) [Infinite Scroll](/patterns/navigation/infinite-scroll) |
| [Hamburger Menu](/patterns/navigation/hambuger-menu) | ✅ Mobile interfaces ✅ Space-saving | ❌ Desktop-first ❌ Critical navigation | ✅ Compact ✅ Expandable | [Navigation Menu](/patterns/navigation/navigation-menu) [Sidebar](/patterns/navigation/sidebar) |
| [Megamenu](/patterns/navigation/megamenu) | ✅ Large sites ✅ Complex hierarchies | ❌ Simple navigation ❌ Mobile interfaces | ✅ Rich content ✅ Category overview | [Navigation Menu](/patterns/navigation/navigation-menu) |
| [Navigation Menu](/patterns/navigation/navigation-menu) | ✅ Primary navigation ✅ Site structure | ❌ Deep hierarchies ❌ Complex categories | ✅ Clear structure ✅ Easy access | [Megamenu](/patterns/navigation/megamenu) |
| [Sidebar](/patterns/navigation/sidebar) | ✅ Dashboard layouts ✅ App interfaces | ❌ Content-heavy sites ❌ Mobile-first | ✅ Persistent nav ✅ Context retention | [Navigation Menu](/patterns/navigation/navigation-menu) |
| [Tabs](/patterns/navigation/tabs) | ✅ Related content ✅ Switching views | ❌ Deep hierarchies ❌ Many sections | ✅ Content grouping ✅ Quick switching | [Navigation Menu](/patterns/navigation/navigation-menu) |
| | | | | |
For implementation details and best practices, visit our [Getting Started](/patterns/getting-started) guide.
# CONTENT-MANAGEMENT: [Accordion](https://ux-patterns-for-developers-nqu072an6.vercel.app/en/patterns/content-management/accordion)
Create effective accordion components for your web applications. Learn best practices for implementing expandable content sections with proper accessibility and keyboard support.
# Accordion
***(Also called collapsible panels)***
## Overview
An **accordion** is a UI component that consists of a vertically stacked list of headers that can be expanded or collapsed to reveal or hide related content. It helps conserve screen space by displaying content in a structured and interactive way.
Accordions are commonly used for **FAQs, settings panels, and structured content** where users need to access multiple sections without scrolling through all the information at once.
## Use Cases
### When to use:
Use an accordion when you need to present **structured content that benefits from progressive disclosure**.
**Common use cases include:**
* **FAQs (Frequently Asked Questions)** – Helps users find answers quickly.
* **Settings and Preferences** – Organizes options into collapsible categories.
* **Product Details or Features** – Allows users to expand sections they are interested in.
* **Documentation or Guides** – Presents step-by-step content in an organized way.
* **Navigation and Filtering** – Used in sidebars for hierarchical content.
### When not to use:
* If **all content needs to be visible at once** (e.g., comparison tables).
* When **content is too short**—collapsing small amounts of text may reduce usability.
* If frequent **switching between sections is necessary**—a tabbed interface might be better.
* When users need to **view multiple sections at the same time** (e.g., Terms and Conditions) —consider popovers, modals, or side panels instead.
* If content requires **deep nesting of multiple levels**, a structured outline or table of contents may work better.
## Benefits
* **Saves space** by showing only relevant content when needed.
* **Improves readability** by reducing visual clutter.
* **Enhances usability** by grouping related content.
* **Optimizes mobile experiences** by minimizing scroll length.
## Drawbacks
* **Hides content by default**, requiring extra interaction to access information.
* **Can make scanning content harder**, especially if multiple sections are collapsed.
* **May not work well for all content types**, particularly if users need to see multiple sections at once.
* **Can have accessibility issues** if not correctly implemented with ARIA roles.
* **Excessive nesting** of accordions can create a poor user experience.
## Anatomy
```mermaid
graph TD
A[Accordion] --> B[Accordion Item 1]
A --> C[Accordion Item 2]
B --> D[Header Trigger 1]
B --> E[Accordion Icon 1]
B --> F[Content Panel 1]
C --> G[Header Trigger 2]
C --> H[Accordion Icon 2]
C --> I[Content Panel 2]
```
### Component Structure
1. **Accordion Container**
* Wraps all the accordion items.
* Handles state management (e.g., open/close behavior).
* Should provide appropriate aria-label for screen reader users.
2. **Accordion Item**
* A single collapsible section consisting of a header (trigger) and a content panel.
3. **Accordion Header (Trigger)**
* The clickable element that expands/collapses the associated content.
* Should be a button element for accessibility.
* Must contain aria-expanded="true|false" to indicate state.
4. **Accordion Icon**
* Provides a visual cue of the accordion state (collapsed or expanded).
* Common examples: chevron icons (▼/▲), plus/minus (+/−).
* Should rotate or change appearance when toggled.
* Must be visually distinguishable and large enough for touch interaction.
5. **Accordion Content Panel**
* The collapsible section that appears when triggered.
* Should be associated with its header via aria-controls and aria-labelledby.
* Must use aria-hidden="true|false" to indicate visibility to screen readers.
#### **Summary of Components**
| Component | Required? | Purpose |
| ------------- | --------- | ------------------------------------------------ |
| Container | ✅ Yes | Wraps all accordion items together. |
| Item | ✅ Yes | Represents an individual expandable section. |
| Trigger | ✅ Yes | Toggles the visibility of the accordion content. |
| Icon | ✅ Yes | Indicates open/closed state (e.g., chevron). |
| Content Panel | ✅ Yes | Holds the content that expands/collapses. |
## Best Practices
### Content & Usability
**Do's ✅**
* **Keep headers clear and concise**—they should describe the content inside.
* **Use progressive disclosure**—prioritize showing only essential information first.
* **Ensure logical grouping**—group related items under the same accordion.
* **Maintain consistent styling**—avoid varying sizes or colors for different headers.
**Don'ts ❌**
* **Don't overload sections**—too much content defeats the purpose of an accordion.
* **Avoid unnecessary animations**—fast, smooth transitions improve usability.
* **Don't use accordions for essential content**—ensure users can still access key information easily.
### Default Open Behavior
**Do's ✅**
* **Decide based on user expectations**—if the first section contains critical information, it may be beneficial to start expanded.
* **Keep the first accordion open** in **FAQs, tutorials, or onboarding flows** where users need immediate guidance.
* **Ensure consistency**—if one accordion is open by default, follow the same pattern across the UI.
* **Provide a clear visual indicator** when an accordion is expanded to avoid confusion.
**Don'ts ❌**
* **Don't force the first section open if the content is non-essential**—let users decide what they need.
* **Avoid inconsistent behavior**—mixing some open and some closed sections can be confusing.
* **Don't prevent users from collapsing the first accordion**—they should be able to close it if they want.
### Icon Placement & Behavior
#### **Placement**
**Do's ✅**
* **Place the icon at the beginning of the header** for better usability, especially for users relying on screen magnification.
* **Ensure the icon remains visually distinguishable**—it should not blend into the text.
* **Make sure the icon is keyboard accessible** and updates its state (`aria-expanded`).
* **Test different placements** in usability studies to determine what works best for your audience.
**Don'ts ❌**
* **Avoid placing the icon too far from the trigger text**—users may not associate them.
* **Don't rely solely on the icon** to indicate expansion—ensure there is a visual or textual cue as well.
* **Avoid animations that make the icon movement too subtle**—it should clearly show state changes.
#### **Behavior**
**Do's ✅**
* **Use an intuitive icon** (e.g., `+` → `−`, or chevron pointing up/down).
* **Ensure the icon changes state** when the accordion is expanded or collapsed.
* **Animate icon transitions smoothly** (e.g., rotate chevron instead of abruptly changing it).
* **Make the icon large enough** to be tappable on mobile devices.
**Don'ts ❌**
* **Don't rely only on the icon** to indicate expansion—also update `aria-expanded` and visually differentiate expanded sections.
* **Avoid using icons that do not clearly indicate** expansion and collapse states.
* **Don't use overly complex animations** that slow down interactions.
### Accessibility
**Do's ✅**
* **Use semantic HTML**—accordion triggers should be `button` elements.
* **Implement `aria-expanded`** to indicate open/closed states.
* **Ensure focus management**—moving between sections should be intuitive.
* **Support keyboard navigation**—allow arrow keys for cycling and `Enter` or `Space` to toggle.
**Don'ts ❌**
* **Don't trap focus** inside an expanded panel.
* **Avoid using `display: none;` on content**—instead, use `visibility` or `aria-hidden` for screen readers.
### Layout & Design
**Do's ✅**
* **Ensure clear distinctions** between expanded and collapsed states.
* **Provide smooth animations** (e.g., height transitions) to improve the user experience.
* **Use appropriate spacing** between items to avoid visual clutter.
* **Align icons and headers consistently** to maintain a structured appearance.
**Don'ts ❌**
* **Don't make accordions too small or too large**—users should easily scan headers.
* **Avoid inconsistent alignment**—headers, icons, and content should be visually aligned.
* **Don't place icons too far from the header text**, making it difficult to associate them with the toggle action.
## Tracking
Tracking accordion interactions helps measure user engagement, assess whether users find the hidden content valuable, and determine if sections should be expanded by default. By analyzing user behavior, we can optimize when and how accordions are used.
### Key Tracking Points
Each accordion interaction provides valuable insights into user behavior. Below are the key events that should be tracked:
| **Event Name** | **Description** | **Why Track It?** |
| ------------------------ | --------------------------------------------------------------------- | ---------------------------------------------------------- |
| `accordion.view` | When the accordion component enters the viewport. | Determines visibility and content discovery. |
| `accordion.expand` | When a user expands an accordion section. | Measures engagement and demand for additional information. |
| `accordion.collapse` | When a user collapses an accordion section. | Helps analyze whether users return to a condensed view. |
| `accordion.auto_expand` | When a section expands automatically (e.g., pre-expanded by default). | Determines if auto-expansion leads to better engagement. |
| `accordion.read_time` | The time a user spends with the expanded content visible. | Helps measure content consumption. |
| `accordion.all_expand` | When a user expands **all** sections at once (if supported). | Indicates if users prefer all content visible upfront. |
| `accordion.all_collapse` | When a user collapses **all** sections at once. | Tracks behavior when content is condensed back. |
### Event Payload Structure
To ensure consistent tracking, here’s a recommended event format:
```json
```
### Key Metrics to Analyze
Once tracking is in place, the following metrics provide actionable insights:
* **Expand Rate** → Percentage of users who expand at least one section.
* **Collapse Rate** → Percentage of users who collapse a section after expanding it.
* **Average Read Time** → How long users keep an expanded section open.
* **Auto-Expand vs. Manual Expand Rate** → Helps assess whether users prefer content pre-expanded or manually triggered.
* **Multi-Expand Rate** → Percentage of users expanding multiple sections in a session.
### Insights & Optimization Based on Tracking
By analyzing tracking data, we can optimize the accordion experience:
* 🚨 **Low Expand Rate?**
→ Users may not notice the accordion sections or find them unnecessary.
**Optimization:** Improve section titles for clarity, make expansion triggers more prominent, or test making key sections pre-expanded.
* ⏳ **Short Read Time After Expand?**
→ Users may not be engaging with the expanded content.
**Optimization:** Ensure content is concise, scannable, and well-structured. Test alternative formats such as inline content or tabs.
* 🔄 **High Collapse Rate?**
→ Users might be overwhelmed by too much content or prefer a more condensed view.
**Optimization:** Reduce section length, highlight key takeaways in the collapsed state, or introduce progressive disclosure.
* 🔁 **High Multi-Expand Rate?**
→ Users frequently expand multiple sections, which may indicate that all content is relevant.
**Optimization:** Consider whether an **accordion** is the right UI choice, or if a fully expanded layout would improve readability.
* ⚙️ **Auto-Expand Not Leading to Higher Engagement?**
→ Automatically expanded sections may be ignored.
**Optimization:** A/B test auto-expanded vs. manually triggered content to determine user preference.
By continuously monitoring these metrics, we can refine accordion usability, ensuring users efficiently access necessary information while avoiding unnecessary interactions.
## Code Example
### **Method 1: Using `