Steppers convey progress through numbered, bullet, or icon-based sequential steps.
npm install @dt-dds/react-stepperSteppers convey progress through numbered, bullet, or icon-based sequential steps.
They support various states including completed, incomplete, warning, error, and disabled.
``jsx
import { Stepper } from '@dt-dds/react-stepper';
export const App = () => {
return (
description="This step is done"
state="completed"
/>
description="Working on this"
state="incomplete"
isActive={true}
/>
description="Needs attention"
state="warning"
/>
description="Something went wrong"
state="error"
/>
description="Not available yet"
state="disabled"
/>
);
};
`
`jsx`
`jsx`
`jsx
import { Icon } from '@dt-dds/react-icon';
icon={
/>
icon={
/>
icon={
/>
`
The useStepper hook provides a complete state management solution for steppers, including navigation, completion tracking, and boundary checks.
`jsx
import { useStepper } from '@dt-dds/react-stepper';
export const ControlledStepper = () => {
const {
activeStep,
handleNext,
handleBack,
canGoNext,
canGoBack,
} = useStepper({
initialStep: 0,
totalSteps: 3,
});
return (
<>
>
);
};
`
| Option | Type | Default | Description |
|-----------------|----------|---------|---------------------------------------|
| initialStep | number | 0 | The initial active step (0-based) |totalSteps
| | number | — | Total number of steps (for boundary checks) |
| Property | Type | Description |
|-----------------------------|----------------------------------------|--------------------------------------------------|
| activeStep | number | Current active step index |isFirstStep
| | boolean | Whether currently on the first step |isLastStep
| | boolean | Whether currently on the last step |canGoNext
| | boolean | Whether navigation to the next step is allowed |canGoBack
| | boolean | Whether navigation to the previous step is allowed |completedSteps
| | Set | Set of completed step indices |handleNext
| | () => void | Navigate to the next step |handleBack
| | () => void | Navigate to the previous step |handleChangeStep
| | (step: number) => void | Navigate to a specific step |handleReset
| | () => void | Reset to initial step and clear completed steps |markStepComplete
| | (step: number) => void | Mark a specific step as completed |markStepIncomplete
| | (step: number) => void | Mark a specific step as incomplete |isStepComplete
| | (step: number) => boolean | Check if a specific step is completed |
| Property | Type | Default | Description |
| ------------- | -------------------------------- | --------- | ---------------------------------------- |
| children | ReactNode | — | Step components to be rendered |orientation
| | "vertical" \| "horizontal" | vertical| Direction of the stepper |variant
| | "number" \| "bullet" \| "icon" | number | Visual style of step indicators |activeStep
| | number | — | Index of the active step (0-based) |dataTestId
| | string | stepper | Test identifier for the stepper container|
| Property | Type | Default | Description |
|--------------|-----------------------------------------------------------------|----------------|----------------------------------------------|
| title | string | — | Title text for the step |description
| | string | — | Description text for the step |state
| | "completed" \| "warning" \| "error" \| "disabled" \| "incomplete" | incomplete | Visual state of the step |isActive
| | boolean | false | Whether the step is currently active |icon
| | ReactNode | — | Custom icon for the icon variant |dataTestId
| | string | step-{index} | Test identifier for the step |
- TypeScript for static type checking
- React — JavaScript library for user interfaces
- Emotion — for writing css styles with JavaScript
- Storybook — UI component environment powered by Vite
- Jest - JavaScript Testing Framework
- React Testing Library - to test UI components in a user-centric way
- ESLint for code linting
- Prettier for code formatting
- Tsup — TypeScript bundler powered by esbuild
- Yarn from managing packages
- yarn build - Build the packageyarn dev
- - Run the package locallyyarn lint
- - Lint all files within this packageyarn test
- - Run all unit testsyarn test:report
- - Open the test coverage reportyarn test:update:snapshot
- - Run all unit tests and update the snapshot
Running yarn build from the root of the package will use tsup to compile the raw TypeScript and React code to plain JavaScript.
The /dist folder contains the compiled output.
`bash``
stepper
└── dist
├── index.d.ts <-- Types
├── index.js <-- CommonJS version
└── index.mjs <-- ES Modules version
...
Follows semantic versioning
Licensed under MIT License