[]previous and next page

HeadTag

Describes one head element.

Describes one head element. key identifies a style for replacement; other tags use their own identity (see useHead).

Import#

ts
import type { HeadTag } from "@shadow-js/web";

Signature#

ts
interface HeadTag {
  /** The element to register: `title`, `meta`, `link`, `style` or `base`. Any other name throws. */
  readonly tag: HeadTagName;
  /**
   * The attributes of the element. Names are case-insensitive, must be valid attribute names, and
   * may not start with `on`.
   * @default undefined (the element has no attributes)
   */
  readonly props?: Readonly<Record<string, HeadAttributeValue>>;
  /**
   * The text of a `title` or `style`. Other tags take no text and throw when it is given.
   * @default undefined (no text)
   */
  readonly children?: string;
  /**
   * Identity of a `style`: a later style with the same key replaces an earlier one. Only `style`
   * takes a key.
   * @default undefined (the style has no identity and always stays)
   */
  readonly key?: string;
}

Members#

Name Type Description
tag readonly tag: HeadTagName The element to register: title, meta, link, style or base. Any other name throws.
props? readonly props?: Readonly<Record<string, HeadAttributeValue>> The attributes of the element. Names are case-insensitive, must be valid attribute names, and may not start with on.
children? readonly children?: string The text of a title or style. Other tags take no text and throw when it is given.
key? readonly key?: string Identity of a style: a later style with the same key replaces an earlier one. Only style takes a key.

Examples#

ts
import type { HeadTag } from "@shadow-js/web";

const description: HeadTag = { tag: "meta", props: { name: "description", content: "Docs" } };