DEV Community

Cover image for blade-flags gives you SVG rectangles. This gives you flags users actually recognize.
K. Polash
K. Polash

Posted on

blade-flags gives you SVG rectangles. This gives you flags users actually recognize.

There's already a popular Laravel flag package. outhebox/blade-flags has 663k installs, and it works fine.

So why did I build another one?

Because SVG rectangular flags and emoji flags solve different problems β€” and most Laravel apps actually need the emoji version.


The difference nobody talks about

When your user sees this in your app:

<x-flag-icon type="country" code="bd" width="24px" />
Enter fullscreen mode Exit fullscreen mode

They see: πŸ‡§πŸ‡©

That's the flag they see in WhatsApp. In Twitter. In their phone keyboard. In every modern app, they use it daily. Their brain recognizes it in zero milliseconds.

blade-flags renders a tiny rectangular SVG of the Bangladeshi flag β€” accurate, technically correct, and completely unfamiliar to most users. It looks like something from a government website.

Emoji flags match the visual language of the modern web. SVG flags don't.


When does this actually matter?

If you're building a developer tool or admin dashboard β€” use blade-flags. SVG flags look sharp and professional at small sizes in dense UIs.

If you're building anything user-facing β€” locale switchers, user profiles, country selectors, chat apps, language pickers β€” use Twemoji flags. Users recognize them instantly. That recognition reduces friction.

The mental model test: your user doesn't think "ISO 3166-1 alpha-2 code for Bangladesh." They think πŸ‡§πŸ‡©. Build for that.


Installation

composer require pola5h/laravel-flags
Enter fullscreen mode Exit fullscreen mode

Auto-registered on Laravel 5.5+. No config publishing, no setup. Done.


Usage

{{-- Country flag --}}
<x-flag-icon type="country" code="us" width="24px" height="24px" />

{{-- Language flag --}}
<x-flag-icon type="language" code="bn" width="24px" height="24px" />
Enter fullscreen mode Exit fullscreen mode

Two parameters that matter: type (country or language) and code (ISO 2-letter code). Width and height are optional β€” they default to auto.


Country flags

Any ISO 3166-1 alpha-2 code works:

<x-flag-icon type="country" code="us" width="20px" /> πŸ‡ΊπŸ‡Έ United States
<x-flag-icon type="country" code="gb" width="20px" /> πŸ‡¬πŸ‡§ United Kingdom
<x-flag-icon type="country" code="bd" width="20px" /> πŸ‡§πŸ‡© Bangladesh
<x-flag-icon type="country" code="de" width="20px" /> πŸ‡©πŸ‡ͺ Germany
<x-flag-icon type="country" code="jp" width="20px" /> πŸ‡―πŸ‡΅ Japan
Enter fullscreen mode Exit fullscreen mode

Dynamic usage from a model:

<x-flag-icon type="country" code="{{ $user->country_code }}" width="20px" />
Enter fullscreen mode Exit fullscreen mode

250+ countries supported.


Language flags

Language flags map to the country most associated with that language. Bengali β†’ Bangladesh, Arabic β†’ Saudi Arabia, French β†’ France.

<x-flag-icon type="language" code="en" width="20px" /> English
<x-flag-icon type="language" code="bn" width="20px" /> Bengali
<x-flag-icon type="language" code="ar" width="20px" /> Arabic
<x-flag-icon type="language" code="zh" width="20px" /> Chinese
<x-flag-icon type="language" code="fr" width="20px" /> French
Enter fullscreen mode Exit fullscreen mode

Dynamic with the current app locale:

<x-flag-icon type="language" code="{{ app()->getLocale() }}" width="20px" />
Enter fullscreen mode Exit fullscreen mode

100+ languages supported.


The use case I built this for: locale switchers

This is where the difference is most visible. A locale switcher with SVG flags feels like a dropdown from 2012. With Twemoji flags it feels native β€” like switching language on your iPhone.

@foreach ($availableLocales as $locale)
    <a href="{{ route('locale.switch', $locale) }}"
       class="{{ app()->getLocale() === $locale ? 'active' : '' }}">
        <x-flag-icon
            type="language"
            code="{{ $locale }}"
            width="18px"
            height="18px"
        />
        {{ strtoupper($locale) }}
    </a>
@endforeach
Enter fullscreen mode Exit fullscreen mode

Clean, familiar, instant recognition.


Side-by-side comparison

pola5h/laravel-flags outhebox/blade-flags
Flag style Twemoji emoji πŸ‡§πŸ‡© SVG rectangular
Best for User-facing UI Admin/dev tools
Countries 250+ 300+
Language flags βœ… Yes ❌ No
Zero config βœ… Yes βœ… Yes
License MIT MIT
Installs New 663k

The one thing blade-flags doesn't have at all: language flags. If you need to show a flag for Bengali, Arabic, or French β€” not the country, but the language β€” this package is currently your only option in the Laravel ecosystem.


Links


Both packages solve real problems. Use SVG flags when precision matters for developers. Use Twemoji flags when recognition matters for users.

If you're building something user-facing, give it a try β€” it's free, MIT licensed, and takes 30 seconds to add to any Laravel project.

What are you building it into? I'd love to see it in the comments.

Top comments (0)