Using Steps
Create visually distinct step-by-step instructions for tutorials and guides
Using Steps
The Steps component creates beautiful, numbered step-by-step instructions perfect for tutorials, installation guides, and any sequential process.
Basic Steps Example
steps
- Install Node.js - Download and install Node.js from the official website
- Create a project - Run
npm initto initialize your project - Install dependencies - Use
npm installto add required packages - Start coding - Open your favorite editor and begin development
Steps with Code Examples
steps
-
Clone the repository
Bashgit clone https://github.com/username/project.git cd project -
Install dependencies
Run the following command to install all required packages:
Bashnpm install -
Configure environment
Create a
.envfile in the root directory:
ENVDATABASE_URL=your_database_url API_KEY=your_api_key -
Run the application
Start the development server:
Bashnpm run devYour app should now be running at
http://localhost:3000
Steps with Nested Content
steps
-
Set up your database
You have several options for database setup:
- PostgreSQL (recommended for production)
- SQLite (good for development)
- MySQL (widely supported)
-
Create database schema
Run the migration command:
Bashnpm run migrate -
Seed initial data
Populate your database with test data:
Bashnpm run seed
Complex Tutorial Example
Building Your First React Component
steps
-
Create the component file
Create a new file
src/components/Button.jsx:
JSXimport React from 'react'; function Button({ children, onClick }) { return ( <button onClick={onClick} className="btn"> {children} </button> ); } export default Button; -
Import the component
In your
App.jsx, import the Button component:
JSXimport Button from './components/Button'; -
Use the component
Add the button to your JSX:
JSXfunction App() { const handleClick = () => { alert('Button clicked!'); }; return ( <div className="App"> <h1>My App</h1> <Button onClick={handleClick}> Click Me! </Button> </div> ); } -
Test your component
Run your application and verify the button works:
Bashnpm startClick the button to see the alert message.
Combining Steps with Asides
steps
-
Install authentication library
Bashnpm install next-auth -
Create authentication configuration
Create
pages/api/auth/[...nextauth].js:
JAVASCRIPTimport NextAuth from 'next-auth'; import Providers from 'next-auth/providers'; export default NextAuth({ providers: [ Providers.GitHub({ clientId: process.env.GITHUB_ID, clientSecret: process.env.GITHUB_SECRET }) ] }); -
Protect your routes
Use the
useSessionhook to check authentication status:
JSXimport { useSession } from 'next-auth/react'; function ProtectedPage() { const { data: session, status } = useSession(); if (status === 'loading') return <p>Loading...</p>; if (!session) return <p>Access Denied</p>; return <p>Welcome {session.user.name}!</p>; } -
Add sign in/out buttons
JSXimport { signIn, signOut, useSession } from 'next-auth/react'; function AuthButton() { const { data: session } = useSession(); if (session) { return ( <button onClick={() => signOut()}> Sign out </button> ); } return ( <button onClick={() => signIn()}> Sign in </button> ); }
Real-World Use Cases
Algorithm Implementation Tutorial
steps
-
Understand the problem
Binary search works by repeatedly dividing the search interval in half.
Requirements:
- Array must be sorted
- Elements must be comparable
- Random access must be possible
-
Write the algorithm
JAVASCRIPTfunction binarySearch(arr, target) { let left = 0; let right = arr.length - 1; while (left <= right) { const mid = Math.floor((left + right) / 2); if (arr[mid] === target) { return mid; // Found it! } else if (arr[mid] < target) { left = mid + 1; // Search right half } else { right = mid - 1; // Search left half } } return -1; // Not found } -
Test your implementation
JAVASCRIPTconst numbers = [1, 3, 5, 7, 9, 11, 13, 15]; console.log(binarySearch(numbers, 7)); // Output: 3 console.log(binarySearch(numbers, 10)); // Output: -1 -
Analyze complexity
- Time Complexity: O(log n)
- Space Complexity: O(1)