npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-smooth-collapse

v0.0.2

Published

High performance collapsible & accordion for React Native using Reanimated

Downloads

71

Readme

react-native-smooth-collapse

🚀 A high-performance, smooth, and fully customizable collapsible/accordion component for React Native powered by Reanimated 3.


✨ Features

  • ⚡ Smooth height animations using Reanimated 3
  • 🧠 Fully typed with TypeScript
  • 🎯 Controlled & imperative API support
  • 📦 Lightweight and dependency minimal
  • 🔁 Progress tracking (0 → 1)
  • 🎛 Custom animation duration
  • 📉 Supports collapsedHeight
  • 🧹 Optional unmountOnCollapse for performance
  • 🧩 Accordion & multi-expand (group support)
  • 📱 Works with FlatList / SectionList
  • 🔌 External progress sync (SharedValue)
  • 🪄 Imperative methods (expand, collapse, toggle)

✨ Demo


📦 Installation

npm install react-native-smooth-collapse

⚠️ Reanimated Setup (Required)

Make sure your app is configured:

// babel.config.js
module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'],
}

🚀 Basic Usage

import {
  CollapsibleGroup,
  CollapsibleItem,
  CollapsibleTrigger,
  CollapsiblePanel,
} from 'react-native-smooth-collapse';

<CollapsibleGroup>
  <CollapsibleItem>
    <CollapsibleTrigger>
      <View>
        <Text>React Native</Text>
      </View>
    </CollapsibleTrigger>

    <CollapsiblePanel>
      <View>
        <Text>Build native mobile apps using React.</Text>
      </View>
    </CollapsiblePanel>
  </CollapsibleItem>
</CollapsibleGroup>

🧩 Group (Accordion / Multi Expand)

import {
  CollapsibleGroup,
  CollapsibleItem,
  CollapsibleTrigger,
  CollapsiblePanel
} from "react-native-smooth-collapse"

<CollapsibleGroup accordion>
  <CollapsibleItem>
    <CollapsibleTrigger>
      <Text>Header 1</Text>
    </CollapsibleTrigger>
    <CollapsiblePanel>
      <Text>Content 1</Text>
    </CollapsiblePanel>
  </CollapsibleItem>

  <CollapsibleItem>
    <CollapsibleTrigger>
      <Text>Header 2</Text>
    </CollapsibleTrigger>
    <CollapsiblePanel>
      <Text>Content 2</Text>
    </CollapsiblePanel>
  </CollapsibleItem>
</CollapsibleGroup>

🚀 Controlled Usage

import React, { useState } from "react"
import { View, Text, TouchableOpacity } from "react-native"
import { Collapsible } from "react-native-smooth-collapse"

export default function App() {
  const [open, setOpen] = useState(false)

  return (
    <View>
      <TouchableOpacity onPress={() => setOpen(!open)}>
        <Text>
          Toggle
        </Text>
      </TouchableOpacity>

      <Collapsible expanded={open}>
        <View>
          <Text>Hello World</Text>
        </View>
      </Collapsible>
    </View>
  )
}

🎛 FlatList Accordion Example

import React, { useState } from "react";
import { View, Text, TouchableOpacity, FlatList } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { Collapsible } from "react-native-smooth-collapse";

const DATA = [
  { id: "1", title: "Item 1", content: "Content 1" },
  { id: "2", title: "Item 2", content: "Content 2" },
];

export default function App() {
  const [openId, setOpenId] = useState<string | null>(null);

  return (
    <GestureHandlerRootView>
      <FlatList
        data={DATA}
        keyExtractor={(item) => item.id}
        renderItem={({ item }) => (
          <Item
            item={item}
            expanded={openId === item.id}
            onPress={() =>
              setOpenId(openId === item.id ? null : item.id)
            }
          />
        )}
      />
    </GestureHandlerRootView>
  );
}

function Item({ item, expanded, onPress }: any) {
  return (
    <View>
      <TouchableOpacity onPress={onPress}>
        <Text>{item.title}</Text>
      </TouchableOpacity>

      <Collapsible expanded={expanded}>
        <Text>{item.content}</Text>
      </Collapsible>
    </View>
  );
}

🎚 Using collapsedHeight

<Collapsible expanded={open} collapsedHeight={50}>
  <Text>Partially visible content</Text>
</Collapsible>

🧹 Unmount on Collapse

<Collapsible expanded={open} unmountOnCollapse>
  <HeavyComponent />
</Collapsible>

🔗 Shared Progress (Reanimated)

import { useSharedValue } from "react-native-reanimated"

const progress = useSharedValue(0)

<Collapsible expanded={open} progress={progress}>
  <Text>Content</Text>
</Collapsible>

🔁 Multi Expand Mode

<CollapsibleGroup accordion={false}>
  {/* multiple items can stay open */}
</CollapsibleGroup>

⚡ Hook Usage (useCollapsible)

import { useCollapsible } from "react-native-smooth-collapse"

const { style } = useCollapsible(
  expanded,
  200, // contentHeight
  300, // duration
  0    // collapsedHeight
)

<Animated.View style={style}>
  <Text>Content</Text>
</Animated.View>

📚 API

Collapsible

| Prop | Type | Default | Description | | ----------------- | ------------------- | ------- | ------------------------------- | | expanded | boolean | false | Controls expand/collapse | | duration | number | 300 | Animation duration | | collapsedHeight | number | 0 | Minimum height | | unmountOnCollapse | boolean | false | Unmount children when collapsed | | progress | SharedValue | - | External progress | | onAnimationEnd | () => void | - | Callback after animation | | onProgress | (progress) => void | - | Progress callback | | children | ReactNode | - | Content |


useCollapsible

| Param | Type | Description | | --------------- | ------- | ------------------ | | expanded | boolean | State | | contentHeight | number | Measured height | | duration | number | Animation duration | | collapsedHeight | number | Min height |


CollapsibleRef

expand()
collapse()
toggle()

CollapsibleGroup

| Prop | Type | Default | Description | | --------- | ------- | ------- | ---------------- | | accordion | boolean | false | Single open item |


🎬 Demo

👉 Add your GIF here:

![demo](./demo.gif)

🧠 Why use this?

  • Faster than traditional collapsible libraries
  • Reanimated-powered (UI thread animations)
  • Clean API + TypeScript support
  • Works in large lists without jank

⭐ Support

If you like this package, please consider giving it a star on GitHub!

🤝 Contributing

Pull requests, bug reports, and feature suggestions welcome! Open an issue


🧑‍💻 Author

Made with ❤️ by Antos Maman


📄 License

MIT License