# Animated TOC

> Table of contents with an SVG rail that snakes through nesting levels and a dot that glides along the curve to the active entry.

<demo-animated-toc>



</demo-animated-toc>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/animated-toc.json"
```

## Usage

```vue
<script setup lang="ts">
  import AnimatedToc from '~/components/ui/animated-toc/AnimatedToc.vue';

  const items = [
    { label: 'Introduction', depth: 0, href: '#introduction' },
    { label: 'Core Concepts', depth: 0, href: '#core-concepts' },
    { label: 'Architecture', depth: 1, href: '#architecture' },
    { label: 'Components', depth: 0, href: '#components' },
  ];
</script>

<template>
  <AnimatedToc v-model="activeIndex" :items="items" />
</template>
```

The rail is a single SVG path with rounded S-bends wherever the nesting
depth changes. Clicking an entry spring-glides the dot along the curve
(measured via `getPointAtLength`), while a second stroke darkens the
traveled portion of the path. `v-model` tracks the active index — drive it
from an `IntersectionObserver` to sync with real page headings.

## Props

<table>
<thead>
  <tr>
    <th>
      Prop
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        items
      </code>
    </td>
    
    <td>
      <code>
        AnimatedTocItem[]
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      Entries (<code>
        label
      </code>
      
      , <code>
        depth
      </code>
      
      , <code>
        href
      </code>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        v-model
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Active entry index
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        row-height
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        48
      </code>
    </td>
    
    <td>
      Row height in px
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        indent
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        24
      </code>
    </td>
    
    <td>
      Indent per depth level in px
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        title
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'On this page'
      </code>
    </td>
    
    <td>
      Heading (empty string hides it)
    </td>
  </tr>
</tbody>
</table>

## Events

<table>
<thead>
  <tr>
    <th>
      Event
    </th>
    
    <th>
      Payload
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        select
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Fired on entry activation
    </td>
  </tr>
</tbody>
</table>
