Layout
Heading
A title in the type scale of the other components: bolder and two steps larger than body text of the same size. With level it is a real <h1>–<h6>; without it, a <p> that only looks like a heading. It takes the element props, so it can carry an icon, a badge or a suffix.
Nothing to show
An <h2> with "Billing" in large, extra-bold text, in the strong neutral color (white in dark mode). The label is translated.
Sizes and colors #
size moves the heading along the same scale as the other components; variant and color change its color. The last one has an info icon before the text, both in blue.
Nothing to show
A heading with more than text #
The slot takes the place of label, and the badge sits after it, vertically centered on the line.
Nothing to show
Title and text together #
A heading followed by a tk:text gets a small gap under it, without margins of your own.
Nothing to show
A heading you can link to #
The first heading gets id="billing-details", the second id="faq". Hovering a heading, or reaching its link with Tab, shows a # after the text that links to #billing-details; copying it gives a URL that scrolls straight to the section, which stops 6rem below the top of the window so a sticky header does not cover it.
Nothing to show
Without a level #
Without level the heading is a <p> that only looks like a heading, for a title that should not enter the document outline.
Looks like a heading, reads as a paragraph
Nothing to show
Sizes #
size moves the heading along the same scale as the other components, from xs to 3xl.
Heading xs
Heading sm
Heading md
Heading lg
Heading xl
Heading 2xl
Heading 3xl
Nothing to show
Scale #
scale sets how far above body text of the same size the heading is, from smallest to largest (the default).
Smallest
Small
Default
Large
Largest
Nothing to show
Strong and accent #
variant also takes strong, a darker neutral than the default, and accent, the theme accent.
Default
Strong
Accent
Nothing to show
Icons, badges and info #
The element props work on a heading: icon, badge, suffix, and info for a help icon with a tooltip.
Home
Reports
Orders 12 items
Revenue
Nothing to show
Badge from state #
The slot takes the place of label and the badge shows the count of open invoices, updated by the Livewire actions.
Open invoices
Nothing to show
Customization #
Classes go to the heading element; as renders another tag, and the parts take their prefixes (icon:, badge:...).
Billing
Rendered as a spanNothing to show
Reference
tk:heading
| Prop | Type | Default | Description |
|---|---|---|---|
level |
int | null |
The heading level, 1 to 6, rendered as <h1>–<h6>. Without it (or with another value) the tag is a <p>. |
label |
string | slot | null |
The text, translated. The default slot takes its place when it has content. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. |
scale |
string | largest |
How far above body text of the same size it is: smallest, small, default, large or largest. |
variant |
string | dark neutral | The neutral color: by default a dark gray, strong a darker one, subtle muted, accent the accent color, or none for no color class. |
color |
string | null |
A color name (blue, red...). Takes precedence over variant. |
anchor |
bool | string | false |
Gives the heading an id and a # link to it. true makes the id from the text (Str::slug of the translated label or of the slot's text); a string is the id. An id written on the tag wins over both. |
Also accepts the element props (icon, badge, suffix, kbd...) and info (a help icon at the end with this text as its tooltip). as on the tag sets any other element (as="legend").
Slots
| Slot | Description |
|---|---|
| default | The text, in place of label. |
Customization
Classes and attributes on the tag go to the heading element; the parts from the element props take their prefixes (icon:, badge:...).
Nothing to show
With anchor, the link takes the anchor: prefix, and a scroll-mt-* class on the tag replaces the default scroll margin (scroll-mt-24), for a taller or shorter sticky header.
Nothing to show
Accessibility
Only level makes it a heading for assistive technology: without it, the text is read as a paragraph, however large it looks. Choose the level by the document outline, and the look with size and scale.
The anchor link is a real link, reached with Tab and shown while it has keyboard focus. Its accessible name is "Link to this section: " followed by the heading's text (translated), so it is not announced as a bare "#".
Behavior notes
- With no label, no slot content and no other part (icon, badge...), nothing is rendered.
- The heading is as wide as its text (
w-fit), so a background or border on it hugs the text. anchorneeds some text: a heading without label or slot content gets no id and no link. Onlyanchorheadings get the scroll margin.- The scroll margin adds to a
scroll-padding-topthe page may set on<html>for its own sticky header; in that case drop it withclass="scroll-mt-0". - The link goes after the heading's other parts (badge,
append...). It is invisible until hovered or focused, but still takes its space, so the heading does not move when it shows. - Ids made from the text must be unique on the page: two headings with the same text get the same id; give one of them
anchor="...".