Flag
Displays a flag as an SVG for the country code you pass. The code prop takes an ISO 3166-1 alpha-2 country code, such as US.
When to use
- Show the country of a region, an IP address, a billing address, or a locale.
- Give a select option, a list row, or a status pill a quick visual cue.
When not to use
- As a stand-in for language. Flags are not languages: Brazilian Portuguese is not "Portugal", and Spanish is not just "Spain". Use a language label instead.
- As decoration where the country isn't meaningful to the user.
Sizing
"s" (16×12), "m" (20×15), and "l" (32×24, default) match common inline, list, and table contexts. Pick the size that matches its neighbors so the flag doesn't dominate or disappear.
Accessibility
The underlying <img> is given alt="flag for {code}". If the country is decorative or already labeled in adjacent text, consider passing aria-hidden via the wrapper <div> to avoid duplicate announcements.
Loading
The SVG loads from ngrok's CDN. Flag defaults to loading="lazy". Use loading="eager" for flags above the fold or in critical content.
API Reference
The Flag accepts the following props in addition to the standard HTML div attributes.
Country codes
@ngrok/mantle/flag also exports the code list and its type guard.