1.0.4 • Published 6 months ago

nixa-react-native-accordion v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

React Native Accordion

nixa-react-native-accordion: a Collapsible Sections for React Native. fork from (https://github.com/mustapha-ghlissi/react-native-accordion)

MIT License npm npm npm npm github github github github

Screenshots

Screen 1 Screen 2 Screen 3 Screen 4 Screen 5 Screen 6

Demo

Demo

Example

You can check out this Example.

Installation

Installing the package

Use npm or yarn to install the package.

npm i nixa-react-native-accordion
yarn add nixa-react-native-accordion
Installing dependencies
npm i react-native-reanimated react-native-vector-icons
yarn add react-native-reanimated react-native-vector-icons

Note: to finish the installation, you have to finish configuring the installed dependencies react-native-reanimated and react-native-vector-icons.

Usage

import {Accordion, AccordionItem} from 'nixa-react-native-accordion';

<Accordion>
    <AccordionItem
        title="Section 1"
        subTitle="SubSection 1">
        {/* Put section body content here */}
    </AccordionItem>
    <AccordionItem title="Section 2">
        {/* Put section body content here */}
    </AccordionItem>
    <AccordionItem title="Section 3">
        {/* Put section body content here */}
    </AccordionItem>
</Accordion>

Common Props

Common Props has specific effects depends on the Component.

ParameterTypeDescription
androidRippleRippleConfig: optionalDefine the ripple of the pressable when pressing in the Accordion Item.
leftIconstring , ReactNode: optionalAccordion Item left icon.
titleStyleTextStyle: optionalAccordion item title style.
subTitleStyleTextStyle: optionalAccordion item sub-title style.
titleContainerStyleViewStyle: optionalAccordion item title container style.
headerStyleViewStyle: optionalAccordion item header style.
itemContainerStyleViewStyle: optionalAccordion item container style.
contentContainerStyleViewStyle: optionalAccordion item body style.
contentWrapperStyleViewStyle: optionalAccordion item body wrapper style.

Accordion Props

All common Props can be used here in addition to the following Props:

ParameterTypeDescription
containerStyleViewStyle: optionalAccordion container style.
animationDurationnumber: optionalThe duration of the collapse action
compactboolean: optionalDefine if the Accordion Items are compact or not.

Accordion Item Props

All common Props can be used here in addition to the following Props:

ParameterTypeDescription
titlestring: requiredAccordion item title.
subTitlestring: optionalAccordion item sub-title
headerReactNode: optionalCustom accordion item header component.
rightIconstring , ReactNode: optionalAccordion Item right icon (default = chevron-right).

Advanced Usage

import {Accordion, AccordionItem} from 'nixa-react-native-accordion';

const styles = StyleSheet.create({
    titleStyle: {
        fontSize: 16,
        fontWeight: 700,
    },
    contentContainerStyle: {
        paddingTop: 15,
        paddingBottom: 20
    }
});

<Accordion
    compact
    animationDuration={250}
    titleStyle={styles.titleStyle}
    contentContainerStyle={styles.contentContainerStyle}>
    <AccordionItem
        rightIcon='account'
        title="Section 1"
        subTitle="SubSection 1">
        {/* Put section body content here */}
    </AccordionItem>
    <AccordionItem
        rightIcon={<Icon name='cogs' size={26} color='#000' />}
        title="Section 2"
    >
        {/* Put section body content here */}
    </AccordionItem>
    <AccordionItem title="Section 3">
        {/* Put section body content here */}
    </AccordionItem>
</Accordion>