Skip to content

Charset

Charset renders a <meta charset> tag for the current document. It is responsible only for serializing the configured character encoding and defaults to utf-8 when no prop is provided.

proptypedefaultrequireddescription
charsetstring"utf-8"NoCharacter encoding used in the rendered meta tag.

Input:

<Charset charset="iso-8859-1" />

Output:

<meta charset="iso-8859-1" />

Uses the integration headTags.appleItunesApp value when no prop is provided, which defaults to utf-8.

Input:

<Charset />

Output:

<meta charset="utf-8" />

Input:

<Charset charset="utf-8" />

Output:

<meta charset="utf-8" />

Charset defaults to utf-8 when no prop is provided. This matches the standard encoding used by modern HTML documents and reduces the need for boilerplate in the common case.

The component always renders a <meta charset> tag because it has a built-in default value. This avoids conditional behavior and guarantees that a document charset is emitted whenever the component is used.

The charset prop is typed as a simple string because the component only needs to serialize the supplied encoding value. Validation of whether a given charset is appropriate is left to the consumer and the browser.