`) based on the user's scroll position.
```ts
activeTocLi: HTMLLIElement | null = null
```
--------------------------------
### Heading Selector Configuration
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
A CSS selector string used to identify which headings should be included in the ToC. The default selector targets `h2`, `h3`, and `h4` elements, excluding those with the `toc-exclude` class.
```ts
headingSelector: string = `:is(h2, h3, h4):not(.toc-exclude)`
```
--------------------------------
### Customizing Individual ToC Items
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
This Svelte code illustrates how to use the `toc-item` slot to customize the rendering of individual headings within the Table of Contents. It provides access to the heading's DOM node and its index in the list, allowing for custom formatting like adding numbering.
```svelte
{idx + 1}. {heading.innerText}
```
--------------------------------
### Aside Element Reference
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
Prop to reference the outer-most `aside` element, which typically receives the `toc` class. This prop is for external access and cannot be set directly.
```ts
aside: HTMLElement | undefined = undefined
```
--------------------------------
### Customizing Active TOC Item Appearance
Source: https://github.com/janosh/svelte-toc/blob/main/src/routes/(demos)/left-border-active-li/+page.md
This Svelte component demonstrates how to customize the active table of contents (TOC) item using CSS variables. It applies a solid cornflowerblue left border, sets the border width, and removes the background color for the active item, while maintaining a grid layout for the main content and the TOC.
```svelte
Hello
Lorem ipsum dolor sit amet consectetur
World
adipisicing elit. Recusandae eos, molestias cumque adipisci
More
veniam totam vitae illo voluptatem assumenda magni consequuntur!
Headings
asperiores ab laboriosam quod est odit accusamus, reiciendis eum
```
--------------------------------
### Conditional Rendering and Auto-Hiding
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
The `hide` prop controls the rendering of the ToC component itself. `autoHide` automatically hides the ToC when no headings are found and un-hides it when headings reappear.
```ts
hide: boolean = false
autoHide: boolean = true
```
--------------------------------
### Heading Level Extraction Function
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
A function that determines the depth (1-6) of a heading, used for indentation and font-size in the ToC. It extracts the level number from the heading's node name (e.g., 'H2' -> 2).
```ts
getHeadingLevels = (node: HTMLHeadingElement): number => Number(node.nodeName[1]) // get the number from H1, H2, ...
```
--------------------------------
### Customizing Scroll Behavior for Headings
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
This CSS snippet demonstrates how to set the `scroll-margin-top` property for headings. This ensures that when a user clicks on a ToC item, the corresponding heading is scrolled into view with a specified offset from the top of the viewport, improving readability.
```css
/* replace next line with appropriate CSS selector for all your headings */
:where(h1, h2, h3, h4) {
scroll-margin-top: 50px;
}
```
--------------------------------
### Keep Active ToC Item in View
Source: https://github.com/janosh/svelte-toc/blob/main/readme.md
When enabled, this prop ensures the currently active ToC item remains visible within the ToC container, even for long ToCs. It relies on the `scrollend` event for functionality.
```ts
keepActiveTocItemInView: boolean = true
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.