npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xsolla/xui-icons-flag

v0.112.0

Published

A cross-platform React flag icons package containing 250+ country flags. Each flag uses ISO 3166-1 alpha-2 country codes and renders as a scalable SVG.

Readme

Icons Flag

A cross-platform React flag icons package containing 250+ country flags. Each flag uses ISO 3166-1 alpha-2 country codes and renders as a scalable SVG.

Installation

npm install @xsolla/xui-icons-flag
# or
yarn add @xsolla/xui-icons-flag

Demo

Individual Flag Import

import * as React from 'react';
import { FlagUS, FlagGB, FlagDE, FlagJP } from '@xsolla/xui-icons-flag';

export default function IndividualFlags() {
  return (
    <div style={{ display: 'flex', gap: 8 }}>
      <FlagUS size={24} />
      <FlagGB size={24} />
      <FlagDE size={24} />
      <FlagJP size={24} />
    </div>
  );
}

Dynamic Flag Component

import * as React from 'react';
import { FlagIcon } from '@xsolla/xui-icons-flag';
import * as Flags from '@xsolla/xui-icons-flag';

export default function DynamicFlag() {
  const countryCode = 'US';
  const FlagComponent = Flags[`Flag${countryCode}`];

  return FlagComponent ? <FlagComponent size={24} /> : null;
}

Flag Sizes

import * as React from 'react';
import { FlagUS } from '@xsolla/xui-icons-flag';

export default function FlagSizes() {
  return (
    <div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
      <FlagUS size={16} />
      <FlagUS size={24} />
      <FlagUS size={32} />
      <FlagUS size={48} />
    </div>
  );
}

Anatomy

import { FlagUS } from '@xsolla/xui-icons-flag';

<FlagUS
  size={24}                   // Size in pixels
  className="flag"            // CSS class
  style={{ margin: 4 }}       // Inline styles
  aria-label="United States"  // Accessible label
/>

Examples

Country Selector

import * as React from 'react';
import { FlagUS, FlagGB, FlagDE, FlagFR, FlagJP } from '@xsolla/xui-icons-flag';

export default function CountrySelector() {
  const [selected, setSelected] = React.useState('US');

  const countries = [
    { code: 'US', name: 'United States', Flag: FlagUS },
    { code: 'GB', name: 'United Kingdom', Flag: FlagGB },
    { code: 'DE', name: 'Germany', Flag: FlagDE },
    { code: 'FR', name: 'France', Flag: FlagFR },
    { code: 'JP', name: 'Japan', Flag: FlagJP },
  ];

  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
      {countries.map(({ code, name, Flag }) => (
        <button
          key={code}
          onClick={() => setSelected(code)}
          style={{
            display: 'flex',
            alignItems: 'center',
            gap: 12,
            padding: '8px 16px',
            background: selected === code ? '#e0e0e0' : 'transparent',
            border: 'none',
            cursor: 'pointer',
          }}
        >
          <Flag size={20} aria-hidden />
          <span>{name}</span>
        </button>
      ))}
    </div>
  );
}

With InputPhone

import * as React from 'react';
import { InputPhone, Country } from '@xsolla/xui-input-phone';
import { FlagUS, FlagGB, FlagDE } from '@xsolla/xui-icons-flag';

export default function PhoneWithFlags() {
  const [phone, setPhone] = React.useState('');
  const [country, setCountry] = React.useState<Country>();

  const countries: Country[] = [
    { code: 'US', name: 'United States', dialCode: '+1', flag: <FlagUS /> },
    { code: 'GB', name: 'United Kingdom', dialCode: '+44', flag: <FlagGB /> },
    { code: 'DE', name: 'Germany', dialCode: '+49', flag: <FlagDE /> },
  ];

  return (
    <InputPhone
      value={phone}
      onChange={(e) => setPhone(e.target.value)}
      countries={countries}
      selectedCountry={country}
      onCountryChange={setCountry}
    />
  );
}

API Reference

Flag Components

Each flag component (e.g., FlagUS, FlagGB) accepts the same props:

FlagIconProps:

| Prop | Type | Default | Description | | :--- | :--- | :------ | :---------- | | size | number | 24 | Size in pixels (width and height). | | className | string | - | CSS class name. | | style | CSSProperties | - | Inline styles. | | data-testid | string | - | Test ID (web). | | testID | string | - | Test ID (React Native). | | aria-label | string | - | Accessible label. | | aria-hidden | boolean | true if no aria-label | Hide from screen readers. |

Available Flags

Flags are named using ISO 3166-1 alpha-2 country codes prefixed with "Flag":

| Code | Component | Country | | :--- | :-------- | :------ | | AD | FlagAD | Andorra | | AE | FlagAE | United Arab Emirates | | AF | FlagAF | Afghanistan | | ... | ... | ... | | US | FlagUS | United States | | GB | FlagGB | United Kingdom | | DE | FlagDE | Germany | | FR | FlagFR | France | | JP | FlagJP | Japan | | ... | ... | ... | | ZW | FlagZW | Zimbabwe |

Over 250 country flags are available. See the full list in the package source.

Tree Shaking

Import individual flags for optimal bundle size:

// Good - only imports US flag
import { FlagUS } from '@xsolla/xui-icons-flag';

// Avoid - imports all flags
import * as Flags from '@xsolla/xui-icons-flag';

Accessibility

  • Flags are hidden from screen readers by default (aria-hidden="true")
  • Use aria-label when the flag conveys meaningful information
  • For decorative flags, keep the default hidden behavior