1.0.1 โข Published 5 months ago
@aniruddha1806/progress-tracker v1.0.1
React Progress Tracker
A flexible, customizable progress tracker component for React applications with TypeScript support. Perfect for multi-step forms, onboarding flows, checkout processes, and any step-by-step user journey.
Installation
npm install @aniruddha1806/progress-trackerFeatures
- ๐จ Extensive customization options (colors, sizes, styles)
 - ๐ฑ Responsive design with multiple size options
 - ๐ง Custom step rendering support
 - ๐ญ Built-in icons and labels with sublabels
 - ๐ Visual state management (active, completed, inactive)
 - ๐จ CSS class and inline style support
 - ๐ TypeScript support with full type definitions
 - โฟ Accessibility-friendly structure
 - ๐ชถ Zero dependencies and lightweight
 
Quick Start
import ProgressTracker from '@aniruddha1806/progress-tracker';
function App() {
  const steps = [
    { 
      label: 'Account', 
      sublabel: 'Create your account',
      icon: '๐ค' 
    },
    { 
      label: 'Profile', 
      sublabel: 'Complete your profile',
      icon: '๐' 
    },
    { 
      label: 'Verification', 
      sublabel: 'Verify your email',
      icon: 'โ๏ธ' 
    },
    { 
      label: 'Complete', 
      sublabel: 'All done!',
      icon: 'โ
' 
    }
  ];
  return (
    <ProgressTracker
      steps={steps}
      currentStep={1} // 0-indexed (step 2 is active)
    />
  );
}Props
ProgressTrackerProps
| Prop | Type | Default | Description | 
|---|---|---|---|
steps | Step[] | required | Array of step objects | 
currentStep | number | required | Current active step (0-indexed) | 
className | string | "" | CSS class for container | 
stepClassName | string | "" | CSS class for step elements | 
labelClassName | string | "" | CSS class for step labels | 
sublabelClassName | string | "" | CSS class for step sublabels | 
iconClassName | string | "" | CSS class for step icons | 
connectorClassName | string | "" | CSS class for connectors | 
activeConnectorClassName | string | "" | CSS class for active connectors | 
inactiveConnectorClassName | string | "" | CSS class for inactive connectors | 
activeColor | string | "#0074D9" | Color for active/completed steps | 
inactiveColor | string | "#E1E8ED" | Color for inactive steps | 
showLabels | boolean | true | Show step labels | 
showConnectors | boolean | true | Show connectors between steps | 
size | "small" \| "medium" \| "large" | "medium" | Overall component size | 
renderCustomStep | function | undefined | Custom step render function | 
Step Interface
interface Step {
  label: string;           // Step title
  sublabel?: string;       // Optional subtitle
  icon: React.ReactNode;   // Icon (emoji, SVG, component)
}Examples
Basic Horizontal Progress
Simple horizontal progress tracker:
import ProgressTracker from '@aniruddha1806/progress-tracker';
function BasicExample() {
  const steps = [
    { label: 'Start', icon: '๐' },
    { label: 'Progress', icon: 'โก' },
    { label: 'Complete', icon: '๐' }
  ];
  return (
    <ProgressTracker
      steps={steps}
      currentStep={1}
    />
  );
}Custom Colors and Styling
Customize appearance with colors and CSS classes:
import ProgressTracker from '@aniruddha1806/progress-tracker';
import './custom-progress.css'; // Your custom CSS
function CustomStyledExample() {
  const steps = [
    { label: 'Design', icon: '๐จ' },
    { label: 'Develop', icon: '๐ป' },
    { label: 'Test', icon: '๐งช' },
    { label: 'Deploy', icon: '๐' }
  ];
  return (
    <ProgressTracker
      steps={steps}
      currentStep={2}
      activeColor="#28a745"
      inactiveColor="#f8f9fa"
      size="large"
      connectorStyle="dashed"
      className="custom-progress"
      stepClassName="custom-step"
      labelClassName="custom-label"
    />
  );
}CSS file (custom-progress.css):
.custom-progress {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 24px;
}
.custom-step {
  transition: transform 0.2s ease;
}
.custom-step:hover {
  transform: scale(1.05);
}
.custom-label {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  color: white;
}With React Icons
Use popular icon libraries:
import ProgressTracker from '@aniruddha1806/progress-tracker';
import { 
  FaUser, 
  FaCreditCard, 
  FaShippingFast, 
  FaCheckCircle 
} from 'react-icons/fa';
function IconExample() {
  const steps = [
    { 
      label: 'Account', 
      sublabel: 'Sign up or login',
      icon: <FaUser /> 
    },
    { 
      label: 'Payment', 
      sublabel: 'Enter payment details',
      icon: <FaCreditCard /> 
    },
    { 
      label: 'Shipping', 
      sublabel: 'Choose delivery option',
      icon: <FaShippingFast /> 
    },
    { 
      label: 'Confirmation', 
      sublabel: 'Order complete',
      icon: <FaCheckCircle /> 
    }
  ];
  return (
    <ProgressTracker
      steps={steps}
      currentStep={1}
      activeColor="#007bff"
      size="large"
    />
  );
}Different Sizes
Show all available sizes:
import ProgressTracker from '@aniruddha1806/progress-tracker';
function SizesExample() {
  const steps = [
    { label: 'Start', icon: '๐' },
    { label: 'Middle', icon: 'โก' },
    { label: 'End', icon: '๐' }
  ];
  return (
    <div style={{ padding: '20px' }}>
      <h3>Small Size</h3>
      <ProgressTracker
        steps={steps}
        currentStep={1}
        size="small"
        activeColor="#dc3545"
      />
      
      <h3 style={{ marginTop: '40px' }}>Medium Size (Default)</h3>
      <ProgressTracker
        steps={steps}
        currentStep={1}
        size="medium"
        activeColor="#ffc107"
      />
      
      <h3 style={{ marginTop: '40px' }}>Large Size</h3>
      <ProgressTracker
        steps={steps}
        currentStep={1}
        size="large"
        activeColor="#28a745"
      />
    </div>
  );
}TypeScript Usage
The component provides full TypeScript support:
import ProgressTracker, { Step, ProgressTrackerProps } from '@aniruddha1806/progress-tracker';
import { ReactNode } from 'react';
interface CustomStep extends Step {
  id: string;
  duration?: number;
  isOptional?: boolean;
}
interface WizardProps {
  steps: CustomStep[];
  onStepChange: (stepIndex: number) => void;
}
const CustomWizard: React.FC<WizardProps> = ({ steps, onStepChange }) => {
  const [currentStep, setCurrentStep] = useState<number>(0);
  const handleStepClick = (stepIndex: number): void => {
    setCurrentStep(stepIndex);
    onStepChange(stepIndex);
  };
  const renderCustomStep = (
    step: Step, 
    index: number, 
    isCompleted: boolean, 
    isActive: boolean
  ): ReactNode => {
    const customStep = step as CustomStep;
    
    return (
      <div
        key={customStep.id}
        onClick={() => handleStepClick(index)}
        style={{
          cursor: 'pointer',
          opacity: customStep.isOptional && !isCompleted ? 0.6 : 1
        }}
      >
        {/* Custom step rendering */}
      </div>
    );
  };
  const progressProps: ProgressTrackerProps = {
    steps,
    currentStep,
    renderCustomStep,
    activeColor: '#6366f1',
    size: 'large'
  };
  return <ProgressTracker {...progressProps} />;
};