Skip to Content
文档

步骤

用于指示多步骤流程的进度

SourceStorybookRecipeArk
Step 1
Step 2
Step 3
Step 2 description

用法

¥Usage

import { Steps } from "@chakra-ui/react"
<Steps.Root>
  <Steps.List>
    <Steps.Item>
      <Steps.Trigger>
        <Steps.Indicator />
        <Steps.Title />
        <Steps.Description />
      </Steps.Trigger>
      <Steps.Separator />
    </Steps.Item>
  </Steps.List>
  <Steps.Content />
  <Steps.CompletedContent />
  <Steps.PrevTrigger />
  <Steps.NextTrigger />
</Steps.Root>

示例

¥Examples

尺寸

¥Sizes

使用 size 属性更改步骤组件的大小。

¥Use the size prop to change the size of the steps component.

Step 1
Step 2
Step 3
Step 1 description
Step 1
Step 2
Step 3
Step 1 description
Step 1
Step 2
Step 3
Step 1 description

变量

¥Variants

使用 variant 属性更改步骤组件的外观。

¥Use the variant prop to change the appearance of the steps component.

Step 1
Step 2
Step 3
Step 1 description
Step 1
Step 2
Step 3
Step 1 description

颜色

¥Colors

使用 colorPalette 属性更改组件的配色方案。

¥Use the colorPalette prop to change the color scheme of the component.

Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description
Step 1
Step 2
Step 3
Step 2 description

触发

¥Trigger

使用 Steps.Trigger 组件使步骤可点击。

¥Use the Steps.Trigger component to make the step clickable.

Step 2 description

垂直

¥Vertical

使用 orientation 属性更改步骤组件的方向。

¥Use the orientation prop to change the orientation of the steps component.

Step 1
Step 2
Step 3
Step 2 description

受控

¥Controlled

使用 steponStepChange 属性控制步骤组件的当前步骤。

¥Use the step and onStepChange props to control the current step of the steps component.

Step 1
Step 2
Step 3
Step 2 description

商店

¥Store

控制步骤的另一种方法是使用 RootProvider 组件和 useSteps 存储钩子。

¥An alternative way to control the steps is to use the RootProvider component and the useSteps store hook.

这样,你就可以从步骤外部访问步骤状态和方法。

¥This way you can access the steps state and methods from outside the steps.

current step: 1
Step 1
Step 2
Step 3
Step 2 description

图标

¥Icon

icon 属性传递给 StepsItem 组件,即可显示图标。

¥Pass the icon prop to the StepsItem component to display an icon.

Payment

描述

¥Description

description 属性传递给 StepsItem 组件,即可显示描述。

¥Pass the description prop to the StepsItem component to display a description.

Step 1
This step
Step 2
That step
Step 3
Final step
Step 2 content

属性

¥Props

根元素

¥Root

PropDefaultType
orientation 'horizontal'
'vertical' | 'horizontal'

The orientation of the component

colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'

The color palette of the component

variant 'solid'
'solid' | 'subtle'

The variant of the component

size 'md'
'xs' | 'sm' | 'md' | 'lg'

The size of the component

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
unstyled
boolean

Whether to remove the component's style.

count
number

The total number of steps

defaultStep
number

The initial value of the stepper when rendered. Use when you don't need to control the value of the stepper.

ids
ElementIds

The custom ids for the stepper elements

linear
boolean

If `true`, the stepper requires the user to complete the steps in order

onStepChange
(details: StepChangeDetails) => void

Callback to be called when the value changes

onStepComplete
VoidFunction

Callback to be called when a step is completed

step
number

The controlled value of the stepper

Previous

分页

Next

标签