Choose a display representation and asset-loading model, then decide whether the application needs a full selection control. Rendering one flag and managing a selected country are separate jobs.
A flag component renders a symbol for a code. A country selector additionally manages a list, labels, interaction, and a selected value. The four packages overlap in visual output but do not all provide the same input control.
| Package | Main interface | Image or symbol delivery |
|---|---|---|
| react-country-flag | countryCode and optional svg | Platform emoji or an SVG image URL |
| react-flag-kit | Named FlagIcon with code and size | CDN-hosted SVG image |
| react-flags-select | selected, onSelect, labels and search | A country-selection UI with flag components |
| react-world-flags | code and fallback | Bundled SVG data rendered as images |
react-country-flag produces regional-indicator emoji by default. The platform determines how that emoji appears. Enabling svg changes the rendering to an image whose URL is built from the code; cdnUrl and cdnSuffix allow adapting that route. These are different presentation and loading models, not two guarantees of identical appearance.
react-flag-kit exposes FlagIcon and creates an image using its own CDN URL pattern. The current implementation does not bundle every FlagKit SVG into the component module. Its declared React peer range covers React 16.6 through 18, so that declaration alone does not establish React 19 support.
react-world-flags resolves its supported country-code forms to a flag and supplies the image from bundled data. It offers fallback content for an unmatched code. Bundling assets and requesting an image remotely have different delivery characteristics; choose based on the intended application build and rendering behavior rather than a generic claim that every flag package works offline in the same way.
react-flags-select uses a required selected string and an onSelect callback that receives the chosen country code. The application updates the selected value. Options include a country subset, custom labels, and searchable choices. Replacing it with a display-only flag component means implementing that selection behavior yourself.
For a simple badge, a display component can be sufficient. For an actual country input, compare the selection and label contract as well as the visual flags. Provide the desired text labels and image attributes through the supported props; do not assume every display component supplies the same labels automatically.
Confirm the accepted code format, framework peer requirements, asset-loading path, and how an unknown code is handled. If changing packages, adapt countryCode versus code and the selector's controlled-value interface explicitly. Similar screenshots do not make these props or asset contracts interchangeable.
Choose a flag component with emoji display by default and an SVG image option. The SVG route uses a configurable image URL; the emoji appearance follows the host platform.
Choose image-based flag display with bundled SVG data and support for documented two-letter, three-letter, or numeric country codes. Provide fallback content for an unmatched code.
Choose a controlled country-selection interface with flags, labels, and optional search. Supply selected and onSelect and update the selected value in application state.
Choose a named FlagIcon component with code and size props. Its current implementation loads SVG images from a CDN rather than embedding the complete asset collection.
React component for emoji/svg country flags.
npm install --save react-country-flag
v3.x NONE only Typescript Types were introduced, enjoy!
v2.x has breaking changes
code is now countryCodetitle and aria-label are not defined any more, it is up to the developer
to pass these instyleProps is now styleAll props are passed onto the element, everything can be overwritten.
import React from "react"
import ReactCountryFlag from "react-country-flag"
function ExampleComponent {
return (
<div>
<ReactCountryFlag countryCode="US" />
<ReactCountryFlag
className="emojiFlag"
countryCode="US"
style={{
fontSize: '2em',
lineHeight: '2em',
}}
aria-label="United States"
/>
<ReactCountryFlag countryCode="US" svg />
<ReactCountryFlag
countryCode="US"
svg
style={{
width: '2em',
height: '2em',
}}
title="US"
/>
<ReactCountryFlag
countryCode="US"
svg
cdnUrl="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.4.3/flags/1x1/"
cdnSuffix="svg"
title="US"
/>
</div>
)
}
export default ExampleComponent
Try this out and conditionally render your country flag https://github.com/danalloway/detect-emoji-support
MIT © danalloway