---
title: "Progress"
description: "Индикатор выполнения, показывающий, насколько завершена задача."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/progress"
---
# Progress

> Индикатор выполнения, показывающий, насколько завершена задача.

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

Директива `v-model` управляет значением Progress.

```vue
<script setup lang="ts">
const value = ref(24)
</script>

<template>
  <B24Progress v-model="value" />
</template>
```

> [!NOTE]
> Компонент [`ProgressGroup`](https://b24-ui.bx-shef.by/raw/docs/components/progress-group.md) делит одну полосу на несколько сегментов, которые в сумме дают общее значение.

### Максимум

Пропс `max` задаёт максимальное значение Progress.

```vue
<script setup lang="ts">
const value = ref(2)
</script>

<template>
  <B24Progress v-model="value" :max="4" />
</template>
```

Если передать в `max` массив строк, под полосой показывается активный шаг, а максимальное значение равно длине массива.

```vue
<script setup lang="ts">
const value = ref(3)
</script>

<template>
  <B24Progress v-model="value" :max="{'0':'Поиск клиентов...','1':'Квалификация...','2':'Презентация...','3':'Переговоры...','4':'Сделка закрыта!'}" />
</template>
```

### Статус

Пропс `status` показывает текущее значение Progress над полосой.

```vue
<script setup lang="ts">
const value = ref(24)
</script>

<template>
  <B24Progress v-model="value" status />
</template>
```

> [!TIP]
> Статус следует за концом полосы; чтобы растянуть его на всю ширину, используйте `:b24ui="{ status: 'w-full' }"`.

### Неопределённое состояние

Когда `v-model` не задан или значение равно `null`, Progress переходит в *неопределённое состояние*: полоса анимируется как `loading`; анимацию можно сменить пропсом [`animation`](#animation).

```vue
<script setup lang="ts">
const value = ref(null)
</script>

<template>
  <B24Progress v-model="value" />
</template>
```

> [!TIP]
> Если пользователь предпочитает уменьшенное движение, анимация отключается, и полоса неопределённого состояния показывается как пульсация на всю ширину.

### Анимация

Пропс `animation` меняет анимацию Progress на обратную карусель, качающуюся полосу или упругую полосу. По умолчанию `loading`.

```vue
<template>
  <B24Progress animation="swing" />
</template>
```

### Ориентация

Пропс `orientation` меняет ориентацию Progress. По умолчанию `horizontal`.

```vue
<template>
  <B24Progress orientation="vertical" class="h-48 justify-center" />
</template>
```

### Цвет

Пропс `color` меняет цвет Progress.

```vue
<template>
  <B24Progress color="air-primary-copilot" />
</template>
```

### Размер

Пропс `size` меняет размер Progress.

```vue
<template>
  <B24Progress size="lg" />
</template>
```

### Инверсия

Пропс `inverted` визуально инвертирует Progress.

```vue
<template>
  <B24Progress inverted v-model="value" />
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the Progress component
 */
interface ProgressProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * The maximum progress value
   */
  max?: number | any[] | undefined;
  /**
   * Display the current progress value
   */
  status?: boolean | undefined;
  /**
   * Whether the progress is visually inverted
   * @default false
   */
  inverted?: boolean | undefined;
  /**
   * @default 'md'
   */
  size?: "xs" | "sm" | "md" | "lg" | undefined;
  /**
   * @default 'air-primary'
   */
  color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary";
  /**
   * The orientation of the progress bar.
   * @default 'horizontal'
   */
  orientation?: "horizontal" | "vertical" | undefined;
  /**
   * @default 'loading'
   */
  animation?: "carousel" | "loading" | "carousel-inverse" | "swing" | "elastic" | undefined;
  b24ui?: { root?: SlotClass; base?: SlotClass; indicator?: SlotClass; status?: SlotClass; steps?: SlotClass; step?: SlotClass; } | undefined;
  /**
   * A function to get the accessible label text in a human-readable format.
   * 
   *  If not provided, the value label will be read as the numeric value as a percentage of the max value.
   */
  getValueLabel?: (value: number | null | undefined, max: number): string | undefined | undefined;
  /**
   * A function to get the accessible value text representing the current value in a human-readable format.
   */
  getValueText?: (value: number | null | undefined, max: number): string | undefined | undefined;
  /**
   * The progress value. Can be bind as `v-model`.
   * @default null
   */
  modelValue?: null | number | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the Progress component
 */
interface ProgressSlots {
  status(): any;
}
```

### События

```ts
/**
 * Emitted events for the Progress component
 */
interface ProgressEmits {
  update:modelValue: (payload: [value: string[] | undefined]) => void;
  update:max: (payload: [value: number]) => void;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    progress: {
      slots: {
        root: 'gap-2',
        base: 'relative overflow-hidden rounded-(--ui-border-radius-pill) bg-(--ui-color-base-5)',
        indicator: 'rounded-(--ui-border-radius-pill) size-full transition-transform duration-200 ease-out motion-reduce:transition-none motion-reduce:data-[state=indeterminate]:animate-pulse bg-(--b24ui-background)',
        status: 'flex justify-end text-legend duration-200 ease-out motion-reduce:transition-none',
        steps: 'grid items-end text-legend',
        step: 'truncate text-end row-start-1 col-start-1 transition-opacity ease-out'
      },
      variants: {
        animation: {
          loading: '',
          carousel: '',
          'carousel-inverse': '',
          swing: '',
          elastic: ''
        },
        color: {
          'air-primary': {
            root: 'style-filled'
          },
          'air-primary-success': {
            root: 'style-filled-success'
          },
          'air-primary-alert': {
            root: 'style-filled-alert'
          },
          'air-primary-copilot': {
            root: 'style-filled-copilot'
          },
          'air-primary-warning': {
            root: 'style-filled-warning'
          },
          'air-secondary': {
            root: 'style-tinted'
          },
          default: {
            root: 'style-old-default'
          },
          danger: {
            root: 'style-old-danger'
          },
          success: {
            root: 'style-old-success'
          },
          warning: {
            root: 'style-old-warning'
          },
          primary: {
            root: 'style-old-primary'
          },
          secondary: {
            root: 'style-old-secondary'
          },
          collab: {
            root: 'style-old-collab'
          },
          ai: {
            root: 'style-old-ai'
          }
        },
        size: {
          xs: {
            status: 'text-(length:--ui-font-size-xs)/(--ui-font-line-height-sm)',
            steps: 'text-(length:--ui-font-size-xs)/(--ui-font-line-height-sm)'
          },
          sm: {
            status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
            steps: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)'
          },
          md: {
            status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
            steps: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)'
          },
          lg: {
            status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
            steps: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)'
          }
        },
        step: {
          active: {
            step: 'opacity-100'
          },
          first: {
            step: 'opacity-100 text-legend'
          },
          other: {
            step: 'opacity-0'
          },
          last: {
            step: ''
          }
        },
        orientation: {
          horizontal: {
            root: 'w-full flex flex-col',
            base: 'w-full',
            status: 'flex-row w-(--percent) transition-[width]'
          },
          vertical: {
            root: 'h-full flex flex-row-reverse',
            base: 'h-full',
            status: 'flex-col min-w-[32px] h-(--percent) transition-[height]'
          }
        },
        inverted: {
          true: {
            status: 'self-end'
          }
        }
      },
      compoundVariants: [
        {
          inverted: true,
          orientation: 'horizontal',
          class: {
            step: 'text-start',
            status: 'flex-row-reverse'
          }
        },
        {
          inverted: true,
          orientation: 'vertical',
          class: {
            steps: 'items-start',
            status: 'flex-col-reverse'
          }
        },
        {
          orientation: 'horizontal',
          size: 'xs',
          class: 'h-[2px]'
        },
        {
          orientation: 'horizontal',
          size: 'sm',
          class: 'h-[4px]'
        },
        {
          orientation: 'horizontal',
          size: 'md',
          class: 'h-2'
        },
        {
          orientation: 'horizontal',
          size: 'lg',
          class: 'h-[12px]'
        },
        {
          orientation: 'vertical',
          size: 'xs',
          class: 'w-[2px]'
        },
        {
          orientation: 'vertical',
          size: 'sm',
          class: 'w-[4px]'
        },
        {
          orientation: 'vertical',
          size: 'md',
          class: 'w-2'
        },
        {
          orientation: 'vertical',
          size: 'lg',
          class: 'w-[12px]'
        },
        {
          orientation: 'horizontal',
          animation: 'carousel',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel_2s_linear_infinite] motion-safe:data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_linear_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'carousel',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-vertical_2s_linear_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'carousel-inverse',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-inverse_2s_linear_infinite] motion-safe:data-[state=indeterminate]:rtl:animate-[carousel-inverse-rtl_2s_linear_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'carousel-inverse',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-inverse-vertical_2s_linear_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'swing',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[swing_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'swing',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[swing-vertical_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'elastic',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[elastic_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'elastic',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[elastic-vertical_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'loading',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[progressbar-loading_2s_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'loading',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[progressbar-loading-vertical_2s_infinite]'
          }
        }
      ],
      defaultVariants: {
        color: 'air-primary',
        animation: 'loading',
        size: 'md'
      }
    }
  }
})
```

## Sitemap

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