Heading
A heading whose level (for structure) is separate from its size (for looks).
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
level | 1 | 2 | 3 | 4 | 5 | 6 | 2 | Document 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
| Class | Stylesheet |
|---|---|
.heading | heading.css |
.heading-display | heading.css |
.heading-lg | heading.css |
.heading-md | heading.css |
.heading-sm | heading.css |
.heading-xl | heading.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.