react-native-country-iso-selector
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

react-native-country-iso-selector

react-native-country-iso-selector is a React Native component library that provides a country selector with ISO codes and flags.

Installation

To install the library, use npm or yarn:

npm install react-native-country-iso-selector

or

yarn add react-native-country-iso-selector

ScreenShots

Example using in popover component

alt text

Usage

Here is an example of how to use the CountrySelector and SelectedCountryDisplay components:

import React, { useState } from 'react';
import { View } from 'react-native';
import { CountrySelector, SelectedCountryDisplay } from 'react-native-country-iso-selector';

const App = () => {
    const [selectedCountry, setSelectedCountry] = useState(null);

    return (
        <View>
            <CountrySelector
                setCountry={setSelectedCountry}
                placeholder="Select a country"
                leftComponent={<YourCustomComponent />}
            />
            <SelectedCountryDisplay
                country={selectedCountry}
                iconSize={20}
                iconColor="blue"
            />
        </View>
    );
};

export default App;

Props

CountrySelector

  • setCountry: Function to set the selected country.
  • placeholder: Placeholder text for the search input.
  • leftComponent: Custom component to display on the left side of the search input.

SelectedCountryDisplay

  • country: The selected country object.
  • styleContainer: Custom style for the container.
  • styleInnerContainer: Custom style for the inner container.
  • styleFlag: Custom style for the flag image.
  • iconSize: Size of the chevron icon.
  • iconColor: Color of the chevron icon.

Interfaces

Country

interface Country {
    country_name: string;
    iso2: string;
    e164_code: number;
}

CountrySelectorProps

interface CountrySelectorProps {
    setCountry: (country: Country) => void;
    placeholder: string;
    leftComponent: React.ReactNode;
}

SelectedCountryDisplayProps

interface SelectedCountryDisplayProps {
    country: Country | null;
    styleContainer?: StyleProp<ViewStyle>;
    styleInnerContainer?: StyleProp<ViewStyle>;
    styleFlag?: StyleProp<ImageStyle>;
    iconSize?: number;
    iconColor?: string;
}

License

This project is licensed under the ISC License.

Author

Hesler Dennis

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-country-iso-selector

Weekly Downloads

6

Version

1.1.0

License

ISC

Unpacked Size

148 kB

Total Files

13

Last publish

Collaborators

  • dennish02