legacy-icons/famfamfam-flags
Laravel package that bundles the classic FamFamFam flag icons for easy use in apps. Provides the full country flag set as lightweight assets you can publish and reference in views, CSS, and UI components for quick, consistent flag display.
Installation Add the package via Composer:
composer require legacy-icons/famfamfam-flags
Publish the CSS (if needed):
php artisan vendor:publish --tag=famfamfam-flags
First Use Case
Include the CSS in your resources/css/app.css:
@import 'legacy-icons/famfamfam-flags/dist/css/famfamfam-flags.css';
Use the flag icons in Blade:
<span class="flag-icon flag-icon-us"></span> <!-- US Flag -->
<span class="flag-icon flag-icon-gb"></span> <!-- UK Flag -->
Where to Look First
vendor/legacy-icons/famfamfam-flags/dist/css/famfamfam-flags.css for all available classes.Dynamic Flag Rendering Use a helper or Blade component to fetch flags dynamically:
// app/Helpers/FlagHelper.php
function renderFlag($countryCode) {
return '<span class="flag-icon flag-icon-' . strtolower($countryCode) . '"></span>';
}
Blade usage:
@renderFlag($user->country_code)
Integration with Laravel Collections Add a flag icon to a user collection:
$users->each(function ($user) {
$user->flag_icon = '<span class="flag-icon flag-icon-' . strtolower($user->country_code) . '"></span>';
});
CSS Customization
Override flag colors/sizes in your app.css:
.flag-icon {
width: 24px;
height: 16px;
background-color: #f00; /* Fallback */
}
Localization + Flags Combine with Laravel’s localization:
// config/app.php
'locales' => ['en', 'fr', 'de'],
Blade:
@foreach(config('app.locales') as $locale)
<span class="flag-icon flag-icon-{{ strtolower($locale) }}"></span>
@endforeach
<span class="flag-icon flag-icon-us w-6 h-4 text-red-500"></span>
// webpack.mix.js
mix.postCss('resources/css/app.css', 'public/css', [
require('tailwindcss'),
]);
<div x-data="{ country: 'us' }">
<span class="flag-icon" :class="'flag-icon-' + country"></span>
</div>
Missing Country Codes
flag-icon-xx may not exist).CSS Specificity Conflicts
!important sparingly or scope your CSS:
.user-flags .flag-icon { ... }
Performance
Responsiveness
max-width or media queries:
@media (max-width: 768px) {
.flag-icon { width: 18px; height: 12px; }
}
background-image: url(...)).php artisan view:clear if flags disappear after updates..flag-icon:not([class*="flag-icon-"]):after {
content: "?";
background: linear-gradient(45deg, #ccc, #999);
}
config/famfamfam-flags.php; all settings are CSS-based.public/css/.Add Missing Flags
SVG Fallback Replace the sprite with inline SVGs for better maintainability:
<svg class="flag-icon" viewBox="0 0 64 48" aria-label="US">
<path d="M0 0h64v48H0z" fill="#b22234"/>
<path d="M0 0h64v15H0z" fill="#fff"/>
<path d="M0 15h32v15H0z" fill="#3c3b6e"/>
</svg>
Dynamic Sprite Loading Load the sprite only when needed (e.g., on pages with flags):
@if(request()->routeIs('users.index'))
<link rel="stylesheet" href="{{ asset('vendor/legacy-icons/famfamfam-flags/dist/css/famfamfam-flags.css') }}">
@endif
How can I help you explore Laravel packages today?