Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

Reference · /bind

FlagPropstype

What a binding's flag takes: the same as <hata-flag>'s attributes. Every field but code may be left out.

Import it

import type { FlagProps } from "@johnmorrisdotca/hata/bind";

Also exported from: @johnmorrisdotca/hata/react, @johnmorrisdotca/hata/vue

Definition

interface FlagProps {
    code: string;
    shape?: "own" | "flag" | "4:3" | "1:1" | "round";
    fit?: Fit;
    size?: "small" | "medium" | "large" | number | string;
    width?: number | string;
    label?: string;
    lang?: "en" | "ja";
    border?: boolean;
    shadow?: boolean;
    theme?: "auto" | "light" | "dark";
    date?: string | Date;
    variant?: string;
    which?: FlagRole;
    allowRestricted?: boolean;
}

Members

NameTypeDescription
codestring

The flag's code, in any case: "JP", "jp-13", "CA-ON", "DE-BY".

shape (optional)"flag" | "4:3" | "1:1" | "round" | "own" | undefined

own (the default: its own proportions), 4:3, 1:1 or round, framed as flag(code, { shape }) frames it.

fit (optional)Fit | undefined

How it fits a frame: auto (the default), whole, crop, cover, hoist or contain, as frame() takes them.

size (optional)string | number | undefined

Its height: small, medium or large (24, 48 or 96 pixels), or a number of pixels. Left out, 1em, the height of the text around it.

width (optional)string | number | undefined

A width in pixels, with the height following the flag's proportions; overrides size.

label (optional)string | undefined

What a screen reader says. Left out, the place's name in lang.

lang (optional)"en" | "ja" | undefined

en or ja, the language of the name read out. Left out, English.

border (optional)boolean | undefined

A hairline round the flag, so a white flag shows on a white page.

shadow (optional)boolean | undefined

A soft shadow under it.

theme (optional)"auto" | "light" | "dark" | undefined

auto (the default), light or dark: the colour of the border on a light or a dark page.

date (optional)string | Date | undefined

The day whose flag to draw: "1962-09-29", "1962-09", "1962" or a Date. The variant wins where both are given.

variant (optional)string | undefined

Which of the place's flags in real use to draw, by its id from variantsOf(code): de-facto, stripes, local. Martinique's local is deprecated, an alias of martinique until 2.0.

which (optional)FlagRole | undefined

With date: legal (the default) or in-use. (Not role, which is the ARIA role of the element.)

allowRestricted (optional)boolean | undefined

Draw a flag whose display the law restricts (Germany's of 1935 to 1945), for history and education. Without it nothing is drawn.

Examples

import { preloadFlags, type FlagProps } from "@johnmorrisdotca/hata/bind";

const tokyo: FlagProps = { code: "JP-13", shape: "round", size: "medium", label: "Tokyo" };
await preloadFlags([tokyo]);

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.