Back to projects← Back

React Beauty Flags

16 November 2024 20 December 2024
React Beauty Flags

React Beauty Flags

React Beauty Flags is a React library that provides over 250 handcrafted SVG flags β€” from countries to cities β€” designed to bring color and style to modern interfaces.

Born from frustration with dull or over-complicated alternatives, it focuses on simplicity, visual harmony, and developer experience.

React Beauty Flags preview

🎯 Motivation

After reusing flags in dozens of projects, I realized existing solutions were either too heavy or lacked design consistency. Inspired by Duolingo’s clean and playful visuals, I decided to design a set that looked great in any modern UI while staying developer-friendly.

β€œI wanted something elegant enough for portfolios but simple enough to drop into production.”

The result is a library now downloaded over 1,000 times (and growing!) through NPM, with strong adoption among UI-focused developers and open-source enthusiasts.


🌟 Highlights

  • 🎨 +250 Handmade Flags β€” Countries, cities, and symbols designed in Figma.
  • ⚑ Lightweight & Fast β€” Zero external dependencies, optimized SVGs.
  • πŸ’… Customizable β€” Supports Tailwind utilities for borders, shadows, and radius.
  • πŸ” Search & Filter β€” Built-in search experience with sharable URLs.
  • 🧠 TypeScript Ready β€” Fully typed, autocompletion in your IDE.
Technical Details
For developers & curious minds

🧰 Tech Stack

ToolPurpose
ReactCore library for rendering components
TypeScriptStatic typing and code reliability
Tailwind CSSUtility-first styling for the demo website
Figma APIFetch and sync vector flag designs
svgoSVG optimization for fast loading
GitHub ActionsCI/CD automation for build and NPM publish

πŸ—‚οΈ Library Structure

β”œβ”€β”€ src
β”‚   β”œβ”€β”€ components/   # Flag components
β”‚   β”œβ”€β”€ data/         # Flag metadata and enums
β”‚   β”œβ”€β”€ scripts/      # Automation scripts (get-figma, build-flags, check-flags)
β”‚   └── index.ts      # Export entry
β”œβ”€β”€ website/          # Next.js showcase website
β”œβ”€β”€ .github/workflows # CI/CD pipelines
└── package.json

βš™οΈ Automation Scripts

get-figma.ts β€” Fetches SVGs from Figma via API and stores them locally.

const response = await fetch(`${FIGMA_API_BASE}/files/${fileKey}`, {
  headers: { 'X-Figma-Token': FIGMA_API_TOKEN! },
});

const flagsPage = fileData.document.children.find(
  (page: any) => page.name === 'Flags' && page.type === 'CANVAS'
);

build-flags.ts β€” Optimizes SVGs with svgo, generates React components and enums.

check-flags.ts β€” Validates flag consistency and missing metadata.


πŸš€ CI/CD Workflow

Every push to main triggers GitHub Actions to:

  1. Fetch latest Figma flags
  2. Build & optimize assets
  3. Publish a new package version to NPM
  4. Deploy the demo site to Vercel automatically

This workflow ensures the library is always up-to-date and deploys in under 2 minutes.


🧩 Website Overview

The official website β€” built with Next.js and TailwindCSS β€” showcases all flags with live filtering, previews, and instant code copy. Each flag includes:

  • Interactive customization (radius, border, shadow)
  • Copy-to-clipboard with prebuilt Tailwind classes
  • Deep-linking via URL for easy sharing
Flag grouping view
Flags grouped alphabetically by type.
Search example
Instant search with URL sync for sharing results.
Empty search feedback
Graceful feedback when no flags match search criteria.
Flag details drawer
Interactive drawer with copy-ready code snippets.

🧠 Lessons & Impact

Building React Beauty Flags reinforced my interest in developer tooling and DX-first design. Automating asset pipelines with TypeScript and Figma APIs improved my workflow, saving over 10 hours of manual flag updates per release.

The project also sparked collaborations from other developers, who contributed designs and new scripts.

Small details make software delightful β€” and flags, surprisingly, are one of them.


🌍 Future Plans

  • 🌐 Add world organization and event flags
  • 🧩 Extend utility functions (color palettes, code matching)
  • πŸ“Š Add analytics on flag usage
  • πŸͺΆ Improve accessibility metadata

πŸͺͺ License

MIT

Similar Projects

React Beauty Flags