Stepper
indiacn/stepperFreeComponent
Step indicator for multi-step flows with horizontal/vertical orientation and completed/active/warning/pending states.
Install it
npx shadcn@latest add https://indiacn.in/r/stepper.jsonSource
1'use client';23import { AlertTriangle, Check } from 'lucide-react';4import { ComponentProps, createContext, useContext } from 'react';56import { Label1, Label2 } from '@/components/ui/typography';7import { cn } from '@/lib/utils';89/*10 * UX4G stepper:11 * icon size: 1.938rem (~31px), font-size 0.875rem, font-weight 50012 * completed icon: color #9E9E9E, border 1px solid #E0E0E013 * done icon: bg #3C9718 with checkmark SVG14 * connector line: 1px solid #C6C6C6, done: #3C971815 * head-text color: #21212116 * vertical connector: left 2.45rem, width 1px17 * horizontal padding: 1.5rem18 */1920interface IStepperContext {21 activeStep: number;22 orientation: 'horizontal' | 'vertical';23}2425const STEPPER_CONTEXT = createContext<IStepperContext>({26 activeStep: 0,27 orientation: 'horizontal',28});2930interface IStepperProps extends ComponentProps<'ul'> {31 activeStep?: number;32 orientation?: 'horizontal' | 'vertical';33}3435/**36 * A stepper component for displaying progress through a multi-step process.37 * Matches the UX4G 2.0 Stepper specification.38 *39 * Uses semantic `<ul>/<li>` elements per UX4G.40 * Supports horizontal/vertical, completed/done/warning/active/pending states.41 */42function Stepper({43 className,44 activeStep = 0,45 orientation = 'horizontal',46 children,47 ...props48}: IStepperProps) {49 return (50 <STEPPER_CONTEXT.Provider value={{ activeStep, orientation }}>51 <ul52 className={cn(53 'relative m-0 flex w-full gap-0 overflow-hidden p-0',54 orientation === 'horizontal' ? 'flex-row justify-between' : 'flex-col',55 className,56 )}57 style={{ listStyle: 'none' }}58 {...props}59 >60 {children}61 </ul>62 </STEPPER_CONTEXT.Provider>63 );64}6566interface IStepProps extends ComponentProps<'li'> {67 step: number;68 title?: string;69 description?: string;70 status?: 'completed' | 'active' | 'warning' | 'pending';71 isLast?: boolean;72}7374/**75 * Individual step within a Stepper.76 * UX4G icon: 1.938rem, connector: 1px #C6C6C6, done connector: #3C9718.77 */78function Step({ className, step, title, description, status, isLast, ...props }: IStepProps) {79 const { activeStep, orientation } = useContext(STEPPER_CONTEXT);8081 const resolvedStatus =82 status ?? (step < activeStep ? 'completed' : step === activeStep ? 'active' : 'pending');8384 const isCompleted = resolvedStatus === 'completed';85 const isActive = resolvedStatus === 'active';86 const isWarning = resolvedStatus === 'warning';8788 return (89 <li90// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from indiacn
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | indiacn | Components | Free | 2 deps | |
| Alertalert | indiacn | Components | Free | 2 deps | |
| Badgebadge | indiacn | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | indiacn | Components | Free | 1 dep | |
| Buttonbutton | indiacn | Components | Free | 3 deps | |
| Button Groupbutton-group | indiacn | Components | Free | no deps | |
| Cardcard | indiacn | Components | Free | 1 dep | |
| Chipchip | indiacn | Components | Free | 2 deps |
