Docs
Accordion

Accordion

A vertically stacked set of interactive headings that each reveal a section of content.

Loading...
Loading...

Installation

npx shadcn-ng@latest add accordion
npm
yarn
pnpm
bun

Install the following dependencies:

npm install @ng-icons/core @ng-icons/lucide
npm
yarn
pnpm
bun

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Update tailwind.config.js

Add the following animations to your tailwind.config.js file:

/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    extend: {
      keyframes: {
        "accordion-down": {
            from: { height: "0" },
            to: { height: "var(--radix-accordion-content-height)" },
        },
        "accordion-up": {
            from: { height: "var(--radix-accordion-content-height)" },
            to: { height: "0" },
        },
      },
      animation: {
        "accordion-down": "accordion-down 0.2s ease-out",
        "accordion-up": "accordion-up 0.2s ease-out",
      },
    },
  },
}

Usage

import {
    UbAccordionDirective,
    UbAccordionItemDirective,
    UbAccordionTriggerDirective,
    UbAccordionContentDirective
} from '@/components/ui/accordion.directive';
<div ubAccordion class="w-full" orientation="vertical">
    <div ubAccordionItem value="item-1">
        <ub-accordion-trigger>Is it accessible?</ub-accordion-trigger>
        <div ubAccordionContent>
            Yes. It adheres to the WAI-ARIA design pattern.
        </div>
    </div>
</div>