Gathering detailed insights and metrics for react-country-region-selector-prime
Gathering detailed insights and metrics for react-country-region-selector-prime
Gathering detailed insights and metrics for react-country-region-selector-prime
Gathering detailed insights and metrics for react-country-region-selector-prime
Country-region dropdowns for your React forms
npm install react-country-region-selector-prime
Typescript
Module System
Node Version
NPM Version
TypeScript (77.92%)
MDX (20.26%)
JavaScript (1.82%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
341 Stars
246 Commits
130 Forks
8 Watchers
4 Branches
23 Contributors
Updated on Jul 05, 2025
Latest Version
1.4.4
Package Id
react-country-region-selector-prime@1.4.4
Size
622.59 kB
NPM Version
3.10.10
Node Version
6.11.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
3
A feature you often need in forms is a connected country and region dropdown, where the region field gets automatically updated when the user selects a country. Coding this is easy of course, but it's a royal pain having to track down all the raw country-region data. This script contains a pair of components to let you add this feature quickly and easily to your forms. It's the React version of this script.
It's pretty versatile:
<CountryDropdown />
, <RegionDropdown>
) that you can embed in your
DOM wherever you need. That sounded like a vulgar euphemism, but it wasn't, honest.Check out the github pages section for some examples + example JSX code.
Ah, modern web development: so many choices! Here's how to install it with the most common build tools:
1npm install react-country-region-selector --save
1bower install react-country-region-selector
Just use the dist/rcrs.min.js
file.
Here are a few examples in a few different formats.
I figure people not using JSX will know how to remove the JSX from the code below, if not open a ticket and I'll write up a non-JSX example too.
1import React from 'react'; 2import { CountryDropdown, RegionDropdown } from 'react-country-region-selector'; 3 4 5class Example extends React.Component { 6 constructor (props) { 7 super(props); 8 this.state = { country: '', region: '' }; 9 } 10 11 selectCountry (val) { 12 this.setState({ country: val }); 13 } 14 15 selectRegion (val) { 16 this.setState({ region: val }); 17 } 18 19 render () { 20 const { country, region } = this.state; 21 return ( 22 <div> 23 <CountryDropdown 24 value={country} 25 onChange={(val) => this.selectCountry(val)} /> 26 <RegionDropdown 27 country={country} 28 value={region} 29 onChange={(val) => this.selectRegion(val)} /> 30 </div> 31 ); 32 } 33}
1// Up to you to include React + the react-country-region-selector (script tags, commonJS, whatever). 2// That's a choice you need to make with your build setup. 3 4var Example = React.createClass({ 5 getInitialState: function () { 6 return { 7 region: '', 8 country: '', 9 }; 10 }, 11 12 selectCountry: function (val) { 13 this.setState({ country: val }); 14 }, 15 16 selectRegion: function (val) { 17 this.setState({ region: val }); 18 }, 19 20 render () { 21 return ( 22 <div> 23 <CountryDropdown 24 value={this.state.country} 25 onChange={this.selectCountry} /> 26 <RegionDropdown 27 country={this.state.country} 28 value={this.state.region} 29 onChange={this.selectRegion} /> 30 </div> 31 ); 32 } 33}
1define([ 2 'react', 3 'react-country-region-selector' 4], function (React, rcrs) { 5 6 var CountryDropdown = rcrs.CountryDropdown; 7 var RegionDropdown = rcrs.CountryDropdown; 8 9 var Example = React.createClass({ 10 getInitialState: function () { 11 return { 12 region: '', 13 country: '', 14 }; 15 }, 16 17 selectCountry: function (val) { 18 this.setState({ country: val }); 19 }, 20 21 selectRegion: function (val) { 22 this.setState({ region: val }); 23 }, 24 25 render () { 26 return ( 27 <div> 28 <CountryDropdown 29 value={this.state.country} 30 onChange={this.selectCountry} /> 31 <RegionDropdown 32 country={this.state.country} 33 value={this.state.region} 34 onChange={this.selectRegion} /> 35 </div> 36 ); 37 } 38 } 39 40 return Example; 41});
<CountryDropdown />
Parameter | Required? | Default | Type | Description |
---|---|---|---|---|
value | Yes | "" | string | The currently selected country. This should either be the shortcode, or the full country name depending on what you're using for your value attribute (see the valueType option). By default it's the full country name. |
onChange | Yes | - | function | Callback that gets called when the user selects a country. Use this to store the value in whatever store you're using (or just the parent component state). |
name | No | "rcrs-country" | string | The name attribute of the generated select box. |
id | No | "" | string | The ID of the generated select box. Not added by default. |
classes | No | "" | string | Any additional space-separated classes you want to add. |
showDefaultOption | No | true | boolean | Whether you want to show a default option. |
defaultOptionLabel | No | "Select Country" | string | The default option label. |
labelType | No | "full" | string | Either "full" or "short" . This governs whether you see country names or country short codes in the dropdown. |
valueType | No | "full" | string | Either "full" or "short" . This controls the actual value attribute of each <option> in the dropdown. Please note, if you set this to "short" you will need to let the corresponding <RegionDropdown /> component know as well, by passing a countryValueType="short" attribute. |
whitelist | No | [] | array | This setting lets you target specific countries to appear in the dropdown. Only those specified here will appear. This should be an array of country shortcodes. See the country-region-data repo for the data and the shortcodes. |
blacklist | No | [] | array | Lets you target countries that should not appear in the dropdown. Should also be an array of country shortcodes. |
disabled | No | false | boolean | Disables the country field. |
<RegionDropdown />
Parameter | Required? | Default | Type | Description |
---|---|---|---|---|
country | Yes | "" | string | The currently selected country. |
value | Yes | "" | string | The currently selected region. |
onChange | Yes | - | function | Callback that gets called when the user selects a region. Use this to store the value in whatever store you're using (or just the parent component state). |
name | No | "rcrs-region" | string | The name attribute of the generated select box. |
id | No | "" | string | The ID of the generated select box. Not added by default. |
classes | No | "" | string | Any additional space-separated classes you want to add. |
blankOptionLabel | No | - | string | The label that appears in the region dropdown when the user hasn't selected a country yet. |
showDefaultOption | No | true | boolean | Whether you want to show a default option. This is what the user sees in the region dropdown after selecting a country. It defaults to the defaultOptionLabel setting (see next). |
defaultOptionLabel | No | Select Region | string | The default region option. |
onChange | No | - | function | Called when the user selects a region. Use this to store the region value. |
countryValueType | No | full | string | If you've changed the country dropdown valueType to short you will need to set this value to short as well, so the component knows what's being passed in the country property. |
labelType | No | "full" | string | Either "full" or "short" . This governs whether you see region names or region short codes in the dropdown. |
valueType | No | "full" | string | Either "full" or "short" . This controls the actual value attribute of each <option> in the dropdown. |
disableWhenEmpty | No | false | boolean | Disables the region field when the user hasn't selected a country. |
disabled | No | false | boolean | Disables the region field. If set to true, it overrides disableWhenEmpty |
<head>
, like so: <meta charset="UTF-8">
event.target.value
is returned as the first value and the full event
as the second.gulp
- regenerate everything.gulp --countries="UK,US"
- generate a custom build of the script in the /lib
and /dist
folder containing only those
countries you specify here. This seriously reduces file size (60KB down to as small as 16KB), so if you can do it, do it.This repo uses the extremely handy react-component-gulp-tasks script for doing most of the gulp tasks (ES6, JSX conversion, UMD file creation, minifications, watchers, etc.). Big thanks to Jed Watson there.
1.2.3
- Nov 7, 2017. Country data updates. React moved to peer dependency, thanks @iamdey!1.2.2
- Oct 4, 2017 - Update to pass event on change. Thanks @robertnealan!1.2.1
- Sept 6, 2017 - IE11 bug fix.1.2.0
- Aug 7, 2017 - updated country-region-data; dependency updates.1.1.0
- May 18, 2017 - dependency updates. disabled
option added to <CountryDropdown />
and <RegionDropdown />
.1.0.4
- April 12, 2017 - bug fix. Thanks @bebbi and @tchaffee!1.0.3
- Jan 2, 2016 - updated country-region-data, repo link fix.1.0.2
- October 16, 2016 - Fix issue where source-data.js in lib had no country data.1.0.0
- July 1, 2016 - initial version.MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More