import { KbqFlagModule } from '@koobiq/components/flag';

KbqFlag

componentCopy link to KbqFlag

Presentational wrapper for a consumer-provided country flag (inline <svg> or <img>). Decorates it with shape and shadow and applies the accessibility contract.

The flag is either projected, or passed as markup through the svg input. Do not bind [innerHTML] on the host element — that write replaces whatever was projected into it.

<kbq-flag decorative><img src="…/AL.svg" alt="" /></kbq-flag> Albania
@Component({ selector: 'kbq-flag', exportAs: 'kbqFlag' })
class KbqFlag {
    readonly shape = input<KbqFlagShape>('rectangle');
    readonly aspectRatio = input<string>();
    readonly shadow = input<KbqFlagShadow>('inset');
    readonly empty = input<boolean>(false);
    readonly svg = input<SafeHtml | string>();
    readonly decorative = input<boolean>(false);
    readonly label = input<string>();
}
shapeinputCopy link to shapeKbqFlagShape

Shape of the flag. The flag is cropped to it, so square/circle are best fed a 1:1 source — a center crop of a rectangular flag can cut off meaningful elements. Defaults to 'rectangle'.

aspectRatioinputCopy link to aspectRatiostring

Proportions of the flag box, as a CSS aspect-ratio value (4 / 3, 1.5). Set it for a source whose proportions differ from the shape — the flag is cropped to the box either way.

It overrides the ratio the shape implies, so shape="square" with an aspectRatio is no longer square. Left unset, the ratio comes from the --kbq-flag-aspect-ratio token, which a plain class rule can still redefine for a whole group of flags at once.

shadowinputCopy link to shadowKbqFlagShadow

Inset hairline that keeps the flag distinct from the background. Its color adapts to the theme. Defaults to 'inset'.

emptyinputCopy link to emptyboolean

Renders a neutral placeholder — use when no flag can be shown (unknown / invalid country code).

svginputCopy link to svgSafeHtml | string

Flag markup rendered into a slot of its own, for flags that come from a package as a string. A plain string is sanitized, and Angular's sanitizer drops <svg> — pass an SVG through DomSanitizer.bypassSecurityTrustHtml, and only for markup known at build time.

decorativeinputCopy link to decorativeboolean

Marks the flag as decorative — hidden from screen readers (use when adjacent text is present).

labelinputCopy link to labelstring

Accessible name for the flag. Use when the flag carries meaning and has no adjacent text. Without it the flag is hidden from screen readers, so a flag whose only name comes from the projected image (alt, <title>) has to repeat it here.

KbqFlagShadow

typeCopy link to KbqFlagShadow

Inset shadow (hairline) that separates the flag from the background.

type KbqFlagShadow = 'inset' | 'none';

KbqFlagShape

typeCopy link to KbqFlagShape

Shape of the flag. rectangle keeps the default 3:2 ratio, square/circle expect a 1:1 source.

type KbqFlagShape = 'rectangle' | 'square' | 'circle';
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.