-50% CODE

BLOOM50

|

Simple Header

Responsive navigation header with mobile menu, smooth animations, and modern styling.

ReactTailwind CSSTypeScriptResponsiveNav

Live Preview

Interactive
Simple Header.tsxLive Code
"use client";

import { useState } from "react";

const navigationItems = [
  { name: "Home", href: "#" },
  { name: "About", href: "#" },
  { name: "Services", href: "#" },
  { name: "Contact", href: "#" },
];

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

  return (
    <header className="bg-white shadow-sm border-b border-gray-200">
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div className="flex justify-between items-center h-16">
          {\/* Logo *\/}
          <div className="flex-shrink-0">
            <div className="flex items-center">
              <div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
                <span className="text-white font-bold text-sm">L<\/span>
              <\/div>
              <span className="ml-2 text-xl font-semibold text-gray-900">
                Logo
              <\/span>
            <\/div>
          <\/div>

          {\/* Desktop Navigation *\/}
          <nav className="hidden md:flex space-x-8">
            {navigationItems.map((item) => (
              <a
                key={item.name}
                href={item.href}
                className="text-gray-700 hover:text-blue-600 px-3 py-2 text-sm font-medium transition-colors duration-200"
              >
                {item.name}
              <\/a>
            ))}
          <\/nav>

          {\/* Desktop CTA *\/}
          <div className="hidden md:flex items-center space-x-4">
            <button className="text-gray-700 hover:text-blue-600 px-3 py-2 text-sm font-medium transition-colors">
              Sign In
            <\/button>
            <button className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors">
              Get Started
            <\/button>
          <\/div>

          {\/* Mobile menu button *\/}
          <div className="md:hidden">
            <button
              onClick={() => setIsMenuOpen(!isMenuOpen)}
              className="text-gray-700 hover:text-blue-600 p-2 rounded-lg transition-colors"
            >
              {isMenuOpen ? (
                <svg
                  className="w-6 h-6 transform transition-transform duration-200"
                  fill="none"
                  stroke="currentColor"
                  viewBox="0 0 24 24"
                >
                  <path
                    strokeLinecap="round"
                    strokeLinejoin="round"
                    strokeWidth={2}
                    d="M6 18L18 6M6 6l12 12"
                  \/>
                <\/svg>
              ) : (
                <svg
                  className="w-6 h-6 transform transition-transform duration-200"
                  fill="none"
                  stroke="currentColor"
                  viewBox="0 0 24 24"
                >
                  <path
                    strokeLinecap="round"
                    strokeLinejoin="round"
                    strokeWidth={2}
                    d="M4 6h16M4 12h16M4 18h16"
                  \/>
                <\/svg>
              )}
            <\/button>
          <\/div>
        <\/div>

        <div
          className={`md:hidden overflow-hidden transition-all duration-300 ease-in-out ${
            isMenuOpen ? "max-h-96 opacity-100" : "max-h-0 opacity-0"
          }`}
        >
          <div className="px-2 pt-4 pb-6 space-y-2 border-t border-gray-200">
            {navigationItems.map((item, index) => (
              <a
                key={item.name}
                href={item.href}
                className={`block px-4 py-3 text-gray-700 hover:text-blue-600 hover:bg-gray-50 rounded-lg text-base font-medium transition-all duration-200 transform ${
                  isMenuOpen
                    ? "translate-y-0 opacity-100"
                    : "translate-y-2 opacity-0"
                }`}
                style={{
                  transitionDelay: isMenuOpen ? `${index * 50}ms` : "0ms",
                }}
              >
                {item.name}
              <\/a>
            ))}

            <div className="pt-4 border-t border-gray-200 mt-4 space-y-3">
              <a
                href="#"
                className={`block px-4 py-3 text-gray-700 hover:text-blue-600 hover:bg-gray-50 rounded-lg text-base font-medium transition-all duration-200 transform ${
                  isMenuOpen
                    ? "translate-y-0 opacity-100"
                    : "translate-y-2 opacity-0"
                }`}
                style={{
                  transitionDelay: isMenuOpen ? "200ms" : "0ms",
                }}
              >
                Sign In
              <\/a>
              <a
                href="#"
                className={`block bg-blue-600 hover:bg-blue-700 text-white px-4 py-3 rounded-lg text-base font-medium text-center transition-all duration-200 transform ${
                  isMenuOpen
                    ? "translate-y-0 opacity-100"
                    : "translate-y-2 opacity-0"
                }`}
                style={{
                  transitionDelay: isMenuOpen ? "250ms" : "0ms",
                }}
              >
                Get Started
              <\/a>
            <\/div>
          <\/div>
        <\/div>
      <\/div>
    <\/header>
  );
}

How to use

  1. 1. Copy the component code
  2. 2. Paste it into your React/Next.js project
  3. 3. Make sure you have Tailwind CSS configured
  4. 4. Customize colors, spacing, and content as needed

Dependencies

react^18.0.0
tailwindcss^3.0.0