Welcome to the Steps Component project! This is a simple and interactive multi-step guide built with Vite and React. The project demonstrates how to navigate through different stages using state management in React.๐ ๏ธ
Live Demo https://steps-component-three.vercel.app
- Vite: A fast and lightweight build tool optimized for modern web development โก
- React: A popular library for building dynamic user interfaces โ๏ธ
- CSS: Styled using basic CSS for clean and minimal design ๐จ
- Step Navigation: Users can move between steps using "Previous" and "Next" buttons โฌ ๏ธโก๏ธ
- Dynamic Step Highlighting: The current step is highlighted for visual clarity ๐
- Responsive Layout: The component is built to adapt to different screen sizes ๐ฑ๐ป
To get started, follow these simple steps:
-
Clone the repository: ๐
git clone https://github.com/ramxcodes/Steps-Component
-
Navigate into the project directory: ๐
cd Steps-Component
-
Install dependencies: ๐ฆ
npm install
-
Start the development server: ๐
npm run dev
-
Open your browser and go to: ๐
http://localhost:5173/
The component is structured with React's useState
to manage the current step. Below is an overview of the main App
component:
import { useState } from "react";
const messages = [
"Learn React โ๏ธ",
"Apply for jobs ๐ผ",
"Invest your new income ๐ค",
];
function App() {
const [step, setStep] = useState(1);
function handlePrevious() {
if (step > 1) setStep(step - 1);
}
function handleNext() {
if (step < 3) setStep(step + 1);
}
return (
<div className="steps">
<div className="numbers">
<div className={step >= 1 ? "active" : ""}>1</div>
<div className={step >= 2 ? "active" : ""}>2</div>
<div className={step >= 3 ? "active" : ""}>3</div>
</div>
<p className="message">
Step {step} : {messages[step - 1]}
</p>
<div className="buttons">
<button
style={{ backgroundColor: "#7950f2", color: "#fff" }}
onClick={handlePrevious}
>
Previous
</button>
<button
style={{ backgroundColor: "#7950f2", color: "#fff" }}
onClick={handleNext}
>
Next
</button>
</div>
</div>
);
}
export default App;