Data display
Flag
A country's flag from its two-letter code, as an image sized to sit beside text: a phone or language picker, a list of countries, a user's location.
Nothing to show
The Brazilian flag, 4:3, as tall as small text, with slightly rounded corners. Screen readers skip it, as it usually sits beside the country name.
Named, round or larger #
A larger Portuguese flag that screen readers read as "Portugal", and a round American flag.
Nothing to show
An image of your own #
For a region, a subdivision or a historical flag, src shows an image with the same sizes and shape.
Nothing to show
Countries #
country takes any two-letter country code.
Nothing to show
Sizes #
size sets the height, from xs to 3xl; the width follows the shape.
Nothing to show
Reference
Flag
| Prop | Type | Default | Description |
|---|---|---|---|
country |
string | null |
The ISO 3166-1 alpha-2 code (br, US), in any case. Anything else renders nothing. |
src |
string | null |
An image URL to show instead of a country's flag. |
alt |
string | null |
The accessible name, translated. Without it the flag is decorative. |
circle |
bool | false |
A round flag (a square image cut to a circle) instead of a 4:3 one. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Sets the height, from 0.75rem to 2rem. |
Customization
Classes and attributes go to the <svg> (or the <img> with src).
Nothing to show
Accessibility
Without alt the flag is decorative: aria-hidden on the SVG, alt="" on an image from src; with it, it is an image with that name.
Behavior notes
- The flags are icons from the
flagandcircle-flagscollections of Iconify (both MIT licensed). Like any icon not in your app yet, a flag is fetched after the first response that uses it and shows from the next page on;php artisan tallkit:icons flag:br-4x3 circle-flags:brfetches the ones you use ahead of time.