Использование
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?: stringdescription?: stringcontent?: stringicon?: IconComponentvalue?: string | numberdisabled?: booleanslot?: stringclass?: anyb24ui?: { 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
Управление активным элементом
Активным элементом управляют пропс default-value или директива v-model со значением value элемента. Если value не задан, берётся индекс.
Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Это шаг «Адрес».
Step 1 of 0
Пропс
value-key меняет ключ, по которому элементы сопоставляются с v-model или default-value.Значение сопоставляется с value-key каждого элемента независимо от его типа. Число сохраняет позиционный смысл, если у элемента на этой позиции нет value-key (поэтому обычные массивы по-прежнему работают по индексу), и превращается в позицию, если ни один элемент не совпал. Числа вне диапазона не выбирают ничего.Со слотом content
Слот #content настраивает содержимое каждого элемента.
Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Это шаг «Адрес».
Step 1 of 0
С собственным слотом
Свойство slot настраивает отдельный элемент.
Вам будут доступны слоты:
#{{ item.slot }}
Адрес
Укажите свой адрес
Доставка
Выберите предпочтительный способ доставки
Оформление заказа
Подтвердите заказ
Адрес
Step 1 of 0
API
Пропсы
Слоты
События
Доступ через ref
Типизированный экземпляр компонента доступен через useTemplateRef.
<script setup lang="ts">
const stepper = useTemplateRef('stepper')
</script>
<template>
<B24Stepper ref="stepper" />
</template>
Он даёт доступ к следующему:
Тема
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'
}
}