Accordion
Expandable sections for organizing and hiding content. Users can reveal or hide sections by clicking on headers.
check_circleWhen to use
- When you need to present multiple related sections of content without overwhelming the user
- For FAQs, documentation, or settings panels with collapsible sections
- When vertical space is limited and content needs to be progressively disclosed
- To organize complex information into digestible, scannable chunks
cancelWhen not to use
- When all content should be visible by default for quick scanning
- For navigation purposes - use tabs or a sidebar instead
- When there are only 1-2 items - consider showing them expanded
- If users need to compare content across sections simultaneously
Default Variant
Multiple Open (default)
Vilkus is a comprehensive design system built with React, TypeScript, and Next.js. It provides a consistent set of components, tokens, and guidelines for building modern web applications.
Install the package via npm or yarn, import the components you need, and start building. All components are fully typed with TypeScript and support CSS modules for styling.
Yes! The design system is built on design tokens that can be customized through CSS variables. You can modify colors, spacing, typography, and more to match your brand.
Single Open
Content for the first section.
Content for the second section.
Content for the third section.
tsx
import { Accordion } from '@/components/Accordion';
const items = [
{
id: '1',
title: 'What is the Vilkus Design System?',
icon: 'palette',
content: 'Vilkus is a comprehensive design system...',
},
// ... more items
];
<Accordion
items={items}
defaultExpanded={['1']}
/>Bordered Variant
Cards with Borders
Vilkus is a comprehensive design system built with React, TypeScript, and Next.js. It provides a consistent set of components, tokens, and guidelines for building modern web applications.
Install the package via npm or yarn, import the components you need, and start building. All components are fully typed with TypeScript and support CSS modules for styling.
Yes! The design system is built on design tokens that can be customized through CSS variables. You can modify colors, spacing, typography, and more to match your brand.
tsx
<Accordion
items={items}
variant="bordered"
/>Sizes
Small
Content for the first section.
Content for the second section.
Medium (default)
Content for the first section.
Content for the second section.
Large
Content for the first section.
Content for the second section.
tsx
<Accordion items={items} size="small" />
<Accordion items={items} size="medium" />
<Accordion items={items} size="large" />Controlled Mode
External Control
Use the expanded and onChange props to control the accordion state from a parent component.
Content for the first section.
Content for the second section.
Content for the third section.
tsx
const [expanded, setExpanded] = useState<string[]>(['1']);
<Accordion
items={items}
expanded={expanded}
onChange={setExpanded}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
items* | AccordionItemData[] | — | Array of accordion items with id, title, content, and optional icon |
allowMultiple | boolean | true | Allow multiple items to be open at once |
defaultExpanded | string[] | [] | Initially expanded item IDs (uncontrolled) |
expanded | string[] | — | Controlled expanded items |
onChange | (expandedIds: string[]) => void | — | Callback when expanded items change |
size | 'small' | 'medium' | 'large' | 'medium' | Size of the accordion items |
variant | 'default' | 'bordered' | 'default' | Visual style variant |
Accessibility
- Keyboard Navigation: Use Enter or Space to toggle accordion items
- ARIA Attributes: Uses
aria-expandedandaria-controlsfor screen readers - Focus Management: Visible focus indicators on accordion headers
- Semantic HTML: Uses
buttonelements for headers and proper heading hierarchy - Region Landmark: Content sections use
role="region"for better navigation