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

  1. Install Node.js - Download and install Node.js from the official website
  2. Create a project - Run npm init to initialize your project
  3. Install dependencies - Use npm install to add required packages
  4. Start coding - Open your favorite editor and begin development

Steps with Code Examples

steps

  1. Clone the repository

    git clone https://github.com/username/project.git
    cd project
    
    Bash
  2. Install dependencies

    Run the following command to install all required packages:

    npm install
    
    Bash
  3. Configure environment

    Create a .env file in the root directory:

    DATABASE_URL=your_database_url
    API_KEY=your_api_key
    ENV
  4. Run the application

    Start the development server:

    npm run dev
    
    Bash

    Your app should now be running at http://localhost:3000

Steps with Nested Content

steps

  1. Set up your database

    You have several options for database setup:

    • PostgreSQL (recommended for production)
    • SQLite (good for development)
    • MySQL (widely supported)
  2. Create database schema

    Run the migration command:

    npm run migrate
    
    Bash
  3. Seed initial data

    Populate your database with test data:

    npm run seed
    
    Bash

Complex Tutorial Example

Building Your First React Component

steps

  1. Create the component file

    Create a new file src/components/Button.jsx:

    import React from 'react';
    
    function Button({ children, onClick }) {
      return (
        <button onClick={onClick} className="btn">
          {children}
        </button>
      );
    }
    
    export default Button;
    
    JSX
  2. Import the component

    In your App.jsx, import the Button component:

    import Button from './components/Button';
    
    JSX
  3. Use the component

    Add the button to your JSX:

    function App() {
      const handleClick = () => {
        alert('Button clicked!');
      };
    
      return (
        <div className="App">
          <h1>My App</h1>
          <Button onClick={handleClick}>
            Click Me!
          </Button>
        </div>
      );
    }
    
    JSX
  4. Test your component

    Run your application and verify the button works:

    npm start
    
    Bash

    Click the button to see the alert message.

Combining Steps with Asides

steps

  1. Install authentication library

    npm install next-auth
    
    Bash
  2. Create authentication configuration

    Create pages/api/auth/[...nextauth].js:

    import 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
        })
      ]
    });
    
    JAVASCRIPT
  3. Protect your routes

    Use the useSession hook to check authentication status:

    import { 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>;
    }
    
    JSX
  4. Add sign in/out buttons

    import { 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>
      );
    }
    
    JSX

Real-World Use Cases

Algorithm Implementation Tutorial

steps

  1. 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
  2. Write the algorithm

    function 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
    }
    
    JAVASCRIPT
  3. Test your implementation

    const numbers = [1, 3, 5, 7, 9, 11, 13, 15];
    
    console.log(binarySearch(numbers, 7));   // Output: 3
    console.log(binarySearch(numbers, 10));  // Output: -1
    
    JAVASCRIPT
  4. Analyze complexity

    • Time Complexity: O(log n)
    • Space Complexity: O(1)