Skip to content

Steps 步骤条

介绍

用于展示操作流程的各个环节,让用户了解当前的操作在整体流程中的位置。

引入

ts
import { IBestSteps } from "@ibestservices/ibest-ui";

代码演示

基础用法

基础用法

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State active: number = 0
  @State groupId: string = 'steps'
  build() {
    Column(){
      IBestSteps({
        groupId: this.groupId,
        active: this.active
      }){
        IBestStep({groupId: this.groupId, title: "步骤一"})
        IBestStep({groupId: this.groupId, title: "步骤二"})
        IBestStep({groupId: this.groupId, title: "步骤三"})
      }
    }
  }
}

标记类型

标记类型

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State active: number = 0
  @State groupId: string = 'steps'
  build() {
    Column(){
      IBestSteps({
        groupId: this.groupId,
        active: this.active,
        type: 'dot'
      }){
        IBestStep({groupId: this.groupId, title: "步骤一"})
        IBestStep({groupId: this.groupId, title: "步骤二"})
        IBestStep({groupId: this.groupId, title: "步骤三"})
      }
    }
  }
}

自定义样式

自定义样式

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State active: number = 0
  @State groupId: string = 'steps'
  build() {
    Column(){
      IBestSteps({
        groupId: this.groupId,
        active: this.active,
        type: 'icon',
        inactiveIcon: "passed",
        activeIcon: "checked",
        activeColor: "#07c160"
      }){
        IBestStep({groupId: this.groupId, title: "步骤一", description: "一些描述信息"})
        IBestStep({groupId: this.groupId, title: "步骤二", description: "一些描述信息"})
        IBestStep({groupId: this.groupId, title: "步骤三", description: "一些描述信息"})
      }
    }
  }
}

竖向步骤条

竖向步骤条

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State active: number = 0
  @State groupId: string = 'steps'
  @Builder customStepContent(index: number){
    Column({space: 10}){
      Text("【城市】物流状态" + (index + 1))
        .fontColor(this.active >= index ? "#1989fa" : "#323233")
      Text("2025-05-01")
        .fontColor(this.active >= index ? "#1989fa" : "#323233")
    }
    .alignItems(HorizontalAlign.Start)
  }
  build() {
    Column(){
      IBestSteps({
        groupId: this.groupId,
        dotSize: 8,
        active: this.active,
        placeDirection: Axis.Vertical
      }){
        ForEach([0, 1, 2], (_: number, index: number) => {
          IBestStep({
            groupId: this.groupId,
            type: index == 1 ? "dot" : "icon",
            inactiveIcon: index == 0 ? "like-o" : "passed",
            activeIcon: index == 0 ? "like" : "checked",
          }){
            this.customStepContent(index)
          }
        })
      }
    }
  }
}

API

IBestSteps @Props

参数说明类型默认值
groupId分组id,通常为一个唯一的字符串,需具备全局唯一性或已入栈的页面唯一性string | number''
active当前激活的步骤索引number0
placeDirection步骤条方向AxisHorizontal
type步骤条标记类型, 可选值 numdoticonstringnum
dotSize点大小string | number6
inactiveIcon未激活底部图标, 仅type为 icon 时有效ResourceStr''
activeIcon激活底部图标, 仅type为 icon 时有效ResourceStr''
iconSize图标大小, 仅type为 icon 时有效string | number14
inactiveColor未激活颜色ResourceColor#969799
activeColor激活颜色ResourceColor#1989fa

IBestSteps 插槽

插槽名说明类型
defaultBuilder默认内容的插槽CustomBuilder

IBestStep @Props

参数说明类型默认值
groupId分组id,与IBestSteps的groupId 一致string | number''
title标题ResourceStr''
description描述ResourceStr''
type步骤条标记类型, 可选值 numdoticonstringnum
dotSize点大小string | number6
inactiveIcon未激活底部图标, 仅type为 icon 时有效ResourceStr''
activeIcon激活底部图标, 仅type为 icon 时有效ResourceStr''
iconSize图标大小, 仅type为 icon 时有效string | number14
inactiveColor未激活颜色ResourceColor#969799
activeColor激活颜色ResourceColor#1989fa

IBestStep 插槽

插槽名说明类型
defaultBuilder默认内容的插槽CustomBuilder