Directory
- Welcome
Details Component
The Details component creates interactive expandable sections that help organize and present content in a clean, accessible way. It features smooth animations, keyboard navigation, and maintains ARIA compliance for better accessibility.
Key Features
-
Smooth Animations: Polished expand/collapse transitions
-
Accessible Design: Full keyboard support and ARIA compliance
-
Flexible Content: Supports any nested content
-
Customizable: Configurable title tags and styling
Basic Usage
Create expandable sections with a title and content:
How do I get started?
<Details title="How do I get started?"> Getting started is easy! Simply install our template and follow the quick setup guide.</Details>
Advanced Examples
Custom Title Tags
Choose semantic heading levels for better document structure:
Section One
<Details title="Section One" titleTag="h2"> Content with h2 heading level</Details>
Rich Content Support
Add complex content structures within Details:
Complex Content Example
<Details title="Complex Content Example"> <h3 class="mb-2 text-lg font-bold">Nested Heading</h3> <p class="mb-2">Paragraph content with rich text support.</p> <ul class="pl-4 mb-2 list-disc"> <li>List item one</li> <li>List item two</li> <li>List item three</li> </ul></Details>
Details Component Props API
Prop | Type | Default | Description |
---|---|---|---|
title | string | - | The title text shown in the summary |
titleTag | div | h1 | h2 | h3 | h4 | h5 | h6 | div | HTML tag for the title |
titleClass | string | Additional classes for the title | |
descriptionClass | string | Additional classes for the content | |
transitionDuration | number | 300 | Transition duration in milliseconds |
Accessibility Features
- Enter/Space to toggle
- Tab for focus management
- Clear focus indicators
- Aria labels
Best Practices
-
Content Organization
- Group related information
- Keep titles concise
- Use consistent patterns
- Consider content hierarchy
-
Visual Design
- Maintain clear indicators
- Use consistent spacing
- Ensure readable text
- Consider mobile views
-
Performance
- Lazy load content when possible
- Optimize animations
- Monitor content size
- Consider initial state
Common Applications
Content Organization
User Interface
Documentation
Limited Time Launch Sale
Ready to create intuitive, accessible expandable content? Get our AstroJS starter template now and start building better user experiences with the Details component.
GET 60% OFF!