Flag
A flag drawn at a 5:4 ratio, from the 304 flags of Tabler Flags. Requires
Tabler 1.7+ and its flags plugin: load tabler-flags.css (or tabler-flags.min.css) next to tabler.css, from
@tabler/core/dist/css/ or the CDN.
<div class="d-flex gap-2"> <twig:Tabler:Flag code="fr" label="France" /> <twig:Tabler:Flag code="de" label="Germany" /> <twig:Tabler:Flag code="BR" label="Brazil" /> <twig:Tabler:Flag code="gb-sct" label="Scotland" /> <twig:Tabler:Flag code="european-union" label="European Union" /></div><div class="d-flex gap-2"> <span class="flag flag-country-fr" role="img" aria-label="France"></span> <span class="flag flag-country-de" role="img" aria-label="Germany"></span> <span class="flag flag-country-br" role="img" aria-label="Brazil"></span> <span class="flag flag-country-gb-sct" role="img" aria-label="Scotland"></span> <span class="flag flag-country-european-union" role="img" aria-label="European Union"></span></div>code is the ISO 3166 code of the country (fr, br) or of a subdivision (gb-sct), and the slug of a flag without
one (european-union, nato, african-union). It is lowercased, so BR works too. The full list is on
Tabler’s flags page.
size takes the avatar sizes, xxs to 2xl, so a flag and an avatar in one list line
up. Without it, the flag is the size of an avatar:
<div class="d-flex align-items-end gap-2"> {% for size in ['2xl', 'xl', 'lg', 'md', 'sm', 'xs', 'xxs'] %} <twig:Tabler:Flag code="us" size="{{ size }}" label="United States" /> {% endfor %}</div><div class="d-flex align-items-end gap-2"> <span class="flag flag-2xl flag-country-us" role="img" aria-label="United States"></span> <span class="flag flag-xl flag-country-us" role="img" aria-label="United States"></span> <span class="flag flag-lg flag-country-us" role="img" aria-label="United States"></span> <span class="flag flag-md flag-country-us" role="img" aria-label="United States"></span> <span class="flag flag-sm flag-country-us" role="img" aria-label="United States"></span> <span class="flag flag-xs flag-country-us" role="img" aria-label="United States"></span> <span class="flag flag-xxs flag-country-us" role="img" aria-label="United States"></span></div>Accessibility
Section titled “Accessibility”A flag is a picture: label names it (role="img" and an aria-label), for a flag on its own. Without label, it is
decoration, hidden with aria-hidden="true": put the country name in text next to it, as here.
<twig:Tabler:ListGroup> {% for office in [ {code: 'fr', city: 'Toulouse', country: 'France'}, {code: 'ca', city: 'Montréal', country: 'Canada'}, {code: 'jp', city: 'Osaka', country: 'Japan'}, ] %} <twig:Tabler:ListGroup:Item title="{{ office.city }}" description="{{ office.country }}"> <twig:block name="media"> <twig:Tabler:ListGroup:Media><twig:Tabler:Flag code="{{ office.code }}" size="sm" /></twig:Tabler:ListGroup:Media> </twig:block> </twig:Tabler:ListGroup:Item> {% endfor %}</twig:Tabler:ListGroup><div class="list-group"> <div class="list-group-item"> <span class="list-group-item-media"><span class="flag flag-sm flag-country-fr" aria-hidden="true"></span></span> <span class="list-group-item-content"> <span class="list-group-item-title">Toulouse</span> <span class="list-group-item-description">France</span> </span> </div> <div class="list-group-item"> <span class="list-group-item-media"><span class="flag flag-sm flag-country-ca" aria-hidden="true"></span></span> <span class="list-group-item-content"> <span class="list-group-item-title">Montréal</span> <span class="list-group-item-description">Canada</span> </span> </div> <div class="list-group-item"> <span class="list-group-item-media"><span class="flag flag-sm flag-country-jp" aria-hidden="true"></span></span> <span class="list-group-item-content"> <span class="list-group-item-title">Osaka</span> <span class="list-group-item-description">Japan</span> </span> </div></div>A flag is not a language: on a language switcher, write the language name, in that language.
| Prop | Type | Default | Description |
|---|---|---|---|
code |
string | — | ISO 3166 code or slug of the flag (flag-country-{code}), lowercased |
size |
string? | null |
xxs xs sm md lg xl 2xl (flag-{size}) |
label |
string? | null |
Accessible name (role="img", aria-label); unset, the flag gets aria-hidden="true" |
Other attributes go to the <span class="flag">.
Sub-components
Section titled “Sub-components”None: a flag has no parts.
Blocks
Section titled “Blocks”None: the flag is an empty <span>, drawn by the stylesheet.
