Skip to content

Country Flag

Free

Shows the flag of a country from its two-letter code, as a rectangle, a circle, or a square. An unknown code shows a globe, and a badge can mark the pick.

  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Pass a country code. Put a CountryFlagBadge inside the flag of the selected choice, so the check sits on the flag.

The sample also uses Choice Card and Radio Group. One command adds them with this item:

site-language.tsx

CountryFlag

<span>
PropTypeDefaultDescription
size"default""lg""sm""xl""xs""default"
variant"circle""rectangle""square""rectangle"
codeRequiredstring | null—ISO 3166-1 alpha-2 ("DE", any case), or a subdivision ("GB-ENG"). Unknown: a globe.
namedbooleanfalseName the flag with the country name in locale ("Germany"): an image with that name. Default false: the flag is decorative, for a flag next to a written name. An aria-label wins.
localestring—The language of the name (Intl.DisplayNames). Default: the DisplayLocaleProvider locale.
popbooleanfalsePop the art in when code changes: scale 0.9 to 1 and a fade on the popup clock.
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

CountryFlagBadge

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.
  • Pass the ISO 3166-1 alpha-2 code as code ("DE", any case).
  • Use variant="circle" in pickers and cards, and the 3:2 rectangle in text, tables, and fields.
  • Add named when the flag stands alone, so it says the country name.
  • Put a CountryFlagBadge inside to mark the selected country.
  • For a picture of a person or a workspace, use Avatar.
  • To pick a country, use the flags inside a Combobox.

With named, the flag is an image named with the country name in the page language.

With no named, the flag is decorative, for a flag next to a written name.

The badge is decorative: the control around it says it is selected.

Change
popup · with `pop`, a new flag scales from 0.9 to 1 and fades in
  1. AddedCountry Flag.
Open the release