---
title: "PageAnchors"
description: "Список якорных ссылок на странице: иконка в рамке и подпись."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/page-anchors"
---
# PageAnchors

> Список якорных ссылок на странице: иконка в рамке и подпись.

## Использование

Компонент PageAnchors выводит список ссылок: на разделы документации, внешние ресурсы, релизы. Текущая ссылка выделена, у ссылки в новой вкладке — значок.

```vue
<script setup lang="ts">
import type { PageAnchor } from '@bxshefby/b24ui-nuxt'

const links = ref<PageAnchor[]>([
  {
    label: "Документация",
    icon: "i-bx24-outline-file",
    to: "/docs/getting-started/"
  },
  {
    label: "Компоненты",
    icon: "i-bx24-outline-folder",
    to: "/docs/components/"
  },
  {
    label: "Шаблоны",
    icon: "i-bx24-outline-screen",
    to: "https://github.com/bx-shef/b24-ui/tree/main/playgrounds",
    target: "_blank"
  },
  {
    label: "Релизы",
    icon: "i-bx24-outline-tag",
    to: "https://github.com/bx-shef/b24-ui/releases",
    target: "_blank"
  }
])
</script>

<template>
  <B24PageAnchors :links="links" />
</template>
```

### Ссылки

Пропс `links` — массив объектов со свойствами:

- `label: string`
- `icon?: IconProp`
- `class?: any`
- `b24ui?: { item?: ClassNameValue, link?: ClassNameValue, linkLabel?: ClassNameValue, linkLabelExternalIcon?: ClassNameValue, linkLeading?: ClassNameValue, linkLeadingIcon?: ClassNameValue }`

Можно передать любое свойство компонента [Link](https://b24-ui.bx-shef.by/raw/docs/components/link.md#props), например `to`, `target` и другие.

```vue
<script setup lang="ts">
import type { PageAnchor } from '@bxshefby/b24ui-nuxt'

const links = ref<PageAnchor[]>([
  {
    label: "Документация",
    icon: "i-bx24-outline-file",
    to: "/docs/getting-started/"
  },
  {
    label: "Компоненты",
    icon: "i-bx24-outline-folder",
    to: "/docs/components/"
  },
  {
    label: "Шаблоны",
    icon: "i-bx24-outline-screen",
    to: "https://github.com/bx-shef/b24-ui/tree/main/playgrounds",
    target: "_blank"
  },
  {
    label: "Релизы",
    icon: "i-bx24-outline-tag",
    to: "https://github.com/bx-shef/b24-ui/releases",
    target: "_blank"
  }
])
</script>

<template>
  <B24PageAnchors :links="links" />
</template>
```

> [!TIP]
> `icon` — компонент иконки или имя Iconify из набора `bx24`, например `'i-bx24-outline-file'`.

## Примеры

### В раскладке

PageAnchors внутри [PageAside](https://b24-ui.bx-shef.by/raw/docs/components/page-aside.md) выводит ссылки над навигацией по разделам ([NavigationMenu](https://b24-ui.bx-shef.by/raw/docs/components/navigation-menu.md)).

```vue [layouts/docs.vue]
<script setup lang="ts">
import type { NavigationMenuItem, PageAnchor } from '@bxshefby/b24ui-nuxt'

const navigation: NavigationMenuItem[] = [{
  label: 'Начало работы',
  to: '/docs/getting-started'
}, {
  label: 'Компоненты',
  to: '/docs/components'
}]

const links: PageAnchor[] = [{
  label: 'Документация',
  icon: 'i-bx24-outline-file',
  to: '/docs/getting-started'
}, {
  label: 'Компоненты',
  icon: 'i-bx24-outline-folder',
  to: '/docs/components'
}, {
  label: 'Шаблоны',
  icon: 'i-bx24-outline-screen',
  to: 'https://github.com/bx-shef/b24-ui/tree/main/playgrounds',
  target: '_blank'
}, {
  label: 'Релизы',
  icon: 'i-bx24-outline-tag',
  to: 'https://github.com/bx-shef/b24-ui/releases',
  target: '_blank'
}]
</script>

<template>
  <B24Page>
    <template #left>
      <B24PageAside>
        <B24PageAnchors :links="links" />

        <B24Separator type="dashed" />

        <B24NavigationMenu :items="navigation" orientation="vertical" />
      </B24PageAside>
    </template>

    <slot />
  </B24Page>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the PageAnchors component
 */
interface PageAnchorsProps {
  /**
   * The element or component this component should render as.
   * @default 'nav'
   */
  as?: any;
  links?: T[] | undefined;
  b24ui?: { root?: SlotClass; list?: SlotClass; item?: SlotClass; link?: SlotClass; linkLeading?: SlotClass; linkLeadingIcon?: SlotClass; linkLabel?: SlotClass; linkLabelExternalIcon?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the PageAnchors component
 */
interface PageAnchorsSlots {
  link(): any;
  link-leading(): any;
  link-label(): any;
  link-trailing(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    pageAnchors: {
      slots: {
        root: '',
        list: '',
        item: 'relative',
        link: 'group text-(length:--ui-font-size-md) flex items-center gap-1.5 py-1 rounded-sm outline-(--ui-color-design-outline-focused-stroke) focus-visible:outline-2',
        linkLeading: 'rounded-md p-1 inline-flex ring-inset ring',
        linkLeadingIcon: 'size-4 shrink-0',
        linkLabel: 'truncate',
        linkLabelExternalIcon: 'size-3 absolute top-0 text-(--ui-color-design-plain-content-icon-secondary)'
      },
      variants: {
        active: {
          true: {
            link: 'text-(--ui-color-accent-main-primary-alt-2) font-(--ui-font-weight-semi-bold)',
            linkLeading: 'bg-(--ui-color-design-filled-bg) ring-(--ui-color-design-filled-stroke) text-(--ui-color-design-filled-content)'
          },
          false: {
            link: 'text-(--ui-color-design-plain-na-content) hover:text-(--ui-color-design-outline-content) font-(--ui-font-weight-medium) transition-colors',
            linkLeading: 'bg-(--ui-color-design-tinted-na-bg) ring-(--ui-color-design-tinted-na-stroke) text-(--ui-color-design-plain-content-icon-secondary) group-hover:bg-(--ui-color-design-filled-bg) group-hover:ring-(--ui-color-design-filled-stroke) group-hover:text-(--ui-color-design-filled-content) transition'
          }
        }
      }
    }
  }
})
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
