BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/trovecn/accordion

Accordion

trovecn/accordion
FreeComponent

Collapsible accordion with spring-animated height and chevron, and proximity hover across every row.

Install it

npx shadcn@latest add https://trovecn.dev/r/accordion.json

Source

src/components/ui/accordion.tsxtrovecn.dev/r/accordion.json · first 6 KB
1"use client";
2
3import {
4 Children,
5 isValidElement,
6 cloneElement,
7 useRef,
8 useState,
9 useEffect,
10 useLayoutEffect,
11 useCallback,
12 useMemo,
13 createContext,
14 useContext,
15 forwardRef,
16 type ReactElement,
17 type ReactNode,
18 type HTMLAttributes,
19} from "react";
20import { motion, AnimatePresence, useReducedMotion } from "motion/react";
21import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
22import { ChevronRight } from "lucide-react";
23
24import { cn } from "@/lib/utils";
25import { spring } from "@/lib/springs";
26import { fontWeights } from "@/lib/font-weight";
27import { ProximityHoverPill } from "@/components/ui/proximity-hover-pill";
28import { useProximityHover, type ItemRect } from "@/hooks/use-proximity-hover";
29
30// SSR-safe layout effect (client components still server-render in Next).
31const useIsoLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
32
33// ─── Contexts ────────────────────────────────────────────────────────────────
34
35interface AccordionContextValue {
36 registerItem: (index: number, element: HTMLElement | null) => void;
37 registerFullItem: (index: number, element: HTMLElement | null) => void;
38 activeIndex: number | null;
39 remeasure: () => void;
40 openValues: Set<string>;
41 openItemRects: Map<number, ItemRect>;
42}
43
44const AccordionContext = createContext<AccordionContextValue | null>(null);
45
46function useAccordionContext() {
47 const ctx = useContext(AccordionContext);
48 if (!ctx) throw new Error("AccordionItem must be used within an Accordion");
49 return ctx;
50}
51
52interface AccordionItemContextValue {
53 index?: number;
54 value: string;
55 isOpen: boolean;
56 triggerRef: React.MutableRefObject<HTMLDivElement | null>;
57}
58
59const AccordionItemContext = createContext<AccordionItemContextValue | null>(null);
60
61function useAccordionItemContext() {
62 const ctx = useContext(AccordionItemContext);
63 if (!ctx)
64 throw new Error("AccordionTrigger/AccordionContent must be used within an AccordionItem");
65 return ctx;
66}
67
68// ─── Accordion ───────────────────────────────────────────────────────────────
69// Every item shares one container: a background pill morphs between the item
70// nearest the cursor and the currently open item(s) — "proximity hover"
71// … truncated

What it pulls in

npm packages

  • motion
  • @base-ui/react
  • lucide-react

Other registry items

  • utils
  • springs
  • font-weight
  • use-proximity-hover

Files it writes

  • src/components/ui/accordion.tsx

Facts

Registry
trovecn
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
In the index
at or before 2026-08-14
Last confirmed
yesterday

Go to the source

trovecn.dev PPRAMANIK62/trovecn on GitHub Raw registry item This item as JSON

More from trovecn

All 26 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Agent Activityagent-activitytrovecnComponentsFree2 deps
Approval Requestapproval-requesttrovecnComponentsFree2 deps
ButtonbuttontrovecnComponentsFree2 deps
CheckboxcheckboxtrovecnComponentsFree2 deps
Checkbox Groupcheckbox-grouptrovecnComponentsFree2 deps
ComboboxcomboboxtrovecnComponentsFree3 deps
Comparison Slidercomparison-slidertrovecnComponentsFree1 dep
Context Menucontext-menutrovecnComponentsFree3 deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex