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 known at build time.
For guaranteed per-flag isolation across Vite, webpack, and framework SSR bundlers, import each
component from its flags/* subpath:
import { FlagUs } from '@sankyu/react-circle-flags/flags/us'import { FlagCn } from '@sankyu/react-circle-flags/flags/cn'import { FlagGb } from '@sankyu/react-circle-flags/flags/gb'
export function Header() { return ( <div> <FlagUs width={32} height={32} /> <FlagCn width={32} height={32} /> <FlagGb width={32} height={32} /> </div> )}<script setup lang="ts">import { FlagUs } from '@sankyu/vue-circle-flags/flags/us'import { FlagCn } from '@sankyu/vue-circle-flags/flags/cn'import { FlagGb } from '@sankyu/vue-circle-flags/flags/gb'</script>
<template> <div> <FlagUs :width="32" :height="32" /> <FlagCn :width="32" :height="32" /> <FlagGb :width="32" :height="32" /> </div></template>Solid (beta): named-import flags currently use className for CSS classes.
import { FlagUs } from '@sankyu/solid-circle-flags/flags/us'import { FlagCn } from '@sankyu/solid-circle-flags/flags/cn'import { FlagGb } from '@sankyu/solid-circle-flags/flags/gb'
export function Header() { return ( <div> <FlagUs width={32} height={32} className="flag-icon" /> <FlagCn width={32} height={32} className="flag-icon" /> <FlagGb width={32} height={32} className="flag-icon" /> </div> )}<script lang="ts"> import FlagUs from '@sankyu/svelte-circle-flags/flags/us' import FlagCn from '@sankyu/svelte-circle-flags/flags/cn' import FlagGb from '@sankyu/svelte-circle-flags/flags/gb'</script>
<div> <FlagUs width={32} height={32} /> <FlagCn width={32} height={32} /> <FlagGb width={32} height={32} /></div>The shorter main-entry form (import { FlagUs } from '@sankyu/react-circle-flags') remains
supported. Use the explicit subpath when bundle size must be deterministic, because the main entry
also exposes DynamicFlag and its complete registry.
Offline-first runtime flags (bundles all flags).
Render any flag from runtime ISO codes without network requests:
import { DynamicFlag } from '@sankyu/react-circle-flags'
export function CountryFlag({ code }: { code: string }) { return <DynamicFlag code={code} width={36} height={36} />}<script setup lang="ts">import { DynamicFlag } from '@sankyu/vue-circle-flags'const props = defineProps<{ code: string }>()</script>
<template> <DynamicFlag :code="props.code" :width="36" :height="36" /></template>import { DynamicFlag } from '@sankyu/solid-circle-flags'
export function CountryFlag(props: { code: string }) { return <DynamicFlag code={props.code} width={36} height={36} />}<script lang="ts"> import { DynamicFlag } from '@sankyu/svelte-circle-flags'
let { code }: { code: string } = $props()</script>
<DynamicFlag {code} width={36} height={36} />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 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 Appimport { FlagUs, FlagCn } from '@sankyu/solid-circle-flags'
export default function App() { return ( <main> <h1>Country Flags</h1> <div class="flex gap-4"> <FlagUs width={56} height={56} className="rounded-full" /> <FlagCn width={56} height={56} className="rounded-full" /> </div> </main> )}<script setup lang="ts">import { FlagUs, FlagCn } from '@sankyu/vue-circle-flags'</script>
<template> <main> <h1>Country Flags</h1> <div class="flex gap-4"> <FlagUs :width="64" :height="64" /> <FlagCn :width="64" :height="64" /> </div> </main></template><script setup lang="ts">import { FlagUs, FlagCn } from '@sankyu/vue-circle-flags'</script>
<template> <div> <h1>Country Flags</h1> <div class="flex gap-4"> <FlagUs :width="48" :height="48" /> <FlagCn :width="48" :height="48" /> </div> </div></template><script lang="ts"> import { FlagUs, FlagCn } from '@sankyu/svelte-circle-flags'</script>
<main> <h1>Country Flags</h1> <div class="flags"> <FlagUs width={48} height={48} /> <FlagCn width={48} height={48} /> </div></main>The repository includes build-tested Next.js SSR, Nuxt SSR, and Vite examples. For SSR boundaries, bundle trade-offs, and troubleshooting, see the SSR compatibility guide.