Steps
inferencesh/stepsFreeBlock
Numbered step component with connecting line for sequential instructions.
Live preview
live · rendered by the registry
Rendered by inferencesh on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.inference.sh/r/steps.jsonSource
1import * as React from "react"2import { cn } from "@/lib/utils"34interface StepsProps extends React.HTMLAttributes<HTMLDivElement> {5 children: React.ReactNode6}78function Steps({ className, children, ...props }: StepsProps) {9 // Count Step children and inject step numbers10 let stepIndex = 011 const childrenWithNumbers = React.Children.map(children, (child) => {12 if (13 React.isValidElement(child) &&14 (child.type as React.FC)?.displayName === "Step"15 ) {16 stepIndex++17 return React.cloneElement(child as React.ReactElement<StepInternalProps>, {18 _stepNumber: stepIndex,19 })20 }21 return child22 })2324 return (25 <div className={cn("flex flex-col", className)} {...props}>26 {childrenWithNumbers}27 </div>28 )29}3031interface StepInternalProps extends React.HTMLAttributes<HTMLDivElement> {32 children: React.ReactNode33 _stepNumber?: number34}3536function Step({ className, children, _stepNumber, ...props }: StepInternalProps) {37 return (38 <div className={cn("grid grid-cols-[auto_1fr] gap-4", className)} {...props}>39 {/* Left column: number + line */}40 <div className="flex flex-col items-center">41 <div className="flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-muted-foreground">42 {_stepNumber}43 </div>44 <div className="my-2 w-px flex-1 bg-border" />45 </div>46 {/* Right column: content */}47 <div>48 {children}49 </div>50 </div>51 )52}53Step.displayName = "Step"5455interface StepTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {56 children: React.ReactNode57}5859function StepTitle({ className, children, ...props }: StepTitleProps) {60 return (61 <h362 className={cn("text-base font-medium leading-6 tracking-tight", className)}63 {...props}64 >65 {children}66 </h3>67 )68}6970interface StepContentProps extends React.HTMLAttributes<HTMLDivElement> {71 children: React.ReactNode72}7374function StepContent({ className, children, ...props }: StepContentProps) {75 return (76 <div className={cn("mt-2", className)} {...props}>77 {children}78 </div>79 )80}8182export { Steps, Step, StepTitle, StepContent }
Files it writes
More from inferencesh
All 14 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Agent Chatagent | inferencesh | Blocks | Free | 1 dep | |
| Chat UI Primitiveschat | inferencesh | Blocks | Free | 1 dep · 15 files | |
| Code Blockcode-block | inferencesh | Blocks | Free | no deps · 7 files | |
| Markdown Renderer (legacy)markdown | inferencesh | Blocks | Free | 2 deps · 2 files | |
| pretext-mdpretext-md | inferencesh | Blocks | Free | 4 deps · 10 files | |
| Sidebar Lightsidebar-light | inferencesh | Blocks | Free | no deps | |
| Table of Contentstable-of-contents | inferencesh | Blocks | Free | no deps | |
| Tasktask | inferencesh | Blocks | Free | 1 dep · 9 files |
