BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/cult/ui/expandable

expandable

cult-ui/expandable
FreeComponent

Expandable component system with smooth animations and customizable presets

Install it

npx shadcn@latest add https://raw.githubusercontent.com/nolly-studio/cult-ui/HEAD/apps/www/public/r/styles/default/expandable.json

Source

registry/default/ui/expandable.tsxraw.githubusercontent.com/nolly-studio/cult-ui/HEAD/apps/www/public/r/styles/default/expandable.json · first 6 KB
1"use client"
2
3import React, {
4 createContext,
5 ReactNode,
6 useContext,
7 useEffect,
8 useState,
9} from "react"
10import {
11 AnimatePresence,
12 HTMLMotionProps,
13 motion,
14 TargetAndTransition,
15 useMotionValue,
16 useSpring,
17} from "motion/react"
18import useMeasure from "react-use-measure"
19
20import { cn } from "@/lib/utils"
21
22const springConfig = { stiffness: 200, damping: 20, bounce: 0.2 }
23
24interface ExpandableContextType {
25 isExpanded: boolean // Indicates whether the component is expanded
26 toggleExpand: () => void // Function to toggle the expanded state
27 expandDirection: "vertical" | "horizontal" | "both" // Direction of expansion
28 expandBehavior: "replace" | "push" // How the expansion affects surrounding content
29 transitionDuration: number // Duration of the expansion/collapse animation
30 easeType:
31 | "easeInOut"
32 | "easeIn"
33 | "easeOut"
34 | "linear"
35 | [number, number, number, number] // Easing function for the animation
36 initialDelay: number // Delay before the animation starts
37 onExpandEnd?: () => void // Callback function when expansion ends
38 onCollapseEnd?: () => void // Callback function when collapse ends
39}
40
41// Create a context with default values
42const ExpandableContext = createContext<ExpandableContextType>({
43 isExpanded: false,
44 toggleExpand: () => {},
45 expandDirection: "vertical", // 'vertical' | 'horizontal' | 'both' // Direction of expansion
46 expandBehavior: "replace", // How the expansion affects surrounding content
47 transitionDuration: 0.3, // Duration of the expansion/collapse animation
48 easeType: "easeInOut" as const, // Easing function for the animation
49 initialDelay: 0,
50})
51
52// Custom hook to use the ExpandableContext
53const useExpandable = () => useContext(ExpandableContext)
54
55type ExpandablePropsBase = Omit<HTMLMotionProps<"div">, "children">
56
57interface ExpandableProps extends ExpandablePropsBase {
58 children: ReactNode | ((props: { isExpanded: boolean }) => ReactNode)
59 expanded?: boolean
60 onToggle?: () => void
61 transitionDuration?: number
62 easeType?:
63 | "easeInOut"
64 | "easeIn"
65 | "easeOut"
66 | "linear"
67 | [number, number, number, number]
68 expandDirection?: "vertical" | "horizontal" | "both"
69 expandBehavior?: "replace" | "push"
70 initialDelay?: number
71 onExpandStart?: () => void
72 onExpandEnd?: () => void
73 onCollapseStart?: () => void
74 onCollapseEnd?: () => void
75}
76// ROOT Expand component
77const Expandable = React.forwardRef<HTMLDivElement, ExpandableProps>(
78 (
79 {
80 children,
81// … truncated

What it pulls in

npm packages

  • motion

Files it writes

  • registry/default/ui/expandable.tsx

Facts

Registry
cult/ui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
today

Go to the source

www.cult-ui.com nolly-studio/cult-ui on GitHub Raw registry item This item as JSON

More from cult/ui

All 157 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
ai-instructionsai-instructionscult/uiComponentsFree2 deps
ai-instructions-demoai-instructions-democult/uiComponentsFreeno deps
animated-numberanimated-numbercult/uiComponentsFree1 dep
animated-number-demoanimated-number-democult/uiComponentsFreeno deps
bg-animate-buttonbg-animate-buttoncult/uiComponentsFreeno deps
bg-animate-button-demobg-animate-button-democult/uiComponentsFreeno deps
bg-animated-fractal-dot-gridbg-animated-fractal-dot-gridcult/uiComponentsFree1 dep
bg-animated-fractal-dot-grid-demobg-animated-fractal-dot-grid-democult/uiComponentsFreeno deps
BlockDex

Built by

Kynth Studio

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

BlockDex

BlockDex

Built by

Kynth Studio

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

BlockDex

BlockDex

Built by

Kynth Studio

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

BlockDex