[javascript] Tailwind Header
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- /* This example requires Tailwind CSS v2.0+ */
- import { Fragment } from 'react'
- import { Disclosure, Menu, Transition } from '@headlessui/react'
- import { BellIcon, MenuIcon, MoonIcon, XIcon } from '@heroicons/react/outline'
- import NextLink from 'next/link'
- import { useRouter } from 'next/router'
- const navigation = [
- { name: 'Home', href: '/', current: true },
- { name: 'Event Bookings', href: '/events', current: false },
- { name: 'Streaming', href: '#', current: false },
- { name: 'Music', href: '#', current: false },
- { name: 'Privacy Policy', href: '#', current: false },
- { name: 'About', href: '/about', current: false }
- ]
- function classNames(...classes) {
- return classes.filter(Boolean).join(' ')
- }
- export default function Header() {
- const router = useRouter()
- return (
- <Disclosure
- as="nav"
- className="bg-slate-50 sticky top-0 z-50 border-2 opacity-80 w-full"
- >
- {({ open }) => (
- <>
- <div className="max-w-8xl x-auto px-2 sm:px-6 lg:px-8">
- <div className="relative flex items-center justify-between h-16">
- <div className="absolute inset-y-0 left-0 flex items-center md:hidden">
- {/* Mobile menu button*/}
- <Disclosure.Button className="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white">
- <span className="sr-only">Open main menu</span>
- {open ? (
- <XIcon className="block h-6 w-6" aria-hidden="true" />
- ) : (
- <MenuIcon className="block h-6 w-6" aria-hidden="true" />
- )}
- </Disclosure.Button>
- </div>
- <div className="flex-1 flex items-center justify-center sm:items-stretch sm:justify-start">
- <div className="flex-shrink-0 font-mono flex items-center">
- <NextLink href="/" passHref>
- <a className="inline-flex items-center justify-center p-2 mr-4">
- <span className="text-lg text-black font-bold uppercase tracking-widest">
- Noceur Media
- </span>
- </a>
- </NextLink>
- </div>
- <div className="hidden py-2 sm:block sm:ml-6">
- <div className="flex space-x-4">
- {navigation.map(item => (
- <NextLink key={item.name} href={item.href} passHref>
- <a
- className={classNames(
- item.current
- ? 'text-black font-bold bg-gradient-to-r from-pink-300 via-purple-300 to-indigo-400'
- : 'text-gray-700 hover:bg-gray-200 hover:text-gray-500 hover:underline hover:underline-offset-2',
- 'px-3 py-2 rounded-md text-sm font-medium font-mono'
- )}
- aria-current={item.current ? 'page' : undefined}
- >
- {item.name}
- </a>
- </NextLink>
- ))}
- </div>
- </div>
- </div>
- <div className="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
- <button
- type="button"
- className="p-1 rounded-full text-gray-400 hover:text-black focus:outline-none"
- >
- <span className="sr-only">View notifications</span>
- <MoonIcon
- className="h-6 w-6 md:hidden lg:inline-flex"
- aria-hidden="true"
- />
- </button>
- {/* Profile dropdown */}
- <Menu as="div" className="ml-3 relative">
- <div>
- <Menu.Button className="bg-gray-800 flex text-sm rounded-full focus:outline-none focus:ring-white">
- <span className="sr-only">Open user menu</span>
- <img
- className="h-8 w-8 rounded-full"
- src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
- alt=""
- />
- </Menu.Button>
- </div>
- <Transition
- as={Fragment}
- enter="transition ease-out duration-100"
- enterFrom="transform opacity-0 scale-95"
- enterTo="transform opacity-100 scale-100"
- leave="transition ease-in duration-75"
- leaveFrom="transform opacity-100 scale-100"
- leaveTo="transform opacity-0 scale-95"
- >
- <Menu.Items className="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none">
- <Menu.Item>
- {({ active }) => (
- <a
- href="#"
- className={classNames(
- active ? 'bg-gray-100' : '',
- 'block px-4 py-2 text-sm text-gray-700'
- )}
- >
- Settings
- </a>
- )}
- </Menu.Item>
- <Menu.Item>
- {({ active }) => (
- <a
- href="#"
- className={classNames(
- active ? 'bg-gray-100' : '',
- 'block px-4 py-2 text-sm text-gray-700'
- )}
- >
- Sign out
- </a>
- )}
- </Menu.Item>
- </Menu.Items>
- </Transition>
- </Menu>
- </div>
- </div>
- </div>
- <Disclosure.Panel className="lg:hidden">
- <div className="px-2 pt-2 pb-3 space-y-1">
- {navigation.map(item => (
- <Disclosure.Button
- key={item.name}
- as="a"
- href={item.href}
- className={classNames(
- item.current
- ? 'text-black bg-gradient-to-r from-pink-300 via-purple-300 to-indigo-400'
- : 'text-gray-400 hover:bg-gray-700 hover:text-white',
- 'block px-3 py-2 rounded-md text-base font-medium'
- )}
- aria-current={item.current ? 'page' : undefined}
- >
- {item.name}
- </Disclosure.Button>
- ))}
- </div>
- </Disclosure.Panel>
- </>
- )}
- </Disclosure>
- )
- }
Editor
You can edit this paste and save as new: