Accordion
An Accordion component is a UI element that allows users to expand and collapse sections of content. It is commonly used to organize information in a compact and accessible manner, displaying only the headers by default and revealing the associated content when clicked. This helps improve the readability of complex or lengthy information by reducing clutter on the page.
Rendered live, with the same build of the library you install.
Single:
Multiple:
Accordion.tsx
import { AccordionTypes, NAccordion } from '@nayan-ui/react';const items = [{ title: 'What is Nayan UI?', message: 'Nayan UI is a modern React component library built with TypeScript and Tailwind CSS.' },{ title: 'How to install?', message: 'Install using npm: npm install @nayan-ui/react' },{ title: 'Is it free?', message: 'Yes, Nayan UI is completely free and open source.' }];const Accordion = () => {return (<div><h3 className="text-foreground mb-2 mt-4 text-sm font-semibold">Single:</h3><NAccordion type={AccordionTypes.SINGLE} items={items} /><h3 className="text-foreground mb-2 mt-4 text-sm font-semibold">Multiple:</h3><NAccordion type={AccordionTypes.MULTIPLE} items={items} /></div>);};export default Accordion;
| Name | Type | Default | Details |
|---|---|---|---|
| className | string | ' ' | You can customise by passing tailwind classes. |
| itemClassName | string | ' ' | You can customise by passing tailwind classes. |
| triggerClassName | string | ' ' | You can customise by passing tailwind classes. |
| contentClassName | string | ' ' | You can customise by passing tailwind classes. |
| type | AccordionTypes | AccordionTypes.SINGLE | You can pass type of the accordion. |
| items | AccordionListItem[] | Required | You can pass list of accordion items. |
| keyExtractor | (item: T, index: number) => string | number | Optional | Custom key extractor function for items. |
| renderTrigger | (item: T, index: number) => React.ReactNode | Optional | Custom render function for accordion triggers. |
| renderContent | (item: T, index: number) => React.ReactNode | Optional | Custom render function for accordion content. |
| indicatorClassName | string | ' ' | Custom class for the expand/collapse indicator. |
| variant | 'default' | 'surface' | 'default' | Visual variant of the accordion. |
Other components solving nearby problems.
- React Accordion
- React Collapsible Component
- React UI Accordion
- React Toggle Panel
- React Dropdown
- React Expandable List
- React Accordion Menu
- Accordion Component for React
- Collapsible UI in React
- React Accordion Plugin
- Custom Accordion in React
- Accordion Animation in React
- React Accordion with Hooks
- React UI Library Accordion
- Example Accordion in React
- Styling React Accordion
- React Accordion Component
- Dynamic React Accordion
- React Accordion Accessibility
- React Multi-Level Accordion
- Accordion UI Component
- Collapsible Content React
- Expandable Component Library
- React Accordion Tutorial
- Accordion Best Practices
- React Accordion Performance
- Mobile Accordion React
- Accordion Responsive Design
- React Accordion TypeScript
- Accordion Component Design System