Installations
npm install react-country-flags-select
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.14.1
NPM Version
9.3.1
Score
61.1
Supply Chain
95.4
Quality
75.1
Maintenance
100
Vulnerability
99.6
License
Contributors
Unable to fetch Contributors
Languages
TypeScript (89.43%)
JavaScript (5.8%)
SCSS (4.61%)
Shell (0.16%)
Developer
Download Statistics
Total Downloads
11,735
Last Day
29
Last Week
225
Last Month
1,040
Last Year
9,233
GitHub Statistics
2 Stars
30 Commits
1 Forks
1 Watching
2 Branches
2 Contributors
Bundle Size
904.82 kB
Minified
263.34 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.2
Package Id
react-country-flags-select@1.1.2
Unpacked Size
4.25 MB
Size
1.09 MB
File Count
253
NPM Version
9.3.1
Node Version
18.14.1
Publised On
01 Mar 2023
Total Downloads
Cumulative downloads
Total Downloads
11,735
Last day
-47.3%
29
Compared to previous day
Last week
-11.8%
225
Compared to previous week
Last month
14.7%
1,040
Compared to previous month
Last year
269%
9,233
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
48
react-country-flags-select
A customizable SVG flags select component and standalone SVG flags components are provided by this React component.
Live demo example
Installation and usage
npm install react-country-flags-select
Usage
ReactCountryFlagsSelect
1import React, { useState } from "react"; 2import ReactCountryFlagsSelect from "react-country-flags-select"; 3 4const App = () => { 5 const [selected, setSelected] = useState(null); 6 7 <ReactCountryFlagsSelect selected={selected} onSelect={setSelected} />; 8}; 9 10export default App;
Countries
List of Countries with country codes. Countries.
Props
-
selected
- is a requiredobject
prop that contains current label and country code of the input. -
onSelect
- is a requiredfunction
prop that receive the selected country from the user, which will be used to update the selected value. -
customCountries
- an optionobject
prop that you can pass to replace default countries with your ownobject
. -
searchable
- an optionboolean
prop that you can pass to make select searchable.false
by default. -
customLabelOptions
- an optionobject
prop that you can pass to rewrite original labels. -
labelWithCountryCode
- an optionboolean
prop that you can pass to see the country label in formatUnited States (US)
.false
by default. -
labelOnlyCountryCode
- an optionboolean
prop that you can pass to see the country label in formatUS
.false
by default. -
searchPlaceholder
- an optionstring
prop that you can pass to replace default placeholder in searchable mode. -
selectPlaceholder
- an optionstring
prop that you can pass to replace default placeholder in not searchable mode. -
CustomOpenIcon
&CustomCloseIcon
- an option props that you can pass to replace default open and close icons. -
clearIcon
- an optionboolean
prop that you can pass to remove clear icon.true
by default. -
selectWidth
&selectHeight
- an optionnumber
props that you can pass to change the width or height of the select. By defaultselectWidth = 250px
,selectHeight = 30px
. -
optionSize
&selectedSize
an optionnumber
props that you can pass to change font size of the option or selected element. By defaultoptionSize = 16px
,selectedSize = 16px
. -
fullWidth
= an optionboolean
prop that you can pass to make select element full width. By defaultfalse
. iffullWidth = true
will ignoreselectWidth
&selectHeight
props. -
optionsListMaxHeight
- an optionnumber
prop that you can pass to change the max height of the dropdown overlay. By defaultoptionsListMaxHeight = 300px
. -
disabled
= an optionboolean
prop that you can pass to disable select element. -
id
= an optionstring
prop that you can pass to container element. -
classes
= an optionobject
prop that you can pass to rewrite default classes.
you can override such classes
as:
container
, selectWrapper
, searchSelect
, buttonSelect
, buttonSelectText
, clearIcon
, optionsWrapper
,
option
, optionFlag
, optionText
, openIcon
, closeIcon
.
1import { ReactComponent as SomeIcon } from "../SomeIcon.svg"; 2 3const [selected, setSelected] = useState(null); 4const customCountries = { 5 US: "United States", 6 AF: "Afghanistan", 7 AL: "Albania", 8 DZ: "Algeria", 9 US: "United States", 10}; 11const customLabelOptions = { 12 US: "U*S*A", 13}; 14const searchPlaceholder = "some custom placeholder"; 15const selectPlaceholder = "some custom placeholder"; 16const classes = { 17 container: "someNewClass", 18 selectWrapper: "someNewClass", 19 searchSelect: "someNewClass", 20 buttonSelect: "someNewClass", 21 buttonSelectText: "someNewClass", 22 clearIcon: "someNewClass", 23 optionsWrapper: "someNewClass", 24 option: "someNewClass", 25 optionFlag: "someNewClass", 26 optionText: "someNewClass", 27 openIcon: "someNewClass", 28 closeIcon: "someNewClass", 29}; 30 31<ReactCountryFlagsSelect 32 selected={selected} 33 onSelect={onSelect} 34 customCountries={customCountries} 35 customLabelOptions={customLabelOptions} 36 searchPlaceholder={searchPlaceholder} 37 selectPlaceholder={selectPlaceholder} 38 CustomOpenIcon={SomeIcon} 39 CustomCloseIcon={SomeIcon} 40 clearIcon={false} 41 searchable 42 labelWithCountryCode 43 labelOnlyCountryCode 44 selectWidth={350} 45 selectHeight={40} 46 optionSize={20} 47 selectedSize={20} 48 fullWidth 49 disabled 50 classes={classes} 51 optionsListMaxHeight={300} 52 id 53/>;
Country Flag
1import React from "react"; 2import { Us } from "react-country-flags-select"; 3 4const Region = () => ( 5 <div> 6 <Us /> United States 7 </div> 8); 9 10export default Region;
Contribution
This project is written in Typescript. Storybook. Tests are written with Jest and React Testing Library. Raise a pull request with your changes.
Installation
npm install
License
MIT license.
No vulnerabilities found.
No security vulnerabilities found.
Other packages similar to react-country-flags-select
react-native-country-flag-quality
This is a React-Native package to display every 254 Country flags with the ISO 3166-1 alpha-2 Standard with image quality select!
react-native-country-selector
A simple react native country picker. It provides name of country, dial code, currency, country code,flag and more.
react-native-country-flag-select
This library is currently compatible with React Native. Its primary purpose is to enable users to implement the selection of country flags in their mobile application
react-country-select-amn
country select with flags and an added prop tag