The m3e-heading component provides expressive, accessible headings for pages and sections
npm i @m3e/heading
This section outlines usage examples and configuration guidance for the components in this package.
The m3e-heading supports five variants: display (default), headline,
title, and label. It supports three size variants: large,
medium (default) and small. Use the variant and
size attributes to change the typescale of a heading.
<m3e-heading variant="display" size="large">Display Large</m3e-heading> <m3e-heading variant="display" size="medium">Display Medium</m3e-heading> <m3e-heading variant="display" size="small">Display Small</m3e-heading> <!-- Additional variants omitted for brevity -->
Use the emphasized attribute to control whether a heading's typescale is emphasized.
<m3e-heading variant="display" size="large" emphasized>Display Large</m3e-heading> <m3e-heading variant="display" size="medium" emphasized>Display Medium</m3e-heading> <m3e-heading variant="display" size="small" emphasized>Display Small</m3e-heading> <!-- Additional variants omitted for brevity -->
By default, headings are not given an ARIA role, indicating that they are treated as neutral, non-semantic elements in the accessibility tree unless explicitly referenced or annotated.
Use the level attribute to control whether a heading adopts the ARIA
role="heading" and aria-level attributes. When level is set,
role="heading" is applied and aria-level reflects the attribute's value. Supported
values range from 1 to 6, aligning with semantic heading levels.
This package uses JavaScript Modules. To use it directly in a browser without a bundler, use a module script similar to the following.
<script type="module" src="/node_modules/@m3e/heading/dist/index.js"></script>
In addition, you must use an import map to include dependencies.
<script type="importmap">
{
"imports": {
"lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
"@m3e/core": "/node_modules/@m3e/core/dist/index.js"
}
}
</script>
For production, use index.min.js for faster load times.
This package includes a Custom Elements Manifest (custom-elements.json), which
documents the properties, attributes, slots, events and CSS custom properties of each component.
You can explore the API below, or integrate the manifest into your own tooling.