v2.15.0

Stepper

Компонент пошагового мастера, который показывает прогресс в многошаговом процессе.

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

Stepper показывает список элементов в виде пошагового мастера.

Адрес
Укажите здесь свой адрес
Доставка
Выберите способ доставки
Оформление
Подтвердите заказ
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

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

Элементы

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

  • title?: string
  • description?: string
  • content?: string
  • icon?: IconComponent
  • value?: string | number
  • disabled?: boolean
  • slot?: string
  • class?: any
  • b24ui?: { item?: ClassNameValue, container?: ClassNameValue, trigger?: ClassNameValue, indicator?: ClassNameValue, icon?: ClassNameValue, separator?: ClassNameValue, wrapper?: ClassNameValue, title?: ClassNameValue, description?: ClassNameValue }
Адрес
Укажите здесь свой адрес
Доставка
Выберите способ доставки
Оформление
Подтвердите заказ
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper :items="items" class="w-full" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper :items="items" class="w-full" />
</template>
Щёлкайте по элементам, чтобы переходить между шагами.

Цвет

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

Адрес
Укажите здесь свой адрес
Доставка
Выберите способ доставки
Оформление
Подтвердите заказ
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper color="air-primary-alert" :items="items" class="w-full" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper color="air-primary-alert" :items="items" class="w-full" />
</template>

Размер

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

Адрес
Укажите здесь свой адрес
Доставка
Выберите способ доставки
Оформление
Подтвердите заказ
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper size="xl" :items="items" class="w-full" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper size="xl" :items="items" class="w-full" />
</template>

Ориентация

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

Адрес
Укажите здесь свой адрес
Доставка
Выберите способ доставки
Оформление
Подтвердите заказ
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper orientation="vertical" :items="items" class="w-full" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper orientation="vertical" :items="items" class="w-full" />
</template>

Отключение

Пропс disabled отключает переходы между шагами.

Адрес
Укажите здесь свой адрес
Доставка
Выберите способ доставки
Оформление
Подтвердите заказ
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper disabled :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'

const items = ref<StepperItem[]>([
  {
    title: 'Адрес',
    description: 'Укажите здесь свой адрес'
  },
  {
    title: 'Доставка',
    description: 'Выберите способ доставки'
  },
  {
    title: 'Оформление',
    description: 'Подтвердите заказ'
  }
])
</script>

<template>
  <B24Stepper disabled :items="items" />
</template>
Это удобно, когда переходить между шагами нужно только с помощью кнопок управления.

Примеры

С кнопками управления

Кнопки добавляют Stepper дополнительное управление.

Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Адрес
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'
import ArrowLeftLIcon from '@bitrix24/b24icons-vue/outline/ArrowLeftLIcon'
import ArrowRightLIcon from '@bitrix24/b24icons-vue/outline/ArrowRightLIcon'
import LocationIcon from '@bitrix24/b24icons-vue/outline/LocationIcon'
import DeliveryIcon from '@bitrix24/b24icons-vue/outline/DeliveryIcon'

const items: StepperItem[] = [
  {
    title: 'Адрес',
    description: 'Укажите свой адрес',
    icon: LocationIcon
  }, {
    title: 'Доставка',
    description: 'Выберите предпочтительный способ доставки',
    icon: DeliveryIcon
  }, {
    title: 'Оформление заказа',
    description: 'Подтвердите заказ'
  }
]

const stepper = useTemplateRef('stepper')
</script>

<template>
  <div class="w-full">
    <B24Stepper ref="stepper" :items="items">
      <template #content="{ item }">
        <Placeholder class="h-[200px]">
          {{ item.title }}
        </Placeholder>
      </template>
    </B24Stepper>

    <div class="flex gap-2 justify-between mt-4">
      <B24Button
        :disabled="!stepper?.hasPrev"
        label="Назад"
        @click="stepper?.prev()"
      >
        <template #leading>
          <ArrowLeftLIcon class="text-(--ui-btn-color) size-(--ui-btn-icon-size)" />
        </template>
      </B24Button>

      <B24Button
        :disabled="!stepper?.hasNext"
        label="Далее"
        @click="stepper?.next()"
      >
        <template #trailing>
          <ArrowRightLIcon class="text-(--ui-btn-color) size-(--ui-btn-icon-size)" />
        </template>
      </B24Button>
    </div>
  </div>
</template>
<script setup lang="ts">
import { useTemplateRef } from 'vue'
import type { StepperItem } from '@bxshefby/b24ui-nuxt'
import ArrowLeftLIcon from '@bitrix24/b24icons-vue/outline/ArrowLeftLIcon'
import ArrowRightLIcon from '@bitrix24/b24icons-vue/outline/ArrowRightLIcon'
import LocationIcon from '@bitrix24/b24icons-vue/outline/LocationIcon'
import DeliveryIcon from '@bitrix24/b24icons-vue/outline/DeliveryIcon'

const items: StepperItem[] = [
  {
    title: 'Адрес',
    description: 'Укажите свой адрес',
    icon: LocationIcon
  }, {
    title: 'Доставка',
    description: 'Выберите предпочтительный способ доставки',
    icon: DeliveryIcon
  }, {
    title: 'Оформление заказа',
    description: 'Подтвердите заказ'
  }
]

const stepper = useTemplateRef('stepper')
</script>

<template>
  <div class="w-full">
    <B24Stepper ref="stepper" :items="items">
      <template #content="{ item }">
        <Placeholder class="h-[200px]">
          {{ item.title }}
        </Placeholder>
      </template>
    </B24Stepper>

    <div class="flex gap-2 justify-between mt-4">
      <B24Button
        :disabled="!stepper?.hasPrev"
        label="Назад"
        @click="stepper?.prev()"
      >
        <template #leading>
          <ArrowLeftLIcon class="text-(--ui-btn-color) size-(--ui-btn-icon-size)" />
        </template>
      </B24Button>

      <B24Button
        :disabled="!stepper?.hasNext"
        label="Далее"
        @click="stepper?.next()"
      >
        <template #trailing>
          <ArrowRightLIcon class="text-(--ui-btn-color) size-(--ui-btn-icon-size)" />
        </template>
      </B24Button>
    </div>
  </div>
</template>

Управление активным элементом

Активным элементом управляют пропс default-value или директива v-model со значением value элемента. Если value не задан, берётся индекс.

Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Это шаг «Адрес».
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'
import { onMounted, ref } from 'vue'
import LocationIcon from '@bitrix24/b24icons-vue/outline/LocationIcon'
import DeliveryIcon from '@bitrix24/b24icons-vue/outline/DeliveryIcon'

const items: StepperItem[] = [
  {
    title: 'Адрес',
    description: 'Укажите свой адрес',
    icon: LocationIcon
  }, {
    title: 'Доставка',
    description: 'Выберите предпочтительный способ доставки',
    icon: DeliveryIcon
  }, {
    title: 'Оформление заказа',
    description: 'Подтвердите заказ'
  }
]

const active = ref(0)

// Примечание: только для демонстрации, в реальном проекте так делать не стоит.
onMounted(() => {
  setInterval(() => {
    active.value = (active.value + 1) % items.length
  }, 2000)
})
</script>

<template>
  <B24Stepper v-model="active" :items="items" class="w-full">
    <template #content="{ item }">
      <Placeholder class="h-[200px]">
        Это шаг «{{ item?.title }}».
      </Placeholder>
    </template>
  </B24Stepper>
</template>
Пропс value-key меняет ключ, по которому элементы сопоставляются с v-model или default-value.Значение сопоставляется с value-key каждого элемента независимо от его типа. Число сохраняет позиционный смысл, если у элемента на этой позиции нет value-key (поэтому обычные массивы по-прежнему работают по индексу), и превращается в позицию, если ни один элемент не совпал. Числа вне диапазона не выбирают ничего.

Со слотом content

Слот #content настраивает содержимое каждого элемента.

Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Это шаг «Адрес».
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'
import LocationIcon from '@bitrix24/b24icons-vue/outline/LocationIcon'
import DeliveryIcon from '@bitrix24/b24icons-vue/outline/DeliveryIcon'

const items: StepperItem[] = [
  {
    title: 'Адрес',
    description: 'Укажите свой адрес',
    icon: LocationIcon
  }, {
    title: 'Доставка',
    description: 'Выберите предпочтительный способ доставки',
    icon: DeliveryIcon
  }, {
    title: 'Оформление заказа',
    description: 'Подтвердите заказ'
  }
]
</script>

<template>
  <B24Stepper ref="stepper" :items="items" class="w-full">
    <template #content="{ item }">
      <Placeholder class="h-[200px]">
        Это шаг «{{ item?.title }}».
      </Placeholder>
    </template>
  </B24Stepper>
</template>

С собственным слотом

Свойство slot настраивает отдельный элемент.

Вам будут доступны слоты:

  • #{{ item.slot }}
Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Адрес
Step 1 of 0
<script setup lang="ts">
import type { StepperItem } from '@bxshefby/b24ui-nuxt'
import LocationIcon from '@bitrix24/b24icons-vue/outline/LocationIcon'
import DeliveryIcon from '@bitrix24/b24icons-vue/outline/DeliveryIcon'

const items: StepperItem[] = [
  {
    title: 'Адрес',
    description: 'Укажите свой адрес',
    icon: LocationIcon,
    slot: 'address'
  }, {
    title: 'Доставка',
    description: 'Выберите предпочтительный способ доставки',
    icon: DeliveryIcon,
    slot: 'shipping'
  }, {
    title: 'Оформление заказа',
    description: 'Подтвердите заказ',
    slot: 'checkout'
  }
]
</script>

<template>
  <B24Stepper :items="items" class="w-full">
    <template #address>
      <Placeholder class="h-[200px]">
        Адрес
      </Placeholder>
    </template>

    <template #shipping>
      <Placeholder class="h-[200px]">
        Доставка
      </Placeholder>
    </template>

    <template #checkout>
      <Placeholder class="h-[200px]">
        Оформление заказа
      </Placeholder>
    </template>
  </B24Stepper>
</template>

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

itemsT[]
size'md' "xs" | "sm" | "md" | "lg" | "xl"
color'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot"
orientation'horizontal' "horizontal" | "vertical"

The orientation of the stepper.

valueKey'value' keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>>

The key used to get the value from the item.

defaultValue string | number

The value of the step that should be active when initially rendered. Use when you do not need to control the state of the steps.

disabledboolean
lineartrueboolean

Whether or not the steps must be completed in order.

modelValue string | number
b24ui { root?: SlotClass; header?: SlotClass; item?: SlotClass; container?: SlotClass; trigger?: SlotClass; indicator?: SlotClass; icon?: SlotClass; separator?: SlotClass; wrapper?: SlotClass; title?: SlotClass; description?: SlotClass; content?: SlotClass; }

Слоты

Slot Type
indicator{ item: T; b24ui: object; }
wrapper{ item: T; }
title{ item: T; }
description{ item: T; }
content{ item: T; }

События

Event Type
next[value: T]
prev[value: T]
update:modelValue[value: string | number | undefined]

Доступ через ref

Типизированный экземпляр компонента доступен через useTemplateRef.

<script setup lang="ts">
const stepper = useTemplateRef('stepper')
</script>

<template>
  <B24Stepper ref="stepper" />
</template>

Он даёт доступ к следующему:

ИмяТип
next() => void
prev() => void
hasNextRef<boolean>
hasPrevRef<boolean>

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/stepper.ts
export default {
  slots: {
    root: 'flex gap-4',
    header: 'flex',
    item: 'group text-center relative w-full',
    container: 'relative',
    trigger: 'cursor-pointer rounded-full font-(--ui-font-weight-medium) text-center align-middle flex items-center justify-center group-data-[state=completed]:text-(--b24ui-color) group-data-[state=active]:text-(--b24ui-color) text-description group-data-[state=completed]:bg-(--b24ui-background) group-data-[state=active]:bg-(--b24ui-background-active) focus-visible:outline-(--b24ui-background-active) bg-(--ui-color-base-8) ring ring-(--ui-color-base-7) focus-visible:outline-2 focus-visible:outline-offset-2',
    indicator: 'flex items-center justify-center size-full',
    icon: 'shrink-0',
    separator: 'absolute rounded-(--ui-border-radius-circle) group-data-[disabled]:opacity-75 group-data-[state=completed]:bg-(--b24ui-background-active) bg-(--ui-color-base-6)',
    wrapper: '',
    title: 'font-(--ui-font-weight-medium) text-legend',
    description: 'text-description text-wrap',
    content: 'size-full'
  },
  variants: {
    orientation: {
      horizontal: {
        root: 'flex-col',
        container: 'flex justify-center',
        separator: 'top-[calc(50%-2px)] h-0.5',
        wrapper: 'mt-1'
      },
      vertical: {
        header: 'flex-col gap-4',
        item: 'flex text-start',
        separator: 'start-[calc(50%-1px)] -bottom-[10px] w-0.5'
      }
    },
    size: {
      xs: {
        trigger: 'size-[28px] text-(length:--ui-font-size-sm)',
        icon: 'size-[26px]',
        title: 'text-(length:--ui-font-size-xs)',
        description: 'text-(length:--ui-font-size-xs)',
        wrapper: 'mt-[6px]'
      },
      sm: {
        trigger: 'size-[32px] text-(length:--ui-font-size-md)',
        icon: 'size-[28px]',
        title: 'text-(length:--ui-font-size-sm)',
        description: 'text-(length:--ui-font-size-sm)',
        wrapper: 'mt-2'
      },
      md: {
        trigger: 'size-[42px] text-(length:--ui-font-size-xl)',
        icon: 'size-[38px]',
        title: 'text-(length:--ui-font-size-md)',
        description: 'text-(length:--ui-font-size-md)',
        wrapper: 'mt-[10px]'
      },
      lg: {
        trigger: 'size-[48px] text-(length:--ui-font-size-2xl)',
        icon: 'size-[44px]',
        title: 'text-(length:--ui-font-size-xl)',
        description: 'text-(length:--ui-font-size-xl)',
        wrapper: 'mt-[12px]'
      },
      xl: {
        trigger: 'size-[60px] text-(length:--ui-font-size-3xl)',
        icon: 'size-[56px]',
        title: 'text-(length:--ui-font-size-2xl)',
        description: 'text-(length:--ui-font-size-2xl)',
        wrapper: 'mt-[14px]'
      }
    },
    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'
      }
    }
  },
  compoundVariants: [
    {
      orientation: 'horizontal',
      size: 'xs',
      class: {
        separator: 'start-[calc(50%+16px)] end-[calc(-50%+16px)]'
      }
    },
    {
      orientation: 'horizontal',
      size: 'sm',
      class: {
        separator: 'start-[calc(50%+20px)] end-[calc(-50%+20px)]'
      }
    },
    {
      orientation: 'horizontal',
      size: 'md',
      class: {
        separator: 'start-[calc(50%+28px)] end-[calc(-50%+28px)]'
      }
    },
    {
      orientation: 'horizontal',
      size: 'lg',
      class: {
        separator: 'start-[calc(50%+32px)] end-[calc(-50%+32px)]'
      }
    },
    {
      orientation: 'horizontal',
      size: 'xl',
      class: {
        separator: 'start-[calc(50%+36px)] end-[calc(-50%+36px)]'
      }
    },
    {
      orientation: 'vertical',
      size: 'xs',
      class: {
        separator: 'top-[30px]',
        item: 'gap-1.5'
      }
    },
    {
      orientation: 'vertical',
      size: 'sm',
      class: {
        separator: 'top-[38px]',
        item: 'gap-2'
      }
    },
    {
      orientation: 'vertical',
      size: 'md',
      class: {
        separator: 'top-[46px]',
        item: 'gap-2.5'
      }
    },
    {
      orientation: 'vertical',
      size: 'lg',
      class: {
        separator: 'top-[54px]',
        item: 'gap-3'
      }
    },
    {
      orientation: 'vertical',
      size: 'xl',
      class: {
        separator: 'top-[62px]',
        item: 'gap-3.5'
      }
    }
  ],
  defaultVariants: {
    size: 'md',
    color: 'air-primary'
  }
}