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

KbqFlag

componentСкопировать ссылку на 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>();
}
shapeinputСкопировать ссылку на 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'.

aspectRatioinputСкопировать ссылку на 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.

shadowinputСкопировать ссылку на shadowKbqFlagShadow

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

emptyinputСкопировать ссылку на emptyboolean

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

svginputСкопировать ссылку на 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.

decorativeinputСкопировать ссылку на decorativeboolean

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

labelinputСкопировать ссылку на 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

typeСкопировать ссылку на KbqFlagShadow

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

type KbqFlagShadow = 'inset' | 'none';

KbqFlagShape

typeСкопировать ссылку на KbqFlagShape

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

type KbqFlagShape = 'rectangle' | 'square' | 'circle';
Предложения по улучшению
Если вы нашли ошибку или хотите доработать статью, создайте запрос на GitHub.