# API of `@koobiq/components/flag`

Documented on [Flag](https://koobiq.io/en/components/flag.md). NgModule: `KbqFlagModule`.

## Components

### KbqFlag (component)

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.

```html
<kbq-flag decorative><img src="…/AL.svg" alt="" /></kbq-flag> Albania
```

```ts
@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>();
}
```

- `[shape]`: `KbqFlagShape` — 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'`.
- `[aspectRatio]`: `string` — 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.
- `[shadow]`: `KbqFlagShadow` — Inset hairline that keeps the flag distinct from the background. Its color adapts to the theme.
  Defaults to `'inset'`.
- `[empty]`: `boolean` — Renders a neutral placeholder — use when no flag can be shown (unknown / invalid country code).
- `[svg]`: `SafeHtml | 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.
- `[decorative]`: `boolean` — Marks the flag as decorative — hidden from screen readers (use when adjacent text is present).
- `[label]`: `string` — 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.

## Types

### KbqFlagShadow (type)

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

```ts
type KbqFlagShadow = 'inset' | 'none';
```

### KbqFlagShape (type)

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

```ts
type KbqFlagShape = 'rectangle' | 'square' | 'circle';
```
