Skip to content

Anchor ​

A navigation component that tracks scroll position and highlights the current section. Supports smooth scrolling, nested items, horizontal mode, and animated indicators.

Basic ​

The anchor tracks which section is visible and highlights the corresponding link. Click a link to smooth-scroll to its section.

Getting Started
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Installation
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Configuration
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Advanced Usage
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
vue
<script setup>
import { ref } from 'vue'
import { VxAnchor } from 'veloxui'

const items = [
  { href: '#getting-started', title: 'Getting Started' },
  { href: '#installation', title: 'Installation' },
  { href: '#configuration', title: 'Configuration' },
  { href: '#advanced', title: 'Advanced Usage' },
]
</script>

<template>
  <VxAnchor :items="items" />
</template>

Nested Items ​

Use children for sub-sections. Nested links are indented automatically.

npm
npm install veloxui
yarn
yarn add veloxui
vue
<VxAnchor :items="[
  { href: '#intro', title: 'Introduction' },
  { href: '#install', title: 'Installation', children: [
    { href: '#npm', title: 'npm' },
    { href: '#yarn', title: 'yarn' },
  ]},
  { href: '#config', title: 'Configuration' },
]" />

Marker Styles ​

Choose between line (default), dot, or none.

vue
<VxAnchor :items="items" marker="line" />
<VxAnchor :items="items" marker="dot" />
<VxAnchor :items="items" marker="none" />

Horizontal ​

Set direction="horizontal" for a horizontal anchor bar.

Overview
Section content goes here.
Features
Section content goes here.
Pricing
Section content goes here.
FAQ
Section content goes here.
vue
<VxAnchor :items="items" direction="horizontal" />

Horizontal Dot ​

vue
<VxAnchor :items="items" direction="horizontal" marker="dot" />

Disabled Items ​

Individual items can be disabled.

vue
<VxAnchor :items="[
  { href: '#a', title: 'Available' },
  { href: '#b', title: 'Locked', disabled: true },
]" />

Hash Change ​

By default, clicking a link updates the URL hash. Disable with :hash-change="false".

vue
<!-- URL hash stays unchanged -->
<VxAnchor :items="items" :hash-change="false" />

Custom Target ​

Scope scroll tracking to a specific container by passing a CSS selector or HTMLElement.

vue
<div id="scroll-area" style="height: 400px; overflow: auto;">
  <VxAnchor :items="items" target="#scroll-area" />
  <div id="section-1">...</div>
  <div id="section-2">...</div>
</div>

Custom Classes ​

Override styling with root-class, item-class, active-class, and indicator-class.

vue
<VxAnchor
  :items="items"
  root-class="my-anchor"
  item-class="my-link"
  active-class="my-active"
  indicator-class="my-indicator"
/>

Custom Item Slot ​

Use the #item slot for custom rendering. Receives item and active.

vue
<VxAnchor :items="items">
  <template #item="{ item, active }">
    <span :style="{ fontWeight: active ? 700 : 400 }">
      {{ active ? '> ' : '' }}{{ item.title }}
    </span>
  </template>
</VxAnchor>

With Affix ​

Wrap with VxAffix to make the anchor sticky while scrolling.

vue
<VxAffix :offset="80" shadow>
  <VxAnchor :items="items" :offset="80" />
</VxAffix>

API ​

VxAnchor Props ​

PropTypeDefaultDescription
itemsAnchorItem[][]Anchor link definitions
v-modelstring—Active href
offsetnumber0Scroll offset from top (px)
direction'vertical' | 'horizontal''vertical'Layout direction
marker'line' | 'dot' | 'none''line'Active indicator style
targetstring | HTMLElementwindowScroll container
smoothbooleantrueSmooth scroll animation
hash-changebooleantrueUpdate URL hash on click
indentnumber16Nested item indentation (px)
root-classstring | string[] | object—Class on root element
item-classstring | string[] | object—Class on every link
active-classstring | string[] | object—Class on active link
indicator-classstring | string[] | object—Class on the indicator

AnchorItem ​

PropertyTypeRequiredDescription
hrefstringYesTarget section id (e.g. #section)
titlestringYesDisplay text
childrenAnchorItem[]NoNested sub-links
disabledbooleanNoDisable this link

Events ​

EventPayloadDescription
update:modelValuestringActive href changed
changestringActive section changed
click(item, event)Link clicked

Slots ​

SlotPropsDescription
item{ item: AnchorItem, active: boolean }Custom link content

Exposed ​

NameTypeDescription
scrollTo(href)functionScroll to a section programmatically
activeHrefRef<string>Current active href