Playground

Heading

A heading whose level (for structure) is separate from its size (for looks).

  • Built on native elements
  • Renders a real h1 to h6; choose the level for the outline, not the size.
  • Styles in one file: heading.css

Import

import '@monoline/css';
import {Heading} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add heading

Usage

import {Heading} from '@monoline/react';

<div style={{display: 'grid', gap: 'var(--s3)'}}>
  <Heading level={1}>Display</Heading>
  <Heading level={2}>Section</Heading>
  <Heading level={3}>Subsection</Heading>
  <Heading level={2} size="sm">An h2 that looks small</Heading>
</div>

Examples

Levels

Props

HeadingProps

PropTypeDefaultDescription
level1 | 2 | 3 | 4 | 5 | 62Document outline level, 1 to 6.
size"sm" | "md" | "lg" | "display" | "xl"–Look. Defaults follow the level. `display` uses the display font.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.headingheading.css
.heading-displayheading.css
.heading-lgheading.css
.heading-mdheading.css
.heading-smheading.css
.heading-xlheading.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.heading {
  border-color: var(--accent);
}

Accessibility

  • Renders a real h1 to h6; choose the level for the outline, not the size.