- Зеленый — когда шаг завершен
- Синий, когда на текущем шаге
- Белый, когда он нетронут.
https://codesandbox.io/p/sandbox/stepper-ppnqgc
body {
margin: 0;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
color: #333;
}
h1,
h2,
h3,
p {
margin: 0;
}
.header {
text-align: center;
padding: 20px;
background-color: #007bff;
color: white;
}
.footer {
display: flex;
justify-content: center;
gap: 15px;
padding: 15px;
background-color: #007bff;
}
.footer-button {
padding: 10px 20px;
font-size: 16px;
color: white;
background-color: #0056b3;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.footer-button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
.footer-button:hover:not(:disabled) {
background-color: #004085;
}
.footer-button.submit {
background-color: #28a745;
}
.footer-button.submit:hover:not(:disabled) {
background-color: #218838;
}
.body {
display: flex;
flex-direction: row;
}
.left {
width: 30%;
padding: 20px;
background-color: #f4f4f4;
border-right: 1px solid #ddd;
}
.steps {
display: flex;
flex-direction: column;
align-items: flex-start;
position: relative;
}
.steps ul {
list-style: none;
padding: 0;
margin: 0;
}
.steps li {
display: flex;
align-items: center;
margin-bottom: 40px;
cursor: pointer;
}
.steps li .circle {
width: 24px;
height: 24px;
border-radius: 50%;
border: 2px solid #ccc;
background-color: #fff;
position: relative;
z-index: 1;
transition: background-color 0.3s, border-color 0.3s;
}
.steps li.complete .circle {
background-color: #28a745;
border-color: #28a745;
}
.steps li.active .circle {
background-color: #007bff;
border-color: #007bff;
}
.steps li .step-label {
margin-left: 15px;
font-size: 16px;
color: #333;
}
.right {
flex: 1;
padding: 20px;
}
.step-content {
padding: 10px;
background-color: #fff;
border-radius: 4px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.step-content p {
font-size: 16px;
line-height: 1.6;
}
import React from "react";
interface StepsProps {
currentStep: number;
isSubmitted: boolean;
stepsData: { title: string }[];
}
const Steps: React.FC = ({
currentStep,
isSubmitted,
stepsData,
}) => (
- {stepsData.map((step, index) => (
- key={index}
className={`${
index < currentStep ||
(index === stepsData.length - 1 && isSubmitted)
? "complete"
: ""
} ${currentStep === index ? "active" : ""}`}
>
{step.title}
))}
export default Steps;
import React from "react";
import Steps from "./Steps";
import StepContent from "./StepContent";
import "./styles.css";
interface BodyProps {
currentStep: number;
isSubmitted: boolean;
stepsData: { title: string; content: string }[];
}
const Body: React.FC = ({ currentStep, isSubmitted, stepsData }) => (
);
export default Body;
Подробнее здесь: https://stackoverflow.com/questions/793 ... es-reactjs