---
title: "ContentSurround"
description: "Пара кнопок «Назад» и «Вперёд» для последовательной навигации по страницам."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/content-surround"
---
# ContentSurround

> Пара кнопок «Назад» и «Вперёд» для последовательной навигации по страницам.

> [!WARNING]
> See: /docs/getting-started/integrations/content/
> Компонент доступен, только если установлен модуль `@nuxt/content`.

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

Пропс `surround` принимает значение `surround`, которое возвращается при получении соседних страниц.

```vue [ContentSurroundExample.vue]
<script setup lang="ts">
import { withoutTrailingSlash, withTrailingSlash } from 'ufo'

const route = useRoute()

const { data: surround } = await useAsyncData(`${route.path}-surround`, async () => {
  const surround = await queryCollectionItemSurroundings('docs', withoutTrailingSlash(route.path), {
    fields: ['description']
  })
  if (surround[0]) {
    surround[0].path = withTrailingSlash(surround[0].path)
  }
  if (surround[1]) {
    surround[1].path = withTrailingSlash(surround[1].path)
  }

  return surround
})
</script>

<template>
  <B24ContentSurround :surround="(surround as any)" />
</template>
```

### Назад / Вперёд

Пропсы `prev-icon` и `next-icon` задают [иконки](https://bitrix24.github.io/b24icons/icons/) кнопок.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
import type { ContentSurroundLink } from '@bxshefby/b24ui-nuxt'

const surround = ref<ContentSurroundLink[]>([
  {
    title: 'ContentSearchButton',
    path: '/docs/components/content-search-button/',
    stem: '3.components/content-search-button',
    description: 'Готовая кнопка Button, которая открывает модальное окно ContentSearch.'
  },
  {
    title: 'ContentToc',
    path: '/docs/components/content-toc/',
    stem: '3.components/content-toc',
    description: 'Закреплённое оглавление с настраиваемыми слотами.'
  }
])
</script>

<template>
  <B24ContentSurround :prev-icon="RocketIcon" :next-icon="RocketIcon" :surround="surround" />
</template>
```

## Примеры

### На странице

Компонент ContentSurround на странице показывает ссылки на предыдущую и следующую страницы:

```vue [pages/[...slug].vue]
<script setup lang="ts">
const route = useRoute()

const { data: page } = await useAsyncData(route.path, () => queryCollection('docs').path(route.path).first())
if (!page.value) {
  throw createError({ status: 404, statusText: 'Page not found', fatal: true })
}
</script>

<template>
  <template v-if="page">
    <ProseH1>{{ page.title }}</ProseH1>

    <template v-if="page?.body?.toc?.links?.length">
      <B24ContentToc :links="page.body.toc.links" />
    </template>

    <div>
      <ContentRenderer v-if="page.body" :value="page" />

      <B24Separator v-if="surround?.filter(Boolean).length" class="my-4" />

      <B24ContentSurround :surround="(surround as any)" />
    </div>
  </template>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the ContentSurround component
 */
interface ContentSurroundProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * The icon displayed in the prev link.
   * @default icons.arrowLeft
   */
  prevIcon?: (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Attrs; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed | undefined) => void; }, "expose">): any | undefined;
  /**
   * The icon displayed in the next link.
   * @default icons.arrowRight
   */
  nextIcon?: (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Attrs; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed | undefined) => void; }, "expose">): any | undefined;
  surround?: T[] | undefined;
  b24ui?: { root?: SlotClass; link?: SlotClass; linkLeading?: SlotClass; linkLeadingIcon?: SlotClass; linkTitle?: SlotClass; linkDescription?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the ContentSurround component
 */
interface ContentSurroundSlots {
  link(): any;
  link-leading(): any;
  link-title(): any;
  link-description(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    contentSurround: {
      slots: {
        root: 'grid grid-cols-1 sm:grid-cols-2 gap-[32px]',
        link: 'group block backdrop-blur-md rounded-(--ui-border-radius-md) px-[24px] py-[32px] bg-(--ui-color-design-outline-bg) border border-(--ui-color-design-outline-stroke) border-(length:--ui-design-outline-stroke-weight) cursor-pointer focus-visible:outline-(--ui-color-accent-main-primary) transition-colors',
        linkLeading: 'inline-flex items-center rounded-full select-none mb-[16px] p-[6px] bg-(--ui-color-design-outline-bg) group-hover:bg-[color-mix(in_srgb,_var(--ui-color-design-selection-bg)_100%,_var(--ui-color-bg-state-hover-default-hex)_var(--ui-color-bg-state-hover-default-opacity))] ring-(--ui-color-design-outline-stroke) ring-(length:--ui-design-outline-stroke-weight) group-hover:ring-[color-mix(in_srgb,_var(--ui-color-design-selection-stroke)_100%,_var(--ui-color-bg-state-hover-default-hex)_var(--ui-color-bg-state-hover-default-opacity))] transition',
        linkLeadingIcon: 'size-[20px] shrink-0 text-(--ui-color-design-outline-content-icon) group-hover:text-(--ui-color-design-outline-content-icon-alt) transition-[color,translate] motion-reduce:transition-none',
        linkTitle: 'font-(--ui-font-weight-bold) text-(length:--ui-font-size-lg)/(--ui-font-line-height-lg) text-(--ui-color-design-outline-content) mb-[4px] truncate',
        linkDescription: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm) text-(--ui-color-design-outline-content-secondary) text-pretty line-clamp-2'
      },
      variants: {
        direction: {
          left: {
            linkLeadingIcon: 'group-active:-translate-x-0.5'
          },
          right: {
            link: 'text-end',
            linkLeadingIcon: 'group-active:translate-x-0.5'
          }
        }
      }
    }
  }
})
```

## Sitemap

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