Introducing AlienX extension – The next evolution of UI development.Check it out on VS Code
Enjoy AlienUI? Give it a star on Github ⭐
An accordion component
A default galactic accordion
import React, { useState } from "react";
import { View, Text, Pressable, ScrollView } from "react-native";
const Accordion = () => {
const [openIndex, setOpenIndex] = useState(null);
const accordionItems = [
{
title: "Is AlienUI a component library?",
content:
"Yes, It is a self-hosted component library but you do not install it as a dependency. It is not available via npm like other traditional component library. Pick the components you need. " +
"Copy and paste the code into your project and customize to your needs. The code is yours.",
},
{
title: "Why copy/paste and not packaged as a dependency?",
content:
"The goal is to give you full control over your components, enabling you to decide their structure and styling. By starting with sensible defaults, you can customize them to fit your needs. Unlike packaged npm components, where styles are tightly coupled to implementation, separating design from functionality ensures flexibility and adaptability.",
},
{
title: "Do you plan to publish it as an npm package?",
content: "No. We have no plans to publish it as an npm package.",
},
{
title: "Which frameworks are supported?",
content:
"You can use any framework that supports React Native. Expo etc.",
},
{
title: "Can I use this in my project?",
content:
"Yes, you can use AlienUI in your React Native project. The code is yours. But hey, let us know if you do. We'd love to see what you build.",
},
];
const toggleAccordion = (index) => {
setOpenIndex(index === openIndex ? null : index);
};
return (
<ScrollView className="flex-1">
<View className="w-11/12 border">
{accordionItems.map((item, index) => (
<View key={index} className="border-b last:border-b-0 border-gray-300">
<Pressable
onPress={() => toggleAccordion(index)}
className={`flex flex-row justify-between items-center px-5 py-4 bg-white ${openIndex === index ? "bg-white" : ""}`}
>
<Text className="text-base text-gray-800">
{item.title}
</Text>
<Text
className={`text-base transition-transform duration-300 ${
openIndex === index ? "rotate-180" : ""
}`}
>
▼
</Text>
</Pressable>
{openIndex === index && (
<View className="px-5 py-4">
<Text className="text-sm text-gray-600">{item.content}</Text>
</View>
)}
</View>
))}
</View>
</ScrollView>
);
}
export default Accordion;
import React from "react";
import { View } from "react-native";
import Accordion from "./components/Accordion/GalaxyAccordion";
const App = () => {
return (
<View>
<Accordion />
</View>
);
};
export default App;