内容与导航
children 可以是函数,接收当前步骤与导航方法。可组合 Card、Button 等组件;只有提供 children 时才渲染内容区。
内容区始终挂载,如何切换、保留或重置内部内容由调用方决定。组件 ref 也提供 next()、prev()、goTo(step),与 children 收到的方法行为一致。
步骤 A
这里是第 1 步的内容。
'use client'
import { Stepper, Button, Card, Inline, Stack, Text } from '@hina-ui/react'
const items = [
{ title: '步骤 A', description: '第一项的说明' },
{ title: '步骤 B', description: '第二项包含更长的说明文字,支持自然换行' },
{ title: '步骤 C', description: '最后一项的说明' },
]
export default function Demo() {
return (
<Stepper items={items}>
{({ item, step, next, prev, canNext, canPrev }) => (
<Card>
<Stack gap="lg">
<Text weight="medium">{item?.title}</Text>
<Text tone="muted">这里是第 {step} 步的内容。</Text>
<Inline justify="between">
<Button variant="outline" tone="neutral" disabled={!canPrev} onClick={prev}>
上一步
</Button>
<Button disabled={!canNext} onClick={next}>
下一步
</Button>
</Inline>
</Stack>
</Card>
)}
</Stepper>
)
}