DlHeading

Divide content with section headings

The DlHeading block component renders a section heading with an optional descriptive paragraph. It supports h1 or h2 levels and offers a spacing toggle for layout rhythm.

Features

  • 🏷️ semantic headings (h1, h2)
  • 📝 optional description under the title
  • 🧩 theme-friendly visual adjustments
  • 📐 optional extra top spacing for section separation

Usage

Use ::dl-heading as a block component with content through the title and description named slots. Choose the heading level as needed.

::dl-heading#titleGetting Started#descriptionKick off your project with sensible defaults and a streamlined setup.::

Result:

As h1 heading level

Having accessibility in mind you can decide which HTML heading level to use by setting the headingLevel prop. We assume that Hero components are usually h1 and section headings are h2 by default. U can use h3 as well.

::dl-heading{heading-level="h1"}#titleDocumentation Overview#descriptionHigh-level guide to the documentation structure and conventions.::

Result:

With extra top spacing

Enable spaced to add extra top margin for improved section separation.

::dl-heading{spaced=true}#titleNext Steps#descriptionWhere to go from here.::

Result:

Props

Here are the properties you can use with the DlHeading component. Each property should be set on an individual component instance; they do not affect the global configuration. More about defining properties in MDC components you can read here.

nametypedefaultdescription
lazybooleanundefined

Whether to lazy load the component.

headingLevel'h1' | 'h2' | 'h3''h2'

HTML heading level to render.

spacedboolean | stringfalse

Adds extra top spacing to the component. Accepts boolean or 'true' string.

Slots

namedescription
title

Heading content. Use plain text or Markdown.

description

Optional paragraph under the title.

ui

Dedicated slot for defining the component’s ui object. More about styling MDC components you can read here.

Styling

Styling from Markdown

Every DocLayer component can be styled directly within your Markdown file using dedicated slot/property configuration. This allows you to customize the appearance of the component's markup elements without modifying global styles. More about components styling you can read here.

Below you'll find the default set of Tailwind classes for the component's dedicated markup elements.

<script lang="ts">const ui = defineDoclayerComponentUi({  base: ['u-space-mt', 'u-space-py', 'text-center'],  title: ['uc-heading-size', 'u-text-weight-black', 'u-text-color'],  description: ['u-text-weight-default', 'u-space-my/2!'],});</script>

CSS Variables

Here is a set of CSS variables you can use to customize the appearance of the DlHeading component globally. More about theming and styling with CSS variables, you can read here.

@theme {  --app-lead-heading-size: 2.5rem;  --app-lead-heading-size-mobile: 2rem;  --app-lead-heading-line-height: 2.8rem;  --app-lead-heading-line-height-mobile: 2.5rem;}

CSS Utilities

Below are the CSS utility classes used by the DlHeading component. They make use of the CSS variables described above and define the default styling for the component's markup elements.

@utility uc-heading-size {  @apply text-(length:--app-lead-heading-size-mobile)! md:text-(length:--app-lead-heading-size)!         leading-(--app-lead-heading-line-height-mobile)! md:leading-(--app-lead-heading-line-height)!;}