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.
Import only the flags you need from the main entry:
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> )}<script setup lang="ts">import { FlagUs, FlagCn, FlagGb } from '@sankyu/vue-circle-flags'</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, FlagCn, FlagGb } from '@sankyu/solid-circle-flags'
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> )}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} />}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 Home() { return ( <main> <h1>Country Flags</h1> <div class="flex gap-4"> <FlagUs width={64} height={64} className="rounded-full" /> <FlagCn width={64} height={64} className="rounded-full" /> </div> </main> )}import { 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>