1.0.3 • Published 2 years ago

@febfeb/react-native-dropdown v1.0.3

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 years ago

@febfeb/react-native-dropdown

A single pure component for drop-down/combobox in react native

react-native-dropdown

Requirement

Please install react-native-vector-icons

Instalation

yarn add @febfeb/react-native-dropdown

Usage (Simple)

import Dropdown from '@febfeb/react-native-dropdown';

let fruits = [
    { id: 1, label: 'Apple'},
    { id: 2, label: 'Orange'},
    { id: 3, label: 'Pineapple'},
];

const [fruit, setFruit] = useState(1);

return (
    <Dropdown
        label='Select fruit'
        value={fruit}
        data={fruits}
        onChange={(val) => {
            setFruit(val);
        }}/>
);

Usage (Dark Theme)

import Dropdown from '@febfeb/react-native-dropdown';

let fruits = [
    { id: 1, label: 'Apple'},
    { id: 2, label: 'Orange'},
    { id: 3, label: 'Pineapple'},
];

const [fruit, setFruit] = useState(1);

const theme = {
    boxStyle: {
        borderColor: 'blue',
    },
};

return (
    <Dropdown
        label="Select fruit"
        theme={{
            containerStyle: {
                backgroundColor: '#000',
            },
            boxStyle: {
                backgroundColor: '#000',
                borderColor: '#fff',
            },
            labelStyle: {
                color: '#fff',
            },
            textContentStyle: {
                color: '#fff',
            },
            rightIconStyle: {
                color: '#fff',
            },
            modalRootStyle: {
                backgroundColor: 'rgba(255,255,255,0.5)',
            },
            modalContentStyle: {
                backgroundColor: '#000',
            },
            searchWrapperStyle: {
                backgroundColor: '#222',
            },
            searchIconStyle: {
                color: '#fff',
            },
            searchInputStyle: {
                color: '#fff',
            },
            listStyle: {
                backgroundColor: '#000',
            },
            listTextStyle: {
                color: "#fff",
            },
        }}
        placeholderTextColor={'rgba(255,255,255,0.8)'}
        value={fruit}
        data={fruits}
        onChange={(val) => {
            setFruit(val);
        }}
    />
);

Props

PropTypeDescription
valuestring/numberThis is mandatory for selecting the default value
dataarray of object with id and label attributeUsed as array of source data
labelstringTitle
onChangefunctionThis event will be triggered after user click the list item
renderDisplayfunctionUse this function to custom render your dropdown
showSearchBarbooleanUse this to show search bar (default false)
themeObjectThis is if you want to customize the appearance
placeholderTextColorstring colorThis is if you want to customize the placeholderTextColor props in TextInput
1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago