Skip to content

Flag ​

The circular flag for a locale. Self-hosted, decorative, and silent when there is none.

Open in demo
Open in demo

Usage ​

src is a public/-relative URL, which flagFor(code) returns for a locale. The flags are self-hosted SVGs from circle-flags, so nothing is fetched from a third party.

It is a component rather than an <img> at each call site because three things have to hold everywhere:

  • The alt text is empty. The language's name is always beside it, and alt text would make a screen reader say it twice.
  • The box is fixed and does not shrink. The assets are 512 by 512 and would shift the row while loading.
  • Nothing renders when src is absent, rather than a broken-image glyph.

A flag is not mirrored in a right-to-left layout. It is an image, not a directional glyph.

Examples ​

Sizes ​

size is a Tailwind size utility. The default, size-5, is 20 pixels, which reads right beside small text.

No flag ​

flagFor returns undefined for a code it does not know, such as one left in a stale saved config. The component renders nothing.

API ​

Source: src/shared/components/common/SaFlag.vue

Props ​

PropTypeDefaultDescription
srcstring—A public/-relative URL, usually from flagFor(code). Absent renders nothing.
sizestring'size-5'A Tailwind size utility.

Emits ​

None.

Slots ​

None.

Accessibility ​

  • The image carries an empty alt and aria-hidden, because the language's name is always the text beside it.
  • It is shrink-0 in a fixed box, so a row does not reflow while the asset loads.
  • It loads lazily and decodes asynchronously, so a list of nine languages does not block the first paint.