Docs
手风琴
手风琴
垂直堆叠的一组交互式标题,每个标题都会显示一部分内容。
安装
运行以下命令:
npx shadcn-ui@latest add accordion
更新 tailwind.config.js
将以下动画添加到 tailwind.config.js
文件中:
tailwind.config.js
/** @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",
},
},
},
}
使用
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion"
<Accordion type="single" collapsible>
<AccordionItem value="item-1">
<AccordionTrigger>可访问吗?</AccordionTrigger>
<AccordionContent>
是的。它遵循 WAI-ARIA 设计模式。
</AccordionContent>
</AccordionItem>
</Accordion>