Skip to content

jamesatomc/kanari-sui

Repository files navigation

# How to Use the Responsive Navigation Bar Component

This guide explains how to use a responsive navigation bar component built with React and Tailwind CSS. The component includes a brand name, navigation links, and a `ConnectButton` from the `@suiet/wallet-kit` library. The navigation bar is responsive and adapts to different screen sizes.

## Prerequisites

- Ensure you have a React project set up.
- Install Tailwind CSS in your project. Follow the [official Tailwind CSS installation guide](https://tailwindcss.com/docs/installation) if you haven't done so.
- Install the `@suiet/wallet-kit` library.

## Component Code

Here is the complete code for the responsive navigation bar component:

```tsx
import { useState } from "react";
import type { MetaFunction } from "@remix-run/node";
import { ConnectButton } from "@suiet/wallet-kit";

export const meta: MetaFunction = () => {
  return [
    { title: "Kanari Sell" },
    { name: "description", content: "ICO" },
  ];
};

export default function Index() {
  const [isMenuOpen, setIsMenuOpen] = useState(false);

  const toggleMenu = () => {
    setIsMenuOpen(!isMenuOpen);
  };

  return (
    <div className="min-h-screen bg-gray-100">
      <nav className="bg-orange-500 p-4">
        <div className="flex justify-between items-center">
          <div className="text-white text-lg">Brand</div>
          <div className="block lg:hidden">
            <button onClick={toggleMenu} className="text-white focus:outline-none">
              <svg className="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 6h16M4 12h16m-7 6h7"></path>
              </svg>
            </button>
          </div>
          <div className="hidden lg:flex space-x-4">
            <a href="#home" className="text-white hover:text-gray-200">Home</a>
            <a href="#about" className="text-white hover:text-gray-200">About</a>
            <a href="#contact" className="text-white hover:text-gray-200">Contact</a>
          </div>
          <div className="hidden lg:block">
            <ConnectButton />
          </div>
        </div>
        <div className={`lg:hidden ${isMenuOpen ? 'block' : 'hidden'}`}>
          <a href="#home" className="block text-white hover:text-gray-200 mt-4">Home</a>
          <a href="#about" className="block text-white hover:text-gray-200 mt-4">About</a>
          <a href="#contact" className="block text-white hover:text-gray-200 mt-4">Contact</a>
          <div className="mt-4">
            <ConnectButton />
          </div>
        </div>
      </nav>
    </div>
  );
}

Explanation

  1. Imports and Meta Function:

    • Import necessary modules and components.
    • Define the meta function to set the page title and description.
  2. State Management:

    • Use the useState hook to manage the state of the mobile menu (isMenuOpen).
  3. Toggle Menu Function:

    • Define the toggleMenu function to toggle the isMenuOpen state.
  4. Component Structure:

    • The component returns a div with a minimum height of the screen and a gray background.
    • Inside the div, a nav element with an orange background and padding is defined.
    • The nav element contains:
      • A brand name.
      • A button to toggle the mobile menu, visible only on smaller screens.
      • Navigation links, visible only on larger screens.
      • The ConnectButton, visible only on larger screens.
      • A dropdown menu for navigation links and the ConnectButton, visible only on smaller screens when the menu is open.

Usage

  1. Add the Component:

    • Add the component to your React application where you want the navigation bar to appear.
  2. Customize:

    • Customize the brand name, navigation links, and styles as needed.
  3. Run the Application:

    • Run your React application to see the responsive navigation bar in action.

Conclusion

This responsive navigation bar component provides a simple and effective way to create a navigation bar that adapts to different screen sizes using React and Tailwind CSS. Customize it further to fit your project's needs.


Save this content in a file named [`README.md`](command:_github.copilot.openRelativePath?%5B%7B%22scheme%22%3A%22file%22%2C%22authority%22%3A%22%22%2C%22path%22%3A%22%2FC%3A%2FUsers%2FPukpuy%2FDesktop%2Fkanari-app%2FREADME.md%22%2C%22query%22%3A%22%22%2C%22fragment%22%3A%22%22%7D%2C%22dd2daeca-042e-45fc-95fb-f4886dbf53ab%22%5D "c:\Users\Pukpuy\Desktop\kanari-app\README.md") or any other suitable name in your project directory.information.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published