Costa Rica Flag

CostaRicaFlag is a typed wrapper around the shared Flag component that renders the Costa Rica national flag with the code preset to cr. It supports no-crop 4:3, 1:1, and original-ratio frames with SVG, PNG, WebP, and JPEG artwork.

componentflagscountriesinternationalizationregistry-item.json
Costa Rica Flag
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @flagcn/cr

Requires @flagcn in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { CostaRicaFlag } from "@/components/flags/countries/cr"export function Example() {  return <CostaRicaFlag />}
  • Showing Costa Rica's flag beside a country selector, language picker, or locale switcher.
  • Displaying a country's flag in a team, travel, shipping, or event listing where the flag must stay uncropped.
  • Rendering a flag in a square avatar or badge slot where a 1:1 frame is needed.
  • Building a country list from typed wrappers when you want each flag to be a named component instead of a string code.

Examples

Basic flag with the default alt text

Renders the flag with the built-in alt text 'Costa Rica flag'.

basic-flag-with-the-default-alt-text.tsx
import { CostaRicaFlag } from "@/components/flags/countries/cr"export function BasicFlag() {  return <CostaRicaFlag />}

Language picker option with a localized alt

Passes a custom alt for a Spanish-language UI so screen readers announce the flag in context.

language-picker-option-with-a-localized-alt.tsx
import { CostaRicaFlag } from "@/components/flags/countries/cr"export function SpanishOption() {  return (    <button type="button">      <CostaRicaFlag alt="Bandera de Costa Rica" />      <span>Costa Rica</span>    </button>  )}

Country list with a decorative flag

Sets alt to an empty string because the country name is already announced next to the flag.

country-list-with-a-decorative-flag.tsx
import { CostaRicaFlag } from "@/components/flags/countries/cr"export function CountryRow() {  return (    <li className="flex items-center gap-2">      <CostaRicaFlag alt="" />      <span>Costa Rica</span>    </li>  )}

API reference

PropTypeDefaultDescription
altstring"Costa Rica flag"Accessible text for the flag image. Applied when alt is undefined. Passing an empty string keeps it empty for decorative use.
...props (FlagProps without code)Omit<FlagProps, "code">—All remaining props from the Flag component's FlagProps type are forwarded to Flag. The code prop is fixed to cr and cannot be overridden. The full list is defined in the @flagcn/flag registry item, which this component depends on, and is not repeated in this item's source.

Accessibility

  • The default alt is 'Costa Rica flag'. Provide a localized alt when the UI language differs.
  • If the country name appears as visible text next to the flag, pass alt="" so screen readers do not repeat the name.
  • Because alt is destructured with a default, only undefined triggers the default. An explicit empty string is preserved.
  • The flag is a static image with no motion, so no reduced-motion handling is needed.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Costa Rica Flag" component (flagcn/cr) from its shadcn registry.1. Install it with: npx shadcn@latest add @flagcn/cr2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: alt, ...props (FlagProps without code).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { CostaRicaFlag } from "@/components/flags/countries/cr"export function Example() {  return <CostaRicaFlag />}```

Files & dependencies

  • src/components/flags/countries/cr.tsx→ @components/flags/countries/cr.tsx
registryDependencies@flagcn/flag

Looks similar, elsewhere