logo
Examples / Linked Headings

Linked Headings

Toggle between rendering modes to see how to add clickable anchor links to headings. Hover over headings in the snippet and renderer modes to reveal the link.

Default Headings

Plain headings with id attributes but no visible anchor links. Users can't easily copy a link to a specific section.

Preview

Linked Headings Demo

Getting Started

Headings rendered by svelte-markdown include id attributes by default, but they don't have clickable anchor links. This example shows two ways to add them.

Installation

Install the package with your preferred package manager:

pnpm add @humanspeak/svelte-markdown

Configuration

Configure the component with your markdown source and any options you need.

Basic Usage

Import and use the component in your Svelte file.

Advanced Topics

Custom Slug Functions

You can provide a custom slug function for full control over heading IDs.

Nested Heading Example

This is a deeply nested heading to show all levels work correctly.