Pattern
Components use the format Flag{ISO} where ISO is the uppercase country code.
Choose the right approach based on your use case:
Best for static flags.
Import only the flags you need from the main entry. Modern bundlers will automatically tree-shake unused exports:
import { FlagUs, FlagCn, FlagGb } from '@sankyu/react-circle-flags'
export function Header() { return ( <div> <FlagUs width={32} height={32} /> <FlagCn width={32} height={32} /> <FlagGb width={32} height={32} /> </div> )}When to use:
Best for dynamic flags.
Load SVG flags from CDN on demand. Perfect for runtime-determined country codes:
import { CircleFlag } from '@sankyu/react-circle-flags'
export function CountryFlag({ code }: { code: string }) { return <CircleFlag countryCode={code} width={36} height={36} />}Result: ~2 KB bundle impact, SVG flags loaded on demand from CDN
When to use:
Loads all flags in a single bundle.
Bundles ALL 400+ flag components. Only use when you absolutely need synchronous rendering of any flag:
import { DynamicFlag } from '@sankyu/react-circle-flags'
export function CountryFlag({ code }: { code: string }) { return <DynamicFlag code={code} width={36} height={36} />}When to use:
All flag components follow a consistent naming pattern:
Pattern
Components use the format Flag{ISO} where ISO is the uppercase country code.
Examples
FlagUs → United States
FlagCn → China
FlagGb → United Kingdom
FlagJp → Japan
The library works seamlessly with all modern React frameworks:
import { FlagUs, FlagCn } from '@sankyu/react-circle-flags'
export default function Page() { return ( <main> <h1>Country Flags</h1> <div className="flex gap-4"> <FlagUs width={64} height={64} /> <FlagCn width={64} height={64} /> </div> </main> )}import { FlagUs, FlagCn } from '@sankyu/react-circle-flags'
export default function Index() { return ( <div> <h1>Country Flags</h1> <div className="flex gap-4"> <FlagUs width={48} height={48} /> <FlagCn width={48} height={48} /> </div> </div> )}import { FlagUs, FlagCn } from '@sankyu/react-circle-flags'
function App() { return ( <> <h1>Country Flags</h1> <div className="flex gap-4"> <FlagUs width={56} height={56} /> <FlagCn width={56} height={56} /> </div> </> )}
export default App