---
title: "PageHeader"
description: "Адаптивная шапка страницы."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/page-header"
---
# PageHeader

> Адаптивная шапка страницы.

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

Компонент PageHeader показывает шапку страницы.

Используйте его в слоте по умолчанию компонента [Page](https://b24-ui.bx-shef.by/raw/docs/components/page.md) перед компонентом [PageBody](https://b24-ui.bx-shef.by/raw/docs/components/page-body.md):

```vue
<template>
  <B24Page>
    <B24PageHeader />

    <B24PageBody />
  </B24Page>
</template>
```

### Заголовок

Пропс `title` показывает заголовок в шапке.

```vue
<template>
  <B24PageHeader title="PageHeader" />
</template>
```

> [!TIP]
> Заголовок по умолчанию отрисовывается как `h1`. Чтобы изменить тег, передайте в пропс `as` объект, например `:as="{ title: 'h2' }"`. Корневой элемент задаётся так же: `:as="{ root: 'section', title: 'h2' }"`.

### Описание

Пропс `description` показывает описание в шапке.

```vue
<template>
  <B24PageHeader title="PageHeader" description="Адаптивная шапка страницы с заголовком, описанием и действиями." />
</template>
```

### Надзаголовок

Пропс `headline` показывает надзаголовок в шапке.

```vue
<template>
  <B24PageHeader title="PageHeader" description="Адаптивная шапка страницы с заголовком, описанием и действиями." headline="Компоненты" />
</template>
```

### Ссылки

Пропс `links` показывает в шапке список кнопок [Button](https://b24-ui.bx-shef.by/raw/docs/components/button.md).

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

const links = ref<ButtonProps[]>([
  {
    label: 'GitHub',
    to: 'https://github.com/bitrix24/b24ui/blob/main/src/runtime/components/PageHeader.vue',
    target: '_blank'
  }
])
</script>

<template>
  <B24PageHeader title="PageHeader" description="Адаптивная шапка страницы с заголовком, описанием и действиями." headline="Компоненты" :links="links" />
</template>
```

## Примеры

> [!NOTE]
> В примерах используется [Nuxt Content](https://content.nuxt.com), но компоненты можно подключить к любой системе управления контентом.

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

Используйте PageHeader на странице, чтобы показать её шапку:

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

definePageMeta({
  layout: 'docs'
})

const { data: page } = await useAsyncData(route.path, () => {
  return queryCollection('docs').path(route.path).first()
})

const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
  return queryCollectionItemSurroundings('content', route.path)
})
</script>

<template>
  <B24Page>
    <B24PageHeader
      :title="page.title"
      :description="page.description"
      :headline="page.headline"
      :links="page.links"
    />

    <B24PageBody>
      <ContentRenderer :value="page" />

      <B24Separator />

      <B24ContentSurround :surround="surround" />
    </B24PageBody>

    <template #right>
      <B24ContentToc :links="page.body.toc.links" />
    </template>
  </B24Page>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the PageHeader component
 */
interface PageHeaderProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  headline?: string | undefined;
  title?: string | undefined;
  description?: string | undefined;
  /**
   * Display a list of Button next to the title.
   * `{ color: 'air-secondary-accent', size: 'sm' }`
   */
  links?: ButtonProps[] | undefined;
  b24ui?: { root?: SlotClass; container?: SlotClass; wrapper?: SlotClass; headline?: SlotClass; title?: SlotClass; description?: SlotClass; links?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the PageHeader component
 */
interface PageHeaderSlots {
  headline(): any;
  title(): any;
  description(): any;
  links(): any;
  default(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    pageHeader: {
      slots: {
        root: 'relative border-b border-(--ui-color-divider-default) py-8',
        container: '',
        wrapper: 'flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4',
        headline: 'mb-2.5 text-(length:--ui-font-size-sm) font-(--ui-font-weight-semi-bold) text-(--ui-color-accent-main-primary) flex items-center gap-1.5',
        title: 'text-(length:--ui-font-size-3xl) sm:text-(length:--ui-font-size-4xl) text-pretty font-(--ui-font-weight-bold) text-label',
        description: 'text-(length:--ui-font-size-lg) text-pretty text-description',
        links: 'flex flex-wrap items-center gap-1.5'
      },
      variants: {
        title: {
          true: {
            description: 'mt-4'
          }
        }
      }
    }
  }
})
```

## Sitemap

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