Skip to content
Devix Open Source

Guide

API reference

flagSvg(code, options?)

Returns the flag as an SVG string.

Option Type Default Description
shape 'rect' | 'square' | 'circle' 'rect' rect is 3:2. square and circle crop to the centre.
title string — Accessible name. Without it the SVG is aria-hidden.
width number — Sets width and a matching height attribute.
radius number 0 Corner radius in art-board units (the board is 30 × 20).
border boolean true A hairline inner edge that keeps white flags visible on white.
className string — Class attribute for the <svg>.

flagDataUri(code, options?)

The same flag as a data:image/svg+xml URI, for <img src> or background-image.

flagElement(code, options?, document?)

An SVGSVGElement ready to append.

flagEmoji(code)

The regional-indicator emoji, e.g. flagEmoji('ae') → 🇦🇪. Useful as a text fallback; note that Windows renders these as letters.

hasFlag(code) and normalizeCode(code)

normalizeCode lower-cases and resolves common aliases (UK → gb). hasFlag tells you whether a drawing exists.

FLAG_CODES

A frozen, sorted array of every supported code.

Sizes

Bundle Gzipped
index.js (all 246 flags) ~14 KB
element.js (web component, needs index.js) ~0.6 KB
flag-icons.css ~4.5 KB
One SVG file ~0.2–1.5 KB
Updated 12 Sep 2026