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.
| prop | type | default | required | description |
|---|---|---|---|---|
charset | string | "utf-8" | No | Character encoding used in the rendered meta tag. |
Examples
Section titled “Examples”Input:
<Charset charset="iso-8859-1" />Output:
<meta charset="iso-8859-1" />Automatic
Section titled “Automatic”Uses the integration headTags.appleItunesApp value when no prop is provided, which defaults to utf-8.
Input:
<Charset />Output:
<meta charset="utf-8" />Complete
Section titled “Complete”Input:
<Charset charset="utf-8" />Output:
<meta charset="utf-8" />Decisions Made
Section titled “Decisions Made”Utf-8 is the default
Section titled “Utf-8 is the default”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
Section titled “The component always renders”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.
Charset stays as a plain string prop
Section titled “Charset stays as a plain string prop”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.