Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Beside a name

The flag sits in the text line with the country name after it, and reads as part of it.

Countries in a list
India United Kingdom United States
Show code
<span class="d-inline-flex align-items-center gap-2"><app-country-flag country="IN" /> India</span>
<span class="d-inline-flex align-items-center gap-2"><app-country-flag country="GB" /> United Kingdom</span>
<span class="d-inline-flex align-items-center gap-2"><app-country-flag country="US" /> United States</span>

A standalone flag

Give a label when the flag stands alone, so it is read out as the country name.

Named flag
Show code
<app-country-flag country="GB" label="United Kingdom" />

Every option

Every value of every prop, one cell each.

country

country="IN"
country="GB"
country="US"

label

label="United Kingdom" (names the flag for screen readers, no visible change)

className

class="opacity-50" (React: className)

Guidance

What to do, and what to avoid.

Use it when

  • A country beside its name in a list, a table cell or a profile.
  • A country column in a table.

Reach for something else when

  • Picking a country. → AppSelect mode="country"
  • A phone number with its country. → AppPhoneNumberInput

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

React, generated from the controls
<AppCountryFlag country="IN" />
Razor, the same props
<app-country-flag country="IN" />

3 props. The 2 most used come first.

Used on most screens 2 props

PropTypeDefaultDescription
countrydefault - string - ISO 3166-1 alpha-2 code of the country, such as IN. The flag follows the size of the text around it.
labeldefault - string - Names the flag for assistive tech. Without it the flag is decorative and hidden, so put the country name in the text beside it.

Less common 1 props

PropTypeDefaultDescription
classdefault - string - Extra classes on the flag.

Screen reader

2 notes
  • Decorative by default: the country name in the text beside it carries the meaning.
  • Give label when the flag stands alone, so assistive tech reads the country.