GitHub
Docs
Accordion

Accordion

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

Loading...
Loading...

Installation

pnpm dlx shadcn-ng@latest add accordion
npx shadcn-ng@latest add accordion
npx shadcn-ng@latest add accordion
bunx --bun shadcn-ng@latest add accordion

Install the following dependencies:

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

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>